diff --git a/.github/workflows/deploy-dapp-example-web.yml b/.github/workflows/deploy-dapp-example-web.yml index 77ea7f66..219efa87 100644 --- a/.github/workflows/deploy-dapp-example-web.yml +++ b/.github/workflows/deploy-dapp-example-web.yml @@ -25,6 +25,7 @@ jobs: # Next.js environment variables echo "NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > ./packages/example/.env echo "NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=${{ secrets.BLOCKFROST_CARDANO_PROJECT_ID }}" >> ./packages/example/.env + echo "NEXT_PUBLIC_OKLINK_API_KEY=${{ secrets.OKLINK_API_KEY }}" >> ./packages/example/.env - name: Install Dependency env: diff --git a/.github/workflows/publish-npm-package.yml b/.github/workflows/publish-npm-package.yml index bc2de42d..f8b98fd4 100644 --- a/.github/workflows/publish-npm-package.yml +++ b/.github/workflows/publish-npm-package.yml @@ -47,6 +47,7 @@ jobs: # Next.js environment variables echo "NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > ./packages/example/.env echo "NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=${{ secrets.BLOCKFROST_CARDANO_PROJECT_ID }}" >> ./packages/example/.env + echo "NEXT_PUBLIC_OKLINK_API_KEY=${{ secrets.OKLINK_API_KEY }}" >> ./packages/example/.env - name: Build Example Web run: | diff --git a/packages/example/.env.simple b/packages/example/.env.simple index da10db09..c5cc2d47 100644 --- a/packages/example/.env.simple +++ b/packages/example/.env.simple @@ -2,4 +2,6 @@ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxxx NEXT_PUBLIC_WALLET_CONNECT_RELAY_URL=wss://relay.walletconnect.com # block frost project id -NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=xxxx \ No newline at end of file +NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=xxxx +# oklink api key +NEXT_PUBLIC_OKLINK_API_KEY=xxxx diff --git a/packages/example/components/ApiForm/ApiAutoTextArea.tsx b/packages/example/components/ApiForm/ApiAutoTextArea.tsx new file mode 100644 index 00000000..b5f18a01 --- /dev/null +++ b/packages/example/components/ApiForm/ApiAutoTextArea.tsx @@ -0,0 +1,69 @@ +import React, { memo, useContext, useEffect } from 'react'; +import { useAtom } from 'jotai'; +import { Label } from '../ui/label'; +import { ApiFormContext } from './ApiForm'; +import { AutoHeightTextarea } from '../ui/textarea'; + + +interface AutoTextAreaProps { + id: string; + placeholder?: string; + label?: string; + required?: boolean; +} + +const TextArea = memo(({ + id, + placeholder, + label, + required +}: AutoTextAreaProps) => { + const context = useContext(ApiFormContext); + if (!context) throw new Error('ApiField must be used within ApiForm'); + + const { store } = context; + const [field, setField] = useAtom(store.fieldsAtom(id)); + + useEffect(() => { + field.name = label; + field.required = required; + }, []); + + return <> + setField({ ...field, value: e.target.value })} + placeholder={placeholder} + disabled={field.disabled} + /> + {field.error && ( +
{field.error}
+ )} + +}); + +export interface ApiAutoTextAreaProps extends AutoTextAreaProps { + id: string; +} + +export const ApiAutoTextArea = memo(({ + id, + label, + placeholder, + required +}: ApiAutoTextAreaProps) => { + return ( +
+ {label && ( + + )} +