diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..e0ae79992 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,65 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy documentation to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["docs-main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./docs + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Pages + uses: actions/configure-pages@v2 + + - name: Setup Nodejs and yarn + uses: actions/setup-node@v2 + with: + node-version: "16" + cache: yarn + + - name: Install dependencies + run: yarn install --immutable + + - name: Build Documentation + env: + NODE_OPTIONS: "--max_old_space_size=8192" + run: yarn build + + - name: Peak at folder contents + run: ls -al + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + # Upload entire repository + path: './docs/build' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/README.md b/README.md index 9b3ef6eda..f26bf5333 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ If you're coming from v1, we've created a [migration guide for you](https://onbo ## Documentation -For full documentation, check out the README.md for each package: +For full documentation, check out the README.md for each package or the [docs page here](https://onboard.blocknative.com/docs/overview/introduction#features): **Core Repo** diff --git a/docs/.eslintignore b/docs/.eslintignore new file mode 100644 index 000000000..38972655f --- /dev/null +++ b/docs/.eslintignore @@ -0,0 +1,13 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example + +# Ignore files for PNPM, NPM and YARN +pnpm-lock.yaml +package-lock.json +yarn.lock diff --git a/docs/.eslintrc.cjs b/docs/.eslintrc.cjs new file mode 100644 index 000000000..c9c248180 --- /dev/null +++ b/docs/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], + plugins: ['svelte3', '@typescript-eslint'], + ignorePatterns: ['*.cjs'], + overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + settings: { + 'svelte3/typescript': () => require('typescript') + }, + parserOptions: { + sourceType: 'module', + ecmaVersion: 2020 + }, + env: { + browser: true, + es2017: true, + node: true + } +} diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..43cdd4575 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +.vercel diff --git a/docs/.npmrc b/docs/.npmrc new file mode 100644 index 000000000..b6f27f135 --- /dev/null +++ b/docs/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/docs/.prettierignore b/docs/.prettierignore new file mode 100644 index 000000000..38972655f --- /dev/null +++ b/docs/.prettierignore @@ -0,0 +1,13 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example + +# Ignore files for PNPM, NPM and YARN +pnpm-lock.yaml +package-lock.json +yarn.lock diff --git a/docs/.prettierrc b/docs/.prettierrc new file mode 100644 index 000000000..4b35d552b --- /dev/null +++ b/docs/.prettierrc @@ -0,0 +1,8 @@ +{ + "useTabs": false, + "tabWidth": 2, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100, + "semi": false +} diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..cbe2776a3 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,25 @@ +# Docs + +## Prereqs + +Install [yarn](https://classic.yarnpkg.com/en/docs/install) + +## Running docs server locally + +Run the following command within the `docs/` folder + +```sh +yarn && yarn dev +``` + +The server should start on [localhost:3000](http://localhost:3000/). + +## Contributing + +Confirm changes look as expected on local instance. + +Run `yarn build` and confirm no errors present from the proposed changes. + +Confirm vercel build within PR builds without error and check instance deployment for accuracy. + +PR should target branch [docs-develop](https://github.com/blocknative/web3-onboard/tree/docs-develop). \ No newline at end of file diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 000000000..de558647f --- /dev/null +++ b/docs/package.json @@ -0,0 +1,81 @@ +{ + "name": "docs", + "version": "0.0.1", + "scripts": { + "dev": "svelte-kit dev", + "build": "NODE_OPTIONS=--max_old_space_size=8192 svelte-kit build", + "package": "svelte-kit package", + "preview": "svelte-kit preview", + "prepare": "svelte-kit sync", + "test": "playwright test", + "check": "svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --check --plugin-search-dir=. . && eslint .", + "format": "prettier --write --plugin-search-dir=. ." + }, + "devDependencies": { + "@algolia/client-search": "^4.14.2", + "@docsearch/css": "^3.2.1", + "@docsearch/js": "^3.2.1", + "@iconify-json/ri": "^1.1.3", + "@playwright/test": "^1.22.2", + "@sveltejs/adapter-static": "^1.0.0-next.39", + "@sveltejs/adapter-vercel": "next", + "@sveltejs/kit": "1.0.0-next.357", + "@svelteness/kit-docs": "^0.22.12", + "@tailwindcss/typography": "^0.5.2", + "@types/react": "^18.0.21", + "@types/react-dom": "^18.0.6", + "@typescript-eslint/eslint-plugin": "^5.27.0", + "@typescript-eslint/parser": "^5.27.0", + "@vitebook/client": "^0.100.5", + "@vitebook/core": "^0.100.5", + "@vitebook/markdown-shiki": "^0.100.5", + "@vitebook/markdown-svelte": "^0.100.5", + "autoprefixer": "^10.4.7", + "clsx": "^1.1.1", + "daisyui": "^2.17.0", + "eslint": "^8.16.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-svelte3": "^4.0.0", + "postcss": "^8.4.14", + "prettier": "^2.6.2", + "prettier-plugin-svelte": "^2.7.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "rollup-plugin-polyfill-node": "^0.11.0", + "shiki": "^0.10.1", + "svelte": "^3.44.0", + "svelte-check": "^2.7.1", + "svelte-preprocess": "^4.10.7", + "tslib": "^2.3.1", + "typescript": "^4.7.2", + "unplugin-icons": "^0.13.4" + }, + "type": "module", + "dependencies": { + "@web3-onboard/coinbase": "^2.1.4", + "@web3-onboard/core": "^2.12.0", + "@web3-onboard/dcent": "^2.2.2", + "@web3-onboard/enkrypt": "^2.0.0", + "@web3-onboard/fortmatic": "^2.0.14", + "@web3-onboard/gas": "^2.1.4", + "@web3-onboard/gnosis": "^2.1.5", + "@web3-onboard/injected-wallets": "^2.4.0", + "@web3-onboard/keepkey": "^2.3.2", + "@web3-onboard/keystone": "^2.3.2", + "@web3-onboard/ledger": "^2.3.2", + "@web3-onboard/magic": "^2.1.3", + "@web3-onboard/mew-wallet": "^2.0.0", + "@web3-onboard/portis": "^2.1.3", + "@web3-onboard/sequence": "^2.0.4", + "@web3-onboard/tallyho": "^2.0.1", + "@web3-onboard/torus": "^2.2.0", + "@web3-onboard/trezor": "^2.3.2", + "@web3-onboard/uauth": "^2.0.1", + "@web3-onboard/walletconnect": "^2.2.1", + "@web3-onboard/web3auth": "^2.1.4", + "animejs": "^3.2.1", + "ethers": "^5.7.0" + } +} diff --git a/docs/playwright.config.ts b/docs/playwright.config.ts new file mode 100644 index 000000000..086f60504 --- /dev/null +++ b/docs/playwright.config.ts @@ -0,0 +1,10 @@ +import type { PlaywrightTestConfig } from '@playwright/test' + +const config: PlaywrightTestConfig = { + webServer: { + command: 'npm run build && npm run preview', + port: 3000 + } +} + +export default config diff --git a/docs/postcss.config.cjs b/docs/postcss.config.cjs new file mode 100644 index 000000000..85f717cc0 --- /dev/null +++ b/docs/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {} + } +} diff --git a/docs/src/app.css b/docs/src/app.css new file mode 100644 index 000000000..b5c61c956 --- /dev/null +++ b/docs/src/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/docs/src/app.d.ts b/docs/src/app.d.ts new file mode 100644 index 000000000..02d3fab72 --- /dev/null +++ b/docs/src/app.d.ts @@ -0,0 +1,14 @@ +/// +/// + +// See https://kit.svelte.dev/docs/types#app +// for information about these interfaces +// and what to do when importing types +declare namespace App { + // interface Locals {} + // interface Platform {} + // interface Session {} + // interface Stuff {} +} + +declare module '@svelteness/kit-docs/tailwind.config.cjs' diff --git a/docs/src/app.html b/docs/src/app.html new file mode 100644 index 000000000..b4594e03c --- /dev/null +++ b/docs/src/app.html @@ -0,0 +1,33 @@ + + + + + + + %sveltekit.head% + + + + + + + + +
%sveltekit.body%
+ + diff --git a/docs/src/img/svelte-horizontal.svg b/docs/src/img/svelte-horizontal.svg new file mode 100644 index 000000000..fadf24d5e --- /dev/null +++ b/docs/src/img/svelte-horizontal.svg @@ -0,0 +1 @@ +svelte-horizontal diff --git a/docs/src/kit-docs/index.ts b/docs/src/kit-docs/index.ts new file mode 100644 index 000000000..cc3f9f4d6 --- /dev/null +++ b/docs/src/kit-docs/index.ts @@ -0,0 +1 @@ +export { Tabs, TabPanel, TabItem } from './tabs' diff --git a/docs/src/kit-docs/tabs/TabItem.svelte b/docs/src/kit-docs/tabs/TabItem.svelte new file mode 100644 index 000000000..b155986d4 --- /dev/null +++ b/docs/src/kit-docs/tabs/TabItem.svelte @@ -0,0 +1,53 @@ + + + + + diff --git a/docs/src/kit-docs/tabs/TabPanel.svelte b/docs/src/kit-docs/tabs/TabPanel.svelte new file mode 100644 index 000000000..4f2f550f5 --- /dev/null +++ b/docs/src/kit-docs/tabs/TabPanel.svelte @@ -0,0 +1,14 @@ + + + diff --git a/docs/src/kit-docs/tabs/Tabs.svelte b/docs/src/kit-docs/tabs/Tabs.svelte new file mode 100644 index 000000000..3a195c552 --- /dev/null +++ b/docs/src/kit-docs/tabs/Tabs.svelte @@ -0,0 +1,40 @@ + + +
+
    + {#each values.filter(isString) as value (value)} + + {/each} + + +
+ +
+ +
+
diff --git a/docs/src/kit-docs/tabs/index.ts b/docs/src/kit-docs/tabs/index.ts new file mode 100644 index 000000000..2cfb8e5ad --- /dev/null +++ b/docs/src/kit-docs/tabs/index.ts @@ -0,0 +1,4 @@ +export { default as TabItem } from './TabItem.svelte' +export { default as TabPanel } from './TabPanel.svelte' +export { default as Tabs } from './Tabs.svelte' +export * from './tabsRegistry' diff --git a/docs/src/kit-docs/tabs/tabsRegistry.ts b/docs/src/kit-docs/tabs/tabsRegistry.ts new file mode 100644 index 000000000..a9e3092ce --- /dev/null +++ b/docs/src/kit-docs/tabs/tabsRegistry.ts @@ -0,0 +1,107 @@ +import { getContext } from 'svelte' +import type { Writable } from 'svelte/store' +import { writable } from 'svelte/store' + +import { isString } from './utils' + +export const TABS_REGISTRY_CTX_KEY = Symbol(import.meta.env.DEV ? 'TABS_REGISTRY' : '') + +export type TabsRegistryItem = string | { value: string; label: string } + +export type TabsRegistry = { + currentValue: Writable + addTab: (item: TabsRegistryItem) => void + selectTab: (item: TabsRegistryItem) => void + getValue: (item: TabsRegistryItem) => string + hasTab: (item: TabsRegistryItem) => boolean + indexOf: (item: TabsRegistryItem) => number + removeTab: (item: TabsRegistryItem) => void +} + +export type TabsRegistryOptions = { + defaultValue?: string | null + groupId?: string | null + onMount: (callback: () => void) => void + onDestroy: (callback: () => void) => void +} + +export function useTabsRegistry(): TabsRegistry { + return getContext(TABS_REGISTRY_CTX_KEY) +} + +const groups: { [id: string]: Writable } = {} + +const getGroupStorageKey = (id: string) => `@vitebook/tabs/group::${id}` + +export function createTabsRegistry( + values: TabsRegistryItem[], + { defaultValue, groupId, onMount, onDestroy }: TabsRegistryOptions +): TabsRegistry { + let currentValue = writable(null) + + const initialValue = () => { + const item = defaultValue ?? values[0] + return isString(item) ? item : item?.value + } + + if (groupId) { + const storageKey = getGroupStorageKey(groupId) + const groupStore = (groups[groupId] ??= writable(null)) + + currentValue = groupStore + + // Avoid SSR mismatch. + let hasInit = false + onMount(() => { + if (hasInit) return + hasInit = true + + currentValue.set(window.localStorage.getItem(storageKey) ?? initialValue()) + + return currentValue.subscribe((value) => { + window.localStorage.setItem(storageKey, value ?? '') + }) + }) + } else { + onMount(() => { + currentValue.set(initialValue()) + }) + } + + const registry: TabsRegistry = { + currentValue, + addTab: (item) => { + if (registry.hasTab(item)) return + const value = isString(item) ? item : item.value + values.push(value) + onDestroy(() => { + registry.removeTab(item) + }) + }, + selectTab: (item) => { + currentValue.set(isString(item) ? item : item.value) + }, + hasTab: (item) => { + return registry.indexOf(item) >= 0 + }, + indexOf: (item) => { + return isString(item) ? values.indexOf(item) : values.findIndex((v) => v === item.value) + }, + getValue: (item) => { + return isString(item) ? item : item?.value + }, + removeTab: (item) => { + const i = registry.indexOf(item) + if (i >= 0) { + values.splice(i, 1) + currentValue.update((current) => + current === item + ? registry.getValue(values[i]) ?? registry.getValue(values[values.length - 1]) + : current + ) + } + } + } + + return registry +} diff --git a/docs/src/kit-docs/tabs/utils.ts b/docs/src/kit-docs/tabs/utils.ts new file mode 100644 index 000000000..00882a42d --- /dev/null +++ b/docs/src/kit-docs/tabs/utils.ts @@ -0,0 +1,25 @@ +const wordSeparators = + // eslint-disable-next-line no-useless-escape + /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/ + +export function toTitleCase(str: string): string { + const words = str.split(wordSeparators) + const len = words.length + const mappedWords = new Array(len) + for (let i = 0; i < len; i++) { + const word = words[i] + if (word === '') { + continue + } + mappedWords[i] = word[0].toUpperCase() + word.slice(1) + } + return mappedWords.join(' ') +} + +/** + * Check if a value is a `string`. + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any +export function isString(value: any): value is string { + return value?.constructor === String +} diff --git a/docs/src/lib/assets/blocknative-onboard-og-image.png b/docs/src/lib/assets/blocknative-onboard-og-image.png new file mode 100644 index 000000000..0da7ff7a5 Binary files /dev/null and b/docs/src/lib/assets/blocknative-onboard-og-image.png differ diff --git a/docs/src/lib/assets/connect-modal.svg b/docs/src/lib/assets/connect-modal.svg new file mode 100644 index 000000000..e171e29e7 --- /dev/null +++ b/docs/src/lib/assets/connect-modal.svg @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/src/lib/assets/transaction-preview.gif b/docs/src/lib/assets/transaction-preview.gif new file mode 100644 index 000000000..938a9d1df Binary files /dev/null and b/docs/src/lib/assets/transaction-preview.gif differ diff --git a/docs/src/lib/assets/transaction-preview.png b/docs/src/lib/assets/transaction-preview.png new file mode 100644 index 000000000..7c34e7ca3 Binary files /dev/null and b/docs/src/lib/assets/transaction-preview.png differ diff --git a/docs/src/lib/assets/uniswap-example.mp4 b/docs/src/lib/assets/uniswap-example.mp4 new file mode 100644 index 000000000..880349a9b Binary files /dev/null and b/docs/src/lib/assets/uniswap-example.mp4 differ diff --git a/docs/src/lib/components/ConnectWalletButton.svelte b/docs/src/lib/components/ConnectWalletButton.svelte new file mode 100644 index 000000000..7bb322997 --- /dev/null +++ b/docs/src/lib/components/ConnectWalletButton.svelte @@ -0,0 +1,37 @@ + + + diff --git a/docs/src/lib/components/Container.svelte b/docs/src/lib/components/Container.svelte new file mode 100644 index 000000000..59b5588d2 --- /dev/null +++ b/docs/src/lib/components/Container.svelte @@ -0,0 +1,14 @@ +
+ + +
+ + diff --git a/docs/src/lib/components/FeatureCard.svelte b/docs/src/lib/components/FeatureCard.svelte new file mode 100644 index 000000000..c501fb30f --- /dev/null +++ b/docs/src/lib/components/FeatureCard.svelte @@ -0,0 +1,59 @@ + + +
+
{title}
+
{text}
+
+ + diff --git a/docs/src/lib/components/FeaturesSection.svelte b/docs/src/lib/components/FeaturesSection.svelte new file mode 100644 index 000000000..f25aef7f3 --- /dev/null +++ b/docs/src/lib/components/FeaturesSection.svelte @@ -0,0 +1,185 @@ + + +
+ +
+ + + + + + +
+
+ +
+
+ +
+
+
+
+
+ +
+ +
+ + + + +
+
+
+ + +
+ +
+ + + + + + + +
+
+ + onboard connect wallets + + +
+ + + + + + +
+
+
+ +
+
+
+ + + + + + +
+
+
+
+ + diff --git a/docs/src/lib/components/Footer.svelte b/docs/src/lib/components/Footer.svelte new file mode 100644 index 000000000..cc01f34bc --- /dev/null +++ b/docs/src/lib/components/Footer.svelte @@ -0,0 +1,134 @@ + + + + + diff --git a/docs/src/lib/components/GettingStarted.svelte b/docs/src/lib/components/GettingStarted.svelte new file mode 100644 index 000000000..600d1a6a3 --- /dev/null +++ b/docs/src/lib/components/GettingStarted.svelte @@ -0,0 +1,25 @@ + + +
+
+ +
+
+ + diff --git a/docs/src/lib/components/HeroSection.svelte b/docs/src/lib/components/HeroSection.svelte new file mode 100644 index 000000000..9f03c8eb2 --- /dev/null +++ b/docs/src/lib/components/HeroSection.svelte @@ -0,0 +1,85 @@ + + +
+
+
{"Web3-Onboard"}
+
+ {"Open-source, framework-agnostic JavaScript library to onboard users to web3 apps. Help your users transact with ease by enabling wallet connection, real-time transaction states, and more."} +
+
+ + {'npm i @web3-onboard/core @web3-onboard/injected-wallets'} + +
+ +
+ onboard connect wallet +
+ + diff --git a/docs/src/lib/components/HomeLayout.svelte b/docs/src/lib/components/HomeLayout.svelte new file mode 100644 index 000000000..d77769921 --- /dev/null +++ b/docs/src/lib/components/HomeLayout.svelte @@ -0,0 +1,56 @@ + + +
+ +
+ + + + + +
+
+
+ + diff --git a/docs/src/lib/components/NavBar.svelte b/docs/src/lib/components/NavBar.svelte new file mode 100644 index 000000000..ff339c1d8 --- /dev/null +++ b/docs/src/lib/components/NavBar.svelte @@ -0,0 +1,39 @@ + + + + + diff --git a/docs/src/lib/components/SEO/OpenGraph.svelte b/docs/src/lib/components/SEO/OpenGraph.svelte new file mode 100644 index 000000000..525a12cd8 --- /dev/null +++ b/docs/src/lib/components/SEO/OpenGraph.svelte @@ -0,0 +1,21 @@ + + + + + + + + + + {#if image} + + + {/if} + diff --git a/docs/src/lib/components/SEO/Twitter.svelte b/docs/src/lib/components/SEO/Twitter.svelte new file mode 100644 index 000000000..2469be3d6 --- /dev/null +++ b/docs/src/lib/components/SEO/Twitter.svelte @@ -0,0 +1,17 @@ + + + + + + + + {#if image} + + + {/if} + diff --git a/docs/src/lib/components/SEO/index.svelte b/docs/src/lib/components/SEO/index.svelte new file mode 100644 index 000000000..48ec553ed --- /dev/null +++ b/docs/src/lib/components/SEO/index.svelte @@ -0,0 +1,34 @@ + + + + diff --git a/docs/src/lib/components/TestimonialSection.svelte b/docs/src/lib/components/TestimonialSection.svelte new file mode 100644 index 000000000..7b6d9d1f0 --- /dev/null +++ b/docs/src/lib/components/TestimonialSection.svelte @@ -0,0 +1,48 @@ + + +
+

+ {"Who's using web3-onboard?"} +

+
+ Web3-Onboard-users +
+
+ + diff --git a/docs/src/lib/components/TextBlock.svelte b/docs/src/lib/components/TextBlock.svelte new file mode 100644 index 000000000..7f1aa7f43 --- /dev/null +++ b/docs/src/lib/components/TextBlock.svelte @@ -0,0 +1,40 @@ + + +
+
{title}
+
{subtitle}
+
{text}
+ +
+ + diff --git a/docs/src/lib/components/ThemeCustomizer.svelte b/docs/src/lib/components/ThemeCustomizer.svelte new file mode 100644 index 000000000..23e7c052e --- /dev/null +++ b/docs/src/lib/components/ThemeCustomizer.svelte @@ -0,0 +1,511 @@ + + +
+
+ +
+
+ {#each Object.keys(defaultStyling) as target} +
+
+ updateTheme(e, target)} + /> +
+ {target} : {defaultStyling[target]} +
+ {/each} +
+
+