feat: implement getComponentSlotClassName utility for dynamic class name generation#35548
Conversation
📊 Bundle size report✅ No changes found |
|
Pull request demo site: URL |
There was a problem hiding this comment.
Considering that the RFC (#35464) was not merged, please don't put any related utils into stable packages.
That's true, and the RFC hasn't been merged yet. However, since it isn't impacting anyone and there's no alternative way to validate the approach and gather real data from partner codebases, I believe we can proceed with checking this in. I can add a note indicating the utils is not meant for public use, or rename it to be |
|
@dmytrokirpa is there a reason why these utils cannot be shipped in a preview package? |
For the headless style hooks, they really need to stay in the component packages - otherwise, the bundler's @layershifter If you have any ideas or suggestions on how we can improve this, I’m all ears. |
ed8a5dc to
da12530
Compare
|
Merged this PR to the headless-components branch instead of master to not block progress, and once the RFC is approved/merged we'll merge it back to master. |
Previous Behavior
Previously, we generated classes from the component state using the pattern
.fui${Component}--${stateValue}. For example,.fuiButton--primaryfor a button with the state{ appearance: "primary" }, or.fuiButton--smallfor{ size: 'small' }. These classes were mapped manually.New Behavior
This PR introduces the utility
getComponentSlotClassName, which maps component state to CSS classes using a new structure:.fui${Component}--${stateName}-${stateValue}or.fui${Component}--${stateName}if the value is a truthy boolean. For instance, a state of{ appearance: "primary", size: 'small' }will result in the class namesfuiButton--appearance-primary fuiButton--size-small.Related Issue(s)