-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
import { Formatter, formatHelpers } from 'style-dictionary/types' | ||
import { fileHeader, formattedVariables } from 'style-dictionary/utils' | ||
import type { | ||
FormatFnArguments, | ||
Config, | ||
LocalOptions, | ||
} from 'style-dictionary/types' | ||
import StyleDictionary from 'style-dictionary' | ||
|
||
export const variables: Formatter = ({ dictionary, options = {}, file }) => { | ||
const selector = | ||
typeof options.selector == 'string' && options.selector | ||
? options.selector | ||
: `:root` | ||
/** style-dictionaryのtypesがany多用しててつらい */ | ||
export const charcoalVariables = ({ | ||
dictionary, | ||
options = {}, | ||
file, | ||
}: Omit<FormatFnArguments, 'options'> & { | ||
options: Config & | ||
LocalOptions & { | ||
selector?: string | ||
} | ||
}) => { | ||
const selector = options.selector ?? `:root` | ||
const { outputReferences } = options | ||
return ( | ||
formatHelpers.fileHeader({ file }) + | ||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-base-to-string | ||
fileHeader({ file }) + | ||
`${selector} {\n` + | ||
formatHelpers.formattedVariables({ | ||
formattedVariables({ | ||
format: 'css', | ||
dictionary, | ||
outputReferences, | ||
}) + | ||
`\n}\n` | ||
) | ||
} | ||
|
||
export const registerCharcoalFormats = () => { | ||
StyleDictionary.registerFormat({ | ||
name: 'css/charcoal-variables', | ||
format: charcoalVariables, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as formats from './format' | ||
import * as transforms from './transform' | ||
import * as formats from './format/index.js' | ||
import * as transforms from './transform/index.js' | ||
|
||
export { formats, transforms } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"types": ["node", "style-dictionary/types"], | ||
"incremental": true, | ||
"outDir": "./dist", | ||
"tsBuildInfoFile": "./.tsbuildinfo" | ||
"tsBuildInfoFile": "./.tsbuildinfo", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext" | ||
}, | ||
"include": ["./src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["./src"] | ||
"include": ["./src"], | ||
"compilerOptions": { | ||
"moduleResolution": "nodenext" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters