-
Notifications
You must be signed in to change notification settings - Fork 725
feat(components): add ui
field in items
#4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3
Are you sure you want to change the base?
Conversation
commit: |
I agree this is a nice addition! However, this change should be applied to all components with an |
@benjamincanac I can work on this. Should I bunch it up into a one big PR or should I create separate PR for each instance? |
Great! No you can do this in this PR π |
iconClass
field in items
Quick checklist to track the progress on this (I will validate it as I go through it):
|
@benjamincanac Just one more idea, what if we added a i.e. for the Accordion each item could have a <AccordionItem
v-for="(item, index) in props.items"
v-slot="{ open }"
:key="index"
:value="item.value || String(index)"
:disabled="item.disabled"
:class="ui.item({ class: [props.ui?.item, item.ui?.item] })"
>
<AccordionHeader as="div" :class="ui.header({ class: [props.ui?.header, item.ui?.header] })">
<AccordionTrigger :class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger], disabled: item.disabled })">
<slot name="leading" :item="item" :index="index" :open="open">
<UIcon v-if="item.icon" :name="item.icon" :class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item?.ui?.leadingIcon] })" />
</slot>
<span v-if="get(item, props.labelKey as string) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })">
<slot :item="item" :index="index" :open="open">{{ get(item, props.labelKey as string) }}</slot>
</span>
<slot name="trailing" :item="item" :index="index" :open="open">
<UIcon :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.trailingIcon({ class: [props.ui?.trailingIcon, item.ui?.trailingIcon] })" />
</slot>
</AccordionTrigger>
</AccordionHeader>
<AccordionContent v-if="item.content || !!slots.content || (item.slot && !!slots[item.slot as keyof AccordionSlots<T>]) || !!slots.body || (item.slot && !!slots[`${item.slot}-body` as keyof AccordionSlots<T>])" :class="ui.content({ class: [props.ui?.content, item.ui?.content] })">
<slot :name="((item.slot || 'content') as keyof AccordionSlots<T>)" :item="(item as Extract<T, { slot: string; }>)" :index="index" :open="open">
<div :class="ui.body({ class: [props.ui?.body, item.ui?.body] })">
<slot :name="((item.slot ? `${item.slot}-body`: 'body') as keyof AccordionSlots<T>)" :item="(item as Extract<T, { slot: string; }>)" :index="index" :open="open">
{{ item.content }}
</slot>
</div>
</slot>
</AccordionContent>
</AccordionItem> I feel like it would be more future proof as everyone might have different needs of per item customization, of course this is more involved solution but I think it might be worth it. |
We could uniformize this as well indeed, I did it in very specific places where I needed to make an example only at the moment: https://github.com/nuxt/ui/blob/v3/src/runtime/components/Select.vue#L243 |
β¦ek/ui into feat/stepper-icon-class
@benjamincanac Here is a quick commit for the accordion component, if you could quickly have a look if I'm going in the right direction with this. |
Maybe I'm being too specific with this? The use can see it in detail in the props section.
iconClass
field in itemsui
field in items
@benjamincanac I think I'm done with this. I have updated the PR description above. Two things worth mentioning:
|
π Linked issue
Resolves: #4059
β Type of change
π Description
I have added the
ui
field initems
array - this affects all components that currently use anitems
prop.This will simplify cases where the user wants to use a specific classes for different parts of an item but does not want affect other items at the same time.
Edit:
π Checklist