🐛 fix: let consumers retheme Sidebar options through className - #685
Merged
Conversation
The NavigationOption hover/active colors lived in Sidebar.css keyed on `li[role='option']`. #677 dropped that invalid role from the `<li>`, so the rules stopped matching and every consumer theming through the `--konstruct-sidebar-hover-bg` / `--konstruct-sidebar-active-bg` custom properties silently fell back to the library default. Rather than re-point the selector, move the styling into the cva variants: a descriptor selector like `.konstruct-sidebar li:hover` (0,2,2) outranks a single utility class (0,1,0), so a consumer could never win through `className` even when the selector did match. - Drop the dead `li[role='option']` rules from Sidebar.css; the variants already cover the layout, padding and anchor styling they mirrored - Add the one rule that was not mirrored (`shrink-0`) to the variants - Prefix the active classes with `data-[active=true]:` so tailwind-merge detects the conflict against a consumer override and drops the default - Remove the now-unused `text-black` and duplicated `font-normal` - Cover both directions with tests: an override wins, no override keeps the default BREAKING CHANGE: `--konstruct-sidebar-hover-bg`, `--konstruct-sidebar-hover-color`, `--konstruct-sidebar-active-bg` and `--konstruct-sidebar-active-color` no longer do anything. Pass the colors to `NavigationOption` via `className` instead: `hover:bg-metal-800 data-[active=true]:bg-metal-800`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NavigationOption's hover and active colors lived inSidebar.css, keyed onli[role='option']:#677 removed that
role="option"from the<li>(correctly — axe flagged it as an invalid role for anlioutside alistbox). The selector stopped matching, so every consumer theming through--konstruct-sidebar-hover-bg/--konstruct-sidebar-active-bgsilently fell back to the library default. In the Civo billing MFE the active item went frommetal-800to#252a41with no code change on their side.Why not just re-point the selector
Because the rule should never have won in the first place.
.konstruct-sidebar li[role='option']:hoverhas specificity(0,2,2); a Tailwind utility has(0,1,0). Even while the selector matched, a consumer could not override the color throughclassName— the library rule always beat it. The custom properties were the only escape hatch, and they were undiscoverable.Change
Move option styling entirely into the cva variants, so cva provides the default and
classNamecan take over:li[role='option']rules fromSidebar.css. The variants already mirrored their layout, padding and anchor styling ([&>a]:p-2.5,[&>a]:flex,group-data-[mode=collapsed]/sidebar:justify-center, …)shrink-0data-[active=true]:sotailwind-mergesees the same modifier as a consumer override and drops the default instead of shipping both and leaving it to stylesheet source ordertext-black(already dropped bytailwind-mergein favour oftext-kubefirst-dark-blue-300) and a duplicatedfont-normalConsumer migration
--konstruct-sidebar-logo-padding-*is unaffected — those rules key off[data-konstruct-sidebar-logo], notrole.Breaking change
--konstruct-sidebar-hover-bg,--konstruct-sidebar-hover-color,--konstruct-sidebar-active-bgand--konstruct-sidebar-active-colorno longer do anything. They have been broken since #677, so this documents reality rather than removing working behavior.Tests
Two new cases pin both directions — a
classNameoverride wins, and the default still applies when nothing is passed. Full suite green (566 tests, 47 files), plus lint, types and prettier.Verified against the real consumer: built locally, copied into the Civo billing MFE and confirmed the active item renders
metal-800again.Also included
A
📝 docscommit tightening the CLAUDE.md comments rule — change rationale belongs in the commit message, not in the source, and the rule now says so explicitly for CSS too.