mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
134 lines
3.8 KiB
TypeScript
134 lines
3.8 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 min-w-0 data-[state=inactive]:text-muted hover:data-[state=inactive]:not-disabled:text-default font-medium rounded-md 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-elevated rounded-lg',
|
|
trigger: 'grow',
|
|
indicator: 'rounded-md shadow-xs'
|
|
},
|
|
link: {
|
|
list: 'border-default',
|
|
indicator: 'rounded-full',
|
|
trigger: 'focus:outline-none'
|
|
}
|
|
},
|
|
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-${color}`,
|
|
trigger: `data-[state=active]:text-inverted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-${color}`
|
|
}
|
|
})), {
|
|
color: 'neutral',
|
|
variant: 'pill',
|
|
class: {
|
|
indicator: 'bg-inverted',
|
|
trigger: 'data-[state=active]:text-inverted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-inverted'
|
|
}
|
|
}, ...(options.theme.colors || []).map((color: string) => ({
|
|
color,
|
|
variant: 'link',
|
|
class: {
|
|
indicator: `bg-${color}`,
|
|
trigger: `data-[state=active]:text-${color} focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}`
|
|
}
|
|
})), {
|
|
color: 'neutral',
|
|
variant: 'link',
|
|
class: {
|
|
indicator: 'bg-inverted',
|
|
trigger: 'data-[state=active]:text-highlighted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-inverted'
|
|
}
|
|
}],
|
|
defaultVariants: {
|
|
color: 'primary',
|
|
variant: 'pill',
|
|
size: 'md'
|
|
}
|
|
})
|