From f3b17743d054c95b37df398d78d13b7474384b74 Mon Sep 17 00:00:00 2001 From: JC Estibariz Date: Thu, 23 Nov 2023 16:22:36 -0500 Subject: [PATCH] feat: mark legacy font tokens as deprecated --- packages/pelagos/less/fonts.less | 22 ++++++++++++ packages/pelagos/scripts/update-fonts.js | 43 +++++++++++++---------- packages/pelagos/stories/styles/Fonts.mdx | 2 +- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/packages/pelagos/less/fonts.less b/packages/pelagos/less/fonts.less index ba8527e0..bd06e38b 100644 --- a/packages/pelagos/less/fonts.less +++ b/packages/pelagos/less/fonts.less @@ -144,46 +144,68 @@ font-weight: 300; letter-spacing: 0; }; + +/** @deprecated */ @font-10-400: { font-size: 10px; font-weight: 400; }; + +/** @deprecated */ @font-10-600: { font-size: 10px; font-weight: 600; }; + +/** @deprecated */ @font-12-400: { font-size: 12px; font-weight: 400; }; + +/** @deprecated */ @font-12-600: { font-size: 12px; font-weight: 600; }; + +/** @deprecated */ @font-14-400: { font-size: 14px; font-weight: 400; }; + +/** @deprecated */ @font-14-600: { font-size: 14px; font-weight: 600; }; + +/** @deprecated */ @font-16-400: { font-size: 16px; font-weight: 400; }; + +/** @deprecated */ @font-16-600: { font-size: 16px; font-weight: 600; }; + +/** @deprecated */ @font-18-400: { font-size: 18px; font-weight: 400; }; + +/** @deprecated */ @font-24-400: { font-size: 24px; font-weight: 400; }; + +/** @deprecated */ @font-68-300: { font-size: 68px; font-weight: 300; diff --git a/packages/pelagos/scripts/update-fonts.js b/packages/pelagos/scripts/update-fonts.js index 9dacbcc4..1a723630 100644 --- a/packages/pelagos/scripts/update-fonts.js +++ b/packages/pelagos/scripts/update-fonts.js @@ -1,6 +1,7 @@ -const {readFileSync, writeFileSync} = require('fs'); +const {readFile, writeFile} = require('node:fs/promises'); const {parse} = require('yaml'); +const {resolveConfig, format} = require('prettier'); const IN = 'defs/fonts.yaml'; const LESS = 'less/fonts.less'; @@ -13,21 +14,25 @@ const HEADER = [ '', ]; -const fonts = Object.entries(parse(readFileSync(IN, 'utf8'))); - -writeFileSync( - LESS, - HEADER.concat( - fonts.map( - ([key, {styles}]) => - '@' + - key + - ': {\n' + - Object.entries(styles) - .map(([k, v]) => `\t${k}: ${v};`) - .join('\n') + - '\n};' - ), - '' - ).join('\n') -); +Promise.all([readFile(IN, 'utf8'), resolveConfig(LESS)]) + .then(([yamlText, options]) => + format( + HEADER.concat( + Object.entries(parse(yamlText)).map( + ([key, {styles}]) => + (/^font-/.test(key) ? '\n/** @deprecated */\n' : '') + + '@' + + key + + ': {\n' + + Object.entries(styles) + .map(([k, v]) => `\t${k}: ${v};`) + .join('\n') + + '\n};' + ), + '' + ).join('\n'), + {...options, filepath: LESS} + ) + ) + .then((code) => writeFile(LESS, code)) + .catch((error) => (console.error(error), process.exit(1))); diff --git a/packages/pelagos/stories/styles/Fonts.mdx b/packages/pelagos/stories/styles/Fonts.mdx index a9ebe711..72c3407c 100644 --- a/packages/pelagos/stories/styles/Fonts.mdx +++ b/packages/pelagos/stories/styles/Fonts.mdx @@ -14,7 +14,7 @@ import fonts from '../../defs/fonts.yaml'; {Object.entries(fonts) - .filter(([k]) => k !== 'root-font') + .filter(([k]) => k !== 'root-font' && !/^font-/.test(k)) .map(([key, {use, styles}]) => (