|
| 1 | +<script> |
| 2 | +</script> |
| 3 | + |
| 4 | +<script setup> |
| 5 | +import { computed } from 'vue' |
| 6 | +import { Separator, useForwardProps } from 'reka-ui' |
| 7 | +import { reactivePick } from '@vueuse/core' |
| 8 | +import { tv } from 'tailwind-variants' |
| 9 | +import { useAppConfig } from '#imports' |
| 10 | +import theme from '#build/ui/separator' |
| 11 | +
|
| 12 | +const props = defineProps({ |
| 13 | + as: { type: null, required: false }, |
| 14 | + label: { type: String, required: false }, |
| 15 | + icon: { type: String, required: false }, |
| 16 | + avatar: { type: Object, required: false }, |
| 17 | + color: { type: null, required: false }, |
| 18 | + size: { type: null, required: false }, |
| 19 | + type: { type: null, required: false }, |
| 20 | + orientation: { type: null, required: false, default: 'horizontal' }, |
| 21 | + class: { type: null, required: false }, |
| 22 | + ui: { type: null, required: false }, |
| 23 | + decorative: { type: Boolean, required: false } |
| 24 | +}) |
| 25 | +const slots = defineSlots() |
| 26 | +const appConfig = useAppConfig() |
| 27 | +const rootProps = useForwardProps(reactivePick(props, 'as', 'decorative', 'orientation')) |
| 28 | +const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.separator || {} })({ |
| 29 | + color: props.color, |
| 30 | + orientation: props.orientation, |
| 31 | + size: props.size, |
| 32 | + type: props.type |
| 33 | +})) |
| 34 | +</script> |
| 35 | +
|
| 36 | +<template> |
| 37 | + <Separator |
| 38 | + v-bind="rootProps" |
| 39 | + :class="ui.root({ class: [props.ui?.root, props.class] })" |
| 40 | + > |
| 41 | + <div |
| 42 | + :class="[ |
| 43 | + ui.border({ class: props.ui?.border }), |
| 44 | + { |
| 45 | + 'max-w-2': label || icon || avatar || !!slots.default |
| 46 | + } |
| 47 | + ]" |
| 48 | + /> |
| 49 | +
|
| 50 | + <template v-if="label || icon || avatar || !!slots.default"> |
| 51 | + <div |
| 52 | + :class="ui.container({ class: props.ui?.container })" |
| 53 | + class="text-muted" |
| 54 | + > |
| 55 | + <slot> |
| 56 | + <span |
| 57 | + v-if="label" |
| 58 | + :class="ui.label({ class: props.ui?.label })" |
| 59 | + >{{ label }}</span> |
| 60 | + <UIcon |
| 61 | + v-else-if="icon" |
| 62 | + :name="icon" |
| 63 | + :class="ui.icon({ class: props.ui?.icon })" |
| 64 | + /> |
| 65 | + <UAvatar |
| 66 | + v-else-if="avatar" |
| 67 | + :size="props.ui?.avatarSize || ui.avatarSize()" |
| 68 | + v-bind="avatar" |
| 69 | + :class="ui.avatar({ class: props.ui?.avatar })" |
| 70 | + /> |
| 71 | + </slot> |
| 72 | + </div> |
| 73 | +
|
| 74 | + <div :class="ui.border({ class: props.ui?.border })" /> |
| 75 | + </template> |
| 76 | + </Separator> |
| 77 | +</template> |
0 commit comments