Skip to content

Commit

Permalink
chore(tokens): sort scss by name then by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
evwilkin committed Jun 12, 2024
1 parent 20fee76 commit 07d32f5
Show file tree
Hide file tree
Showing 6 changed files with 1,249 additions and 1,218 deletions.
8 changes: 4 additions & 4 deletions packages/module/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const StyleDictionary = require('style-dictionary');

const build = (selector) => {
const { fileHeader, formattedVariables } = StyleDictionary.formatHelpers;
const { fileHeader, formattedVariables, sortByName, sortByReference } = StyleDictionary.formatHelpers;

console.log('Build started...');
console.log('\n============================');
Expand All @@ -12,6 +12,8 @@ const build = (selector) => {
name: 'customFormat',
formatter: function ({ dictionary, file, options }) {
const { outputReferences } = options;
const alphaSort = (a, b) => sortByName(a, b) * -1;
dictionary.allTokens = dictionary.allTokens.sort(alphaSort).sort((tokens) => sortByReference(tokens));
return (
fileHeader({ file, commentStyle: 'short' }) +
`${selector} {\n` +
Expand All @@ -38,9 +40,7 @@ const build = (selector) => {
StyleDictionary.registerTransform({
name: 'patternfly/global/ms',
type: 'value',
matcher: (token) =>
token.attributes.type === 'duration' ||
token.attributes.type === 'delay',
matcher: (token) => token.attributes.type === 'duration' || token.attributes.type === 'delay',
transformer: (token) => `${token.value}ms`
});

Expand Down
Loading

0 comments on commit 07d32f5

Please sign in to comment.