Skip to content

Commit

Permalink
sort output (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Dec 16, 2024
1 parent 5d89108 commit 11cd81a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/formats/cssCustomMedia.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {format} from 'prettier'
import type {FormatFn, FormatFnArguments} from 'style-dictionary/types'
import {fileHeader} from 'style-dictionary/utils'
import {fileHeader, sortByName} from 'style-dictionary/utils'

/**
* @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
Expand All @@ -11,7 +11,7 @@ export const cssCustomMedia: FormatFn = async ({dictionary, options: _options, f
// add file header
const output = [await fileHeader({file})]
// add single theme css
dictionary.allTokens.map(({name, $value}) => {
dictionary.allTokens.sort(sortByName).map(({name, $value}) => {
output.push(`@custom-media --${name} ${$value};`)
})
// return prettified
Expand Down
3 changes: 2 additions & 1 deletion src/formats/jsonOneDimensional.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {format} from 'prettier'
import {jsonToFlat} from './utilities/jsonToFlat.js'
import type {FormatFn, FormatFnArguments} from 'style-dictionary/types'
import {sortByName} from 'style-dictionary/utils'
/**
* @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
* @param FormatFnArguments
Expand All @@ -10,7 +11,7 @@ import type {FormatFn, FormatFnArguments} from 'style-dictionary/types'
export const jsonOneDimensional: FormatFn = ({dictionary, file: _file, options}: FormatFnArguments) => {
// option to allow verbose output (object) or just the value
const {outputVerbose, propertyConversion} = options
const tokens = jsonToFlat(dictionary.allTokens, outputVerbose)
const tokens = jsonToFlat(dictionary.allTokens.sort(sortByName), outputVerbose)
if (propertyConversion === undefined) {
//
const output = JSON.stringify(tokens, null, 2)
Expand Down

0 comments on commit 11cd81a

Please sign in to comment.