Repository navigation
Keep light and dark --om-* tokens in tokens.css only #35294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shah-harshit
wants to merge
4
commits into
main
Choose a base branch
from
shah-harshit/om-tokens-single-source
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
08c4979
Keep light and dark --om-* tokens in tokens.css only
shah-harshit 3b552e1
Merge remote-tracking branch 'origin/main' into shah-harshit/om-token…
shah-harshit 8e149d4
docs: correct dark-mode brand-primary and brand-border values in colo…
detail-app[bot] a4d9075
chore(ui): regenerate design tokens after merging main
shah-harshit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
docs/decisions/2026-10-13-om-tokens-have-one-source-file.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Every --om-* token is declared in tokens.css, light and dark side by side | ||
|
|
||
| - **Status:** Accepted | ||
| - **Revisions:** v1 2026-10-13 (initial) | ||
| - **Deciders:** Harshit Shah | ||
| - **Guard:** `openmetadata-ui/src/main/resources/ui/scripts/design-tokens/theme-contract.test.js` (run by `yarn token-drift` and the `token-drift` pre-commit hook) | ||
| - **Related:** open-metadata/OpenMetadata#34936, open-metadata/OpenMetadata#35271, ADR:2026-10-12-dark-mode-targets-ai-mode-core-surfaces-only | ||
|
|
||
| ## Context | ||
| Each legacy LESS palette var (`@grey-15`, `@blue-29`, the status tints, …) was defined in three | ||
| files: the LESS var and its fallback hex in `variables.less`, the light `--om-*` value on `:root` | ||
| in `tokens.css`, and the dark `--om-*` value under `.dark-mode` in `app.less`. #34936 added the | ||
| light values to `tokens.css`. That file is imported after `app.less`, and `:root` has the same | ||
| specificity as `.dark-mode` on `<html>`, so the light values won and every bridged var | ||
| (the app-wide `@grey-15` border, `@grey-1/2/5/6/9/26`, `@blue-29/30`, the status tints) stayed | ||
| light in dark mode. #35271 patched the selector to `:root.dark-mode`, but the split itself, where | ||
| correctness depends on import order across files, remained. The same split had already let | ||
| `variables.less` carry two `@grey-25` definitions with different fallbacks. | ||
|
|
||
| ## Decision | ||
| - Core tokens (`--color-*`, `--tw-*`, and the other Tailwind theme namespaces) are declared only in | ||
| core `globals.css`, light in `@theme` and dark in `.dark-mode`. | ||
| - Project `--om-*` tokens are declared only in `openmetadata-ui/.../src/styles/tokens.css`. A | ||
| token's light value goes on `:root` and its dark value on `:root.dark-mode` in the same file. | ||
| `:root.dark-mode` out-ranks `:root` regardless of order. | ||
| - No other stylesheet (`app.less`, component `.less`/`.css`) declares an `--om-*` property. The one | ||
| exception is `--om-page-height`, a layout value each shell re-declares so its `calc()` resolves | ||
| against that shell's navbar height. It is not a themed token. | ||
| - Every dark `--om-*` override has a light value in `tokens.css`. | ||
| - A `variables.less` bridge (`@x: var(--om-x, <fallback>)`) is defined once, and its fallback | ||
| equals the `tokens.css` light value. | ||
| - `theme-contract.test.js` enforces all of the above. | ||
|
|
||
| ## Consequences | ||
| Adding or changing a themed legacy colour is a one-file edit, and the guard fails the | ||
| `token-drift` hook if a second file starts declaring `--om-*`. Overrides that must beat inline | ||
| custom properties on `<html>` (the `.dark-mode body` brand-accent block in `app.less`) target the | ||
| core `--tw-*` layer, not `--om-*`, so they are outside this rule. They stay where they are until | ||
| the brand injection stops writing inline vars. Revisit if `tokens.css` is split into per-theme | ||
| files, in which case the guard must check the import order instead. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractBlock(css, ':root.dark-mode')usesindexOf. The first match is the header comment this PR adds in tokens.css at line 32 (:root.dark-mode — both here…), not the rule at line 386. The next{after that comment opens the light:root {block at line 45, sodarkandlightend up as the same map. The test 'gives every dark --om-* override a light value' checks the light block against itself and can never fail. A dark-only token added at line 386 would get through, even though the PR says it tested exactly that case. Fix: anchor the marker to a real rule, e.g.' :root.dark-mode {'or a regex like/^:root\.dark-mode\s*\{/m. Also assert that the dark map contains a known dark token such as--om-grey-15with valuevar(--color-border-subtle).Anchor the marker to the rule, not the comment, and check that the right block was parsed:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎