Skip to content

Commit

Permalink
replace cssVariables formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Apr 24, 2024
1 parent 7815b23 commit 6c5314a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 83 deletions.
12 changes: 0 additions & 12 deletions src/PrimerStyleDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ import {
javascriptEsm,
typescriptExportDefinition,
jsonNestedPrefixed,
cssThemed,
cssCustomMedia,
jsonOneDimensional,
jsonPostCssFallback,
cssMediaQuery,
cssVariables,
jsonFigma,
} from './formats'

Expand All @@ -49,11 +47,6 @@ StyleDictionary.registerParser(w3cJsonParser)
* Formats
*
*/
StyleDictionary.registerFormat({
name: 'css/themed',
formatter: cssThemed,
})

StyleDictionary.registerFormat({
name: 'css/customMedia',
formatter: cssCustomMedia,
Expand All @@ -64,11 +57,6 @@ StyleDictionary.registerFormat({
formatter: cssMediaQuery,
})

StyleDictionary.registerFormat({
name: 'css/variables',
formatter: cssVariables,
})

StyleDictionary.registerFormat({
name: 'javascript/esm',
formatter: javascriptEsm,
Expand Down
35 changes: 0 additions & 35 deletions src/formats/cssThemed.ts

This file was deleted.

24 changes: 16 additions & 8 deletions src/formats/cssVariables.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {cssVariables} from './cssVariables'
import {cssMediaQuery} from './cssMediaQuery'
import {getMockFormatterArguments} from '../test-utilities'
import {format} from 'prettier'

Expand All @@ -14,13 +14,17 @@ describe('Format: css/variables', () => {
printWidth: 500,
},
)
expect(cssVariables(input)).toStrictEqual(expectedOutput)
expect(cssMediaQuery(input)).toStrictEqual(expectedOutput)
})

it('Formats tokens with custom selectors', () => {
const input = getMockFormatterArguments({
options: {
selector: `[data-color-mode="dark"]`,
file: {
destination: 'test.css',
options: {
showFileHeader: false,
selector: `[data-color-mode="dark"]`,
},
},
})
const expectedOutput = format(
Expand All @@ -29,13 +33,17 @@ describe('Format: css/variables', () => {
}`,
{parser: 'css', printWidth: 500},
)
expect(cssVariables(input)).toStrictEqual(expectedOutput)
expect(cssMediaQuery(input)).toStrictEqual(expectedOutput)
})

it('Formats tokens with only options.selector', () => {
const input = getMockFormatterArguments({
options: {
selector: `[data-color-mode="dark"]`,
file: {
destination: 'test.css',
options: {
showFileHeader: false,
selector: `[data-color-mode="dark"]`,
},
},
})
const expectedOutput = format(
Expand All @@ -44,6 +52,6 @@ describe('Format: css/variables', () => {
}`,
{parser: 'css', printWidth: 500},
)
expect(cssVariables(input)).toStrictEqual(expectedOutput)
expect(cssMediaQuery(input)).toStrictEqual(expectedOutput)
})
})
25 changes: 0 additions & 25 deletions src/formats/cssVariables.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/formats/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export {cssThemed} from './cssThemed'
export {cssCustomMedia} from './cssCustomMedia'
export {cssMediaQuery} from './cssMediaQuery'
export {cssVariables} from './cssVariables'
export {jsonFigma} from './jsonFigma'
export {javascriptCommonJs} from './javascriptCommonJs'
export {javascriptEsm} from './javascriptEsm'
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
},
{
destination: `${outputFile}`,
format: `css/variables`,
format: `css/mediaQuery`,
filter: token => isSource(token) && options?.themed !== true,
options: {
showFileHeader: false,
Expand Down

0 comments on commit 6c5314a

Please sign in to comment.