diff --git a/examples/ui-demo/components/ui/switch.tsx b/examples/ui-demo/components/ui/switch.tsx index bc69cf2dbf..5785949b8b 100644 --- a/examples/ui-demo/components/ui/switch.tsx +++ b/examples/ui-demo/components/ui/switch.tsx @@ -11,7 +11,7 @@ const Switch = React.forwardRef< >(({ className, ...props }, ref) => ( (() => { - const output = []; - if (config.auth.showEmail) { - output.push([{ type: "email" as const }]); - } - - output.push([{ type: "passkey" as const }]); - - return output; - }, [config.auth]); + const [showCode, setShowCode] = useState(false); return (
-
-
-
- } - showSignInText - showNavigation - sections={sections} - /> +
+
+
+ Configuration preview
+
+ {/* Don't unmount when showing code preview so that the auth card retains its state */} + + {showCode && }
); } - -function AuthCardHeader() { - const { - config: { - ui: { logoDark, logoLight, theme }, - }, - } = useConfig(); - - const logo = theme === "dark" ? logoDark : logoLight; - - if (!logo) return null; - - return ( - {logo.fileName} - ); -} diff --git a/examples/ui-demo/src/components/icons/code.tsx b/examples/ui-demo/src/components/icons/code.tsx new file mode 100644 index 0000000000..719a0a84d1 --- /dev/null +++ b/examples/ui-demo/src/components/icons/code.tsx @@ -0,0 +1,21 @@ +import { SVGProps } from "react"; + +export const Code = ({ + stroke = "currentColor", + ...props +}: JSX.IntrinsicAttributes & SVGProps) => ( + + + +); diff --git a/examples/ui-demo/src/components/preview/AuthCardWrapper.tsx b/examples/ui-demo/src/components/preview/AuthCardWrapper.tsx new file mode 100644 index 0000000000..693c5b1dee --- /dev/null +++ b/examples/ui-demo/src/components/preview/AuthCardWrapper.tsx @@ -0,0 +1,60 @@ +import { cn } from "@/lib/utils"; +import { useConfig } from "@/src/app/state"; +import { AuthCard, AuthType } from "@account-kit/react"; +import { useMemo } from "react"; + +export function AuthCardWrapper({ className }: { className?: string }) { + const { config } = useConfig(); + + const sections = useMemo(() => { + const output = []; + if (config.auth.showEmail) { + output.push([{ type: "email" as const }]); + } + + output.push([{ type: "passkey" as const }]); + + return output; + }, [config.auth]); + + return ( +
+
+
+ } + showSignInText + showNavigation + sections={sections} + /> +
+
+
+ ); +} + +function AuthCardHeader() { + const { + config: { + ui: { logoDark, logoLight, theme }, + }, + } = useConfig(); + + const logo = theme === "dark" ? logoDark : logoLight; + + if (!logo) return null; + + return ( + {logo.fileName} + ); +} diff --git a/examples/ui-demo/src/components/preview/CodePreview.tsx b/examples/ui-demo/src/components/preview/CodePreview.tsx new file mode 100644 index 0000000000..03d0bc3ffc --- /dev/null +++ b/examples/ui-demo/src/components/preview/CodePreview.tsx @@ -0,0 +1,58 @@ +import { cn } from "@/lib/utils"; +import ExternalLink from "../shared/ExternalLink"; + +import { Roboto_Mono } from "next/font/google"; +const robotoMono = Roboto_Mono({ + subsets: ["latin"], + display: "swap", +}); + +export function CodePreview() { + return ( +
+
+
+ Export configuration +
+
+ To get started, simply paste the below code into your environment. + You’ll need to add your Alchemy API key and Gas Policy ID too. Login + to automatically inject the keys into the code below.{" "} + + Fully customize CSS here. + +
+
+
+
Style
+ +
+
+
Config
+ +
+
+ ); +} + +function CodeBlock({ title, code }: { title: string; code: string }) { + return ( +
+
+ {title} +
+
+        {code}
+      
+
+ ); +} + +const styleCode = `import { withAccountKitUi } from "@alchemy/aa-alchemy/tailwind"; +import type { Config } from "tailwindcss"; + +const config: Config = ; +export default withAccountKitUi(config); +`; diff --git a/examples/ui-demo/src/components/shared/CodePreviewSwitch.tsx b/examples/ui-demo/src/components/shared/CodePreviewSwitch.tsx new file mode 100644 index 0000000000..05175d9cd4 --- /dev/null +++ b/examples/ui-demo/src/components/shared/CodePreviewSwitch.tsx @@ -0,0 +1,32 @@ +"use client" + +import * as React from "react" +import * as SwitchPrimitives from "@radix-ui/react-switch" + +import { cn } from "@/lib/utils" +import { Code } from "../icons/code" + +const CodePreviewSwitch = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + +)) +CodePreviewSwitch.displayName = SwitchPrimitives.Root.displayName + +export { CodePreviewSwitch }