diff --git a/docs/app/components/content/ComponentCode.vue b/docs/app/components/content/ComponentCode.vue index e03b531b..a0b0094a 100644 --- a/docs/app/components/content/ComponentCode.vue +++ b/docs/app/components/content/ComponentCode.vue @@ -3,6 +3,7 @@ import { upperFirst, camelCase } from 'scule' import * as theme from '#build/ui' const props = defineProps<{ + ignore?: string[] props?: { [key: string]: any } slots?: { [key: string]: any } }>() @@ -16,22 +17,24 @@ const name = `U${upperFirst(camelName)}` const componentProps = reactive({ ...(props.props || {}) }) const componentTheme = theme[camelName] -// const meta = await fetchComponentMeta(name as any) +const meta = await fetchComponentMeta(name as any) -const options = computed(() => Object.keys(props.props || {}).map((key) => { - // const prop = meta?.meta?.props?.find((prop: any) => prop.name === key) - const variants = componentTheme.variants?.[key] - const items = variants - ? Object.keys(variants).map(variant => ({ +const options = computed(() => Object.keys(props.props || {}).filter((key) => { + return !props.ignore?.includes(key) +}).map((key) => { + const prop = meta?.meta?.props?.find((prop: any) => prop.name === key) + const variants = Object.keys(componentTheme.variants?.[key] || {}) + const items = prop?.type === 'boolean' + ? [{ value: true, label: 'true' }, { value: false, label: 'false' }] + : variants.map(variant => ({ value: variant, label: variant, chip: key === 'color' ? { color: variant } : undefined })).filter(variant => key === 'color' ? !['error'].includes(variant.value) : true) - : [] return { name: key, - label: camelCase(key), + label: key, items } })) @@ -41,7 +44,29 @@ const code = computed(() => {