Skip to content

Commit

Permalink
Merge 0f97987 into a17e9a7
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Dec 5, 2024
2 parents a17e9a7 + 0f97987 commit 1ab3e95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/khaki-kiwis-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': minor
---

Changing the way we use references in css output, to keep all references to tokens that are present in the final output
10 changes: 9 additions & 1 deletion src/platforms/css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {isFromFile, isSource} from '../filters/index.js'
import type {PlatformInitializer} from '../types/platformInitializer.js'
import type {PlatformConfig, TransformedToken} from 'style-dictionary/types'
import {outputReferencesTransformed, outputReferencesFilter} from 'style-dictionary/utils'

const getCssSelectors = (outputFile: string) => {
// check for dark in the beginning of the output filename
Expand Down Expand Up @@ -58,7 +59,8 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
]),
options: {
showFileHeader: false,
outputReferences: false,
outputReferences: (token, platformOptions) =>
outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
descriptions: false,
queries: getCssSelectors(outputFile),
...options?.options,
Expand All @@ -77,6 +79,8 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
]),
options: {
showFileHeader: false,
outputReferences: (token, platformOptions) =>
outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
descriptions: false,
...options?.options,
},
Expand All @@ -87,6 +91,8 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
filter: token => isSource(token) && options?.themed !== true && token.$type === 'custom-viewportRange',
options: {
showFileHeader: false,
outputReferences: (token, platformOptions) =>
outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
},
},
{
Expand All @@ -100,6 +106,8 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
]),
options: {
descriptions: false,
outputReferences: (token, platformOptions) =>
outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
showFileHeader: false,
queries: [
{
Expand Down

0 comments on commit 1ab3e95

Please sign in to comment.