mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 09:50:33 +01:00
docs: improve props
This commit is contained in:
31
docs/app/components/content/ComponentPropsSchema.vue
Normal file
31
docs/app/components/content/ComponentPropsSchema.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import type { PropertyMeta } from 'vue-component-meta'
|
||||
|
||||
const props = defineProps<{
|
||||
prop: PropertyMeta
|
||||
}>()
|
||||
|
||||
function getSchemaProps(schema: PropertyMeta['schema']) {
|
||||
if (!schema || typeof schema === 'string') {
|
||||
return []
|
||||
}
|
||||
|
||||
if (schema.kind === 'object') {
|
||||
return Object.values(schema.schema)
|
||||
}
|
||||
|
||||
return (Array.isArray(schema.schema) ? schema.schema : Object.values(schema.schema)).flatMap(getSchemaProps)
|
||||
}
|
||||
|
||||
const schemaProps = computed(() => getSchemaProps(props.prop.schema))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Collapsible v-if="schemaProps?.length" class="mt-1" :ui="{ trigger: 'ml-1.5' }">
|
||||
<ProseUl>
|
||||
<ProseLi v-for="schemaProp in schemaProps" :key="schemaProp.name">
|
||||
<HighlightInlineType :type="`${schemaProp.name}: ${schemaProp.type}`" />
|
||||
</ProseLi>
|
||||
</ProseUl>
|
||||
</Collapsible>
|
||||
</template>
|
||||
Reference in New Issue
Block a user