@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
37 lines • 2.08 kB
JavaScript
import typographyTokens from '@atlaskit/tokens/atlassian-typography';
import typographyPalette from '@atlaskit/tokens/typography-palette';
export var typographyValueToToken = typographyTokens
// we're filtering here to remove the `font` tokens.
.filter(function (t) {
return t.attributes.group === 'typography';
}).filter(function (t) {
return 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(function (t) {
return !t.cleanName.includes('UNSAFE');
}).map(function (currentToken) {
var _typographyPalette$fi, _typographyPalette$fi2, _typographyPalette$fi3;
var individualValues = {
fontSize: (_typographyPalette$fi = typographyPalette.find(function (baseToken) {
return 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(function (baseToken) {
return 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(function (baseToken) {
return 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
};
});