-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add semantic layer token machinery (#3349)
This PR introduces the core and semantic layer tokens into the styles package. With this, a couple of new entry files become available as well as mixins to generate token maps. New entry files: ``` post-external.scss post-internal.scss post-tokens-external.scss post-tokens-internal.scss ``` New mixins: ``` _media.scss (for min, max, between media queries) _tokens.scss (for creating token maps from the scss list outputs) ``` - [x] Implementation in documentation is missing due to pnpm/pnpm#8338 - [x] Use component layer tokens like it's intended --------- Co-authored-by: Alizé Debray <[email protected]>
- Loading branch information
1 parent
1d2650e
commit a767c23
Showing
19 changed files
with
133 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@swisspost/design-system-styles': minor | ||
--- | ||
|
||
Added four new entry files that enable working with Design Tokens: | ||
|
||
- post-external.(s)css: For portal and other external pages | ||
- post-internal.(s)css: For applications and other internal pages | ||
- post-tokens-external.(s)css: External tokens only | ||
- post-tokens-internal.(s)css: Internal tokens only |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ storybook-static | |
# Mac OSX Finder files. | ||
**/.DS_Store | ||
.DS_Store | ||
|
||
# Temporary files | ||
src/tokens/temp/ |
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,17 @@ | ||
@mixin min($device-size) { | ||
@media screen and (min-width: $device-size) { | ||
@content; | ||
} | ||
} | ||
|
||
@mixin max($device-size) { | ||
@media screen and (max-width: ($device-size - 0.01)) { | ||
@content; | ||
} | ||
} | ||
|
||
@mixin between($min-size, $max-size) { | ||
@media screen and (min-width: $min-size) and (max-width: ($max-size - 0.01)) { | ||
@content; | ||
} | ||
} |
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,5 @@ | ||
@mixin from($map) { | ||
@each $key, $value in $map { | ||
--#{$key}: #{$value}; | ||
} | ||
} |
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,10 @@ | ||
@use '../tokens/temp/mode' as mode; | ||
@use './../mixins/tokens'; | ||
|
||
%color-mode-light { | ||
@include tokens.from(mode.$post-light); | ||
} | ||
|
||
%color-mode-dark { | ||
@include tokens.from(mode.$post-dark); | ||
} |
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,2 @@ | ||
@use './post-tokens-external'; | ||
@use './components'; |
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,2 @@ | ||
@use './post-tokens-internal'; | ||
@use './components'; |
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 @@ | ||
@use './tokens/modes'; | ||
@use './tokens/device'; | ||
@use './tokens/external'; | ||
@use './tokens/post-theme'; |
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 @@ | ||
@use './tokens/modes'; | ||
@use './tokens/device'; | ||
@use './tokens/internal'; | ||
@use './tokens/post-theme'; |
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 @@ | ||
@use './temp/core'; |
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,19 @@ | ||
@use './temp/device' as device; | ||
|
||
@use './core'; | ||
@use './../mixins/tokens'; | ||
@use './../mixins/media'; | ||
|
||
:root { | ||
@include media.max(600px) { | ||
@include tokens.from(device.$post-mobile); | ||
} | ||
|
||
@include media.between(600px, 1024px) { | ||
@include tokens.from(device.$post-tablet); | ||
} | ||
|
||
@include media.min(1024px) { | ||
@include tokens.from(device.$post-desktop); | ||
} | ||
} |
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,8 @@ | ||
@use './temp/channel' as channel; | ||
|
||
@use './core'; | ||
@use './../mixins/tokens'; | ||
|
||
:root { | ||
@include tokens.from(channel.$post-edk); | ||
} |
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,8 @@ | ||
@use './temp/channel' as channel; | ||
|
||
@use './core'; | ||
@use './../mixins/tokens'; | ||
|
||
:root { | ||
@include tokens.from(channel.$post-idk); | ||
} |
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,11 @@ | ||
@use './core'; | ||
@use './../placeholders/modes'; | ||
|
||
:root, | ||
[data-color-mode='light'] { | ||
@extend %color-mode-light; | ||
} | ||
|
||
[data-color-mode='dark'] { | ||
@extend %color-mode-dark; | ||
} |
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,8 @@ | ||
@use './temp/theme' as themes; | ||
|
||
@use './core'; | ||
@use './../mixins/tokens'; | ||
|
||
:root { | ||
@include tokens.from(themes.$post-theme); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.