diff --git a/libs/@guardian/design-tokens/src/tokens.json b/libs/@guardian/design-tokens/src/tokens.json index 704d2bdb0..f9fedc799 100644 --- a/libs/@guardian/design-tokens/src/tokens.json +++ b/libs/@guardian/design-tokens/src/tokens.json @@ -530,42 +530,6 @@ "$value": 700 } }, - "textDecorationThicknessForFontSize": { - "$type": "dimension", - "12": { - "$value": "2px" - }, - "14": { - "$value": "2px" - }, - "15": { - "$value": "2px" - }, - "17": { - "$value": "2px" - }, - "20": { - "$value": "3px" - }, - "24": { - "$value": "3px" - }, - "28": { - "$value": "3px" - }, - "34": { - "$value": "4px" - }, - "42": { - "$value": "5px" - }, - "50": { - "$value": "6px" - }, - "70": { - "$value": "6px" - } - }, "body": { "$type": "typography", "xSmall": { @@ -1537,7 +1501,7 @@ "fontSize": "{typography.fontSize.14}", "lineHeight": "{typography.lineHeight.regular}", "fontWeight": "{typography.fontWeight.regular}", - "fontStyle": "Italic" + "fontStyle": "italic" } }, "textSansItalic15": { diff --git a/libs/@guardian/design-tokens/tokens.d.ts b/libs/@guardian/design-tokens/tokens.d.ts index 6cc89de9d..b565abe73 100644 --- a/libs/@guardian/design-tokens/tokens.d.ts +++ b/libs/@guardian/design-tokens/tokens.d.ts @@ -1444,7 +1444,7 @@ export declare const tokens: { readonly fontSize: '14px'; readonly lineHeight: 1.3; readonly fontWeight: 400; - readonly fontStyle: 'Italic'; + readonly fontStyle: 'italic'; }; readonly textSansItalic15: { readonly fontFamily: readonly [ @@ -1570,19 +1570,6 @@ export declare const tokens: { readonly fontStyle: 'normal'; }; }; - readonly textDecorationThicknessForFontSize: { - readonly '12': '2px'; - readonly '14': '2px'; - readonly '15': '2px'; - readonly '17': '2px'; - readonly '20': '3px'; - readonly '24': '3px'; - readonly '28': '3px'; - readonly '34': '4px'; - readonly '42': '5px'; - readonly '50': '6px'; - readonly '70': '6px'; - }; readonly textSans: { readonly large: { readonly fontFamily: readonly [ diff --git a/libs/@guardian/design-tokens/tokens.js b/libs/@guardian/design-tokens/tokens.js index 91ae76d49..b791f6f6f 100644 --- a/libs/@guardian/design-tokens/tokens.js +++ b/libs/@guardian/design-tokens/tokens.js @@ -1440,7 +1440,7 @@ export const tokens = { fontSize: '14px', lineHeight: 1.3, fontWeight: 400, - fontStyle: 'Italic', + fontStyle: 'italic', }, textSansItalic15: { fontFamily: [ @@ -1554,19 +1554,6 @@ export const tokens = { fontStyle: 'normal', }, }, - textDecorationThicknessForFontSize: { - 12: '2px', - 14: '2px', - 15: '2px', - 17: '2px', - 20: '3px', - 24: '3px', - 28: '3px', - 34: '4px', - 42: '5px', - 50: '6px', - 70: '6px', - }, textSans: { large: { fontFamily: [ diff --git a/libs/@guardian/design-tokens/variables.css b/libs/@guardian/design-tokens/variables.css index 57492a7c1..c8416e775 100644 --- a/libs/@guardian/design-tokens/variables.css +++ b/libs/@guardian/design-tokens/variables.css @@ -1410,7 +1410,7 @@ --source-typography-presets-textSansItalic14-font-size: var( --source-typography-fontSize-14 ); - --source-typography-presets-textSansItalic14-font-style: Italic; + --source-typography-presets-textSansItalic14-font-style: italic; --source-typography-presets-textSansItalic14-font-weight: var( --source-typography-fontWeight-regular ); @@ -1534,17 +1534,6 @@ --source-typography-presets-titlepiece70-line-height: var( --source-typography-lineHeight-tight ); - --source-typography-textDecorationThicknessForFontSize-12: 0.125rem; - --source-typography-textDecorationThicknessForFontSize-14: 0.125rem; - --source-typography-textDecorationThicknessForFontSize-15: 0.125rem; - --source-typography-textDecorationThicknessForFontSize-17: 0.125rem; - --source-typography-textDecorationThicknessForFontSize-20: 0.1875rem; - --source-typography-textDecorationThicknessForFontSize-24: 0.1875rem; - --source-typography-textDecorationThicknessForFontSize-28: 0.1875rem; - --source-typography-textDecorationThicknessForFontSize-34: 0.25rem; - --source-typography-textDecorationThicknessForFontSize-42: 0.3125rem; - --source-typography-textDecorationThicknessForFontSize-50: 0.375rem; - --source-typography-textDecorationThicknessForFontSize-70: 0.375rem; --source-typography-textSans-large-font-family: var( --source-typography-fontFamily-textSans ); diff --git a/libs/@guardian/source-foundations/scripts/build-type-presets.ts b/libs/@guardian/source-foundations/scripts/build-type-presets.ts index ee39e4b2d..7a660167f 100644 --- a/libs/@guardian/source-foundations/scripts/build-type-presets.ts +++ b/libs/@guardian/source-foundations/scripts/build-type-presets.ts @@ -5,13 +5,7 @@ import { fontArrayToString, pxStringToRem } from '../src/utils/convert-value'; const STRIP_WHITESPACE = /^\s+/gm; const STRIP_TABS = /^\t{3}|\t{2}/gm; -const { presets, fontSize, textDecorationThicknessForFontSize } = - tokens.typography; - -type FontSize = keyof typeof fontSize; - -const textDecorationThickness = (size: string) => - textDecorationThicknessForFontSize[size.slice(0, -2) as FontSize]; +const { presets } = tokens.typography; console.log('Building typography presets…'); @@ -23,19 +17,23 @@ const banner = ` // Typography presets // Auto-generated by scripts/build-type-presets.ts // DO NOT EDIT + `.replace(STRIP_WHITESPACE, ''); +const importStatement = ` +import type { TypographyPreset } from './types'; + +`; // Generate CSS representation of presets as a string const css = Object.entries(presets) .map( ([preset, properties]) => ` - export const ${preset} = \` + export const ${preset}: TypographyPreset = \` font-family: ${fontArrayToString(properties.fontFamily)}; font-size: ${pxStringToRem(properties.fontSize)}rem; line-height: ${properties.lineHeight}; font-weight: ${properties.fontWeight}; font-style: ${properties.fontStyle}; - --source-text-decoration-thickness: ${textDecorationThickness(properties.fontSize)}; \`; `, ) @@ -58,6 +56,6 @@ const object = Object.entries(presets) .join('') .replace(STRIP_TABS, ''); -fs.writeFileSync(cssOutputPath, banner + css); +fs.writeFileSync(cssOutputPath, banner + importStatement + css); fs.writeFileSync(objectOutputPath, banner + object); console.log(`✓ ${presetTotal} presets built`); diff --git a/libs/@guardian/source-foundations/src/index.ts b/libs/@guardian/source-foundations/src/index.ts index 06ea1ed0c..b6e88e8fb 100644 --- a/libs/@guardian/source-foundations/src/index.ts +++ b/libs/@guardian/source-foundations/src/index.ts @@ -107,6 +107,7 @@ export type { FontWeightDefinition, Option, TypographyStyles, + TypographyPreset, TypographySizes, TitlepieceSizes, HeadlineSizes, diff --git a/libs/@guardian/source-foundations/src/tokens.test.ts b/libs/@guardian/source-foundations/src/tokens.test.ts index 1949430ca..430033775 100644 --- a/libs/@guardian/source-foundations/src/tokens.test.ts +++ b/libs/@guardian/source-foundations/src/tokens.test.ts @@ -914,7 +914,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -925,7 +924,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -936,7 +934,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -947,7 +944,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -958,7 +954,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -969,7 +964,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -980,7 +974,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -991,7 +984,6 @@ describe('Typography preset CSS output', () => { line-height: 1.4; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1002,7 +994,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1013,7 +1004,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1024,7 +1014,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1035,7 +1024,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1046,7 +1034,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1057,7 +1044,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1068,7 +1054,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1079,7 +1064,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1090,7 +1074,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1101,7 +1084,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1112,7 +1094,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1123,7 +1104,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1134,7 +1114,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1145,7 +1124,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1156,7 +1134,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1167,7 +1144,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1178,7 +1154,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1189,7 +1164,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1200,7 +1174,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1211,7 +1184,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1222,7 +1194,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1233,7 +1204,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1244,7 +1214,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1255,7 +1224,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1266,7 +1234,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1277,7 +1244,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1288,7 +1254,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1299,7 +1264,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1310,7 +1274,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1321,7 +1284,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1332,7 +1294,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1343,7 +1304,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1354,7 +1314,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1365,7 +1324,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1376,7 +1334,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1387,7 +1344,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1398,7 +1354,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1409,7 +1364,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1420,7 +1374,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1431,7 +1384,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1442,7 +1394,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1453,7 +1404,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1464,7 +1414,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1475,7 +1424,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1486,7 +1434,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1497,7 +1444,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1508,7 +1454,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1519,7 +1464,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1530,7 +1474,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1541,7 +1484,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1552,7 +1494,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1563,7 +1504,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1574,7 +1514,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1585,7 +1524,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1596,7 +1534,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1607,7 +1544,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1618,7 +1554,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1629,7 +1564,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1640,7 +1574,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1651,7 +1584,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1662,7 +1594,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1673,7 +1604,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1684,7 +1614,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1695,7 +1624,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1706,7 +1634,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1717,7 +1644,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1728,7 +1654,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1739,7 +1664,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1750,7 +1674,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1761,7 +1684,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1772,7 +1694,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1783,7 +1704,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1794,7 +1714,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1805,7 +1724,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1816,7 +1734,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1827,7 +1744,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1838,7 +1754,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1849,7 +1764,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1860,7 +1774,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1871,7 +1784,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: Italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1882,7 +1794,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1893,7 +1804,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `, { isFragment: true }, ); @@ -1904,7 +1814,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1915,7 +1824,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1926,7 +1834,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 3px; `, { isFragment: true }, ); @@ -1937,7 +1844,6 @@ describe('Typography preset CSS output', () => { line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 4px; `, { isFragment: true }, ); @@ -1948,7 +1854,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 5px; `, { isFragment: true }, ); @@ -1959,7 +1864,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -1970,7 +1874,6 @@ describe('Typography preset CSS output', () => { line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `, { isFragment: true }, ); @@ -2681,7 +2584,7 @@ describe('Typography preset object output', () => { fontSize: '0.875rem', lineHeight: 1.3, fontWeight: 400, - fontStyle: 'Italic', + fontStyle: 'italic', }); expect(typePresetObject.textSansItalic15Object).toEqual({ fontFamily: diff --git a/libs/@guardian/source-foundations/src/typography/css.ts b/libs/@guardian/source-foundations/src/typography/css.ts index 1a9532a45..ac4cb1077 100644 --- a/libs/@guardian/source-foundations/src/typography/css.ts +++ b/libs/@guardian/source-foundations/src/typography/css.ts @@ -2,875 +2,780 @@ // Auto-generated by scripts/build-type-presets.ts // DO NOT EDIT -export const article15 = ` +import type { TypographyPreset } from './types'; + +export const article15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.4; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const article17 = ` +export const article17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.4; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const articleBold15 = ` +export const articleBold15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.4; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const articleBold17 = ` +export const articleBold17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.4; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const articleBoldItalic15 = ` +export const articleBoldItalic15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.4; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const articleBoldItalic17 = ` +export const articleBoldItalic17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.4; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const articleItalic15 = ` +export const articleItalic15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.4; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const articleItalic17 = ` +export const articleItalic17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.4; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const headlineBold14 = ` +export const headlineBold14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineBold17 = ` +export const headlineBold17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineBold20 = ` +export const headlineBold20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineBold24 = ` +export const headlineBold24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineBold28 = ` +export const headlineBold28: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.75rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineBold34 = ` +export const headlineBold34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 4px; `; -export const headlineBold42 = ` +export const headlineBold42: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 5px; `; -export const headlineBold50 = ` +export const headlineBold50: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineBold70 = ` +export const headlineBold70: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineLight14 = ` +export const headlineLight14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineLight17 = ` +export const headlineLight17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineLight20 = ` +export const headlineLight20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineLight24 = ` +export const headlineLight24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineLight28 = ` +export const headlineLight28: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.75rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineLight34 = ` +export const headlineLight34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 4px; `; -export const headlineLight42 = ` +export const headlineLight42: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 5px; `; -export const headlineLight50 = ` +export const headlineLight50: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineLight70 = ` +export const headlineLight70: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 300; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineLightItalic14 = ` +export const headlineLightItalic14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const headlineLightItalic17 = ` +export const headlineLightItalic17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const headlineLightItalic20 = ` +export const headlineLightItalic20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineLightItalic24 = ` +export const headlineLightItalic24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineLightItalic28 = ` +export const headlineLightItalic28: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.75rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineLightItalic34 = ` +export const headlineLightItalic34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 4px; `; -export const headlineLightItalic42 = ` +export const headlineLightItalic42: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 5px; `; -export const headlineLightItalic50 = ` +export const headlineLightItalic50: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 6px; `; -export const headlineLightItalic70 = ` +export const headlineLightItalic70: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 300; font-style: italic; - --source-text-decoration-thickness: 6px; `; -export const headlineMedium14 = ` +export const headlineMedium14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineMedium17 = ` +export const headlineMedium17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const headlineMedium20 = ` +export const headlineMedium20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineMedium24 = ` +export const headlineMedium24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineMedium28 = ` +export const headlineMedium28: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.75rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const headlineMedium34 = ` +export const headlineMedium34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 4px; `; -export const headlineMedium42 = ` +export const headlineMedium42: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 5px; `; -export const headlineMedium50 = ` +export const headlineMedium50: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineMedium70 = ` +export const headlineMedium70: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 500; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const headlineMediumItalic14 = ` +export const headlineMediumItalic14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const headlineMediumItalic17 = ` +export const headlineMediumItalic17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const headlineMediumItalic20 = ` +export const headlineMediumItalic20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineMediumItalic24 = ` +export const headlineMediumItalic24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineMediumItalic28 = ` +export const headlineMediumItalic28: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.75rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 3px; `; -export const headlineMediumItalic34 = ` +export const headlineMediumItalic34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 4px; `; -export const headlineMediumItalic42 = ` +export const headlineMediumItalic42: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 5px; `; -export const headlineMediumItalic50 = ` +export const headlineMediumItalic50: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 500; font-style: italic; - --source-text-decoration-thickness: 6px; `; -export const headlineMediumItalic70 = ` +export const headlineMediumItalic70: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 6px; `; -export const kicker14 = ` +export const kicker14: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const kicker17 = ` +export const kicker17: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const kicker20 = ` +export const kicker20: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.25rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const kicker24 = ` +export const kicker24: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 1.5rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 3px; `; -export const kicker34 = ` +export const kicker34: TypographyPreset = ` font-family: "GH Guardian Headline", "Guardian Egyptian Web", Georgia, serif; font-size: 2.125rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 4px; `; -export const textEgyptian14 = ` +export const textEgyptian14: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptian15 = ` +export const textEgyptian15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptian17 = ` +export const textEgyptian17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.3; font-weight: 400; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBold14 = ` +export const textEgyptianBold14: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBold15 = ` +export const textEgyptianBold15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBold17 = ` +export const textEgyptianBold17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.3; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBoldItalic14 = ` +export const textEgyptianBoldItalic14: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBoldItalic15 = ` +export const textEgyptianBoldItalic15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianBoldItalic17 = ` +export const textEgyptianBoldItalic17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.3; font-weight: 700; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianItalic14 = ` +export const textEgyptianItalic14: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.875rem; line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianItalic15 = ` +export const textEgyptianItalic15: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 0.9375rem; line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textEgyptianItalic17 = ` +export const textEgyptianItalic17: TypographyPreset = ` font-family: GuardianTextEgyptian, "Guardian Text Egyptian Web", Georgia, serif; font-size: 1.0625rem; line-height: 1.3; font-weight: 400; font-style: italic; - --source-text-decoration-thickness: 2px; `; -export const textSans12 = ` +export const textSans12: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSans14 = ` +export const textSans14: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSans15 = ` +export const textSans15: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSans17 = ` +export const textSans17: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSans20 = ` +export const textSans20: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSans24 = ` +export const textSans24: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSans28 = ` +export const textSans28: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSans34 = ` +export const textSans34: TypographyPreset = ` 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; - --source-text-decoration-thickness: 4px; `; -export const textSansBold12 = ` +export const textSansBold12: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansBold14 = ` +export const textSansBold14: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansBold15 = ` +export const textSansBold15: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansBold17 = ` +export const textSansBold17: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansBold20 = ` +export const textSansBold20: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansBold24 = ` +export const textSansBold24: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansBold28 = ` +export const textSansBold28: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansBold34 = ` +export const textSansBold34: TypographyPreset = ` 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; - --source-text-decoration-thickness: 4px; `; -export const textSansItalic12 = ` +export const textSansItalic12: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansItalic14 = ` +export const textSansItalic14: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; + font-style: italic; `; -export const textSansItalic15 = ` +export const textSansItalic15: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansItalic17 = ` +export const textSansItalic17: TypographyPreset = ` 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; - --source-text-decoration-thickness: 2px; `; -export const textSansItalic20 = ` +export const textSansItalic20: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansItalic24 = ` +export const textSansItalic24: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansItalic28 = ` +export const textSansItalic28: TypographyPreset = ` 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; - --source-text-decoration-thickness: 3px; `; -export const textSansItalic34 = ` +export const textSansItalic34: TypographyPreset = ` 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; - --source-text-decoration-thickness: 4px; `; -export const titlepiece42 = ` +export const titlepiece42: TypographyPreset = ` font-family: "GT Guardian Titlepiece", Georgia, serif; font-size: 2.625rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 5px; `; -export const titlepiece50 = ` +export const titlepiece50: TypographyPreset = ` font-family: "GT Guardian Titlepiece", Georgia, serif; font-size: 3.125rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `; -export const titlepiece70 = ` +export const titlepiece70: TypographyPreset = ` font-family: "GT Guardian Titlepiece", Georgia, serif; font-size: 4.375rem; line-height: 1.15; font-weight: 700; font-style: normal; - --source-text-decoration-thickness: 6px; `; diff --git a/libs/@guardian/source-foundations/src/typography/data.ts b/libs/@guardian/source-foundations/src/typography/data.ts index b2a2d79c6..1d8399be0 100644 --- a/libs/@guardian/source-foundations/src/typography/data.ts +++ b/libs/@guardian/source-foundations/src/typography/data.ts @@ -134,75 +134,33 @@ export const italicsFontWeights = { export const underlineThickness = { textSans: { - xxsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[12], - ), - xsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[14], - ), - small: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[15], - ), - medium: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[17], - ), - large: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[20], - ), - xlarge: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[24], - ), - xxlarge: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[28], - ), - xxxlarge: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[34], - ), + xxsmall: 2, + xsmall: 2, + small: 2, + medium: 2, + large: 3, + xlarge: 3, + xxlarge: 3, + xxxlarge: 4, }, body: { - xsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[14], - ), - small: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[15], - ), - medium: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[17], - ), + xsmall: 2, + small: 2, + medium: 2, }, headline: { - xxxsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[17], - ), - xxsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[20], - ), - xsmall: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[24], - ), - small: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[28], - ), - medium: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[34], - ), - large: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[42], - ), - xlarge: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[50], - ), + xxxsmall: 2, + xxsmall: 3, + xsmall: 3, + small: 3, + medium: 4, + large: 5, + xlarge: 6, }, titlepiece: { - small: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[42], - ), - medium: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[50], - ), - large: pxStringToNumber( - tokens.typography.textDecorationThicknessForFontSize[70], - ), + small: 5, + medium: 6, + large: 6, }, } as const; diff --git a/libs/@guardian/source-foundations/src/typography/objects.ts b/libs/@guardian/source-foundations/src/typography/objects.ts index c1b0f00a1..396e2b781 100644 --- a/libs/@guardian/source-foundations/src/typography/objects.ts +++ b/libs/@guardian/source-foundations/src/typography/objects.ts @@ -741,7 +741,7 @@ export const textSansItalic14Object = { fontSize: '0.875rem', lineHeight: 1.3, fontWeight: 400, - fontStyle: 'Italic', + fontStyle: 'italic', }; export const textSansItalic15Object = { diff --git a/libs/@guardian/source-foundations/src/typography/types.ts b/libs/@guardian/source-foundations/src/typography/types.ts index 70865d6e8..fbe036f06 100644 --- a/libs/@guardian/source-foundations/src/typography/types.ts +++ b/libs/@guardian/source-foundations/src/typography/types.ts @@ -115,3 +115,11 @@ export type Fs = < unit: ScaleUnit; }, ) => TypographyStyles; + +export type TypographyPreset = ` + font-family: ${string}; + font-size: ${number}rem; + line-height: ${number}; + font-weight: ${number}; + font-style: ${'normal' | 'italic'}; +`; diff --git a/libs/@guardian/source-react-components/src/link/@types/SharedLinkProps.ts b/libs/@guardian/source-react-components/src/link/@types/SharedLinkProps.ts index b8ff6e024..01d34dd92 100644 --- a/libs/@guardian/source-react-components/src/link/@types/SharedLinkProps.ts +++ b/libs/@guardian/source-react-components/src/link/@types/SharedLinkProps.ts @@ -1,3 +1,4 @@ +import type { TypographyPreset } from '@guardian/source-foundations'; import type { ReactElement, ReactNode } from 'react'; import type { Props } from '../../@types/Props'; import type { ThemeLink } from '../theme'; @@ -38,4 +39,5 @@ export interface SharedLinkProps extends Props { * */ theme?: Partial; + typography?: TypographyPreset; } diff --git a/libs/@guardian/source-react-components/src/link/ButtonLink.tsx b/libs/@guardian/source-react-components/src/link/ButtonLink.tsx index d07f661a3..97116b6cd 100644 --- a/libs/@guardian/source-react-components/src/link/ButtonLink.tsx +++ b/libs/@guardian/source-react-components/src/link/ButtonLink.tsx @@ -25,6 +25,7 @@ export const ButtonLink = ({ cssOverrides, children, theme, + typography, ...props }: ButtonLinkProps): EmotionJSX.Element => { return ( @@ -36,6 +37,7 @@ export const ButtonLink = ({ iconSide, cssOverrides, theme, + typography, })} {...props} > diff --git a/libs/@guardian/source-react-components/src/link/Link.stories.tsx b/libs/@guardian/source-react-components/src/link/Link.stories.tsx index 6dc11d7c0..f85cd9833 100644 --- a/libs/@guardian/source-react-components/src/link/Link.stories.tsx +++ b/libs/@guardian/source-react-components/src/link/Link.stories.tsx @@ -1,11 +1,52 @@ import { css } from '@emotion/react'; -import { headline, palette, textSans } from '@guardian/source-foundations'; +import { + headlineMedium14, + headlineMedium17, + headlineMedium20, + headlineMedium24, + headlineMedium28, + headlineMedium34, + headlineMedium42, + headlineMedium50, + headlineMedium70, + palette, + textSans12, + textSans14, + textSans15, + textSans17, + textSans20, + textSans24, + textSans28, + textSans34, +} from '@guardian/source-foundations'; import type { Meta, StoryFn } from '@storybook/react'; import { SvgExternal } from '../../vendor/icons/SvgExternal'; import { Link } from './Link'; import type { LinkProps } from './Link'; import { linkThemeBrand, linkThemeBrandAlt } from './theme'; +const textSansPresets = [ + textSans34, + textSans28, + textSans24, + textSans20, + textSans17, + textSans15, + textSans14, + textSans12, +]; + +const headlinePresets = [ + headlineMedium70, + headlineMedium50, + headlineMedium42, + headlineMedium34, + headlineMedium28, + headlineMedium24, + headlineMedium20, + headlineMedium17, + headlineMedium14, +]; const meta: Meta = { title: 'Link', component: Link, @@ -49,19 +90,11 @@ const UnderlineHoverHeadlineTemplate: StoryFn = ( } `} > - {Object.values(headline) - .reverse() - .map((size, i) => ( - - {headlineText} - - ))} + {headlinePresets.map((headlinePreset, i) => ( + + {headlineText} + + ))} ); }; @@ -76,34 +109,25 @@ const UnderlineHoverTextSansTemplate: StoryFn = ( css={css` display: flex; flex-direction: column; - a { padding: 20px 0; } `} > - {Object.values(textSans) - .reverse() - .map((size, i) => ( -
- Some text sans, with a{' '} - - {headlineText} - {' '} - in the middle of it -
- ))} + {textSansPresets.map((typographyPreset) => ( +
+ Some text sans, with a{' '} + + {headlineText} + {' '} + in the middle of it +
+ ))} ); }; diff --git a/libs/@guardian/source-react-components/src/link/Link.tsx b/libs/@guardian/source-react-components/src/link/Link.tsx index b798673f4..a32e2f484 100644 --- a/libs/@guardian/source-react-components/src/link/Link.tsx +++ b/libs/@guardian/source-react-components/src/link/Link.tsx @@ -25,6 +25,7 @@ export const Link = ({ cssOverrides, children, theme, + typography, ...props }: LinkProps): EmotionJSX.Element => { return ( @@ -35,6 +36,7 @@ export const Link = ({ iconSide, cssOverrides, theme, + typography, })} {...props} > diff --git a/libs/@guardian/source-react-components/src/link/styles.ts b/libs/@guardian/source-react-components/src/link/styles.ts index 4df386f51..705dd4096 100644 --- a/libs/@guardian/source-react-components/src/link/styles.ts +++ b/libs/@guardian/source-react-components/src/link/styles.ts @@ -1,9 +1,10 @@ import type { SerializedStyles } from '@emotion/react'; import { css } from '@emotion/react'; +import type { TypographyPreset } from '@guardian/source-foundations'; import { focusHalo, space, - textSans, + textSans17, width, } from '@guardian/source-foundations'; import type { ReactElement } from 'react'; @@ -13,26 +14,28 @@ import type { IconSide, LinkPriority } from './@types/SharedLinkProps'; import type { ThemeLink } from './theme'; import { themeLink as defaultTheme } from './theme'; -export const link = css` - position: relative; - ${textSans.medium()}; - cursor: pointer; - text-decoration: underline; - text-underline-position: under; - text-underline-offset: 5%; +export const link = (typographyPreset = textSans17) => { + return css` + position: relative; + cursor: pointer; + text-decoration: underline; + text-underline-position: under; + text-underline-offset: 5%; + ${typographyPreset}; + display: inline; + text-decoration-thickness: 0.1em; - display: inline; - align-items: center; + align-items: center; - &:focus { - ${focusHalo}; - } + &:focus { + ${focusHalo}; + } - &:hover { - /* If the hover text decoration thickness is not set, we default to the initial value. */ - text-decoration-thickness: var(--source-text-decoration-thickness, auto); - } -`; + &:hover { + text-decoration-thickness: calc(0.1em + 1px); + } + `; +}; export const buttonLink = css` /* override user agent styles */ @@ -105,6 +108,7 @@ export const linkStyles = ({ iconSide = 'left', cssOverrides, theme, + typography, }: { isButton?: boolean; priority: LinkPriority; @@ -113,13 +117,14 @@ export const linkStyles = ({ iconSide?: IconSide; cssOverrides?: SerializedStyles | SerializedStyles[]; theme?: Partial; + typography?: TypographyPreset; }) => { const mergedTheme = (providerTheme: Theme['link']): ThemeLink => mergeThemes(defaultTheme, theme, providerTheme); return ( providerTheme: Theme, ): Array => [ - link, + link(typography), isButton ? buttonLink : '', priorities[priority](mergedTheme(providerTheme.link)), iconSvg ? icon : '',