Skip to content

Commit

Permalink
BREAKING CHANGE: Update Spirit design tokens to v3 and rewrite themin…
Browse files Browse the repository at this point in the history
…g API
  • Loading branch information
adamkudrna committed Feb 1, 2025
1 parent 23e2909 commit d3821f3
Show file tree
Hide file tree
Showing 25 changed files with 462 additions and 243 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,11 @@ Start local development server:
yarn start
```
This will make the development server accessible http://localhost:3000/ .
This will make the development server accessible http://localhost:5173/ .
* The library with init function is served on: http://localhost:3000/dist/init.js
* Javascript module: http://localhost:3000/dist/CookieConsentManager.js
* CSS: http://localhost:3000/dist/CookieConsentManager.css
* The library with init function is served on: http://localhost:5173/dist/init.js
* Javascript module: http://localhost:5173/dist/CookieConsentManager.js
* CSS: http://localhost:5173/dist/CookieConsentManager.css
### Contributing
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ See readme for [callbacks documentation](README.md#callbacks).

## Theming changes and Spirit Design System upgrade

...
TODO

See readme for [full theming documentation](README.md#theming).

Expand Down
19 changes: 11 additions & 8 deletions dist/scss/index.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Order matters, do not alter.

@forward 'theme/default';
// @forward 'theme/default';

@forward 'style/themes';
@forward 'theme/default-to-vanilla';
@forward 'style/typography';
@forward 'style/links';
@forward 'style/buttons';
@forward 'style/toggles';
@forward 'style/main';
@forward 'style/consent-modal';
@forward 'style/preferences-modal';

// @forward 'style/typography';
// @forward 'style/links';
// @forward 'style/buttons';
// @forward 'style/toggles';
// @forward 'style/main';
// @forward 'style/consent-modal';
// @forward 'style/preferences-modal';
12 changes: 6 additions & 6 deletions dist/scss/settings/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ $enable-link-buttons: false; // Optionally render secondary button(s) in consent
$breakpoint-tablet-down: 688px; // Original value from Cookie Consent styles.
$breakpoint-desktop-down: 1024px - 1;

$button-padding: calc(#{units.convert2em(tokens.$space-400)} - var(--lmcccm-p-btn-border-width))
units.convert2em(tokens.$space-700);
$button-spacing-x: units.convert2em(tokens.$space-600);
$button-spacing-y: units.convert2em(tokens.$space-600);
$button-padding: calc(#{units.convert2em(tokens.$space-500)} - var(--lmcccm-p-btn-border-width))
units.convert2em(tokens.$space-900);
$button-spacing-x: units.convert2em(tokens.$space-700);
$button-spacing-y: units.convert2em(tokens.$space-700);

$consent-box-max-width: 40em;
$consent-cloud-max-width: 68em;

$modal-padding-desktop: units.convert2em(tokens.$space-700);
$modal-padding-tablet: units.convert2em(tokens.$space-600);
$modal-padding-desktop: units.convert2em(tokens.$space-900);
$modal-padding-tablet: units.convert2em(tokens.$space-700);
$modal-header-height-desktop: 4.8125em;
$modal-header-height-tablet: 3.375em;
$modal-footer-height-desktop: 5.5em;
Expand Down
4 changes: 2 additions & 2 deletions dist/scss/style/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ $_consent-modal-button-selector: '#cm .c-bn' !default;
#cm .c-bn.c_link,
#c-bns.swap .c_link:first-child,
#c-bns:not(.swap) .c_link:last-child {
padding-right: units.convert2em(tokens.$space-400);
padding-left: units.convert2em(tokens.$space-400);
padding-right: units.convert2em(tokens.$space-500);
padding-left: units.convert2em(tokens.$space-500);
font-weight: inherit;
font-size: inherit;
text-decoration: var(--lmcccm-p-link-text-decoration);
Expand Down
20 changes: 10 additions & 10 deletions dist/scss/style/_consent-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

#cm {
max-width: settings.$consent-box-max-width;
max-height: calc(100vh - #{units.convert2em(tokens.$space-800)});
padding: units.convert2em(tokens.$space-800);
max-height: calc(100vh - #{units.convert2em(tokens.$space-1000)});
padding: units.convert2em(tokens.$space-1000);
overflow-y: auto;
box-shadow: tokens.$shadow-100;
-webkit-overflow-scrolling: touch;
}

#cm.box,
#cm.bar {
padding: units.convert2em(tokens.$space-900);
padding: units.convert2em(tokens.$space-1100);
}

#cm.bar {
Expand All @@ -28,7 +28,7 @@

#cm.bar #c-inr-i {
flex-grow: 1;
margin-right: units.convert2em(tokens.$space-1000);
margin-right: units.convert2em(tokens.$space-1200);
}

#cm.bar #c-bns {
Expand All @@ -50,12 +50,12 @@

#cm.cloud {
max-width: settings.$consent-cloud-max-width;
padding: units.convert2em(tokens.$space-900) units.convert2em(tokens.$space-1000);
padding: units.convert2em(tokens.$space-1100) units.convert2em(tokens.$space-1200);
overflow-y: auto;
}

.cc_div #c-bns {
margin-top: units.convert2em(tokens.$space-800);
margin-top: units.convert2em(tokens.$space-1000);
}

@media screen and (max-width: settings.$breakpoint-desktop-down) {
Expand All @@ -66,7 +66,7 @@

#cm.bar #c-inr-i {
margin-right: 0;
margin-bottom: units.convert2em(tokens.$space-800);
margin-bottom: units.convert2em(tokens.$space-1000);
}

#cm.bar #c-bns {
Expand All @@ -80,15 +80,15 @@
#cm.left,
#cm.right {
// stylelint-disable-next-line declaration-no-important -- Override original styles.
padding: units.convert2em(tokens.$space-700) !important;
padding: units.convert2em(tokens.$space-900) !important;
}

.cc_div #c-bns {
margin-top: units.convert2em(tokens.$space-700);
margin-top: units.convert2em(tokens.$space-900);
}

#cm.bar #c-inr-i {
margin-bottom: units.convert2em(tokens.$space-700);
margin-bottom: units.convert2em(tokens.$space-900);
}

#cm.bar #c-bns {
Expand Down
16 changes: 8 additions & 8 deletions dist/scss/style/_preferences-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
}

#s-inr {
#cc-main .pm {
max-width: var(--lmcccm-p-modal-max-width);
padding-top: settings.$modal-header-height-desktop;
padding-bottom: settings.$modal-footer-height-desktop;
Expand Down Expand Up @@ -136,10 +136,10 @@
}

#s-bl .c-bl {
margin-bottom: units.convert2em(tokens.$space-400);
margin-bottom: units.convert2em(tokens.$space-500);

&:first-child {
margin-bottom: units.convert2em(tokens.$space-600);
margin-bottom: units.convert2em(tokens.$space-700);
}

&:last-child {
Expand All @@ -148,14 +148,14 @@
}

#s-bl .b-acc .p {
padding: units.convert2em(tokens.$space-600);
padding: units.convert2em(tokens.$space-700);
}

#s-cnt .b-bn .b-tl {
padding: units.convert2em(tokens.$space-600) 5em units.convert2em(tokens.$space-600) 3.25em;
font-weight: map.get(tokens.$body-medium-text-regular, 'mobile', 'font-weight');
font-size: units.convert2em(map.get(tokens.$body-medium-text-regular, 'mobile', 'font-size'));
line-height: map.get(tokens.$body-medium-text-regular, 'mobile', 'line-height');
padding: units.convert2em(tokens.$space-700) 5em units.convert2em(tokens.$space-700) 3.25em;
font-weight: map.get(tokens.$body-medium-regular, 'mobile', 'font-weight');
font-size: units.convert2em(map.get(tokens.$body-medium-regular, 'mobile', 'font-size'));
line-height: map.get(tokens.$body-medium-regular, 'mobile', 'line-height');
}

.cc_div .act .b-bn .exp::before,
Expand Down
4 changes: 4 additions & 0 deletions dist/scss/style/_themes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@use '@themes' as themes;
@use '../tools/themes' as themes-tools;

@include themes-tools.generate($themes: themes.$themes);
24 changes: 12 additions & 12 deletions dist/scss/style/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@use '../tools/units';

.cc_div {
$_line-height: map.get(tokens.$body-medium-text-regular, 'mobile', 'line-height');
$_line-height: map.get(tokens.$body-medium-regular, 'mobile', 'line-height');

font-size: var(--lmcccm-p-base-font-size);
line-height: $_line-height;
Expand All @@ -18,35 +18,35 @@
}

strong {
font-weight: map.get(tokens.$body-medium-text-bold, 'mobile', 'font-weight');
font-weight: map.get(tokens.$body-medium-bold, 'mobile', 'font-weight');
}
}

#c-txt p:not(:last-child) {
margin-bottom: units.convert2em(tokens.$space-600);
margin-bottom: units.convert2em(tokens.$space-700);
}

#c-ttl,
#s-ttl {
$_font-size: units.convert2em(map.get(tokens.$heading-small-text, 'desktop', 'font-size'));
.pm__title,
.pm__section-title {
$_font-size: units.convert2em(map.get(tokens.$heading-small-bold, 'desktop', 'font-size'));

margin-bottom: units.convert2em(tokens.$space-600, $current-font-size: $_font-size);
font-weight: map.get(tokens.$heading-small-text, 'mobile', 'font-weight');
margin-bottom: units.convert2em(tokens.$space-700, $current-font-size: $_font-size);
font-weight: map.get(tokens.$heading-small-bold, 'mobile', 'font-weight');
font-size: $_font-size;
line-height: map.get(tokens.$heading-medium-text, 'mobile', 'line-height');
line-height: map.get(tokens.$heading-medium-bold, 'mobile', 'line-height');

@media screen and (max-width: settings.$breakpoint-desktop-down) {
font-size: units.convert2em(map.get(tokens.$heading-small-text, 'tablet', 'font-size'));
font-size: units.convert2em(map.get(tokens.$heading-small-bold, 'tablet', 'font-size'));
}

@media screen and (max-width: settings.$breakpoint-tablet-down) {
font-size: units.convert2em(map.get(tokens.$heading-small-text, 'mobile', 'font-size'));
font-size: units.convert2em(map.get(tokens.$heading-small-bold, 'mobile', 'font-size'));
}
}

#c-txt,
.cc_div .cloud #c-txt {
margin-bottom: 0;
font-size: units.convert2em(map.get(tokens.$body-medium-text-regular, 'mobile', 'font-size'));
font-size: units.convert2em(map.get(tokens.$body-medium-regular, 'mobile', 'font-size'));
line-height: inherit;
}
79 changes: 56 additions & 23 deletions dist/scss/theme/_default-to-vanilla.scss
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
//
// Map Alma Career CCM **private** theming API to the original (vanilla) Cookie Consent custom properties.
//
// TODO
// Assignment below is applied through `.cc_div` instead of `:root`, so it works for both light and
// dark theme.
//
// 1. We don't want to style scrollbars at this moment, but let's keep the options here to know they are still available.

.cc_div {
--cc-bg: var(--lmcccm-p-bg);
--cc-text: var(--lmcccm-p-text);
--cc-btn-primary-bg: var(--lmcccm-p-btn-primary-bg);
--cc-btn-primary-text: var(--lmcccm-p-btn-primary-text);
--cc-btn-primary-hover-bg: var(--lmcccm-p-btn-primary-hover-bg);
--cc-btn-secondary-bg: var(--lmcccm-p-btn-secondary-bg);
--cc-btn-secondary-text: var(--lmcccm-p-btn-secondary-text);
--cc-btn-secondary-hover-bg: var(--lmcccm-p-btn-secondary-hover-bg);
--cc-toggle-bg-off: var(--lmcccm-p-toggle-bg-off);
--cc-toggle-bg-on: var(--lmcccm-p-toggle-bg-on);
--cc-toggle-bg-readonly: var(--lmcccm-p-toggle-bg-readonly);
--cc-toggle-knob-bg: var(--lmcccm-p-toggle-knob-bg);
--cc-toggle-knob-icon-color: var(--lmcccm-p-toggle-knob-icon-color);
--cc-block-text: var(--lmcccm-p-text);
--cc-cookie-category-block-bg: var(--lmcccm-p-cookie-category-bg);
--cc-cookie-category-block-bg-hover: var(--lmcccm-p-cookie-category-hover-bg);
--cc-section-border: var(--lmcccm-p-modal-section-border);
--cc-cookie-table-border: var(--lmcccm-p-cookie-table-border);
--cc-overlay-bg: var(--lmcccm-p-backdrop-color);

// --cc-webkit-scrollbar-bg: #cfd5db; // 1.
// --cc-webkit-scrollbar-bg-hover: #9199a0; // 1.
// stylelint-disable custom-property-empty-line-before -- Grouping is useful here.

@use '@tokens' as tokens;

:root {
--cc-bg: #{tokens.$background-primary};
--cc-primary-color: #{tokens.$text-primary};
--cc-secondary-color: #{tokens.$text-secondary};

--cc-btn-primary-bg: #{tokens.$component-button-primary-state-default};
--cc-btn-primary-color: #{tokens.$component-button-primary-content};
--cc-btn-primary-border-color: #{tokens.$component-button-primary-border};
--cc-btn-primary-hover-bg: #{tokens.$component-button-primary-state-hover};
--cc-btn-primary-hover-color: #{tokens.$component-button-primary-content};
--cc-btn-primary-hover-border-color: #{tokens.$component-button-primary-border};

--cc-btn-secondary-bg: #eaeff2;
--cc-btn-secondary-color: var(--cc-primary-color);
--cc-btn-secondary-border-color: var(--cc-btn-secondary-bg);
--cc-btn-secondary-hover-bg: #d4dae0;
--cc-btn-secondary-hover-color: #000;
--cc-btn-secondary-hover-border-color: #d4dae0;

--cc-separator-border-color: #{tokens.$border-basic};

--cc-toggle-on-bg: var(--cc-btn-primary-bg);
--cc-toggle-off-bg: #667481;
--cc-toggle-on-knob-bg: #fff;
--cc-toggle-off-knob-bg: var(--cc-toggle-on-knob-bg);

--cc-toggle-enabled-icon-color: var(--cc-bg);
--cc-toggle-disabled-icon-color: var(--cc-bg);

--cc-toggle-readonly-bg: #d5dee2;
--cc-toggle-readonly-knob-bg: #fff;
--cc-toggle-readonly-knob-icon-color: var(--cc-toggle-readonly-bg);

--cc-section-category-border: var(--cc-cookie-category-block-bg);

--cc-cookie-category-block-bg: #f0f4f7;
--cc-cookie-category-block-border: #f0f4f7;
--cc-cookie-category-block-hover-bg: #e9eff4;
--cc-cookie-category-block-hover-border: #e9eff4;
--cc-cookie-category-expanded-block-bg: transparent;
--cc-cookie-category-expanded-block-hover-bg: #dee4e9;

--cc-overlay-bg: rgb(0 0 0 / 65%);

// 1.
// --cc-webkit-scrollbar-bg: var(--cc-section-category-border);
// --cc-webkit-scrollbar-hover-bg: var(--cc-btn-primary-hover-bg);

--cc-footer-bg: var(--cc-btn-secondary-bg);
--cc-footer-color: var(--cc-secondary-color);
--cc-footer-border-color: #e4eaed;
}
Loading

0 comments on commit d3821f3

Please sign in to comment.