Skip to content

Commit

Permalink
Merge pull request #69 from evwilkin/chore/17-sort-scss
Browse files Browse the repository at this point in the history
chore(tokens): sort scss by name then by reference
  • Loading branch information
srambach authored Jun 21, 2024
2 parents e13067b + cf4ce04 commit 718de05
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 } = 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);
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 718de05

Please sign in to comment.