Skip to content

Commit

Permalink
feat: mark legacy font tokens as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
JC Estibariz committed Nov 29, 2023
1 parent 6f27491 commit f3b1774
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
22 changes: 22 additions & 0 deletions packages/pelagos/less/fonts.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
43 changes: 24 additions & 19 deletions packages/pelagos/scripts/update-fonts.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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)));
2 changes: 1 addition & 1 deletion packages/pelagos/stories/styles/Fonts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import fonts from '../../defs/fonts.yaml';
</thead>
<tbody>
{Object.entries(fonts)
.filter(([k]) => k !== 'root-font')
.filter(([k]) => k !== 'root-font' && !/^font-/.test(k))
.map(([key, {use, styles}]) => (
<tr key={key}>
<td
Expand Down

0 comments on commit f3b1774

Please sign in to comment.