mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
133 lines
3.9 KiB
TypeScript
133 lines
3.9 KiB
TypeScript
import type { ModuleOptions } from '../module'
|
|
|
|
export default (options: Required<ModuleOptions>) => ({
|
|
slots: {
|
|
root: 'flex items-center gap-2',
|
|
list: 'relative flex p-1 group',
|
|
indicator: 'absolute transition-[translate,width] duration-200',
|
|
trigger: ['group relative inline-flex items-center shrink-0 min-w-0 data-[state=inactive]:text-(--ui-text-muted) hover:data-[state=inactive]:not-disabled:text-(--ui-text) font-medium rounded-[calc(var(--ui-radius)*1.5)] disabled:cursor-not-allowed disabled:opacity-75', options.theme.transitions && 'transition-colors'],
|
|
content: 'focus:outline-none w-full',
|
|
leadingIcon: 'shrink-0',
|
|
leadingAvatar: 'shrink-0',
|
|
leadingAvatarSize: '',
|
|
label: 'truncate'
|
|
},
|
|
variants: {
|
|
color: {
|
|
...Object.fromEntries((options.theme.colors || []).map((color: string) => [color, ''])),
|
|
neutral: ''
|
|
},
|
|
variant: {
|
|
pill: {
|
|
list: 'bg-(--ui-bg-elevated) rounded-[calc(var(--ui-radius)*2)]',
|
|
trigger: 'flex-1 w-full',
|
|
indicator: 'rounded-[calc(var(--ui-radius)*1.5)] shadow-xs'
|
|
},
|
|
link: {
|
|
list: 'border-(--ui-border)',
|
|
indicator: 'rounded-full'
|
|
}
|
|
},
|
|
orientation: {
|
|
horizontal: {
|
|
root: 'flex-col',
|
|
list: 'w-full',
|
|
indicator: 'left-0 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position)',
|
|
trigger: 'justify-center'
|
|
},
|
|
vertical: {
|
|
list: 'flex-col',
|
|
indicator: 'top-0 h-(--reka-tabs-indicator-size) translate-y-(--reka-tabs-indicator-position)'
|
|
}
|
|
},
|
|
size: {
|
|
xs: {
|
|
trigger: 'px-2 py-1 text-xs gap-1',
|
|
leadingIcon: 'size-4',
|
|
leadingAvatarSize: '3xs'
|
|
},
|
|
sm: {
|
|
trigger: 'px-2.5 py-1.5 text-xs gap-1.5',
|
|
leadingIcon: 'size-4',
|
|
leadingAvatarSize: '3xs'
|
|
},
|
|
md: {
|
|
trigger: 'px-3 py-1.5 text-sm gap-1.5',
|
|
leadingIcon: 'size-5',
|
|
leadingAvatarSize: '2xs'
|
|
},
|
|
lg: {
|
|
trigger: 'px-3 py-2 text-sm gap-2',
|
|
leadingIcon: 'size-5',
|
|
leadingAvatarSize: '2xs'
|
|
},
|
|
xl: {
|
|
trigger: 'px-3 py-2 text-base gap-2',
|
|
leadingIcon: 'size-6',
|
|
leadingAvatarSize: 'xs'
|
|
}
|
|
}
|
|
},
|
|
compoundVariants: [{
|
|
orientation: 'horizontal',
|
|
variant: 'pill',
|
|
class: {
|
|
indicator: 'inset-y-1'
|
|
}
|
|
}, {
|
|
orientation: 'horizontal',
|
|
variant: 'link',
|
|
class: {
|
|
list: 'border-b -mb-px',
|
|
indicator: '-bottom-px h-px'
|
|
}
|
|
}, {
|
|
orientation: 'vertical',
|
|
variant: 'pill',
|
|
class: {
|
|
indicator: 'inset-x-1',
|
|
list: 'items-center'
|
|
}
|
|
}, {
|
|
orientation: 'vertical',
|
|
variant: 'link',
|
|
class: {
|
|
list: 'border-s -ms-px',
|
|
indicator: '-start-px w-px'
|
|
}
|
|
}, ...(options.theme.colors || []).map((color: string) => ({
|
|
color,
|
|
variant: 'pill',
|
|
class: {
|
|
indicator: `bg-(--ui-${color})`,
|
|
trigger: `data-[state=active]:text-(--ui-bg) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ui-${color})`
|
|
}
|
|
})), {
|
|
color: 'neutral',
|
|
variant: 'pill',
|
|
class: {
|
|
indicator: 'bg-(--ui-bg-inverted)',
|
|
trigger: 'data-[state=active]:text-(--ui-bg) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ui-border-inverted)'
|
|
}
|
|
}, ...(options.theme.colors || []).map((color: string) => ({
|
|
color,
|
|
variant: 'link',
|
|
class: {
|
|
indicator: `bg-(--ui-${color})`,
|
|
trigger: `data-[state=active]:text-(--ui-${color}) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--ui-${color})`
|
|
}
|
|
})), {
|
|
color: 'neutral',
|
|
variant: 'link',
|
|
class: {
|
|
indicator: 'bg-(--ui-bg-inverted)',
|
|
trigger: 'data-[state=active]:text-(--ui-text-highlighted) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--ui-border-inverted)'
|
|
}
|
|
}],
|
|
defaultVariants: {
|
|
color: 'primary',
|
|
variant: 'pill',
|
|
size: 'md'
|
|
}
|
|
})
|