diff --git a/docs/components/content/ComponentCard.vue b/docs/components/content/ComponentCard.vue index 63ae3c0d..e4f57ca4 100644 --- a/docs/components/content/ComponentCard.vue +++ b/docs/components/content/ComponentCard.vue @@ -41,7 +41,7 @@ @@ -113,6 +113,7 @@ const props = defineProps({ const baseProps = reactive({ ...props.baseProps }) const componentProps = reactive({ ...props.props }) +const { $prettier } = useNuxtApp() const appConfig = useAppConfig() const route = useRoute() // eslint-disable-next-line vue/no-dupe-keys @@ -124,7 +125,7 @@ const meta = await fetchComponentMeta(name) // Computed -const fullProps = computed(() => ({ ...baseProps, ...componentProps })) +const fullProps = computed(() => ({ ...componentProps, ...baseProps })) const vModel = computed({ get: () => baseProps.modelValue, set: (value) => { @@ -186,7 +187,7 @@ const propsToSelect = computed(() => Object.keys(componentProps).map((key) => { const code = computed(() => { let code = `\`\`\`html <${name}` - for (const [key, value] of Object.entries(componentProps)) { + for (const [key, value] of Object.entries(fullProps.value)) { if (value === 'undefined' || value === null) { continue } @@ -206,7 +207,7 @@ const code = computed(() => { code += `> ${props.code}` } else { - code += `>${props.code}` + code += `>${props.code.endsWith('>') ? `${props.code}\n` : props.code}` } } else { code += ' />' @@ -235,16 +236,27 @@ function renderObject (obj: any) { const shikiHighlighter = useShikiHighlighter({}) const codeHighlighter = async (code: string, lang: string, theme: any, highlights: number[]) => shikiHighlighter.getHighlightedAST(code, lang, theme, { highlights }) -const { data: ast } = await useAsyncData(`${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots })}`, () => transformContent('content:_markdown.md', code.value, { - markdown: { - highlight: { - highlighter: codeHighlighter, - theme: { - light: 'material-theme-lighter', - default: 'material-theme', - dark: 'material-theme-palenight' - } +const { data: ast } = await useAsyncData( + `${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots })}`, + async () => { + let formatted = '' + try { + formatted = await $prettier.format(code.value) || code.value + } catch (error) { + formatted = code.value } - } -}), { watch: [code] }) + + return transformContent('content:_markdown.md', formatted, { + markdown: { + highlight: { + highlighter: codeHighlighter, + theme: { + light: 'material-theme-lighter', + default: 'material-theme', + dark: 'material-theme-palenight' + } + } + } + }) + }, { watch: [code] }) diff --git a/docs/components/content/examples/FormGroupErrorSlotExample.vue b/docs/components/content/examples/FormGroupErrorSlotExample.vue index d09826bf..7ce9b38a 100644 --- a/docs/components/content/examples/FormGroupErrorSlotExample.vue +++ b/docs/components/content/examples/FormGroupErrorSlotExample.vue @@ -5,8 +5,9 @@ diff --git a/docs/content/2.elements/4.badge.md b/docs/content/2.elements/4.badge.md index 0ef061a9..14911e70 100644 --- a/docs/content/2.elements/4.badge.md +++ b/docs/content/2.elements/4.badge.md @@ -38,6 +38,7 @@ Use the `color` and `variant` props to change the visual style of the Badge. props: color: 'primary' variant: 'solid' +code: Badge --- Badge @@ -59,6 +60,7 @@ options: - solid excludedProps: - color +code: Badge --- Badge @@ -78,6 +80,7 @@ options: - solid excludedProps: - color +code: Badge --- Badge @@ -97,6 +100,7 @@ options: - solid excludedProps: - color +code: Badge --- Badge @@ -110,6 +114,7 @@ Use the `size` prop to change the size of the Badge. --- props: size: 'sm' +code: Badge --- Badge @@ -126,6 +131,7 @@ props: rounded: 'rounded-full' excludedProps: - ui +code: Badge --- Badge diff --git a/docs/content/2.elements/5.button.md b/docs/content/2.elements/5.button.md index 2267403d..ec9e4e3f 100644 --- a/docs/content/2.elements/5.button.md +++ b/docs/content/2.elements/5.button.md @@ -36,6 +36,7 @@ Use the `color` and `variant` props to change the visual style of the Button. props: color: 'primary' variant: 'solid' +code: Button --- Button @@ -56,9 +57,10 @@ options: restriction: expected values: - solid - - ghost + - ghost excludedProps: - color +code: Button --- Button @@ -77,9 +79,10 @@ options: values: - solid - ghost - - link + - link excludedProps: - color +code: Button --- Button @@ -97,9 +100,10 @@ options: restriction: expected values: - solid - - link + - link excludedProps: - color +code: Button --- Button @@ -113,6 +117,7 @@ Use the `size` prop to change the size of the Button. --- props: size: 'sm' +code: Button --- Button @@ -129,6 +134,7 @@ props: rounded: 'rounded-full' excludedProps: - ui +code: Button --- Button @@ -183,6 +189,7 @@ Use the `disabled` prop to disable the Button. --- props: disabled: true +code: Button --- Button @@ -198,6 +205,7 @@ Use the `loading-icon` prop to set a different icon or change it globally in `ui --- props: loading: true +code: Button --- Button @@ -211,6 +219,7 @@ Use the `block` prop to make the Button fill the width of its container. --- props: block: true +code: Button --- Button @@ -225,6 +234,7 @@ Use the `to` prop to make the Button a link. props: to: 'https://volta.net' target: '_blank' +code: Button --- Button diff --git a/docs/content/3.forms/1.input.md b/docs/content/3.forms/1.input.md index 0078d8ad..1f19ad96 100644 --- a/docs/content/3.forms/1.input.md +++ b/docs/content/3.forms/1.input.md @@ -19,7 +19,6 @@ Use the `color` and `variant` props to change the visual style of the Input. ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: color: 'primary' @@ -34,7 +33,6 @@ Besides all the colors from the `ui.colors` object, you can also use the `white` ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: color: 'white' @@ -49,7 +47,6 @@ excludedProps: ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: color: 'gray' @@ -65,8 +62,6 @@ Use the `size` prop to change the size of the Input. ::component-card --- -baseProps: - name: 'input' props: size: 'sm' --- @@ -80,8 +75,6 @@ We have improved the implementation of certain types such as [Checkbox](/forms/c ::component-card --- -baseProps: - name: 'input' props: type: 'password' --- @@ -93,8 +86,6 @@ Use the `placeholder` prop to set a placeholder text. ::component-card --- -baseProps: - name: 'input' props: placeholder: 'Search...' --- @@ -109,7 +100,6 @@ Use the `leading` and `trailing` props to set the icon position or the `leading- ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: icon: 'i-heroicons-magnifying-glass-20-solid' @@ -134,7 +124,6 @@ Use the `disabled` prop to disable the Input. ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: disabled: true @@ -150,7 +139,6 @@ Use the `loading-icon` prop to set a different icon or change it globally in `ui ::component-card --- baseProps: - name: 'input' placeholder: 'Searching...' props: loading: true @@ -171,7 +159,6 @@ Use the `#leading` slot to set the content of the leading icon. slots: leading: baseProps: - name: 'input' placeholder: 'Search...' --- @@ -188,7 +175,6 @@ Use the `#trailing` slot to set the content of the trailing icon. slots: trailing: EUR baseProps: - name: 'input' placeholder: 'Search...' --- diff --git a/docs/content/3.forms/2.textarea.md b/docs/content/3.forms/2.textarea.md index b03a8210..264d5edd 100644 --- a/docs/content/3.forms/2.textarea.md +++ b/docs/content/3.forms/2.textarea.md @@ -19,7 +19,6 @@ Use the `color` and `variant` props to change the visual style of the Textarea. ::component-card --- baseProps: - name: 'textarea' placeholder: 'Search...' props: color: 'primary' @@ -34,7 +33,6 @@ Besides all the colors from the `ui.colors` object, you can also use the `white` ::component-card --- baseProps: - name: 'textarea' placeholder: 'Search...' props: color: 'white' @@ -49,7 +47,6 @@ excludedProps: ::component-card --- baseProps: - name: 'textarea' placeholder: 'Search...' props: color: 'gray' @@ -66,7 +63,6 @@ Use the `size` prop to change the size of the Textarea. ::component-card --- baseProps: - name: 'textarea' props: size: 'sm' --- @@ -78,8 +74,6 @@ Use the `placeholder` prop to set a placeholder text. ::component-card --- -baseProps: - name: 'textarea' props: placeholder: 'Search...' --- @@ -92,7 +86,6 @@ Use the `rows` prop to set the number of rows of the Textarea. ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: rows: 1 @@ -106,7 +99,6 @@ Use the `disabled` prop to disable the Textarea. ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: disabled: true @@ -120,7 +112,6 @@ Use the `autoresize` prop to enable the autoresize. Writing more lines than the ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' modelValue: 'Here is an autoresize Textarea, write new lines to make the Textarea grow up...' props: @@ -135,7 +126,6 @@ Use the `resize` prop to enable the resize control. ::component-card --- baseProps: - name: 'input' placeholder: 'Search...' props: resize: true diff --git a/docs/content/3.forms/3.select.md b/docs/content/3.forms/3.select.md index 2b85a39a..ca789a6f 100644 --- a/docs/content/3.forms/3.select.md +++ b/docs/content/3.forms/3.select.md @@ -27,7 +27,6 @@ Use the `color` and `variant` props to change the visual style of the Select. ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -45,7 +44,6 @@ Besides all the colors from the `ui.colors` object, you can also use the `white` ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -63,7 +61,6 @@ excludedProps: ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -83,7 +80,6 @@ Use the `size` prop to change the size of the Select. ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -100,7 +96,6 @@ Use the `placeholder` prop to set a placeholder text. ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -119,7 +114,6 @@ Use the `trailing-icon` prop to set a different icon or change it globally in `u ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -147,7 +141,6 @@ Use the `disabled` prop to disable the Select. ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -169,7 +162,6 @@ Use the `loading-icon` prop to set a different icon or change it globally in `ui ::component-card --- baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -194,7 +186,6 @@ Use the `#leading` slot to set the content of the leading icon. slots: leading: baseProps: - name: 'select' options: - 'United States' - 'Canada' @@ -215,7 +206,6 @@ Use the `#trailing` slot to set the content of the trailing icon. slots: trailing: baseProps: - name: 'input' placeholder: 'Search...' --- diff --git a/docs/content/3.forms/5.checkbox.md b/docs/content/3.forms/5.checkbox.md index 6d67949c..d6c90d26 100644 --- a/docs/content/3.forms/5.checkbox.md +++ b/docs/content/3.forms/5.checkbox.md @@ -18,8 +18,6 @@ Use the `label` prop to display a label on the right. ::component-card --- -baseProps: - name: 'checkbox1' props: label: 'Label' --- @@ -32,7 +30,6 @@ Use the `color` prop to change the style of the Checkbox. ::component-card --- baseProps: - name: 'checkbox2' label: 'Label' props: color: 'primary' @@ -45,8 +42,6 @@ Use the `required` prop to display a red star next to the label. ::component-card --- -baseProps: - name: 'checkbox3' props: label: 'Label' required: true @@ -59,8 +54,6 @@ Use the `help` prop to display some text under the Checkbox. ::component-card --- -baseProps: - name: 'checkbox4' props: label: 'Label' help: 'Please check this box' @@ -73,9 +66,6 @@ Use the `disabled` prop to disable the Checkbox. ::component-card --- -baseProps: - name: 'checkbox4' - modelValue: true props: disabled: true --- @@ -91,8 +81,6 @@ Use the `#label` slot to override the content of the label. --- slots: label: Label -baseProps: - name: 'checkbox5' --- #label diff --git a/docs/content/3.forms/6.radio.md b/docs/content/3.forms/6.radio.md index 62311706..ba6ad0d4 100644 --- a/docs/content/3.forms/6.radio.md +++ b/docs/content/3.forms/6.radio.md @@ -18,8 +18,6 @@ Use the `label` prop to display a label on the right. ::component-card --- -baseProps: - name: 'radio1' props: label: 'Label' --- @@ -32,7 +30,6 @@ Use the `color` prop to change the style of the Radio. ::component-card --- baseProps: - name: 'radio2' label: 'Label' props: color: 'primary' @@ -45,8 +42,6 @@ Use the `required` prop to display a red star next to the label. ::component-card --- -baseProps: - name: 'radio3' props: label: 'Label' required: true @@ -59,8 +54,6 @@ Use the `help` prop to display some text under the Radio. ::component-card --- -baseProps: - name: 'radio4' props: label: 'Label' help: 'Please choose one' @@ -74,9 +67,7 @@ Use the `disabled` prop to disable the Radio. ::component-card --- baseProps: - name: 'radio5' label: 'Label' - value: true props: disabled: true --- @@ -92,8 +83,6 @@ Use the `#label` slot to override the content of the label. --- slots: label: Label -baseProps: - name: 'radio6' --- #label diff --git a/docs/content/3.forms/8.range.md b/docs/content/3.forms/8.range.md index 126a8f35..ce4a7cdd 100644 --- a/docs/content/3.forms/8.range.md +++ b/docs/content/3.forms/8.range.md @@ -19,7 +19,6 @@ Use the `color` prop to change the visual style of the Range. ::component-card --- baseProps: - name: range' placeholder: 'Search...' props: color: 'primary' @@ -32,8 +31,6 @@ Use the `size` prop to change the size of the Range. ::component-card --- -baseProps: - name: 'range' props: size: 'md' --- @@ -45,8 +42,6 @@ Use the `disabled` prop to disable the Range. ::component-card --- -baseProps: - name: 'range' props: disabled: true --- @@ -58,8 +53,6 @@ Use the `min` and `max` prop to configure the Range. ::component-card --- -baseProps: - name: 'range' props: min: 0 max: 100 @@ -72,8 +65,6 @@ Use the `step` prop to change the step increment. ::component-card --- -baseProps: - name: 'range' props: step: 20 --- diff --git a/docs/content/3.forms/9.form-group.md b/docs/content/3.forms/9.form-group.md index 398c549b..5a62ad71 100644 --- a/docs/content/3.forms/9.form-group.md +++ b/docs/content/3.forms/9.form-group.md @@ -10,13 +10,12 @@ links: ## Usage -Use the FormGroup component around an [Input](/forms/input), [Textarea](/forms/textarea), [Select](/forms/select) or a [SelectMenu](/forms/select-menu) with the `name` prop to automatically associate a `