Conversation
|
@benjamincanac Here is a POC of the Seeking guidance on the following, the types are a bit tricky:
|
📝 WalkthroughWalkthroughThis change introduces a new variant theming system for components by adding a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/runtime/composables/useComponentVariant.ts`:
- Around line 32-39: The computed in useComponentVariant currently merges theme
overrides with props.variants which doesn't exist, so component props (e.g.,
color, variant) are ignored and not tracked; update the merge to use the actual
props object (e.g., defu(props, themeOverrides)) so explicit props take
precedence and Vue reactivity tracks prop changes inside the computed returned
by useComponentVariant; optionally, to reduce over-tracking, pick only the
variant-related keys from props before calling defu.
🧹 Nitpick comments (1)
src/runtime/components/Theme.vue (1)
20-26: Consider whether nested<UTheme>should merge contexts.Currently, each
<UTheme>fully replaces both the UI and variant contexts for its descendants. If a user nests<UTheme :variants="{ button: { color: 'red' } }">inside<UTheme :variants="{ button: { variant: 'soft' } }">, the inner theme will lose the outer'svariant: 'soft'.This may be intentional for a POC, but worth considering whether
defu-merging with the parent context (similar to howuseComponentVariantmerges props with theme overrides) would provide a more intuitive cascading behavior.
|
@benjamincanac Any feedback on this POC? Would love to proceed with implementing on all components. Still Seeking guidance on the following, the types are a bit tricky:
|
|
We really need this. |
|
@Bobakanoosh Will look into it asap! |
variants prop
commit: |
|
@Bobakanoosh I pushed some improvements on top of your work to unify theme context. However, before rolling out to all components, I want to think about the broader direction. Right now A few open questions:
Thoughts? cc @sandros94 @jd-solanki |
My personal gut feeling is your second option: a clear separation between the overrides from the global configs (UTheme and UApp respectively) |
|
@sandros94 So you think we should keep UTheme only to override |
@benjamincanac yes indeed |
|
I don't see why not both - the problem The same could potentially be said for component prop defaults. I'd propose: <UTheme
:ui="..."
:variants="..."
:components="{
tooltip: {
delayDuration: 150
}
}"
>
...
</UTheme@benjamincanac in reference to your 1 option:
Following this argument, one could say that we should even have a |
|
Here are my thoughts:
<UTheme
:ui="{}"
:props="{
tooltip: {
delayDuration: 150
}
}"
/>
Instead of per component prop, having single
Supporting global app-wide props is better idea and less confusing than selecting props like variant only. It also becomes AI to understand that
|
@Bobakanoosh I'm mostly worried on a conceptual level atm, I would prefer avoiding transforming In fact, I really like @jd-solanki idea of having a
At which point we do not even need This also leaves Which means I now more lean to @benjamincanac option 1 ahahahah; it removes the "where is this controlled from?" problem. Since In contrast, with option 2 the DX would force having a combination of multiple |
|
Yeah agreed |
Resolves #6359
❓ Type of change
📚 Description
Follow-up to #4387, adding a
variantsprop to UTheme as discussed.📝 Checklist