Skip to content

refactor(ui): tokenize raw z-index one-offs into a semantic layering scale#8049

Merged
JSONbored merged 2 commits into
mainfrom
z-index-tokens-7841
Jul 24, 2026
Merged

refactor(ui): tokenize raw z-index one-offs into a semantic layering scale#8049
JSONbored merged 2 commits into
mainfrom
z-index-tokens-7841

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

~56 sites across apps/ui and packages/ui-kit used bare Tailwind z-* steps (z-10/20/30/40/50 plus z-[60]/z-[100]) with no documented layering system. Nothing was visibly broken, but undocumented stacking is how a future component silently lands behind a modal or above a toast.

Tokens

Added to packages/ui-kit/src/styles.css:

Token Value Use for
--mg-z-sticky 10 Sticky theads/toolbars, scroll shadows, in-flow progress bars
--mg-z-raised 20 Elements that must clear sticky content within the same page section
--mg-z-nav 30 Site header/nav chrome
--mg-z-overlay 40 Drawers, back-to-top, hover cards, lightweight menus
--mg-z-modal 50 Dialogs, popovers, sheets, command palette (matches Radix's own default)
--mg-z-progress 60 Route-transition progress bar
--mg-z-skip-link 100 a11y skip-link

Sweep

All 50 non-exception sites converted to z-[var(--mg-z-*)]. Two didn't transliterate literally: column-customizer.tsx's click-outside backdrop and page-actions.tsx's overflow menu were both bare z-30, but neither is nav chrome — they're popover-style overlays, so both moved to --mg-z-overlay instead (their DOM order already keeps the visible panel above its own backdrop at equal z-index, so no stacking change).

Left alone (documented exception): the 6 z-[1]/z-[2] sticky-cell sites in subnets-compare-drawer.tsx and validators-compare-drawer.tsx — a sticky corner cell over its own sticky row/col, a local stacking context rather than a global layer. Added a comment on each.

Guardrail + docs

  • Warn-tier no-restricted-syntax rule in both eslint.config.ts files flags any remaining bare z-10/20/30/40/50 or z-[N] step — including the 6 documented exceptions above, same residual-worklist convention the shadow-token rule already uses.
  • Full layer table documented in apps/ui/CONTRIBUTING.md's Bone & Ink section.

Verification

  • tsc --noEmit clean in both packages
  • eslint . (full package, not just src) — 0 errors in both packages; exactly 6 warnings from the documented z-index exceptions, no others
  • vitest run — 191 files / 1461 tests in apps/ui, 16 files / 88 tests in ui-kit, all passing
  • packages/ui-kit rebuilt (dist/index.{js,cjs,css})
  • Live preview: getComputedStyle confirms all 7 --mg-z-* custom properties resolve to their intended numeric values, and the sticky table header (z-index: 10) / site nav (z-index: 30) report the correct resolved values on a real rendered page

Closes #7841

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-ui 6b4d417 Commit Preview URL

Branch Preview URL
Jul 24 2026, 08:49 PM

…scale

~56 sites across both packages used bare Tailwind z-* steps (z-10/20/30/40/50
plus z-[60]/z-[100]) with no documented layering system -- undocumented
stacking is how a future component silently lands behind a modal or above
a toast.

Author a named --mg-z-* scale in packages/ui-kit/src/styles.css:
--mg-z-sticky(10)/raised(20)/nav(30)/overlay(40)/modal(50)/progress(60)/
skip-link(100), matching Radix's own z-50 default so its portalled
primitives (dialog/sheet/popover/tooltip/hover-card) need no override.

Sweep all 50 non-exception sites onto z-[var(--mg-z-*)]. Two sites didn't
transliterate 1:1: a column-customizer.tsx click-outside backdrop and a
page-actions.tsx overflow menu were both bare z-30, but neither is nav
chrome -- they're popover-style overlays, so both moved to --mg-z-overlay
(their DOM order already keeps the visible panel above its own backdrop
at equal z-index).

Left the 6 z-[1]/z-[2] sticky-cell sites in the two compare drawers alone
-- local stacking context (a sticky corner cell over its own sticky
row/col), not a global layer -- and added a comment on each explaining why.

Guardrail (warn-tier) in both eslint configs flags any remaining bare
z-10/20/30/40/50 or z-[N] step, including the 6 documented exceptions
(same residual-worklist convention the shadow-token rule already uses).
Documented the full scale in apps/ui/CONTRIBUTING.md's Bone & Ink section.

Verified via getComputedStyle: all 7 --mg-z-* custom properties resolve
to their intended numeric values, and the sticky table header / site nav
report the correct 10/30 z-index in a live preview.

Closes #7841
… style

CI's format:check caught this -- prettier pads markdown table columns to a
fixed width, which the table added in the previous commit didn't match.
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.67%. Comparing base (9d0b380) to head (6b4d417).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8049   +/-   ##
=======================================
  Coverage   97.67%   97.67%           
=======================================
  Files         220      220           
  Lines       27206    27211    +5     
  Branches    10783    10788    +5     
=======================================
+ Hits        26574    26579    +5     
  Misses        140      140           
  Partials      492      492           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier. label Jul 24, 2026
@JSONbored
JSONbored merged commit 3d7503c into main Jul 24, 2026
11 checks passed
@JSONbored
JSONbored deleted the z-index-tokens-7841 branch July 24, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design tokens 2/5: semantic z-index layering scale

1 participant