Skip to content
Snippets Groups Projects
Commit db783a1a authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor(AFieldset): rework title look and support custom tags

parent d0dcd5c1
No related branches found
No related tags found
No related merge requests found
<template>
<component :is="as" class="tw-shadow tw-p-6 tw-rounded tw-m-0">
<component :is="as" class="tw-shadow tw-rounded tw-m-0">
<template v-if="title">
<component
:is="as === 'fieldset' ? 'legend' : 'h2'"
class="tw-text-xl tw-font-bold -tw-mt-2 tw-m-0 tw-mb-3"
:is="titleTag ? titleTag : as === 'fieldset' ? 'legend' : 'h2'"
class="tw-font-bold tw-m-0 tw-px-6 tw-py-3 tw-border-b tw-border-gray-200 tw-w-full"
:class="{ 'tw-float-left tw-w-full': as === 'fieldset' }"
>{{ title }}</component
>
<div v-if="as === 'fieldset'" class="tw-clear-left" role="presentation" />
</template>
<slot />
<div class="tw-p-6">
<slot />
</div>
</component>
</template>
......@@ -19,10 +21,12 @@ withDefaults(
defineProps<{
title?: string
as?: string
titleTag?: string | undefined
}>(),
{
as: 'fieldset',
title: '',
titleTag: undefined,
},
)
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment