-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(pad): add theme-color meta to match toolbar on mobile (#7606) #7636
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
JohnMcLear
wants to merge
5
commits into
ether:develop
Choose a base branch
from
JohnMcLear:feat/theme-color-7606
base: develop
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
5 commits
Select commit
Hold shift + click to select a range
29f0a11
feat(pad): add <meta name="theme-color"> matching toolbar (#7606)
JohnMcLear 7b41829
fix(timeslider): emit single theme-color matching configured toolbar
JohnMcLear dcedf72
fix(pad): emit unconditional theme-color so dark-OS users still match
JohnMcLear d6753cc
fix(theme-color): align dark meta with client-side super-dark override
JohnMcLear 51115af
refactor(theme-color): server-side only, drop fragile dark media query
JohnMcLear 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| 'use strict'; | ||
|
|
||
| // Toolbar background colors that the colibris skin variants resolve to. | ||
| // Mirrors --bg-color in src/static/skins/colibris/src/pad-variants.css. Only | ||
| // the colibris skin has a known mapping; for any other skin we cannot derive | ||
| // the toolbar color server-side and emit no theme-color meta. | ||
| // | ||
| // Order matters: when skinVariants contains multiple *-toolbar tokens the | ||
| // CSS cascade picks the rule defined last in pad-variants.css, so iterate in | ||
| // source order and let the last matching token win. | ||
| const TOOLBAR_COLORS_IN_CSS_ORDER: Array<[string, string]> = [ | ||
| ['super-light-toolbar', '#ffffff'], | ||
| ['light-toolbar', '#f2f3f4'], | ||
| ['super-dark-toolbar', '#485365'], | ||
| ['dark-toolbar', '#576273'], | ||
| ]; | ||
|
|
||
| const COLIBRIS_DEFAULT_TOOLBAR_COLOR = '#ffffff'; | ||
|
|
||
| // The toolbar color the user actually sees on first paint, derived from the | ||
| // configured skin and skinVariants. Returns null when the skin is unknown so | ||
| // callers can omit the meta rather than emit a misleading value. | ||
| export const configuredToolbarColor = ( | ||
| skinName: string | undefined | null, | ||
| skinVariants: string | undefined | null, | ||
| ): string | null => { | ||
| if (skinName !== 'colibris') return null; | ||
| const tokens = new Set((skinVariants || '').split(/\s+/).filter(Boolean)); | ||
| let color: string | null = null; | ||
| for (const [variant, c] of TOOLBAR_COLORS_IN_CSS_ORDER) { | ||
| if (tokens.has(variant)) color = c; | ||
| } | ||
| return color || COLIBRIS_DEFAULT_TOOLBAR_COLOR; | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import {configuredToolbarColor} from "../../../node/utils/SkinColors"; | ||
| import {expect, describe, it} from "vitest"; | ||
|
|
||
| describe('SkinColors.configuredToolbarColor', function () { | ||
| it('returns null for non-colibris skins so the meta is omitted', function () { | ||
| expect(configuredToolbarColor('no-skin', 'super-light-toolbar')).toBeNull(); | ||
| expect(configuredToolbarColor(null, 'super-light-toolbar')).toBeNull(); | ||
| expect(configuredToolbarColor('custom-skin', 'dark-toolbar')).toBeNull(); | ||
| }); | ||
|
|
||
| it('returns the colibris default when no toolbar token is set', function () { | ||
| expect(configuredToolbarColor('colibris', '')).toBe('#ffffff'); | ||
| expect(configuredToolbarColor('colibris', null)).toBe('#ffffff'); | ||
| expect(configuredToolbarColor('colibris', 'full-width-editor')).toBe('#ffffff'); | ||
| }); | ||
|
|
||
| it('maps each *-toolbar token to its colibris --bg-color', function () { | ||
| expect(configuredToolbarColor('colibris', 'super-light-toolbar')).toBe('#ffffff'); | ||
| expect(configuredToolbarColor('colibris', 'light-toolbar')).toBe('#f2f3f4'); | ||
| expect(configuredToolbarColor('colibris', 'super-dark-toolbar')).toBe('#485365'); | ||
| expect(configuredToolbarColor('colibris', 'dark-toolbar')).toBe('#576273'); | ||
| }); | ||
|
|
||
| it('respects CSS source order when multiple toolbar tokens are present', function () { | ||
| // pad-variants.css declares dark-toolbar last, so it wins on tie regardless of token order. | ||
| expect(configuredToolbarColor('colibris', 'super-light-toolbar dark-toolbar')).toBe('#576273'); | ||
| expect(configuredToolbarColor('colibris', 'dark-toolbar super-light-toolbar')).toBe('#576273'); | ||
| // super-dark-toolbar precedes dark-toolbar in CSS, so dark wins when both are present. | ||
| expect(configuredToolbarColor('colibris', 'super-dark-toolbar dark-toolbar')).toBe('#576273'); | ||
| // super-dark-toolbar wins over light-toolbar. | ||
| expect(configuredToolbarColor('colibris', 'light-toolbar super-dark-toolbar')).toBe('#485365'); | ||
| }); | ||
|
|
||
| it('ignores unrelated tokens', function () { | ||
| expect(configuredToolbarColor('colibris', 'super-light-toolbar full-width-editor light-background')) | ||
| .toBe('#ffffff'); | ||
| }); | ||
| }); |
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.
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.
1. theme-color skipped for non-colibris
📎 Requirement gap≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools