@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
25 lines • 1.9 kB
JavaScript
import typographyTokens from '@atlaskit/tokens/atlassian-typography';
import typographyPalette from '@atlaskit/tokens/typography-palette';
export const typographyValueToToken = typographyTokens
// we're filtering here to remove the `font` tokens.
.filter(t => t.attributes.group === 'typography').filter(t => t.cleanName.includes('font.heading') || t.cleanName.includes('font.body'))
// Filtering out UNSAFE tokens that were meant for migrations, these tokens are deprecated and will be removed in the future
.filter(t => !t.cleanName.includes('UNSAFE')).map(currentToken => {
var _typographyPalette$fi, _typographyPalette$fi2, _typographyPalette$fi3;
const individualValues = {
fontSize: (_typographyPalette$fi = typographyPalette.find(baseToken => baseToken.path.slice(-1)[0] ===
// @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
currentToken.original.value.fontSize)) === null || _typographyPalette$fi === void 0 ? void 0 : _typographyPalette$fi.value,
fontWeight: (_typographyPalette$fi2 = typographyPalette.find(baseToken => baseToken.path.slice(-1)[0] ===
// @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
currentToken.original.value.fontWeight)) === null || _typographyPalette$fi2 === void 0 ? void 0 : _typographyPalette$fi2.value,
lineHeight: (_typographyPalette$fi3 = typographyPalette.find(baseToken => baseToken.path.slice(-1)[0] ===
// @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
currentToken.original.value.lineHeight)) === null || _typographyPalette$fi3 === void 0 ? void 0 : _typographyPalette$fi3.value
};
return {
tokenName: currentToken.cleanName,
tokenValue: currentToken.value,
values: individualValues
};
});