From cb962888ab339306a40ca87d1a8168d75eae9479 Mon Sep 17 00:00:00 2001 From: zernonia Date: Sat, 23 Mar 2024 16:18:28 +0800 Subject: [PATCH] feat: block preview --- .../theme/components/BlockPreview.vue | 234 ++++++++++++++++++ .../.vitepress/theme/components/Blocks.vue | 63 +++++ .../theme/components/ComponentLoader.vue | 3 +- .../theme/components/ComponentPreview.vue | 2 +- apps/www/.vitepress/theme/config/docs.ts | 4 + apps/www/src/content/blocks.md | 9 + .../default/block/Authentication01.vue | 41 +++ .../new-york/block/Authentication01.vue | 41 +++ 8 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 apps/www/.vitepress/theme/components/BlockPreview.vue create mode 100644 apps/www/.vitepress/theme/components/Blocks.vue create mode 100644 apps/www/src/content/blocks.md create mode 100644 apps/www/src/lib/registry/default/block/Authentication01.vue create mode 100644 apps/www/src/lib/registry/new-york/block/Authentication01.vue diff --git a/apps/www/.vitepress/theme/components/BlockPreview.vue b/apps/www/.vitepress/theme/components/BlockPreview.vue new file mode 100644 index 00000000..10352231 --- /dev/null +++ b/apps/www/.vitepress/theme/components/BlockPreview.vue @@ -0,0 +1,234 @@ + + + diff --git a/apps/www/.vitepress/theme/components/Blocks.vue b/apps/www/.vitepress/theme/components/Blocks.vue new file mode 100644 index 00000000..0b60c559 --- /dev/null +++ b/apps/www/.vitepress/theme/components/Blocks.vue @@ -0,0 +1,63 @@ + + + diff --git a/apps/www/.vitepress/theme/components/ComponentLoader.vue b/apps/www/.vitepress/theme/components/ComponentLoader.vue index fa3d533e..b57c59d5 100644 --- a/apps/www/.vitepress/theme/components/ComponentLoader.vue +++ b/apps/www/.vitepress/theme/components/ComponentLoader.vue @@ -5,12 +5,13 @@ import { useConfigStore } from '@/stores/config' const props = defineProps<{ name: string + typeName?: 'example' | 'block' }>() const { style } = useConfigStore() const Component = defineAsyncComponent({ loadingComponent: Spinner, - loader: () => import(`../../../src/lib/registry/${style.value}/example/${props.name}.vue`), + loader: () => import(`../../../src/lib/registry/${style.value}/${props.typeName}/${props.name}.vue`), timeout: 5000, }) diff --git a/apps/www/.vitepress/theme/components/ComponentPreview.vue b/apps/www/.vitepress/theme/components/ComponentPreview.vue index cc42bd56..bcf9629b 100644 --- a/apps/www/.vitepress/theme/components/ComponentPreview.vue +++ b/apps/www/.vitepress/theme/components/ComponentPreview.vue @@ -83,7 +83,7 @@ watch([style, codeConfig], async () => { 'items-end': align === 'end', })" > - + diff --git a/apps/www/.vitepress/theme/config/docs.ts b/apps/www/.vitepress/theme/config/docs.ts index 31187fdc..a3056849 100644 --- a/apps/www/.vitepress/theme/config/docs.ts +++ b/apps/www/.vitepress/theme/config/docs.ts @@ -38,6 +38,10 @@ export const docsConfig: DocsConfig = { title: 'Examples', href: '/examples/mail', }, + { + title: 'Blocks', + href: '/blocks', + }, { title: 'GitHub', href: 'https://github.com/radix-vue/shadcn-vue', diff --git a/apps/www/src/content/blocks.md b/apps/www/src/content/blocks.md new file mode 100644 index 00000000..82408799 --- /dev/null +++ b/apps/www/src/content/blocks.md @@ -0,0 +1,9 @@ +--- +title: Blocks - shadcn-vue +--- + + + + diff --git a/apps/www/src/lib/registry/default/block/Authentication01.vue b/apps/www/src/lib/registry/default/block/Authentication01.vue new file mode 100644 index 00000000..05760fe1 --- /dev/null +++ b/apps/www/src/lib/registry/default/block/Authentication01.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/apps/www/src/lib/registry/new-york/block/Authentication01.vue b/apps/www/src/lib/registry/new-york/block/Authentication01.vue new file mode 100644 index 00000000..a679a45f --- /dev/null +++ b/apps/www/src/lib/registry/new-york/block/Authentication01.vue @@ -0,0 +1,41 @@ + + + + +