-
Notifications
You must be signed in to change notification settings - Fork 690
Implement a contrast-ratio-based adaptive color theme #18745
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
gcamacho079
wants to merge
28
commits into
6.x
Choose a base branch
from
a11y/update-colors
base: 6.x
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
28 commits
Select commit
Hold shift + click to select a range
d93a970
Update semantic colors in light mode to meet min contrast, toggle vit…
gcamacho079 b087a59
Add text to variant story table headers
gcamacho079 33ff437
Update colors again to maintain appearance of solid colors like yello…
gcamacho079 506bdf3
Update semantic colors to use Leonardo-generated colors
gcamacho079 7806ca8
Update colors with hex from Leonardo to fix purple/blue issue
gcamacho079 81b9f30
Update the remaining colors to use Leonardo-exported palette
gcamacho079 bfe1901
Update loud warning colors to use inverse (dark orange text on light …
gcamacho079 f112d34
Fix some instances of colors not meeting contrast minimum
gcamacho079 07fbd8f
Set dark mode to default for testing, start working on fixing/marking…
gcamacho079 f94a310
Remove extra navigation role from breadcrumb component, set default l…
gcamacho079 cbf3d90
Build
gcamacho079 bc90dc1
Update chip story to include accessible button name
gcamacho079 22ae3e8
Add labels to chip actions and icon-only buttons
gcamacho079 29e7724
Turn off svg-img-alt error for now
gcamacho079 619b7f5
Start adding leonardo
gcamacho079 ca475b2
Add script to generate colors, update filenames
gcamacho079 c1ac4ef
Separate script to write variables from the one with the theme color …
gcamacho079 5b92d83
Update colors
gcamacho079 a4e1fae
Remove dark mode colors from colorable generate colors script, add st…
gcamacho079 6dc7266
Add object for looking up color increments for consistent foll/border…
gcamacho079 a1e84bd
Have semantic colors be auto-generated
gcamacho079 0c758f2
Update names and build
gcamacho079 33f0dc2
Refactor generate color palette script
gcamacho079 9f8adfa
Update docs
gcamacho079 f13af3e
Build
gcamacho079 4f86931
Remove commented code in script
gcamacho079 8b05b7c
Change default theme back to light
gcamacho079 f6eacc3
Update lightScale fxn name
gcamacho079 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,56 @@ | ||
| import {writeFileSync} from 'fs'; | ||
| import {dirname, resolve} from 'path'; | ||
| import {fileURLToPath} from 'url'; | ||
| import {stops, lightTheme, darkTheme} from '../src/styles/color-definitions.js'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const ROOT = resolve(__dirname, '..'); | ||
| const OUT_FILE = resolve(ROOT, 'src/styles/shared/color-palette.css'); | ||
|
|
||
| function comment() { | ||
| return '/* Auto-generated by scripts/generate-color-palette.js — do not edit manually */'; | ||
| } | ||
|
|
||
| function colorsToCssVariables(colors, customPrefix = null) { | ||
| let result = ''; | ||
| let isFirstLine = true; | ||
| for (const color of colors) { | ||
| if (!color.values) continue; | ||
|
|
||
| if (!isFirstLine) result += '\n'; | ||
|
|
||
| const declarations = color.values.map((value, index) => { | ||
| let prefix = customPrefix ? `--${customPrefix}` : `--color`; | ||
| return ` ${prefix}-${color.name}-${stops[index]}: ${value.value};`; | ||
| }); | ||
|
|
||
| result += declarations.join('\n'); | ||
| isFirstLine = false; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| function printStyles() { | ||
| let lines = []; | ||
| const lightColors = colorsToCssVariables(lightTheme.contrastColors); | ||
| const darkColors = colorsToCssVariables(darkTheme.contrastColors); | ||
| const staticColors = colorsToCssVariables( | ||
| lightTheme.contrastColors, | ||
| 'color-static' | ||
| ); | ||
|
|
||
| lines.push(comment()); | ||
| lines.push('\n:root,\n:host {'); | ||
| lines.push(lightColors); | ||
| lines.push(` /* Static colors */\n`); | ||
| lines.push(staticColors); | ||
| lines.push('}\n'); | ||
| lines.push("[data-theme='dark'] {"); | ||
| lines.push(darkColors); | ||
| lines.push('}\n'); | ||
|
|
||
| writeFileSync(OUT_FILE, lines.join('\n')); | ||
| console.log(`Generated ${OUT_FILE}`); | ||
| } | ||
|
|
||
| printStyles(); |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.