-
Notifications
You must be signed in to change notification settings - Fork 31
feat(ColorModes): Base ColorMode support and serialization of color variables [GM-177] #1545
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
Merged
Conversation
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
…dules into ar-static-cms-fonts
…dules into ar-static-cms-fonts
jakemhiller
approved these changes
Mar 26, 2021
Member
jakemhiller
left a comment
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.
siiiiiick
…es into ar-color-mode-v1
Collaborator
📬Published Alpha Packages:@codecademy/gamut-illustrations@0.9.9-alpha.88a8a1.0 |
Collaborator
|
🚀 Styleguide deploy preview ready! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This adds the concept of ColorModes which are a critical pieces to scalability of our design system. Adding predictability and interoperability at a foundational level.
Important Context
Interactive Docs
ModeToJoy.mp4
ColorModes
In order to guarantee that our components work in all contexts this introduces the concept of Color Modes. A defined set of color aliases that create a consistent visual output, without added configuration at the component level.
Each color mode consists of a set of aliased color tokens. Each alias has semantic meaning for how the color is used throughout our design system:
text: The standard text color for all type.background: The base background color.primary: The color used for interactive elements with a primary action.secondary: The color used for interactive elements with a secondary action.Note: This set is not final and is likely to expand as our needs grow.
Gamut components will built using these aliases instead of referring to specific tokens directly, guaranteeing that:
themeColor modes are defined at the theme level as an object:
The active mode is serialized to CSS variables in the current scope.
The default definitions are placed on
:root. Overrides are placed on the containing element and scoped to all descendants.Provisioning
Consumption
We only want users to access these variables through JS so all color variables are accessible through the
colorkey on theme. The values of all colors on theme now only gets the css variable reference.<ColorMode />A component that will switch the active mode and provision the correct variables for consumption. And wrap the children in a
<ThemeProvider />that overrides theactivekey to allow components to know what context they are currently in.Usage
<Background />To handle the many cases where we need a specific background color for a section of a page, like a card or a landing page. Instead of having to guess the right mode for the background, we've added a
<Background />component to automatically detect the contrast of the background and change the mode to an accessible one. Allowing you to be sure that all components inside your background will meet contrast requirements and designs without any configuration!Usage
PR Checklist