File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ Optional except for `type`.
191
191
| type | Set the name of each theme (colors, fontSize, etc.) for ` 'all' ` or tailwind. | ` 'all' ` or string |
192
192
| formatType | Set the format of the Tailwind CSS configuration file. <br >Default value: ` js ` | ` 'js' ` ` 'cjs' ` |
193
193
| isVariables | Set when using CSS custom variables. <br >Default value: ` false ` | boolean |
194
+ | extend | Set to add transformed styles to the ` 'extend' ` key within the ` 'theme' ` key or not. <br >Default value: ` true ` | boolean |
194
195
| source | [ ` source ` ] ( https://github.com/amzn/style-dictionary/blob/main/README.md#configjson ) attribute of style-dictionary.<br >Default value: ` ['tokens/**/*.json'] ` | Array of strings |
195
196
| transforms | [ ` platform.transforms ` ] ( https://github.com/amzn/style-dictionary/blob/main/README.md#configjson ) attribute of style-dictionary.<br >Default value: ` ['attribute/cti','name/cti/kebab'] ` | Array of strings |
196
197
| buildPath | [ ` platform.buildPath ` ] ( https://github.com/amzn/style-dictionary/blob/main/README.md#configjson ) attribute of style-dictionary.<br >Default value: ` 'build/web/' ` | string |
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export const getTailwindFormat = ({
46
46
type,
47
47
isVariables,
48
48
prefix,
49
+ extend,
49
50
tailwind
50
51
} : TailwindFormatObjType ) => {
51
52
const content = formatTokens ( allTokens , type , isVariables , prefix )
@@ -72,6 +73,7 @@ export const getTailwindFormat = ({
72
73
content ,
73
74
darkMode ,
74
75
tailwindContent ,
76
+ extend ,
75
77
plugins
76
78
)
77
79
@@ -85,6 +87,7 @@ export const makeSdTailwindConfig = ({
85
87
type,
86
88
formatType = 'js' ,
87
89
isVariables = false ,
90
+ extend = true ,
88
91
source,
89
92
transforms,
90
93
buildPath,
@@ -107,6 +110,7 @@ export const makeSdTailwindConfig = ({
107
110
dictionary,
108
111
formatType,
109
112
isVariables,
113
+ extend,
110
114
prefix,
111
115
type,
112
116
tailwind
Original file line number Diff line number Diff line change @@ -23,11 +23,12 @@ export type SdTailwindConfigType = {
23
23
buildPath ?: Platform [ 'buildPath' ]
24
24
prefix ?: Platform [ 'prefix' ]
25
25
tailwind ?: Partial < TailwindOptions >
26
+ extend ?: boolean
26
27
}
27
28
28
29
export type TailwindFormatObjType = Pick <
29
30
SdTailwindConfigType ,
30
- 'type' | 'isVariables' | 'prefix' | 'tailwind'
31
+ 'type' | 'isVariables' | 'prefix' | 'tailwind' | 'extend'
31
32
> & {
32
33
dictionary : Dictionary
33
34
formatType : TailwindFormatType
Original file line number Diff line number Diff line change @@ -62,16 +62,19 @@ export const getTemplateConfigByType = (
62
62
content : string ,
63
63
darkMode : TailwindOptions [ 'darkMode' ] ,
64
64
tailwindContent : TailwindOptions [ 'content' ] ,
65
+ extend : SdTailwindConfigType [ 'extend' ] ,
65
66
plugins : string [ ]
66
67
) => {
68
+ const extendTheme = extend
69
+ ? `theme: { extend: ${ unquoteFromKeys ( content , type ) } , },`
70
+ : `theme: ${ unquoteFromKeys ( content , type ) } ,`
71
+
67
72
const getTemplateConfig = ( ) => {
68
73
let config = `{
69
74
mode: "jit",
70
75
content: [${ tailwindContent } ],
71
76
darkMode: "${ darkMode } ",
72
- theme: {
73
- extend: ${ unquoteFromKeys ( content , type ) } ,
74
- },`
77
+ ${ extendTheme } `
75
78
76
79
if ( plugins . length > 0 ) {
77
80
config += `\n plugins: [${ plugins } ]`
You can’t perform that action at this time.
0 commit comments