Skip to content

Commit a350314

Browse files
authored
fix(font-family): fallback coming from tokens was badly formatted (#30703)
## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> - The variables when being generated from the tokens were causing the fallback to `$ion-font-family` to be with invalid format: ``` $ion-font-family: var( --token-font-family, "-apple-system, system-ui, " Segoe UI ", Roboto, Helvetica, Arial, sans-serif, " Apple Color Emoji ", " Segoe UI Emoji", " Segoe UI Symbol "", sans-serif ); ``` - Additionally the command to generate the css from the tokens, was not prepared to run on windows machines. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removed the added quotes to the variable coming from the tokens: ``` $ion-font-family: var( --token-font-family, -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" ); ``` - Changed the command `build.tokens` to run on windows - Generated a new version of `ionic.vars.scss` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information N/A <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 42f3447 commit a350314

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"build.css": "npm run css.sass && npm run css.minify",
8181
"build.debug": "npm run clean && stencil build --debug",
8282
"build.docs.json": "stencil build --docs-json dist/docs.json",
83-
"build.tokens": "npx build.tokens --config scripts/tokens/index.mjs && npm run prettier.tokens",
83+
"build.tokens": "node ./node_modules/outsystems-design-tokens/scripts/index.js --config ./scripts/tokens/index.mjs && npm run prettier.tokens",
8484
"clean": "node scripts/clean.js",
8585
"css.minify": "cleancss -O2 -o ./css/ionic.bundle.css ./css/ionic.bundle.css",
8686
"css.sass": "sass --embed-sources --style compressed src/css:./css",

core/scripts/tokens/index.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
// - It also works very well out of the box with any kind of Design Tokens formats, like Figma Tokens, as well as APIs to adjust to more custom ones.
55
// - It is probably the most well-known and widely used Design Tokens tool. It has also been regularly maintained for a long time.
66
// - It can easily scale to different necessities we might have in the future.
7+
import StyleDictionary from 'style-dictionary';
8+
79
import * as utils from './utils.mjs';
10+
811
const {
912
generateShadowValue,
1013
generateFontSizeValue,
@@ -23,7 +26,6 @@ const {
2326
generateShadowUtilityClasses,
2427
generateUtilityClasses
2528
} = utils;
26-
import StyleDictionary from 'style-dictionary';
2729

2830
const customHeader = `// Do not edit directly, this file was auto-generated.`;
2931
// Set the prefix for classes

core/scripts/tokens/utils.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export function generateFontFamilyValue(prop, propName, variableType = 'css') {
9393
const _propName = propName.split('-').slice(0, -1).join('-');
9494

9595
return variableType === 'scss'
96-
? `$${classAndScssPrefix}-${_propName}: var(--${variablesPrefix}-${_propName}, "${prop.$value}", sans-serif);`
97-
: `--${variablesPrefix}-${_propName}: "${prop.$value}", sans-serif;`;
96+
? `$${classAndScssPrefix}-${_propName}: var(--${variablesPrefix}-${_propName}, ${prop.$value});`
97+
: `--${variablesPrefix}-${_propName}: ${prop.$value};`;
9898
}
9999

100100
// Generates a final value, based if the Design Token is of type color or not

core/src/foundations/ionic.vars.scss

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,16 @@ $ion-transition-time-1000: var(--token-transition-time-1000, 1000ms);
875875
$ion-transition-time-1500: var(--token-transition-time-1500, 1500ms);
876876
$ion-font-family: var(
877877
--token-font-family,
878-
"-apple-system, system-ui, " Segoe UI ", Roboto, Helvetica, Arial, sans-serif, " Apple Color Emoji ", " Segoe UI Emoji
879-
", " Segoe UI Symbol "",
880-
sans-serif
878+
-apple-system,
879+
system-ui,
880+
"Segoe UI",
881+
Roboto,
882+
Helvetica,
883+
Arial,
884+
sans-serif,
885+
"Apple Color Emoji",
886+
"Segoe UI Emoji",
887+
"Segoe UI Symbol"
881888
);
882889
$ion-font-weight-thin: var(--token-font-weight-thin, 100);
883890
$ion-font-weight-extra-light: var(--token-font-weight-extra-light, 200);

0 commit comments

Comments
 (0)