docs(ComponentProps): improve display

This commit is contained in:
Benjamin Canac
2024-07-24 15:53:31 +02:00
parent 5176bf92bc
commit 5114136d25
2 changed files with 4 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
return !props.ignore?.includes(prop.name)
}).map((prop) => {
prop.default = prop.default ?? prop.tags?.find(tag => tag.name === 'defaultValue')?.text ?? componentTheme?.defaultVariants?.[prop.name]
// @ts-expect-error - Type is not correct
prop.type = !['boolean'].includes(prop.type) && prop.schema?.kind === 'enum' && Object.keys(prop.schema.schema)?.length ? Object.values(prop.schema.schema).map(schema => schema?.type ? schema.type : schema).join(' | ') : prop.type
return prop
}).sort((a, b) => {
if (a.name === 'as') {

View File

@@ -25,9 +25,8 @@ const schemaProps = computed(() => getSchemaProps(props.prop.schema))
<ProseUl>
<ProseLi v-for="schemaProp in schemaProps" :key="schemaProp.name">
<HighlightInlineType :type="`${schemaProp.name}${schemaProp.required === false ? '?' : ''}: ${schemaProp.type}`" />
<p v-if="schemaProp.description" class="text-gray-600 dark:text-gray-400">
{{ schemaProp.description }}
</p>
<MDC v-if="schemaProp.description" :value="schemaProp.description" class="text-gray-500 dark:text-gray-400 my-1" />
</ProseLi>
</ProseUl>
</Collapsible>