-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for theming on Web (#71)
This adds basic support for overriding semantic tokens on Web via a CSS cascade layer, for which it was necessary to separate base and semantic tokens into different sets of files. Documentation for this theming mechanism will be provided over at the Compound Storybook repository, but it can be used like so: @import "@vector-im/compound-design-tokens/assets/web/css/compound-design-tokens.css" layer(compound); @layer compound.custom { :root, [class*="cpd-theme-"] { --cpd-color-icon-accent-tertiary: var(--cpd-color-blue-800); } }
- Loading branch information
Showing
24 changed files
with
227 additions
and
133 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,17 +1,21 @@ | ||
/** | ||
* TODO: Auto-generate this file to allow for dynamic themes to be generated | ||
*/ | ||
/* Establish a layer order that allows semantic tokens to be customized, but not base tokens */ | ||
@layer semantic, custom, base; | ||
|
||
@import url("./cpd-common.css"); | ||
|
||
@import url("./cpd-light.css") screen; | ||
@import url("./cpd-light-hc.css") screen; | ||
@import url("./cpd-dark.css") screen; | ||
@import url("./cpd-dark-hc.css") screen; | ||
|
||
@import url("./cpd-light-mq.css") screen and (prefers-color-scheme: light); | ||
@import url("./cpd-light-hc-mq.css") screen and (prefers-color-scheme: light) | ||
and (prefers-contrast: more); | ||
@import url("./cpd-dark-mq.css") screen and (prefers-color-scheme: dark); | ||
@import url("./cpd-dark-hc-mq.css") screen and (prefers-color-scheme: dark) and | ||
(prefers-contrast: more); | ||
@import url("./cpd-common-base.css") layer(base) screen; | ||
@import url("./cpd-common-semantic.css") layer(semantic) screen; | ||
@import url("./cpd-theme-light-base.css") layer(base) screen; | ||
@import url("./cpd-theme-light-base-mq.css") layer(base) screen and (prefers-color-scheme: light); | ||
@import url("./cpd-theme-light-semantic.css") layer(semantic) screen; | ||
@import url("./cpd-theme-light-semantic-mq.css") layer(semantic) screen and (prefers-color-scheme: light); | ||
@import url("./cpd-theme-light-hc-base.css") layer(base) screen; | ||
@import url("./cpd-theme-light-hc-base-mq.css") layer(base) screen and (prefers-color-scheme: light) and (prefers-contrast: more); | ||
@import url("./cpd-theme-light-hc-semantic.css") layer(semantic) screen; | ||
@import url("./cpd-theme-light-hc-semantic-mq.css") layer(semantic) screen and (prefers-color-scheme: light) and (prefers-contrast: more); | ||
@import url("./cpd-theme-dark-base.css") layer(base) screen; | ||
@import url("./cpd-theme-dark-base-mq.css") layer(base) screen and (prefers-color-scheme: dark); | ||
@import url("./cpd-theme-dark-semantic.css") layer(semantic) screen; | ||
@import url("./cpd-theme-dark-semantic-mq.css") layer(semantic) screen and (prefers-color-scheme: dark); | ||
@import url("./cpd-theme-dark-hc-base.css") layer(base) screen; | ||
@import url("./cpd-theme-dark-hc-base-mq.css") layer(base) screen and (prefers-color-scheme: dark) and (prefers-contrast: more); | ||
@import url("./cpd-theme-dark-hc-semantic.css") layer(semantic) screen; | ||
@import url("./cpd-theme-dark-hc-semantic-mq.css") layer(semantic) screen and (prefers-color-scheme: dark) and (prefers-contrast: more); |
This file contains 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 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,66 @@ | ||
:root, [class*="cpd-theme-"] { | ||
--cpd-color-icon-on-solid-primary: var(--cpd-color-theme-bg); | ||
--cpd-color-icon-info-primary: var(--cpd-color-blue-900); | ||
--cpd-color-icon-success-primary: var(--cpd-color-green-900); | ||
--cpd-color-icon-critical-primary: var(--cpd-color-red-900); | ||
--cpd-color-icon-accent-tertiary: var(--cpd-color-green-800); | ||
--cpd-color-icon-quaternary-alpha: var(--cpd-color-alpha-gray-700); | ||
--cpd-color-icon-tertiary-alpha: var(--cpd-color-alpha-gray-800); | ||
--cpd-color-icon-secondary-alpha: var(--cpd-color-alpha-gray-900); | ||
--cpd-color-icon-primary-alpha: var(--cpd-color-alpha-gray-1400); | ||
--cpd-color-icon-disabled: var(--cpd-color-gray-700); | ||
--cpd-color-icon-quaternary: var(--cpd-color-gray-700); | ||
--cpd-color-icon-tertiary: var(--cpd-color-gray-800); | ||
--cpd-color-icon-secondary: var(--cpd-color-gray-900); | ||
--cpd-color-icon-primary: var(--cpd-color-gray-1400); | ||
--cpd-color-border-info-subtle: var(--cpd-color-blue-500); | ||
--cpd-color-border-success-subtle: var(--cpd-color-green-500); | ||
--cpd-color-border-critical-subtle: var(--cpd-color-red-500); | ||
--cpd-color-border-critical-hovered: var(--cpd-color-red-1000); | ||
--cpd-color-border-critical-primary: var(--cpd-color-red-900); | ||
--cpd-color-border-interactive-hovered: var(--cpd-color-gray-1100); | ||
--cpd-color-border-interactive-secondary: var(--cpd-color-gray-600); | ||
--cpd-color-border-interactive-primary: var(--cpd-color-gray-800); | ||
--cpd-color-border-focused: var(--cpd-color-blue-900); | ||
--cpd-color-border-disabled: var(--cpd-color-gray-500); | ||
--cpd-color-bg-decorative-6: var(--cpd-color-alpha-orange-300); | ||
--cpd-color-bg-decorative-5: var(--cpd-color-alpha-pink-300); | ||
--cpd-color-bg-decorative-4: var(--cpd-color-alpha-purple-300); | ||
--cpd-color-bg-decorative-3: var(--cpd-color-alpha-fuchsia-300); | ||
--cpd-color-bg-decorative-2: var(--cpd-color-alpha-cyan-300); | ||
--cpd-color-bg-decorative-1: var(--cpd-color-alpha-lime-300); | ||
--cpd-color-bg-info-subtle: var(--cpd-color-blue-200); | ||
--cpd-color-bg-success-subtle: var(--cpd-color-green-200); | ||
--cpd-color-bg-critical-subtle-hovered: var(--cpd-color-red-300); | ||
--cpd-color-bg-critical-subtle: var(--cpd-color-red-200); | ||
--cpd-color-bg-critical-hovered: var(--cpd-color-red-1000); | ||
--cpd-color-bg-critical-primary: var(--cpd-color-red-900); | ||
--cpd-color-bg-action-secondary-pressed: var(--cpd-color-alpha-gray-300); | ||
--cpd-color-bg-action-secondary-hovered: var(--cpd-color-alpha-gray-200); | ||
--cpd-color-bg-action-secondary-rest: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-action-primary-disabled: var(--cpd-color-gray-700); | ||
--cpd-color-bg-action-primary-pressed: var(--cpd-color-gray-1100); | ||
--cpd-color-bg-action-primary-hovered: var(--cpd-color-gray-1200); | ||
--cpd-color-bg-action-primary-rest: var(--cpd-color-gray-1400); | ||
--cpd-color-bg-canvas-disabled: var(--cpd-color-gray-200); | ||
--cpd-color-bg-canvas-default: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-subtle-secondary: var(--cpd-color-gray-300); | ||
--cpd-color-bg-subtle-primary: var(--cpd-color-gray-400); | ||
--cpd-color-text-decorative-6: var(--cpd-color-orange-1100); | ||
--cpd-color-text-decorative-5: var(--cpd-color-pink-1100); | ||
--cpd-color-text-decorative-4: var(--cpd-color-purple-1100); | ||
--cpd-color-text-decorative-3: var(--cpd-color-fuchsia-1100); | ||
--cpd-color-text-decorative-2: var(--cpd-color-cyan-1100); | ||
--cpd-color-text-decorative-1: var(--cpd-color-lime-1100); | ||
--cpd-color-text-on-solid-primary: var(--cpd-color-theme-bg); | ||
--cpd-color-text-info-primary: var(--cpd-color-blue-900); | ||
--cpd-color-text-success-primary: var(--cpd-color-green-900); | ||
--cpd-color-text-critical-primary: var(--cpd-color-red-900); | ||
--cpd-color-text-link-external: var(--cpd-color-blue-900); | ||
--cpd-color-text-action-accent: var(--cpd-color-green-900); | ||
--cpd-color-text-action-primary: var(--cpd-color-gray-1400); | ||
--cpd-color-text-disabled: var(--cpd-color-gray-800); | ||
--cpd-color-text-placeholder: var(--cpd-color-gray-800); | ||
--cpd-color-text-secondary: var(--cpd-color-gray-900); | ||
--cpd-color-text-primary: var(--cpd-color-gray-1400); | ||
} |
This file contains 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 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 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 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 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,4 @@ | ||
:root { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-gray-300); | ||
} |
This file contains 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,4 @@ | ||
.cpd-theme-dark-hc.cpd-theme-dark-hc { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-gray-300); | ||
} |
This file contains 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,4 @@ | ||
:root { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-gray-300); | ||
} |
This file contains 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,4 @@ | ||
.cpd-theme-dark.cpd-theme-dark { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-theme-bg); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-gray-300); | ||
} |
This file contains 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 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 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 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 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,4 @@ | ||
:root { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-gray-300); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-theme-bg); | ||
} |
This file contains 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,4 @@ | ||
.cpd-theme-light-hc.cpd-theme-light-hc { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-gray-300); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-theme-bg); | ||
} |
This file contains 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,4 @@ | ||
:root { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-gray-300); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-theme-bg); | ||
} |
This file contains 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,4 @@ | ||
.cpd-theme-light.cpd-theme-light { | ||
--cpd-color-bg-subtle-secondary-level-0: var(--cpd-color-gray-300); | ||
--cpd-color-bg-canvas-default-level-1: var(--cpd-color-theme-bg); | ||
} |
This file contains 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 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 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.