mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
docs(ComponentExample): add iframe prop
This commit is contained in:
@@ -5,6 +5,11 @@ import { get, set } from '#ui/utils'
|
||||
const props = withDefaults(defineProps<{
|
||||
name: string
|
||||
class?: any
|
||||
/**
|
||||
* Whether to render the component in an iframe
|
||||
* @defaultValue false
|
||||
*/
|
||||
iframe?: boolean | { [key: string]: any }
|
||||
props?: { [key: string]: any }
|
||||
/**
|
||||
* Whether to format the code with Prettier
|
||||
@@ -112,6 +117,8 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
|
||||
}
|
||||
return acc
|
||||
}, {} as Record<string, any>) || {})
|
||||
|
||||
const urlSearchParams = computed(() => new URLSearchParams(optionsValues.value).toString())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -170,7 +177,8 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center p-4" :class="props.class">
|
||||
<component :is="camelName" v-bind="{ ...componentProps, ...optionsValues }" />
|
||||
<iframe v-if="iframe" v-bind="typeof iframe === 'object' ? iframe : {}" :src="`/examples/${name}?${urlSearchParams}`" class="w-full" />
|
||||
<component :is="camelName" v-else v-bind="{ ...componentProps, ...optionsValues }" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -5,7 +5,7 @@ const name = route.params.slug?.[0]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-4 flex flex-col justify-center h-screen overflow-auto">
|
||||
<component :is="name" />
|
||||
<div class="flex flex-col justify-center items-center h-screen">
|
||||
<component :is="name" v-bind="route.query" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user