Skip to content
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

feat: add semantic layer token machinery #3349

Merged
merged 29 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8800cad
feat: add device tokens
gfellerph Jul 24, 2024
1d4ac31
feat: add color mode styles
gfellerph Jul 24, 2024
8c98caa
feat: add the rest of the semantic layer
gfellerph Jul 24, 2024
e84b51e
feat: add semantic layer token machinery
gfellerph Jul 24, 2024
4798c4a
Revert "feat: add semantic layer token machinery"
gfellerph Jul 24, 2024
310e044
feat: add token only output targets
gfellerph Jul 24, 2024
305ff06
feat: add missing core tokens
gfellerph Jul 24, 2024
684693c
chore: add changeset
gfellerph Jul 24, 2024
21b2718
fix: use more specific media queries
gfellerph Jul 24, 2024
f2621eb
hoist token definitions
gfellerph Jul 24, 2024
ef0b1c1
add temporary copy workaround
gfellerph Jul 25, 2024
bb19961
import tokens into docs
gfellerph Jul 25, 2024
cbafb2e
set button primary fore- and background with tokens
gfellerph Jul 25, 2024
1d7ba3a
implement light-dark (with a workaround)
gfellerph Jul 26, 2024
8b9c454
rename mode placeholders
gfellerph Jul 26, 2024
aba68d5
Revert light-dark experiment
gfellerph Aug 7, 2024
ffea852
Revert "set button primary fore- and background with tokens"
gfellerph Aug 7, 2024
783ab0f
Merge branch 'main' into 3310-tokens-set-up-semantic-layer-for-channels
gfellerph Aug 7, 2024
b836913
Update packages/documentation/.storybook/styles/preview.scss
gfellerph Aug 12, 2024
97ffe7f
Update packages/styles/gulpfile.js
gfellerph Aug 12, 2024
fcf60fc
Update packages/styles/gulpfile.js
gfellerph Aug 12, 2024
a047516
Update packages/styles/gulpfile.js
gfellerph Aug 12, 2024
0c86132
Update .changeset/large-weeks-tap.md
gfellerph Aug 12, 2024
b2e6462
Update packages/styles/src/mixins/_media.scss
gfellerph Aug 12, 2024
c3acc68
Update packages/styles/src/mixins/_media.scss
gfellerph Aug 12, 2024
2afbe7f
Update packages/styles/src/mixins/_tokens.scss
gfellerph Aug 12, 2024
f0ed82a
Update packages/styles/src/mixins/_tokens.scss
gfellerph Aug 12, 2024
68fdfd1
chore: add comment to gulpfile about temporary fix
gfellerph Aug 12, 2024
11dac21
Merge branch '3310-tokens-set-up-semantic-layer-for-channels' of http…
gfellerph Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/large-weeks-tap.md
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
3 changes: 1 addition & 2 deletions packages/documentation/.storybook/styles/preview.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// importing the complete styles package scss
// TODO: replace intranet.scss with index.scss as soon as the issues in the portal.scss are fixed
@use '@swisspost/design-system-styles/intranet.scss';
@use '@swisspost/design-system-styles/post-external.scss';
@use '@swisspost/design-system-styles/core.scss' as post;
@use '@swisspost/design-system-styles/mixins/utilities';
@use '@swisspost/internet-header/dist/swisspost-internet-header/swisspost-internet-header.css';
Expand Down
3 changes: 3 additions & 0 deletions packages/styles/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ storybook-static
# Mac OSX Finder files.
**/.DS_Store
.DS_Store

# Temporary files
src/tokens/temp/
20 changes: 16 additions & 4 deletions packages/styles/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ gulp.task('copy', () => {
.pipe(gulp.dest(options.outputDir));
});

/**
* Temporary task to copy token files from tokens package to the styles package since
* pnpm does not correctly install dependencies of dependencies for workspace packages.
* See https://github.com/pnpm/pnpm/issues/8338 for more information and reproduction
*/
gulp.task('temporarily-copy-token-files', () => {
return gulp.src(['../tokens/dist/*.scss']).pipe(gulp.dest('./src/tokens/temp'));
});

/**
* Autoprefix SCSS files
*/
Expand Down Expand Up @@ -168,9 +177,12 @@ gulp.task('sass:tests', () => {
/**
* Watch task for scss development
*/
gulp.task('watch', () => {
return gulp.watch('./src/**/*.scss', gulp.series('copy'));
});
gulp.task(
'watch',
gulp.series('temporarily-copy-token-files', () => {
return gulp.watch('./src/**/*.scss', 'copy');
}),
);

/**
* Run copy and sass task in parallel per default
Expand All @@ -179,7 +191,7 @@ exports.default = gulp.task(
'build',
gulp.parallel(
gulp.series('map-icons', 'copy', 'autoprefixer', 'transform-package-json'),
gulp.series('sass'),
gulp.series('temporarily-copy-token-files', 'sass'),
gulp.series('build-components'),
),
);
1 change: 1 addition & 0 deletions packages/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"bootstrap": "5.3.3"
},
"devDependencies": {
"@swisspost/design-system-tokens": "workspace:*",
"@swisspost/design-system-icons": "workspace:8.1.0",
"@types/node": "20.14.14",
"autoprefixer": "10.4.19",
Expand Down
17 changes: 17 additions & 0 deletions packages/styles/src/mixins/_media.scss
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;
}
}
5 changes: 5 additions & 0 deletions packages/styles/src/mixins/_tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@mixin from($map) {
@each $key, $value in $map {
--#{$key}: #{$value};
}
}
10 changes: 10 additions & 0 deletions packages/styles/src/placeholders/_modes.scss
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);
}
2 changes: 2 additions & 0 deletions packages/styles/src/post-external.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@use './post-tokens-external';
@use './components';
2 changes: 2 additions & 0 deletions packages/styles/src/post-internal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@use './post-tokens-internal';
@use './components';
4 changes: 4 additions & 0 deletions packages/styles/src/post-tokens-external.scss
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';
4 changes: 4 additions & 0 deletions packages/styles/src/post-tokens-internal.scss
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';
1 change: 1 addition & 0 deletions packages/styles/src/tokens/_core.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use './temp/core';
19 changes: 19 additions & 0 deletions packages/styles/src/tokens/_device.scss
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the breakpoints be tokenized too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we were talking about this. We'll update this once they are (also, there might be two more).

@include tokens.from(device.$post-mobile);
}
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved

@include media.between(600px, 1024px) {
@include tokens.from(device.$post-tablet);
}

@include media.min(1024px) {
@include tokens.from(device.$post-desktop);
}
}
8 changes: 8 additions & 0 deletions packages/styles/src/tokens/_external.scss
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 {
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
@include tokens.from(channel.$post-edk);
}
8 changes: 8 additions & 0 deletions packages/styles/src/tokens/_internal.scss
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);
}
11 changes: 11 additions & 0 deletions packages/styles/src/tokens/_modes.scss
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;
}
8 changes: 8 additions & 0 deletions packages/styles/src/tokens/_post-theme.scss
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);
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.