docs(ComponentCode): handle case where theme doesn't exist

This commit is contained in:
Benjamin Canac
2024-07-11 17:14:27 +02:00
parent c1ed04f722
commit c712e2e682

View File

@@ -4,7 +4,9 @@ import { upperFirst, camelCase } from 'scule'
import * as theme from '#build/ui' import * as theme from '#build/ui'
const props = defineProps<{ const props = defineProps<{
/** List of props to ignore */
ignore?: string[] ignore?: string[]
/** List of items for each prop */
items?: { [key: string]: string[] } items?: { [key: string]: string[] }
props?: { [key: string]: any } props?: { [key: string]: any }
slots?: { [key: string]: any } slots?: { [key: string]: any }
@@ -32,7 +34,7 @@ const options = computed(() => Object.keys(props.props || {}).filter((key) => {
})) }))
: prop?.type === 'boolean' : prop?.type === 'boolean'
? [{ value: true, label: 'true' }, { value: false, label: 'false' }] ? [{ value: true, label: 'true' }, { value: false, label: 'false' }]
: Object.keys(componentTheme.variants?.[key] || {}).map(variant => ({ : Object.keys(componentTheme?.variants?.[key] || {}).map(variant => ({
value: variant, value: variant,
label: variant, label: variant,
chip: key === 'color' ? { color: variant } : undefined chip: key === 'color' ? { color: variant } : undefined