|
| 1 | +--- |
| 2 | +import { Tabs, TabItem, Code, Card } from "@astrojs/starlight/components"; |
| 3 | +import daisyuiStyles from '@sjsf/daisyui-theme/styles.css?inline'; |
| 4 | +import flowbiteStyles from '@sjsf/flowbite-theme/styles.css?inline'; |
| 5 | +import skeletonStyles from '@sjsf/skeleton-theme/styles.css?inline'; |
| 6 | +
|
| 7 | +import type { Theme } from "@/shared"; |
| 8 | +import { ShadowHost } from "@/components/shadow"; |
| 9 | +
|
| 10 | +import WithBasic from "./_with-basic.svelte"; |
| 11 | +import WithSkeleton from "./_with-skeleton.svelte"; |
| 12 | +import WithDaisyui from "./_with-daisyui.svelte"; |
| 13 | +import WithFlowbite from "./_with-flowbite.svelte"; |
| 14 | +
|
| 15 | +import schemaCode from "./_schema?raw"; |
| 16 | +import validatorCode from './_validator?raw'; |
| 17 | +import withBasicCode from "./_with-basic.svelte?raw"; |
| 18 | +import withSkeletonCode from "./_with-skeleton.svelte?raw"; |
| 19 | +import withDaisyuiCode from "./_with-daisyui.svelte?raw"; |
| 20 | +import withFlowbiteCode from "./_with-flowbite.svelte?raw"; |
| 21 | +
|
| 22 | +const theme = (Astro.params.theme ?? "basic") as Theme; |
| 23 | +
|
| 24 | +const STYLES = { |
| 25 | + basic: "", |
| 26 | + daisyui: daisyuiStyles, |
| 27 | + flowbite: flowbiteStyles, |
| 28 | + skeleton: skeletonStyles, |
| 29 | +} satisfies Record<Theme, string>; |
| 30 | +
|
| 31 | +const CODE = { |
| 32 | + basic: withBasicCode, |
| 33 | + daisyui: withDaisyuiCode, |
| 34 | + flowbite: withFlowbiteCode, |
| 35 | + skeleton: withSkeletonCode, |
| 36 | +} satisfies Record<Theme, string>; |
| 37 | +--- |
| 38 | + |
| 39 | +<Tabs> |
| 40 | + <TabItem label="Form.svelte"> |
| 41 | + <Code code={CODE[theme]} lang="svelte" /> |
| 42 | + </TabItem> |
| 43 | + <TabItem label="_schema.ts"> |
| 44 | + <Code code={schemaCode} lang="typescript" /> |
| 45 | + </TabItem> |
| 46 | + <TabItem label="_validator.ts"> |
| 47 | + <Code code={validatorCode} lang="typescript" /> |
| 48 | + </TabItem> |
| 49 | +</Tabs> |
| 50 | + |
| 51 | +<Card title=""> |
| 52 | + <ShadowHost client:only="svelte" style={STYLES[theme]}> |
| 53 | + { |
| 54 | + theme === "basic" ? ( |
| 55 | + <WithBasic client:only="svelte" /> |
| 56 | + ) : theme === "daisyui" ? ( |
| 57 | + <WithDaisyui client:only="svelte" /> |
| 58 | + ) : theme === "flowbite" ? ( |
| 59 | + <WithFlowbite client:only="svelte" /> |
| 60 | + ) : theme === "skeleton" ? ( |
| 61 | + <WithSkeleton client:only="svelte" /> |
| 62 | + ) : null |
| 63 | + } |
| 64 | + </ShadowHost> |
| 65 | +</Card> |
0 commit comments