diff --git a/README.md b/README.md index 6a5398b9a..b3f5faf06 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ Project-specific are defined in their `project.json`, and can be run with `make - `make @guardian/source-foundations:build` - `make @guardian/source-foundations:build-storybook` +- `make @guardian/source-foundations:build-type-presets` - `make @guardian/source-foundations:dev` - `make @guardian/source-foundations:fix` - `make @guardian/source-foundations:lint` diff --git a/libs/@guardian/design-tokens/src/tokens.json b/libs/@guardian/design-tokens/src/tokens.json index c1bcf1e2d..bc78e11dc 100644 --- a/libs/@guardian/design-tokens/src/tokens.json +++ b/libs/@guardian/design-tokens/src/tokens.json @@ -1372,7 +1372,7 @@ "textSans14": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.14}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1381,7 +1381,7 @@ "textSans15": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.15}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1390,7 +1390,7 @@ "textSans17": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.17}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1399,7 +1399,7 @@ "textSans20": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.20}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1408,7 +1408,7 @@ "textSans24": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.24}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1417,7 +1417,7 @@ "textSans28": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.28}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1426,7 +1426,7 @@ "textSans34": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.34}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "normal" @@ -1444,7 +1444,7 @@ "textSansBold14": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.14}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1453,7 +1453,7 @@ "textSansBold15": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.15}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1462,7 +1462,7 @@ "textSansBold17": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.17}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1471,7 +1471,7 @@ "textSansBold20": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.20}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1480,7 +1480,7 @@ "textSansBold24": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.24}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1489,7 +1489,7 @@ "textSansBold28": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.28}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1498,7 +1498,7 @@ "textSansBold34": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.34}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.bold}", "fontStyle": "normal" @@ -1516,7 +1516,7 @@ "textSansItalic14": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.14}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "Italic" @@ -1525,7 +1525,7 @@ "textSansItalic15": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.15}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" @@ -1534,7 +1534,7 @@ "textSansItalic17": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.17}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" @@ -1543,7 +1543,7 @@ "textSansItalic20": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.20}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" @@ -1552,7 +1552,7 @@ "textSansItalic24": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.24}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" @@ -1561,7 +1561,7 @@ "textSansItalic28": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.28}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" @@ -1570,7 +1570,7 @@ "textSansItalic34": { "$value": { "fontFamily": "{typography.fontFamily.textSans}", - "fontSize": "{typography.fontSize.12}", + "fontSize": "{typography.fontSize.34}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", "fontStyle": "italic" diff --git a/libs/@guardian/design-tokens/tokens.d.ts b/libs/@guardian/design-tokens/tokens.d.ts index ca50c4813..c1a8c2b89 100644 --- a/libs/@guardian/design-tokens/tokens.d.ts +++ b/libs/@guardian/design-tokens/tokens.d.ts @@ -1201,7 +1201,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '14px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1216,7 +1216,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '15px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1231,7 +1231,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '17px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1246,7 +1246,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '20px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1261,7 +1261,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '24px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1276,7 +1276,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '28px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1291,7 +1291,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '34px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'normal'; @@ -1321,7 +1321,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '14px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1336,7 +1336,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '15px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1351,7 +1351,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '17px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1366,7 +1366,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '20px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1381,7 +1381,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '24px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1396,7 +1396,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '28px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1411,7 +1411,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '34px'; readonly lineHeight: 1.3; readonly fontWeight: 700; readonly fontStyle: 'normal'; @@ -1441,7 +1441,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '14px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'Italic'; @@ -1456,7 +1456,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '15px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; @@ -1471,7 +1471,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '17px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; @@ -1486,7 +1486,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '20px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; @@ -1501,7 +1501,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '24px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; @@ -1516,7 +1516,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '28px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; @@ -1531,7 +1531,7 @@ export declare const tokens: { 'Lucida Grande', 'sans-serif', ]; - readonly fontSize: '12px'; + readonly fontSize: '34px'; readonly lineHeight: 1.3; readonly fontWeight: 400; readonly fontStyle: 'italic'; diff --git a/libs/@guardian/design-tokens/tokens.js b/libs/@guardian/design-tokens/tokens.js index 4f5dcff51..0d4777411 100644 --- a/libs/@guardian/design-tokens/tokens.js +++ b/libs/@guardian/design-tokens/tokens.js @@ -1197,7 +1197,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '14px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1212,7 +1212,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '15px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1227,7 +1227,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '17px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1242,7 +1242,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '20px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1257,7 +1257,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '24px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1272,7 +1272,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '28px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1287,7 +1287,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '34px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'normal', @@ -1317,7 +1317,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '14px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1332,7 +1332,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '15px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1347,7 +1347,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '17px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1362,7 +1362,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '20px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1377,7 +1377,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '24px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1392,7 +1392,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '28px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1407,7 +1407,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '34px', lineHeight: 1.3, fontWeight: 700, fontStyle: 'normal', @@ -1437,7 +1437,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '14px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'Italic', @@ -1452,7 +1452,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '15px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', @@ -1467,7 +1467,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '17px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', @@ -1482,7 +1482,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '20px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', @@ -1497,7 +1497,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '24px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', @@ -1512,7 +1512,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '28px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', @@ -1527,7 +1527,7 @@ export const tokens = { 'Lucida Grande', 'sans-serif', ], - fontSize: '12px', + fontSize: '34px', lineHeight: 1.3, fontWeight: 400, fontStyle: 'italic', diff --git a/libs/@guardian/design-tokens/variables.css b/libs/@guardian/design-tokens/variables.css index 7d722f9cd..29cf43670 100644 --- a/libs/@guardian/design-tokens/variables.css +++ b/libs/@guardian/design-tokens/variables.css @@ -1200,7 +1200,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans14-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-14 ); --source-typography-presets-textSans14-font-style: normal; --source-typography-presets-textSans14-font-weight: var( @@ -1213,7 +1213,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans15-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-15 ); --source-typography-presets-textSans15-font-style: normal; --source-typography-presets-textSans15-font-weight: var( @@ -1226,7 +1226,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans17-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-17 ); --source-typography-presets-textSans17-font-style: normal; --source-typography-presets-textSans17-font-weight: var( @@ -1239,7 +1239,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans20-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-20 ); --source-typography-presets-textSans20-font-style: normal; --source-typography-presets-textSans20-font-weight: var( @@ -1252,7 +1252,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans24-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-24 ); --source-typography-presets-textSans24-font-style: normal; --source-typography-presets-textSans24-font-weight: var( @@ -1265,7 +1265,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans28-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-28 ); --source-typography-presets-textSans28-font-style: normal; --source-typography-presets-textSans28-font-weight: var( @@ -1278,7 +1278,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSans34-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-34 ); --source-typography-presets-textSans34-font-style: normal; --source-typography-presets-textSans34-font-weight: var( @@ -1304,7 +1304,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold14-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-14 ); --source-typography-presets-textSansBold14-font-style: normal; --source-typography-presets-textSansBold14-font-weight: var( @@ -1317,7 +1317,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold15-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-15 ); --source-typography-presets-textSansBold15-font-style: normal; --source-typography-presets-textSansBold15-font-weight: var( @@ -1330,7 +1330,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold17-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-17 ); --source-typography-presets-textSansBold17-font-style: normal; --source-typography-presets-textSansBold17-font-weight: var( @@ -1343,7 +1343,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold20-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-20 ); --source-typography-presets-textSansBold20-font-style: normal; --source-typography-presets-textSansBold20-font-weight: var( @@ -1356,7 +1356,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold24-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-24 ); --source-typography-presets-textSansBold24-font-style: normal; --source-typography-presets-textSansBold24-font-weight: var( @@ -1369,7 +1369,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold28-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-28 ); --source-typography-presets-textSansBold28-font-style: normal; --source-typography-presets-textSansBold28-font-weight: var( @@ -1382,7 +1382,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansBold34-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-34 ); --source-typography-presets-textSansBold34-font-style: normal; --source-typography-presets-textSansBold34-font-weight: var( @@ -1408,7 +1408,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic14-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-14 ); --source-typography-presets-textSansItalic14-font-style: Italic; --source-typography-presets-textSansItalic14-font-weight: var( @@ -1421,7 +1421,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic15-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-15 ); --source-typography-presets-textSansItalic15-font-style: italic; --source-typography-presets-textSansItalic15-font-weight: var( @@ -1434,7 +1434,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic17-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-17 ); --source-typography-presets-textSansItalic17-font-style: italic; --source-typography-presets-textSansItalic17-font-weight: var( @@ -1447,7 +1447,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic20-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-20 ); --source-typography-presets-textSansItalic20-font-style: italic; --source-typography-presets-textSansItalic20-font-weight: var( @@ -1460,7 +1460,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic24-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-24 ); --source-typography-presets-textSansItalic24-font-style: italic; --source-typography-presets-textSansItalic24-font-weight: var( @@ -1473,7 +1473,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic28-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-28 ); --source-typography-presets-textSansItalic28-font-style: italic; --source-typography-presets-textSansItalic28-font-weight: var( @@ -1486,7 +1486,7 @@ --source-typography-fontFamily-textSans ); --source-typography-presets-textSansItalic34-font-size: var( - --source-typography-fontSize-12 + --source-typography-fontSize-34 ); --source-typography-presets-textSansItalic34-font-style: italic; --source-typography-presets-textSansItalic34-font-weight: var( diff --git a/libs/@guardian/source-foundations/package.json b/libs/@guardian/source-foundations/package.json index 832a63d9a..45def1a30 100644 --- a/libs/@guardian/source-foundations/package.json +++ b/libs/@guardian/source-foundations/package.json @@ -13,6 +13,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "tslib": "2.6.2", + "tsx": "^4.7.1", "typescript": "5.3.3" }, "peerDependencies": { diff --git a/libs/@guardian/source-foundations/project.json b/libs/@guardian/source-foundations/project.json index 193c662f1..bd9487332 100644 --- a/libs/@guardian/source-foundations/project.json +++ b/libs/@guardian/source-foundations/project.json @@ -5,6 +5,7 @@ "projectType": "library", "targets": { "build": { + "dependsOn": ["build-type-presets"], "executor": "@csnx/npm-package:build", "outputs": ["{options.outputPath}"], "options": { @@ -72,6 +73,14 @@ "cwd": "libs/@guardian/source-foundations", "color": true } + }, + "build-type-presets": { + "executor": "nx:run-commands", + "options": { + "command": "tsx ./scripts/build-type-presets.ts", + "cwd": "libs/@guardian/source-foundations", + "color": true + } } }, "tags": [] diff --git a/libs/@guardian/source-foundations/scripts/build-type-presets.ts b/libs/@guardian/source-foundations/scripts/build-type-presets.ts new file mode 100644 index 000000000..290ade40f --- /dev/null +++ b/libs/@guardian/source-foundations/scripts/build-type-presets.ts @@ -0,0 +1,36 @@ +import fs from 'node:fs'; +import { tokens } from '@guardian/design-tokens'; +import { fontArrayToString, pxStringToRem } from '../src/utils/convert-value'; + +console.log('Building typography presets…'); + +const STRIP_WHITESPACE = /^\s+/gm; +const STRIP_TABS = /^\t{3}|\t{2}/gm; + +const { presets } = tokens.typography; +const presetTotal = Object.keys(presets).length; +const outputPath = `${process.cwd()}/src/typography/presets.ts`; + +const banner = ` + // Typography presets + // Auto-generated by scripts/build-type-presets.ts + // DO NOT EDIT +`.replace(STRIP_WHITESPACE, ''); + +const css = Object.entries(presets) + .map( + ([preset, properties]) => ` + export const ${preset} = \` + font-family: ${fontArrayToString(properties.fontFamily)}; + font-size: ${pxStringToRem(properties.fontSize)}rem; + line-height: ${properties.lineHeight}; + font-weight: ${properties.fontWeight}; + font-style: ${properties.fontStyle}; + \`; + `, + ) + .join('') + .replace(STRIP_TABS, ''); + +fs.writeFileSync(outputPath, banner + css); +console.log(`✓ ${presetTotal} presets built`); diff --git a/libs/@guardian/source-foundations/src/index.test.ts b/libs/@guardian/source-foundations/src/index.test.ts index 61bad2f44..a165ff9b5 100644 --- a/libs/@guardian/source-foundations/src/index.test.ts +++ b/libs/@guardian/source-foundations/src/index.test.ts @@ -27,6 +27,14 @@ it('Should have exactly these exports', () => { expect(Object.keys(pkgExports).sort()).toEqual([ 'FocusStyleManager', 'appearance', + 'article15', + 'article17', + 'articleBold15', + 'articleBold17', + 'articleBoldItalic15', + 'articleBoldItalic17', + 'articleItalic15', + 'articleItalic17', 'background', 'between', 'body', @@ -55,10 +63,60 @@ it('Should have exactly these exports', () => { 'from', 'generateSourceId', 'headline', + 'headlineBold14', + 'headlineBold17', + 'headlineBold20', + 'headlineBold24', + 'headlineBold28', + 'headlineBold34', + 'headlineBold42', + 'headlineBold50', + 'headlineBold70', + 'headlineLight14', + 'headlineLight17', + 'headlineLight20', + 'headlineLight24', + 'headlineLight28', + 'headlineLight34', + 'headlineLight42', + 'headlineLight50', + 'headlineLight70', + 'headlineLightItalic14', + 'headlineLightItalic17', + 'headlineLightItalic20', + 'headlineLightItalic24', + 'headlineLightItalic28', + 'headlineLightItalic34', + 'headlineLightItalic42', + 'headlineLightItalic50', + 'headlineLightItalic70', + 'headlineMedium14', + 'headlineMedium17', + 'headlineMedium20', + 'headlineMedium24', + 'headlineMedium28', + 'headlineMedium34', + 'headlineMedium42', + 'headlineMedium50', + 'headlineMedium70', + 'headlineMediumItalic14', + 'headlineMediumItalic17', + 'headlineMediumItalic20', + 'headlineMediumItalic24', + 'headlineMediumItalic28', + 'headlineMediumItalic34', + 'headlineMediumItalic42', + 'headlineMediumItalic50', + 'headlineMediumItalic70', 'headlineObjectStyles', 'headlineSizes', 'height', 'iconSize', + 'kicker14', + 'kicker17', + 'kicker20', + 'kicker24', + 'kicker34', 'labs', 'lifestyle', 'line', @@ -84,10 +142,49 @@ it('Should have exactly these exports', () => { 'success', 'svgBackgroundImage', 'text', + 'textEgyptian14', + 'textEgyptian15', + 'textEgyptian17', + 'textEgyptianBold14', + 'textEgyptianBold15', + 'textEgyptianBold17', + 'textEgyptianBoldItalic14', + 'textEgyptianBoldItalic15', + 'textEgyptianBoldItalic17', + 'textEgyptianItalic14', + 'textEgyptianItalic15', + 'textEgyptianItalic17', 'textSans', + 'textSans12', + 'textSans14', + 'textSans15', + 'textSans17', + 'textSans20', + 'textSans24', + 'textSans28', + 'textSans34', + 'textSansBold12', + 'textSansBold14', + 'textSansBold15', + 'textSansBold17', + 'textSansBold20', + 'textSansBold24', + 'textSansBold28', + 'textSansBold34', + 'textSansItalic12', + 'textSansItalic14', + 'textSansItalic15', + 'textSansItalic17', + 'textSansItalic20', + 'textSansItalic24', + 'textSansItalic28', + 'textSansItalic34', 'textSansObjectStyles', 'textSansSizes', 'titlepiece', + 'titlepiece42', + 'titlepiece50', + 'titlepiece70', 'titlepieceObjectStyles', 'titlepieceSizes', 'transitions', diff --git a/libs/@guardian/source-foundations/src/index.ts b/libs/@guardian/source-foundations/src/index.ts index aac8c94cb..492522ebd 100644 --- a/libs/@guardian/source-foundations/src/index.ts +++ b/libs/@guardian/source-foundations/src/index.ts @@ -72,6 +72,7 @@ export { export { space, remSpace } from './space/space'; // typography +export * from './typography/presets'; export { titlepiece, headline, diff --git a/libs/@guardian/source-foundations/src/tokens.test.ts b/libs/@guardian/source-foundations/src/tokens.test.ts index b19b58f53..f7f4a5cd0 100644 --- a/libs/@guardian/source-foundations/src/tokens.test.ts +++ b/libs/@guardian/source-foundations/src/tokens.test.ts @@ -43,6 +43,7 @@ import { titlepieceSizes, underlineThickness, } from './typography/data'; +import * as presets from './typography/presets'; import { bodyObjectStyles, headlineObjectStyles, @@ -903,6 +904,981 @@ describe('Typography API object style output', () => { }); }); +describe('Typography preset CSS output', () => { + it('should match expected output', () => { + expect(presets.article15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.article17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.articleBold15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.articleBold17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.articleBoldItalic15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.articleBoldItalic17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.articleItalic15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.articleItalic17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineBold14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold28).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold42).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold50).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineBold70).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight28).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight42).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight50).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLight70).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic28).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic42).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic50).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineLightItalic70).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium28).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium42).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium50).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMedium70).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic28).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic42).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic50).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.headlineMediumItalic70).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.kicker14).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.kicker17).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.kicker20).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.kicker24).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.kicker34).toMatchCSS( + ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptian14).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptian15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptian17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBold14).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBold15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBold17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBoldItalic14).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBoldItalic15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianBoldItalic17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianItalic14).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianItalic15).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textEgyptianItalic17).toMatchCSS( + ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSans12).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans14).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans15).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans17).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans20).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans24).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans28).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSans34).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold12).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold14).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold15).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold17).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold20).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold24).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold28).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansBold34).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic12).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic14).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: Italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic15).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic17).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic20).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic24).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic28).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.textSansItalic34).toMatchCSS( + ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; + `, + { isFragment: true }, + ); + expect(presets.titlepiece42).toMatchCSS( + ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.titlepiece50).toMatchCSS( + ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + expect(presets.titlepiece70).toMatchCSS( + ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; + `, + { isFragment: true }, + ); + }); +}); + /** * Deprecated tokens */ diff --git a/libs/@guardian/source-foundations/src/typography/presets.ts b/libs/@guardian/source-foundations/src/typography/presets.ts new file mode 100644 index 000000000..8e16f321f --- /dev/null +++ b/libs/@guardian/source-foundations/src/typography/presets.ts @@ -0,0 +1,779 @@ +// Typography presets +// Auto-generated by scripts/build-type-presets.ts +// DO NOT EDIT + +export const article15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 400; + font-style: normal; +`; + +export const article17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 400; + font-style: normal; +`; + +export const articleBold15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 700; + font-style: normal; +`; + +export const articleBold17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 700; + font-style: normal; +`; + +export const articleBoldItalic15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 700; + font-style: italic; +`; + +export const articleBoldItalic17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 700; + font-style: italic; +`; + +export const articleItalic15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.4; + font-weight: 400; + font-style: italic; +`; + +export const articleItalic17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.4; + font-weight: 400; + font-style: italic; +`; + +export const headlineBold14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold28 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold42 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold50 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineBold70 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const headlineLight14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight28 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight42 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight50 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLight70 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 300; + font-style: normal; +`; + +export const headlineLightItalic14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic28 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic42 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic50 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineLightItalic70 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 300; + font-style: italic; +`; + +export const headlineMedium14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium28 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium42 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium50 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMedium70 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 500; + font-style: normal; +`; + +export const headlineMediumItalic14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic28 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.75rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic42 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic50 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 500; + font-style: italic; +`; + +export const headlineMediumItalic70 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: italic; +`; + +export const kicker14 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const kicker17 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const kicker20 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.25rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const kicker24 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 1.5rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const kicker34 = ` + font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; + font-size: 2.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const textEgyptian14 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textEgyptian15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textEgyptian17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textEgyptianBold14 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textEgyptianBold15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textEgyptianBold17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textEgyptianBoldItalic14 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; +`; + +export const textEgyptianBoldItalic15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; +`; + +export const textEgyptianBoldItalic17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: italic; +`; + +export const textEgyptianItalic14 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textEgyptianItalic15 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textEgyptianItalic17 = ` + font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSans12 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans14 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans15 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans17 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans20 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans24 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans28 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSans34 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 400; + font-style: normal; +`; + +export const textSansBold12 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold14 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold15 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold17 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold20 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold24 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold28 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansBold34 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 700; + font-style: normal; +`; + +export const textSansItalic12 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.75rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic14 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.875rem; + line-height: 1.3; + font-weight: 400; + font-style: Italic; +`; + +export const textSansItalic15 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 0.9375rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic17 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.0625rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic20 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.25rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic24 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.5rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic28 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 1.75rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const textSansItalic34 = ` + font-family: GuardianTextSans, "Guardian Text Sans Web", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 2.125rem; + line-height: 1.3; + font-weight: 400; + font-style: italic; +`; + +export const titlepiece42 = ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 2.625rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const titlepiece50 = ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 3.125rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; + +export const titlepiece70 = ` + font-family: "GT Guardian Titlepiece", Georgia, serif; + font-size: 4.375rem; + line-height: 1.15; + font-weight: 700; + font-style: normal; +`; diff --git a/libs/@guardian/source-foundations/src/typography/storybookTypographyPresets.tsx b/libs/@guardian/source-foundations/src/typography/storybookTypographyPresets.tsx new file mode 100644 index 000000000..bc6b341b3 --- /dev/null +++ b/libs/@guardian/source-foundations/src/typography/storybookTypographyPresets.tsx @@ -0,0 +1,82 @@ +import { tokens } from '@guardian/design-tokens'; +import { css } from '@emotion/react'; +import * as presets from './presets'; +import { space } from '../space/space'; +import { palette } from '../colour/palette'; + +const presetTokens = tokens.typography.presets; +type Preset = keyof typeof presetTokens; + +const listCss = css` + list-style: none; + padding: 0; + li + li { + margin-top: ${space[4]}px; + padding-top: ${space[4]}px; + border-top: 1px solid ${palette.neutral[86]}; + } +`; + +const presetNameCss = css` + display: block; + font-weight: 700; +`; + +const specimenCss = css` + display: flex; + gap: ${space[8]}px; +`; + +const propertiesCss = css` + display: flex; + gap: ${space[4]}px; + dt { + ${presets.textSans12} + color: ${palette.neutral[38]}; + margin: 0; + padding: 0; + } + dd { + ${presets.textSans14} + margin: 0; + padding: 0; + } +`; + +export const TypographyPresets = () => ( + +); diff --git a/libs/@guardian/source-foundations/src/typography/typography.stories.mdx b/libs/@guardian/source-foundations/src/typography/typography.stories.mdx index a4d1843bd..584f21aec 100644 --- a/libs/@guardian/source-foundations/src/typography/typography.stories.mdx +++ b/libs/@guardian/source-foundations/src/typography/typography.stories.mdx @@ -1,16 +1,5 @@ import { Meta, Canvas, Story } from '@storybook/addon-docs'; -import { - headlineObjectStyles, - bodyObjectStyles, - textSansObjectStyles, - titlepieceObjectStyles, -} from '@guardian/source-foundations'; -import { - FontStylesRenderer, - LineHeightRenderer, - FontWeightRenderer, - ItalicsRenderer, -} from './storybookTypographyRenderers'; +import { TypographyPresets } from './storybookTypographyPresets'; - - - - +The Guardian has four bespoke typefaces, which were created for different +purposes. When used effectively, they create contrast and alter the tone in +which text is read. -#### Line height +### Where do we use web typography presets? -The default for headline is `tight`. This maps to `1.15 (115%)`. +Any content in a web browser or a webview in the app uses web typography +presets. - - - - - +- _Browser_ — All [theguardian.com](https://www.theguardian.com) content + (front and article pages) and supporter revenue pages. +- _App webview_ — Article pages, sign-in and registration pages -### Body +#### Guardian Headline -```css -font-family: 'GuardianTextEgyptian, Guardian Text Egyptian Web, Georgia, serif'; -``` +Use for headlines, headings and any short form text like pull quotes, bylines +and titles. - - - - - +#### Kicker — Guardian Headline -#### Line height +Use for a kicker in the fronts card. -The default for body is `loose`. This maps to `1.40 (140%)`. +#### Guardian Text Sans -This meets the [WCAG 2.1 AAA success criterion for visual presentation](https://www.w3.org/TR/WCAG21/#visual-presentation). +Use for interactive page elements like buttons and text input fields and for +meta information like datelines, image captions and data visualisations. - - - - - +_Note:_ Text Sans is used across the board on paid content templates to help +differentiate from editorial content. -### Text sans - -```css -font-family: 'GuardianTextSans, Guardian Text Sans Web, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif'; -``` - - - - - - - -#### Line height - -The default for text-sans is `regular`. This maps to `1.3 (130%)`. - - - - - - - -### Titlepiece - -```css -font-family: 'GT Guardian Titlepiece, Georgia, serif'; -``` - - - - - - - -#### Line height - -The default for titlepiece is `tight`. This maps to `1.15 (115%)`. - - - - - - - -### Options - -Each method may receive an `options` object. Missing options are merged with sensible defaults for each font family. - -#### Line height - -The available options for line height are documented in the table below. - - - - - - - - - - - - - - - - - - -
Alias in SourceLine height
loose140% (1.4)
regular130% (1.30)
tight115% (1.15)
- -We calculate the final line height based on the font size using the following formula: - -```ts -// line-height is defined as a unitless value, so we multiply -// by the element's font-size in px to get the px value -const finalLineHeight = `${lineHeight * fontSizeInPx}px`; -``` +#### Guardian Titlepiece -And a worked example: - -```ts -const lineHeight = - 1.15 * // line-height: tight (unitless) - 30; // font-size: small (px) - -// lineHeight === 34.5px -``` - -#### Font weight - -```tsx -headline.medium({ fontWeight: 'bold' }); -``` - - - - - - - -The default for body and textSans is `regular`. The `light` and `medium` font weights are not available for these fonts. - -The default for headline is `medium`. The `regular` font-weight is not available for this font. - -The default and only font-weight for titlepiece is `bold`. - -#### Font style - -```tsx -headline.medium({ fontStyle: 'italic' }); -``` - -`normal` (default) is available for all fonts. - -`italic` is available for the following fonts: - - - - - - - -#### Unit - -```tsx -headline.medium({ unit: 'px' }); -``` +Use for impact. Ideal for marketing messages, page headers and numerals. Use +sparingly and at large sizes only. -Specifies units for the font-size and line-height values. +_Note:_ this font is not available on [theguardian.com](https://theguardian.com) -By default, font-size is expressed in `rem`, and line-height is expressed as a [unitless value](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#values). +### Specimen -You can override this behaviour by setting the `unit` option to `px`. As a result, both font-size and line-height will be expressed in `px` values. + + + diff --git a/libs/@guardian/source-foundations/src/typography/typographyDeprecated.stories.mdx b/libs/@guardian/source-foundations/src/typography/typographyDeprecated.stories.mdx new file mode 100644 index 000000000..e22303855 --- /dev/null +++ b/libs/@guardian/source-foundations/src/typography/typographyDeprecated.stories.mdx @@ -0,0 +1,255 @@ +import { Meta, Canvas, Story } from '@storybook/addon-docs'; +import { + headlineObjectStyles, + bodyObjectStyles, + textSansObjectStyles, + titlepieceObjectStyles, +} from '@guardian/source-foundations'; +import { + FontStylesRenderer, + LineHeightRenderer, + FontWeightRenderer, + ItalicsRenderer, +} from './storybookTypographyRenderers'; + + + +# Typography API (deprecated) + +_Note:_ the typography API is deprecated and will be removed in a future +release. Please use the typography presets in all new code. + +Typographic choices affect how textual content is interpreted; influencing tone, +hierarchy and legibility. + +## Example + +```tsx +import { headline, body, textSans } from '@guardian/source-foundations'; + +const h1 = css` + ${headline.large()}; +`; + +const p = css` + ${body.medium()}; +`; + +const copyright = css` + ${textSans.xsmall()}; +`; +``` + +You can also use the [object style syntax](https://emotion.sh/docs/object-styles): + +```tsx +import { headlineObjectStyles } from '@guardian/source-foundations'; + +const h1 = { + ...headlineObjectStyles.large(), +}; +``` + +## Where can I find The Guardian's fonts? + +The canonical source of fonts is https://github.com/guardian/fonts + +They should be loaded from the locations specified in [font-faces.css](https://github.com/guardian/fonts/blob/main/fonts/web/font-faces.css). This optimises for consistency and performance across The Guardian's digital products. + +## API + +Each font family has an associated import, exposing methods that return snippets +of CSS depending on the desired font size. + +A range of font sizes are available for each font family. The `medium` font size +should be considered the default. + +Pixel values are given below for ease of understanding. By default the +typography API assigns font size in rems. + +### Headline + +```css +font-family: 'GH Guardian Headline, Guardian Egyptian Web, Georgia, serif'; +``` + + + + + + + +#### Line height + +The default for headline is `tight`. This maps to `1.15 (115%)`. + + + + + + + +### Body + +```css +font-family: 'GuardianTextEgyptian, Guardian Text Egyptian Web, Georgia, serif'; +``` + + + + + + + +#### Line height + +The default for body is `loose`. This maps to `1.40 (140%)`. + +This meets the [WCAG 2.1 AAA success criterion for visual presentation](https://www.w3.org/TR/WCAG21/#visual-presentation). + + + + + + + +### Text sans + +```css +font-family: 'GuardianTextSans, Guardian Text Sans Web, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif'; +``` + + + + + + + +#### Line height + +The default for text-sans is `regular`. This maps to `1.3 (130%)`. + + + + + + + +### Titlepiece + +```css +font-family: 'GT Guardian Titlepiece, Georgia, serif'; +``` + + + + + + + +#### Line height + +The default for titlepiece is `tight`. This maps to `1.15 (115%)`. + + + + + + + +### Options + +Each method may receive an `options` object. Missing options are merged with sensible defaults for each font family. + +#### Line height + +The available options for line height are documented in the table below. + + + + + + + + + + + + + + + + + + +
Alias in SourceLine height
loose140% (1.4)
regular130% (1.30)
tight115% (1.15)
+ +We calculate the final line height based on the font size using the following formula: + +```ts +// line-height is defined as a unitless value, so we multiply +// by the element's font-size in px to get the px value +const finalLineHeight = `${lineHeight * fontSizeInPx}px`; +``` + +And a worked example: + +```ts +const lineHeight = + 1.15 * // line-height: tight (unitless) + 30; // font-size: small (px) + +// lineHeight === 34.5px +``` + +#### Font weight + +```tsx +headline.medium({ fontWeight: 'bold' }); +``` + + + + + + + +The default for body and textSans is `regular`. The `light` and `medium` font weights are not available for these fonts. + +The default for headline is `medium`. The `regular` font-weight is not available for this font. + +The default and only font-weight for titlepiece is `bold`. + +#### Font style + +```tsx +headline.medium({ fontStyle: 'italic' }); +``` + +`normal` (default) is available for all fonts. + +`italic` is available for the following fonts: + + + + + + + +#### Unit + +```tsx +headline.medium({ unit: 'px' }); +``` + +Specifies units for the font-size and line-height values. + +By default, font-size is expressed in `rem`, and line-height is expressed as a [unitless value](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#values). + +You can override this behaviour by setting the `unit` option to `px`. As a result, both font-size and line-height will be expressed in `px` values. diff --git a/libs/@guardian/source-foundations/src/utils/convert-value.test.ts b/libs/@guardian/source-foundations/src/utils/convert-value.test.ts index 099699487..b5c59ce0b 100644 --- a/libs/@guardian/source-foundations/src/utils/convert-value.test.ts +++ b/libs/@guardian/source-foundations/src/utils/convert-value.test.ts @@ -1,15 +1,15 @@ import { fontArrayToString, pxStringToNumber, + pxStringToRem, pxToRem, - rootPixelFontSize, } from './convert-value'; describe('pxToRem', () => { it('should calculate a rem equivalent of a pixel value', () => { const value = 17; const result = pxToRem(value); - expect(result).toBe(value / rootPixelFontSize); + expect(result).toBe(1.0625); }); }); @@ -22,6 +22,15 @@ describe('pxStringToNumber', () => { }); }); +describe('pxStringToRem', () => { + it('should convert a value with a px unit to rem equivalent', () => { + const value = '20px'; + const result = pxStringToRem(value); + expect(result).toBe(1.25); + expect(typeof result).toBe('number'); + }); +}); + describe('fontArrayToString', () => { it('should convert an array of font names to a valid `font-family` value', () => { const value = ['GuardianTextEgyptian', 'Georgia', 'serif']; diff --git a/libs/@guardian/source-foundations/src/utils/convert-value.ts b/libs/@guardian/source-foundations/src/utils/convert-value.ts index c836fc87a..f581a503f 100644 --- a/libs/@guardian/source-foundations/src/utils/convert-value.ts +++ b/libs/@guardian/source-foundations/src/utils/convert-value.ts @@ -1,5 +1,7 @@ export const rootPixelFontSize = 16; export const pxToRem = (px: number): number => px / rootPixelFontSize; export const pxStringToNumber = (px: string): number => Number(px.slice(0, -2)); +export const pxStringToRem = (px: string): number => + pxToRem(pxStringToNumber(px)); export const fontArrayToString = (fonts: readonly string[]): string => fonts.map((name) => (name.includes(' ') ? `"${name}"` : name)).join(', '); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a21eb180a..481b7331b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -608,6 +608,9 @@ importers: tslib: specifier: 2.6.2 version: 2.6.2 + tsx: + specifier: ^4.7.1 + version: 4.7.1 typescript: specifier: 5.3.3 version: 5.3.3 @@ -17342,6 +17345,17 @@ packages: typescript: 5.3.3 dev: true + /tsx@4.7.1: + resolution: {integrity: sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g==} + engines: {node: '>=18.0.0'} + hasBin: true + dependencies: + esbuild: 0.19.12 + get-tsconfig: 4.7.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /tty-table@4.1.6: resolution: {integrity: sha512-kRj5CBzOrakV4VRRY5kUWbNYvo/FpOsz65DzI5op9P+cHov3+IqPbo1JE1ZnQGkHdZgNFDsrEjrfqqy/Ply9fw==} engines: {node: '>=8.0.0'}