mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-28 02:40:35 +01:00
feat(InputMenu): new component (#86)
This commit is contained in:
@@ -28,11 +28,11 @@ export interface BreadcrumbProps<T> extends Omit<PrimitiveProps, 'asChild'> {
|
||||
type SlotProps<T> = (props: { item: T, index: number, active?: boolean }) => any
|
||||
|
||||
export type BreadcrumbSlots<T extends { slot?: string }> = {
|
||||
leading: SlotProps<T>
|
||||
label: SlotProps<T>
|
||||
trailing: SlotProps<T>
|
||||
item: SlotProps<T>
|
||||
separator(): any
|
||||
'item': SlotProps<T>
|
||||
'item-leading': SlotProps<T>
|
||||
'item-label': SlotProps<T>
|
||||
'item-trailing': SlotProps<T>
|
||||
'separator'(): any
|
||||
} & DynamicSlots<T, SlotProps<T>>
|
||||
</script>
|
||||
|
||||
@@ -55,21 +55,21 @@ const ui = computed(() => tv({ extend: breadcrumb, slots: props.ui })())
|
||||
<Primitive :as="as" aria-label="breadcrumb" :class="ui.root({ class: props.class })">
|
||||
<ol :class="ui.list()">
|
||||
<template v-for="(item, index) in items" :key="index">
|
||||
<li :class="ui.item()">
|
||||
<ULink as="span" v-bind="omit(item, ['label', 'icon', 'avatar', 'slot'])" :aria-current="index === items!.length - 1 ? 'page' : undefined" :class="ui.link({ active: index === items!.length - 1, disabled: !!item.disabled, to: !!item.to })" raw>
|
||||
<li :class="ui.itemWrapper()">
|
||||
<ULink as="span" v-bind="omit(item, ['label', 'icon', 'avatar', 'slot'])" :aria-current="index === items!.length - 1 ? 'page' : undefined" :class="ui.item({ active: index === items!.length - 1, disabled: !!item.disabled, to: !!item.to })" raw>
|
||||
<slot :name="item.slot || 'item'" :item="item" :index="index">
|
||||
<slot name="leading" :item="item" :active="index === items!.length - 1" :index="index">
|
||||
<UAvatar v-if="item.avatar" size="2xs" v-bind="item.avatar" :class="ui.linkLeadingAvatar({ active: index === items!.length - 1 })" />
|
||||
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.linkLeadingIcon({ active: index === items!.length - 1 })" />
|
||||
<slot :name="item.slot ? `${item.slot}-leading`: 'item-leading'" :item="item" :active="index === items!.length - 1" :index="index">
|
||||
<UAvatar v-if="item.avatar" size="2xs" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ active: index === items!.length - 1 })" />
|
||||
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.itemLeadingIcon({ active: index === items!.length - 1 })" />
|
||||
</slot>
|
||||
|
||||
<span v-if="item.label || $slots.label" :class="ui.linkLabel()">
|
||||
<slot name="label" :item="item" :active="index === items!.length - 1" :index="index">
|
||||
<span v-if="item.label || $slots[item.slot ? `${item.slot}-label`: 'item-label']" :class="ui.itemLabel()">
|
||||
<slot :name="item.slot ? `${item.slot}-label`: 'item-label'" :item="item" :active="index === items!.length - 1" :index="index">
|
||||
{{ item.label }}
|
||||
</slot>
|
||||
</span>
|
||||
|
||||
<slot name="trailing" :item="item" :active="index === items!.length - 1" :index="index" />
|
||||
<slot :name="item.slot ? `${item.slot}-trailing`: 'item-trailing'" :item="item" :active="index === items!.length - 1" :index="index" />
|
||||
</slot>
|
||||
</ULink>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user