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(docs): add cargo theme #3993

Open
wants to merge 2 commits into
base: export-palette-tokens
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changeset/khaki-cougars-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-styles': minor
'@swisspost/design-system-documentation': minor
---

Addes Cargo theme styles.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { IconButton, WithTooltip } from '@storybook/components';

const THEMES = ['Post'] as const;
const THEMES = ['Post', 'Cargo'] as const;
const CHANNELS = ['External', 'Internal'] as const;
const SCHEMES = ['Light', 'Dark'] as const;

Expand All @@ -15,18 +15,6 @@ const possibleStylesheets = THEMES.flatMap(theme => {
return CHANNELS.map(channel => getStylesheetUrl(theme, channel));
});

/*
* Backgrounds
*/
const backgroundClasses: { [key in (typeof SCHEMES)[number]]: string } = {
Light: 'bg-white',
Dark: 'bg-dark',
};
const getBackgroundClass = (scheme: string) => {
return scheme in backgroundClasses ? backgroundClasses[scheme] : '';
};
const possibleBackgrounds = SCHEMES.map(scheme => getBackgroundClass(scheme));

/*
* Local storage access
*/
Expand Down Expand Up @@ -113,9 +101,8 @@ function StylesSwitcher() {
if (!stories) return;

stories.forEach(story => {
story.classList.remove(...possibleBackgrounds);
story.classList.add(getBackgroundClass(currentScheme));
story.setAttribute('data-color-scheme', currentScheme.toLowerCase());
if (!story.classList.contains('palette-default')) story.classList.add('palette-default');
});
}, [stories, currentScheme]);

Expand Down
2 changes: 2 additions & 0 deletions packages/documentation/.storybook/styles/preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ $monospace: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier

#storybook-root,
#storybook-docs {
background-color: white;

.sbdocs-content .container >,
.sbdocs-content .container > post-tabs > post-tab-panel >,
.sbdocs-content .container > migration-global-state {
Expand Down
7 changes: 7 additions & 0 deletions packages/styles/src/cargo-external.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@use './tokens/schemes';
@use './tokens/device';
@use './tokens/external';
@use './tokens/cargo-theme';
@use './utilities';
@use './elements';
@use './components';
7 changes: 7 additions & 0 deletions packages/styles/src/cargo-internal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@use './tokens/schemes';
@use './tokens/device';
@use './tokens/internal';
@use './tokens/cargo-theme';
@use './utilities';
@use './elements';
@use './components';
8 changes: 8 additions & 0 deletions packages/styles/src/cargo-tokens-external.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use 'sass:meta';

@layer design-system {
@include meta.load-css('./tokens/schemes');
@include meta.load-css('./tokens/device');
@include meta.load-css('./tokens/external');
@include meta.load-css('./tokens/cargo-theme');
}
8 changes: 8 additions & 0 deletions packages/styles/src/cargo-tokens-internal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use 'sass:meta';

@layer design-system {
@include meta.load-css('./tokens/schemes');
@include meta.load-css('./tokens/device');
@include meta.load-css('./tokens/internal');
@include meta.load-css('./tokens/cargo-theme');
}
5 changes: 4 additions & 1 deletion packages/styles/src/post-external.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@use './post-tokens-external';
@use './tokens/schemes';
@use './tokens/device';
@use './tokens/external';
@use './tokens/post-theme';
@use './utilities';
@use './elements';
@use './components';
5 changes: 4 additions & 1 deletion packages/styles/src/post-internal.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@use './post-tokens-internal';
@use './tokens/schemes';
@use './tokens/device';
@use './tokens/internal';
@use './tokens/post-theme';
@use './utilities';
@use './elements';
@use './components';
8 changes: 8 additions & 0 deletions packages/styles/src/tokens/_cargo-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-cargo);
}