Color
https://www.youtube.com/watch?v=SfhjbsqEQA0
Benefits
Switch section or element color themes from component & CMS fields
Globally adjust styles like button solid & outlined across multiple types of buttons
Create visual consistency throughout a project
Easily animate between themes with GSAP
Setting themes with data attributes
The following data attributes can be applied to elements to set a theme
data-theme="invert" (inverts the parent's theme)
data-theme="inherit" (inherits from the parent's theme)
data-theme="dark"
data-theme="light"
Setting button styles with data attributes
The following data attributes can be applied to buttons to switch their style (usually between solid and outlined)
data-button-style="primary"
data-button-style="secondary"
Text Color Utilities
u-color-inherit
inherits from parent's font color
u-color-faded
--theme--text
variable at a 60% opacity
Swatch Folder
All colors should be saved in the swatch folder. These swatches can fit into three categories: dark, light, & brand. Names are abstracted to prevent renaming if values ever change.
Whenever --swatch--brand
is applied as a background color, --swatch--brand-text
is applied as its font color. If the brand color ever needs to change in the future to a darker color that requires light text, we can update that brand-text color from one place.
The core colors related to the page or section. Values are left empty so they can be redefined for light, dark, and brand themes. If multiple types are needed within each theme, extend with background-secondary, text-secondary, border-secondary.
Element folders can be set for elements like buttons, links, cards, or any other elements that need their own background, text, border colors.
Themes are applied with data attributes so they can be linked to component and cms fields. Link theme and element variables to global swatches and define their values for both light, dark, and any other themes. This code is set in the .page_code_color
embed.
Instead of creating a separate folder just for the secondary version of our button, we can dynamically replace our primary button variables with the secondary version by using a data attribute. This allows us to easily switch the button style from a component field so we don’t have to upkeep multiple versions of the same button component.
Switching the value of --theme--background or --theme--text on an element doesn’t do anything if the element doesn’t have a background or font color applied. Instead of manually setting a background color and font color each time we apply an attribute, we can let the attribute apply the colors for us. These colors are completely overridable with native style panel.
We can apply [data-theme=”invert”] to any element so it does the opposite of its parent’s theme.
Reducing the opacity of any variable natively
The below script automatically retrieves all themes and theme variables from our .page_code_color
embed. This means any future variables we add to the embed will be automatically included in our animations.
gsap.to(".my-card", { ...colorTheme[2] });
animates the card to the second theme in our embed
Multi-brand sites with Lumos
For multi-brand sites, we can use a data-brand attribute to dynamically switch out the brand colors.
Last updated