Skip to content

fix(css): revert #257 @layer wrapping — sidebar content was centered - #260

Merged
Astro-Han merged 2 commits into
mainfrom
claude/revert-257-layer
Jun 25, 2026
Merged

fix(css): revert #257 @layer wrapping — sidebar content was centered#260
Astro-Han merged 2 commits into
mainfrom
claude/revert-257-layer

Conversation

@Astro-Han

@Astro-HanAstro-Han commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Symptom

The sidebar nav rows (新任务 / 每日回顾 / 技能 / 定时任务), session-list rows, and the settings button all rendered with their content centered when they should be left-aligned. It's subtle in a narrow sidebar and increasingly obvious the wider the sidebar is dragged.

Root cause

#257 (cbdf1088) wrapped styles.css component rules into @layer base / @layer components, described as "pure structural wrapping." But Tailwind v4 orders the cascade base → components → utilities, so utilities have the highest priority.

The sidebar nav rows render as <UiButton size="nav" className="maka-nav-row">: the cva button base always carries the Tailwind utilities inline-flex items-center justify-center, and .maka-nav-row (display: grid + text-align: left) only overrode them while it stayed unlayered. Once moved into @layer components, it lost to the utilities → content centered. The compensating !important cleanup was deferred to "Round H," so the override has nothing to lean on today.

Evidence (CDP toggle)

Injecting a rule into the live renderer with the same selector and specificity as .maka-nav-row, differing only in being unlayered:

State.maka-nav-row computed display
Layered (#257 as-is)flex (the inline-flex utility wins)
Unlayered injectiongrid (.maka-nav-row wins, layout restored)
Injection removedflex (centered again)

Same rule, one variable (layer membership) → the cause is the cascade layer, not specificity.

Change

  • Revert refactor(css): wrap styles.css rules into @layer base + components (Round A, #253) #257 (removes the 5 lines of @layer wrapping), restoring the unlayered cascade the whole stylesheet's override pattern depends on. Fixes every affected element at once (nav rows, session rows, settings button).
  • Adds a regression contract testrenderer-style-layer-cascade-contract.test.ts: asserts .maka-nav-row is not nested in any @layer. Red on cbdf1088, green after the revert.

Verification

  • Real window: all four nav labels share a uniform 42px left offset (if centered, different label lengths would start at different offsets), display: grid, and session rows are left-aligned too.
  • npm run -w @maka/desktop test: this PR adds zero new failures. The 16 failures already present in the suite are pre-existing on origin/main — stale contracts introduced by ancestors of refactor(css): wrap styles.css rules into @layer base + components (Round A, #253) #257 (e.g. BOT_BRAND moved to @maka/ui, a changed copyFile signature, a radius value) — and are out of scope here.

Known trade-off (reviewed)

A full revert also returns the global form/button resets (button/input/textarea/select { font: inherit }, the global button { transition }) to unlayered, so they again outrank Tailwind text utilities. Measured impact vs #257: ~85 controls go from font-weight: 500 back to 400, and ~48 controls go from 13.125px (text-sm) back to the inherited 15px. This is not a new regression — it is the exact control typography the app shipped for months before #257; #257 incidentally flipped it one day ago alongside the sidebar break. Restoring it wholesale is the intended behavior of this revert. Whether controls should let text-sm / font-medium win is a deliberate design decision deferred to the sidebar-redesign / CSS-layering-governance follow-up, not this hotfix.

Follow-up (not in this PR)

  • If Round A (styles.css 优化 #253) re-lands, component-override rules must sit in a layer declared after utilities (or stay unlayered) — not in @layer components.
  • Sidebar redesign + governance of the shadcn-primitive vs bespoke-CSS styling authority is tracked separately.

…nents (Round A, #253) (#257)"
This reverts commit cbdf108.
#257 wrapped styles.css component rules into @layer base/components. Tailwind v4 orders the cascade base, components, utilities, so layered rules lose to utilities. The sidebar nav rows render as <UiButton size="nav" className="maka-nav-row">; the cva button base always carries inline-flex items-center justify-center utilities, and .maka-nav-row (display: grid + text-align: left) only overrode them while it stayed unlayered. Layered, it lost — collapsing every sidebar button (nav rows, session rows, settings) to flex-centered content for users whose sidebar is wide enough to show the gap.
Restore the unlayered cascade. The Round A cleanup needs a different approach (overrides must sit above utilities) before it can re-land.
…d button utilities
Regression lock for #257: a node:test contract that fails if .maka-nav-row is nested in any @layer in styles.css (which would let the cva button base's inline-flex/justify-center utilities win and re-center the sidebar). Red on cbdf108, green after the revert.
@Astro-Han
Astro-Han merged commit 2b45e09 into mainJun 25, 2026
@Astro-Han
Astro-Han deleted the claude/revert-257-layer branch June 25, 2026 13:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Astro-Han