Repository navigation
Mechanize UI color token enforcement - #614
ArthurArthurArthur0817 wants to merge 1 commit into
Conversation
5b0898d to
64cdc76
Compare
64cdc76 to
218ebe2
Compare
218ebe2 to
f5ea34c
Compare
cc08714 to
f5ea34c
Compare
a197749 to
6bcce30
Compare
Shih-Hsuan
left a comment
There was a problem hiding this comment.
The diff removes token-reference validation and leaves peer-interview timers stopped when a back/forward restore encounters a transient refresh failure.
|
This commit is built on an older tree and, merged as it is, would revert work already on |
|
Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open. Not addressed at the current head:
Checked at ec13877. |
|
@ArthurArthurArthur0817 Three replies on this pull request say a change was made, and none of them is in the head, which is still |
| assert.deepEqual( | ||
| unusedThemeTokens(`${theme}\n:root { --obsolete: #fff; }`, allCss), | ||
| ["--obsolete"], | ||
| "orphan token in theme.css must be caught", | ||
| ); |
There was a problem hiding this comment.
Nothing here reaches the fallback form that the var\(\s*(--[\w-]+)\s*(?=[,)]) pattern in unusedThemeTokens was widened for. No component sheet reads a theme token with a fallback today, so putting back var\((--[\w-]+)\) there still passes every test in this file. A case beside the orphan one keeps it covered. It passes at this head and fails with the old pattern:
| assert.deepEqual( | |
| unusedThemeTokens(`${theme}\n:root { --obsolete: #fff; }`, allCss), | |
| ["--obsolete"], | |
| "orphan token in theme.css must be caught", | |
| ); | |
| assert.deepEqual( | |
| unusedThemeTokens(`${theme}\n:root { --obsolete: #fff; }`, allCss), | |
| ["--obsolete"], | |
| "orphan token in theme.css must be caught", | |
| ); | |
| assert.deepEqual( | |
| unusedThemeTokens( | |
| `${theme}\n:root { --fallback-read: #fff; }`, | |
| `${allCss}\n.card { color: var(--fallback-read, currentColor); }`, | |
| ), | |
| [], | |
| "a token read with a fallback must count as read", | |
| ); |
Per review, extend theme.test.js to enforce CSS token usage. Prevent stacked var() declarations and strictly scope recording.css color literals to its own :root. Change-Id: I3e851d6f126e9ecb26499b8578373191d479e2d1
Problem and behavior
UI colors must be defined as design tokens to ensure consistency across light and dark themes. To prevent hardcoded color literals from slipping into the codebase, this PR mechanizes the enforcement.
Per the maintainer's review, rather than introducing a standalone Python checker, this PR drops the Python script and strictly extends the existing
tests/browser/theme.test.jsto enforce CSS token usage across the repository.Notes
The extended test suite now enforces the following strict zero-tolerance rules:
var()declarations within the same component rule (i.e., a declaration must not shadow a token read in the same rule) to avoid cascade overrides.recording.cssScoping: Confines color literals inweb/recording/recording.cssstrictly to its own:rootblock. Existing out-of-scope literals have been converted into semantic variables.web/theme.cssto ensure every declared token is read by at least one component or derived token, preventing unused tokens from accumulating.Testing
Coverage is now integrated directly into
tests/browser/theme.test.js. The tests will fail if a component sheet shadows a token read, ifrecording.cssleaks literals outside its:root, or iftheme.cssleaves tokens unused.Close #578