mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
chore(SelectCustom): improve option slot
This commit is contained in:
@@ -36,12 +36,12 @@
|
|||||||
:value="option"
|
:value="option"
|
||||||
:disabled="option.disabled"
|
:disabled="option.disabled"
|
||||||
>
|
>
|
||||||
<li :class="resolveOptionClass({ active, disabled })">
|
<li :class="resolveOptionClass({ active, selected, disabled })">
|
||||||
<span :class="[selected ? 'font-semibold' : 'font-normal', 'block truncate']">
|
<div :class="listOptionContainerClass">
|
||||||
<slot name="option" :option="option" :active="active" :selected="selected">
|
<slot name="option" :option="option" :active="active" :selected="selected">
|
||||||
{{ option[textAttribute] }}
|
<span class="block truncate">{{ option[textAttribute] }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</div>
|
||||||
|
|
||||||
<span v-if="selected" :class="resolveOptionIconClass({ active })">
|
<span v-if="selected" :class="resolveOptionIconClass({ active })">
|
||||||
<Icon :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
|
<Icon :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
|
||||||
@@ -147,6 +147,10 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.selectCustom.list.option.base
|
default: () => $ui.selectCustom.list.option.base
|
||||||
},
|
},
|
||||||
|
listOptionContainerClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.selectCustom.list.option.container
|
||||||
|
},
|
||||||
listOptionActiveClass: {
|
listOptionActiveClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.selectCustom.list.option.active
|
default: () => $ui.selectCustom.list.option.active
|
||||||
@@ -155,6 +159,14 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.selectCustom.list.option.inactive
|
default: () => $ui.selectCustom.list.option.inactive
|
||||||
},
|
},
|
||||||
|
listOptionSelectedClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.selectCustom.list.option.selected
|
||||||
|
},
|
||||||
|
listOptionUnselectedClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.selectCustom.list.option.unselected
|
||||||
|
},
|
||||||
listOptionDisabledClass: {
|
listOptionDisabledClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.selectCustom.list.option.disabled
|
default: () => $ui.selectCustom.list.option.disabled
|
||||||
@@ -234,10 +246,11 @@ const iconWrapperClass = classNames(
|
|||||||
$ui.selectCustom.icon.trailing.wrapper
|
$ui.selectCustom.icon.trailing.wrapper
|
||||||
)
|
)
|
||||||
|
|
||||||
function resolveOptionClass ({ active, disabled }: { active: boolean, disabled: boolean }) {
|
function resolveOptionClass ({ active, selected, disabled }: { active: boolean, selected: boolean, disabled: boolean }) {
|
||||||
return classNames(
|
return classNames(
|
||||||
props.listOptionBaseClass,
|
props.listOptionBaseClass,
|
||||||
active ? props.listOptionActiveClass : props.listOptionInactiveClass,
|
active ? props.listOptionActiveClass : props.listOptionInactiveClass,
|
||||||
|
selected ? props.listOptionSelectedClass : props.listOptionUnselectedClass,
|
||||||
disabled && props.listOptionDisabledClass
|
disabled && props.listOptionDisabledClass
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,9 +194,12 @@ export default (variantColors: string[]) => {
|
|||||||
container: 'z-10 w-full py-1',
|
container: 'z-10 w-full py-1',
|
||||||
base: 'u-bg-white shadow-lg rounded-md ring-1 u-ring-gray-200 focus:outline-none overflow-y-auto py-1 max-h-60',
|
base: 'u-bg-white shadow-lg rounded-md ring-1 u-ring-gray-200 focus:outline-none overflow-y-auto py-1 max-h-60',
|
||||||
option: {
|
option: {
|
||||||
base: 'cursor-default select-none relative py-2 pl-4 pr-10 text-sm',
|
base: 'cursor-default select-none relative py-2 pl-4 pr-10 text-sm group',
|
||||||
|
container: 'flex items-center',
|
||||||
active: 'text-white bg-primary-600',
|
active: 'text-white bg-primary-600',
|
||||||
inactive: 'u-text-gray-900',
|
inactive: 'u-text-gray-900',
|
||||||
|
selected: 'font-semibold',
|
||||||
|
unselected: 'font-normal',
|
||||||
disabled: 'cursor-not-allowed opacity-50',
|
disabled: 'cursor-not-allowed opacity-50',
|
||||||
icon: {
|
icon: {
|
||||||
base: 'absolute inset-y-0 right-0 flex items-center pr-4',
|
base: 'absolute inset-y-0 right-0 flex items-center pr-4',
|
||||||
|
|||||||
Reference in New Issue
Block a user