Skip to content

Conversation

@dmytrokirpa
Copy link
Contributor

@dmytrokirpa dmytrokirpa commented Dec 7, 2025

Previous Behavior

Previously, we generated classes from the component state using the pattern .fui${Component}--${stateValue}. For example, .fuiButton--primary for a button with the state { appearance: "primary" }, or .fuiButton--small for { 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 names fuiButton--appearance-primary fuiButton--size-small.

Related Issue(s)

  • Fixes #

@dmytrokirpa dmytrokirpa self-assigned this Dec 7, 2025
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Pull request demo site: URL

@dmytrokirpa dmytrokirpa changed the title feat: implement getComponentSlotClassName utility for dynamic class n… …ame generation feat: implement getComponentSlotClassName utility for dynamic class name generation Dec 7, 2025
expect(getComponentSlotClassName('fui-Button', state.root, state)).toContain('fui-Button--appearance-secondary');
});

it('generates modifier classes from state numeric properties', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a string property and not a numeric one, right?

@dmytrokirpa dmytrokirpa marked this pull request as ready for review December 9, 2025 08:18
@dmytrokirpa dmytrokirpa requested review from a team and marcosmoura as code owners December 9, 2025 08:18
Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the RFC (#35464) was not merged, please don't put any related utils into stable packages.

@dmytrokirpa
Copy link
Contributor Author

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 getComponentSlotClassName__experimental/getComponentSlotClassName__unstable if you think that would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants