Skip to content

Commit

Permalink
fix(spacing): use base 20 fallback spacing logic
Browse files Browse the repository at this point in the history
use 20 instead of 16 - 20 is the default described in the docs
allow for 16 to be set using --cds-global-base, even if the global css doesn't load

fixes vmware-clarity/ng-clarity#138
  • Loading branch information
Ashley Ryan committed Jun 16, 2022
1 parent a727b22 commit b29a19b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion projects/core/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,4 @@ const dataThemeDecorator = (story, { globals }) => {
export const decorators = [themeDecorator, dataThemeDecorator];

// We have this here since storybook does not have a easy way to set the <html> element in demos
// The token system generates a base 16px set of variables for apps that may not be able to easily set the base font to 125%
document.body.setAttribute('cds-text', 'body');
5 changes: 4 additions & 1 deletion projects/core/build/build.tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ function tokenToSass(token: Token, fallback = false) {
let fallbackValue = convertCSSValue(token);

if (typeof token.value === 'number') {
fallbackValue = `${token.value / 16}rem`; // worst case scenario, fallback to base 16 if base 20 not set at root
// fallback to using the global base as a divisor,
// which can be set even if global CSS isn't loaded
// worse case scenario, use base 20, Clarity's default
fallbackValue = `calc(${token.value} * (1rem / var(--cds-global-base, 20)))`;
}

if (token.config.raw) {
Expand Down
2 changes: 1 addition & 1 deletion projects/core/src/index.performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('performance', () => {
expect((await testBundleSize('@cds/core/list/list.min.css')).kb).toBeLessThan(0.5);

// contained in @cds/core/global.min.css
expect((await testBundleSize('@cds/core/styles/module.layout.min.css')).kb).toBeLessThan(4.5);
expect((await testBundleSize('@cds/core/styles/module.layout.min.css')).kb).toBeLessThan(4.6);
expect((await testBundleSize('@cds/core/styles/module.reset.min.css')).kb).toBeLessThan(0.5);
expect((await testBundleSize('@cds/core/styles/module.tokens.min.css')).kb).toBeLessThan(2.5);
expect((await testBundleSize('@cds/core/styles/module.typography.min.css')).kb).toBeLessThan(1.6);
Expand Down

0 comments on commit b29a19b

Please sign in to comment.