mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 04:07:56 +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<{
|
const props = withDefaults(defineProps<{
|
||||||
name: string
|
name: string
|
||||||
class?: any
|
class?: any
|
||||||
|
/**
|
||||||
|
* Whether to render the component in an iframe
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
iframe?: boolean | { [key: string]: any }
|
||||||
props?: { [key: string]: any }
|
props?: { [key: string]: any }
|
||||||
/**
|
/**
|
||||||
* Whether to format the code with Prettier
|
* Whether to format the code with Prettier
|
||||||
@@ -112,6 +117,8 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
|
|||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {} as Record<string, any>) || {})
|
}, {} as Record<string, any>) || {})
|
||||||
|
|
||||||
|
const urlSearchParams = computed(() => new URLSearchParams(optionsValues.value).toString())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -170,7 +177,8 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-center p-4" :class="props.class">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const name = route.params.slug?.[0]
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="p-4 flex flex-col justify-center h-screen overflow-auto">
|
<div class="flex flex-col justify-center items-center h-screen">
|
||||||
<component :is="name" />
|
<component :is="name" v-bind="route.query" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user