diff --git a/.vscode/settings.json b/.vscode/settings.json
index 47b2103f..c9442fbf 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,4 +1,5 @@
{
+ "vue.server.hybridMode": true,
"eslint.experimental.useFlatConfig": true,
"prettier.enable": false,
"editor.formatOnSave": false,
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 31bf7db9..8970fe1c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -19,7 +19,7 @@ This repository is structured as follows:
```
apps
└── www
- ├── src
+ ├── src
│ └── content
└── registry
├── default
@@ -32,12 +32,12 @@ packages
└── cli
```
-| Path | Description |
-| --------------------- | ---------------------------------------- |
-| `apps/www/app` | The Next.js application for the website. |
-| `apps/www/content` | The content for the website. |
-| `apps/www/registry` | The registry for the components. |
-| `packages/cli` | The `shadcn-vue` package. |
+| Path | Description |
+| ----------------------------| -------------------------------------------|
+| `apps/www/.vitepress` | The Vitepress application for the website. |
+| `apps/www/src/content` | The content for the website. |
+| `apps/www/src/lib/registry` | The registry for the components. |
+| `packages/cli` | The `shadcn-vue` package. |
## Development
@@ -79,22 +79,24 @@ The documentation for this project is located in the `www` workspace. You can ru
pnpm dev
```
-Documentation is written using [md](https://vitepress.dev/guide/markdown). You can find the documentation files in the `apps/www/content/docs` directory.
+Documentation is written using [md](https://vitepress.dev/guide/markdown). You can find the documentation files in the `apps/www/src/content` directory.
## Components
-We use a registry system for developing components. You can find the source code for the components under `apps/www/registry`. The components are organized by styles.
+We use a registry system for developing components. You can find the source code for the components under `apps/www/src/lib/registry`. The components are organized by styles.
```bash
apps
└── www
- └── registry
- ├── default
- │ ├── example
- │ └── ui
- └── new-york
- ├── example
- └── ui
+ └── src
+ └── lib
+ └── registry
+ ├── default
+ │ ├── example
+ │ └── ui
+ └── new-york
+ ├── example
+ └── ui
```
When adding or modifying components, please ensure that:
@@ -130,13 +132,10 @@ the following categories:
e.g. `feat(components): add new prop to the avatar component`
-
If you are interested in the detailed specification you can visit
https://www.conventionalcommits.org/ or check out the
[Angular Commit Message Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines).
-
-
## Requests for new components
If you have a request for a new component, please open a discussion on GitHub. We'll be happy to help you out.
@@ -155,4 +154,4 @@ Tests are written using [Vitest](https://vitest.dev). You can run all the tests
pnpm test
```
-Please ensure that the tests are passing when submitting a pull request. If you're adding new features, please include tests.
\ No newline at end of file
+Please ensure that the tests are passing when submitting a pull request. If you're adding new features, please include tests.
diff --git a/apps/www/.vitepress/config.mts b/apps/www/.vitepress/config.mts
index 69ffd5f9..d729444e 100644
--- a/apps/www/.vitepress/config.mts
+++ b/apps/www/.vitepress/config.mts
@@ -3,16 +3,12 @@ import { defineConfig } from 'vitepress'
import Icons from 'unplugin-icons/vite'
import tailwind from 'tailwindcss'
import autoprefixer from 'autoprefixer'
-import { createCssVariablesTheme } from 'shiki'
+import { cssVariables } from './theme/config/shiki'
// import { transformerMetaWordHighlight, transformerNotationWordHighlight } from '@shikijs/transformers'
import { siteConfig } from './theme/config/site'
import ComponentPreviewPlugin from './theme/plugins/previewer'
-
-const cssVariables = createCssVariablesTheme({
- variablePrefix: '--shiki-',
- variableDefaults: {},
-})
+import CodeWrapperPlugin from './theme/plugins/codewrapper'
// https://vitepress.dev/reference/site-config
export default defineConfig({
@@ -65,6 +61,7 @@ export default defineConfig({
],
config(md) {
md.use(ComponentPreviewPlugin)
+ md.use(CodeWrapperPlugin)
},
},
rewrites: {
diff --git a/apps/www/.vitepress/theme/components/CodeConfigCustomizer.vue b/apps/www/.vitepress/theme/components/CodeConfigCustomizer.vue
new file mode 100644
index 00000000..fa85049a
--- /dev/null
+++ b/apps/www/.vitepress/theme/components/CodeConfigCustomizer.vue
@@ -0,0 +1,98 @@
+
+
+
+ {
+ if (open) setValues(codeConfig)
+ }"
+ >
+
+
+
+
+
+
+
+
diff --git a/apps/www/.vitepress/theme/components/CodeSandbox.vue b/apps/www/.vitepress/theme/components/CodeSandbox.vue
index 8b55d399..56bfb25c 100644
--- a/apps/www/.vitepress/theme/components/CodeSandbox.vue
+++ b/apps/www/.vitepress/theme/components/CodeSandbox.vue
@@ -1,10 +1,10 @@
diff --git a/apps/www/.vitepress/theme/components/CodeWrapper.ts b/apps/www/.vitepress/theme/components/CodeWrapper.ts
new file mode 100644
index 00000000..4b9a4b37
--- /dev/null
+++ b/apps/www/.vitepress/theme/components/CodeWrapper.ts
@@ -0,0 +1,46 @@
+import { type VNode, type VNodeArrayChildren, cloneVNode, defineComponent } from 'vue'
+import { useConfigStore } from '@/stores/config'
+
+function crawlSpan(children: VNodeArrayChildren, cb: (vnode: VNode) => void) {
+ children.forEach((childNode) => {
+ if (!Array.isArray(childNode) && typeof childNode === 'object') {
+ if (typeof childNode?.children === 'string')
+ cb(childNode)
+ else
+ crawlSpan(childNode?.children as VNodeArrayChildren ?? [], cb)
+ }
+ })
+}
+
+export default defineComponent(
+ (props, { slots }) => {
+ const { codeConfig } = useConfigStore()
+
+ return () => {
+ const clonedVNode = slots.default?.()?.[0]
+ ? cloneVNode(slots.default?.()?.[0], {
+ key: JSON.stringify(codeConfig.value),
+ })
+ : undefined
+
+ // @ts-expect-error cloneVNode
+ const preVNode = [...clonedVNode?.children].find((node: VNode) => node.type === 'pre') as VNode
+ // @ts-expect-error cloneVNode
+ const codeVNode = preVNode.children?.at(0) as VNode
+
+ if (codeVNode) {
+ crawlSpan(codeVNode.children as VNodeArrayChildren, (vnode) => {
+ if (typeof vnode.children === 'string') {
+ vnode.children = vnode.children.replaceAll('@/components', codeConfig.value.componentsPath)
+ vnode.children = vnode.children.replaceAll('@/libs', codeConfig.value.utilsPath)
+ }
+ })
+
+ return clonedVNode
+ }
+ else {
+ return slots.default?.()
+ }
+ }
+ },
+)
diff --git a/apps/www/.vitepress/theme/components/ComponentPreview.vue b/apps/www/.vitepress/theme/components/ComponentPreview.vue
index 7620e0da..cc42bd56 100644
--- a/apps/www/.vitepress/theme/components/ComponentPreview.vue
+++ b/apps/www/.vitepress/theme/components/ComponentPreview.vue
@@ -1,4 +1,8 @@
@@ -47,8 +72,8 @@ const { style } = useConfigStore()
-
-
+
+
-
+
diff --git a/apps/www/.vitepress/theme/components/Logo.vue b/apps/www/.vitepress/theme/components/Logo.vue
index 3d0b8252..3acb528c 100644
--- a/apps/www/.vitepress/theme/components/Logo.vue
+++ b/apps/www/.vitepress/theme/components/Logo.vue
@@ -2,7 +2,7 @@
-
+
```
-
## Examples
### Primary
-
-
+
### Secondary
-
### Destructive
-
### Outline
@@ -138,4 +133,4 @@ import { Button } from '@/components/ui/button'
### As Child
-
\ No newline at end of file
+
diff --git a/apps/www/src/content/docs/components/calendar.md b/apps/www/src/content/docs/components/calendar.md
index ab0dff47..416aa0f8 100644
--- a/apps/www/src/content/docs/components/calendar.md
+++ b/apps/www/src/content/docs/components/calendar.md
@@ -1,12 +1,11 @@
---
title: Calendar
description: A date field component that allows users to enter and edit date.
-source: apps/www/src/lib/registry/default/ui/calendar
+source: apps/www/src/lib/registry/default/ui/calendar
primitive: https://vcalendar.io/
---
-
-
+
## About
@@ -34,13 +33,10 @@ npm install v-calendar
### Copy and paste the following code into your project
-
<<< @/lib/registry/default/ui/calendar/Calendar.vue
-
-
@@ -92,4 +88,4 @@ import { Calendar } from '@/components/ui/calendar'
-```
\ No newline at end of file
+```
diff --git a/apps/www/src/content/docs/components/card.md b/apps/www/src/content/docs/components/card.md
index 512d1761..dd11d35c 100644
--- a/apps/www/src/content/docs/components/card.md
+++ b/apps/www/src/content/docs/components/card.md
@@ -3,16 +3,13 @@ title: Card
description: Displays a card with header, content, and footer.
---
-
-
+
## Installation
-
-
```bash
npx shadcn-vue@latest add card
-```
+```
## Usage
@@ -46,4 +43,4 @@ import {
## Examples
-
\ No newline at end of file
+
diff --git a/apps/www/src/content/docs/components/checkbox.md b/apps/www/src/content/docs/components/checkbox.md
index 07697e6e..283d1fe4 100644
--- a/apps/www/src/content/docs/components/checkbox.md
+++ b/apps/www/src/content/docs/components/checkbox.md
@@ -1,20 +1,17 @@
---
title: Checkbox
description: A control that allows the user to toggle between checked and not checked.
-source: apps/www/src/lib/registry/default/ui/checkbox
+source: apps/www/src/lib/registry/default/ui/checkbox
primitive: https://www.radix-vue.com/components/checkbox.html
---
-
-
-
+
## Installation
-
```bash
npx shadcn-vue@latest add checkbox
-```
+```
## Usage
diff --git a/apps/www/src/content/docs/components/collapsible.md b/apps/www/src/content/docs/components/collapsible.md
index 19f32739..185601d4 100644
--- a/apps/www/src/content/docs/components/collapsible.md
+++ b/apps/www/src/content/docs/components/collapsible.md
@@ -1,23 +1,21 @@
----
+---
title: Collapsible
description: An interactive component which expands/collapses a panel.
-source: apps/www/src/lib/registry/default/ui/collapsible
+source: apps/www/src/lib/registry/default/ui/collapsible
primitive: https://www.radix-vue.com/components/collapsible.html
---
-
-
+
## Installation
-
### Run the following command
```bash
npx shadcn-vue@latest add collapsible
-```
+```
### Update `tailwind.config.js`
@@ -46,9 +44,8 @@ module.exports = {
},
}
```
-
-
+
## Usage
@@ -73,4 +70,4 @@ const isOpen = ref(false)
-```
\ No newline at end of file
+```
diff --git a/apps/www/src/content/docs/components/command.md b/apps/www/src/content/docs/components/command.md
index eb77f9b6..f059004d 100644
--- a/apps/www/src/content/docs/components/command.md
+++ b/apps/www/src/content/docs/components/command.md
@@ -1,21 +1,17 @@
---
title: Command
description: Fast, composable, unstyled command menu.
-source: apps/www/src/lib/registry/default/ui/command
+source: apps/www/src/lib/registry/default/ui/command
primitive: https://www.radix-vue.com/components/combobox.html
---
-
-
-
-
+
## Installation
-
```bash
npx shadcn-vue@latest add command
-```
+```
## Usage
```vue
@@ -66,9 +62,9 @@ import {
```
-## Examples
+## Examples
-### Dialog
+### Dialog
diff --git a/apps/www/src/content/docs/components/context-menu.md b/apps/www/src/content/docs/components/context-menu.md
index 13bc11ec..cc718ce8 100644
--- a/apps/www/src/content/docs/components/context-menu.md
+++ b/apps/www/src/content/docs/components/context-menu.md
@@ -1,18 +1,17 @@
----
+---
title: Context Menu
description: Displays a menu to the user — such as a set of actions or functions — triggered by a button.
-source: apps/www/src/lib/registry/default/ui/context-menu
+source: apps/www/src/lib/registry/default/ui/context-menu
primitive: https://www.radix-vue.com/components/context-menu.html
---
-
-
+
## Installation
-
+
```bash
npx shadcn-vue@latest add context-menu
-```
+```
## Usage
@@ -46,4 +45,4 @@ import {
-```
\ No newline at end of file
+```
diff --git a/apps/www/src/content/docs/components/date-picker.md b/apps/www/src/content/docs/components/date-picker.md
index 3fbdc563..7416c51c 100644
--- a/apps/www/src/content/docs/components/date-picker.md
+++ b/apps/www/src/content/docs/components/date-picker.md
@@ -3,8 +3,7 @@ title: Date Picker
description: A date picker component with range and presets.
---
-
-
+
## Installation
@@ -53,7 +52,6 @@ const date = ref()
```
-
## Examples
### Date Picker
diff --git a/apps/www/src/content/docs/components/dialog.md b/apps/www/src/content/docs/components/dialog.md
index 5c407e19..de448dbb 100644
--- a/apps/www/src/content/docs/components/dialog.md
+++ b/apps/www/src/content/docs/components/dialog.md
@@ -1,13 +1,12 @@
---
title: Dialog
description: A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
-source: apps/www/src/lib/registry/default/ui/dialog
+source: apps/www/src/lib/registry/default/ui/dialog
primitive: https://www.radix-vue.com/components/dialog.html
---
+
-
-
## Installation
```bash
npx shadcn-vue@latest add dialog
@@ -49,11 +48,11 @@ import {
```
-## Examples
+## Examples
### Custom close button
-
+
### Scroll body
@@ -67,7 +66,6 @@ import {
To activate the `Dialog` component from within a `Context Menu` or `Dropdown Menu`, you must encase the `Context Menu` or `Dropdown Menu` component in the `Dialog` component. For more information, refer to the linked issue [here](https://github.com/radix-ui/primitives/issues/1836).
-
```js:line-numbers showLineNumber{14-25}