@atlaskit/tokens 1.11.3 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +25 -0
- package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +25 -0
- package/dist/cjs/artifacts/generated-pairs.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-legacy-dark.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-legacy-light.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-light.js +2 -2
- package/dist/cjs/artifacts/token-default-values.js +7 -1
- package/dist/cjs/artifacts/token-names.js +7 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +137 -5
- package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
- package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +137 -5
- package/dist/cjs/constants.js +3 -1
- package/dist/cjs/custom-theme.js +108 -0
- package/dist/cjs/get-token-value.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/set-global-theme.js +156 -59
- package/dist/cjs/tokens/atlassian-dark/color/background.js +22 -0
- package/dist/cjs/tokens/atlassian-legacy-dark/color/background.js +22 -0
- package/dist/cjs/tokens/atlassian-legacy-light/color/background.js +22 -0
- package/dist/cjs/tokens/atlassian-light/color/background.js +22 -0
- package/dist/cjs/tokens/default/color/background.js +54 -2
- package/dist/cjs/utils/color-utils.js +178 -0
- package/dist/cjs/utils/custom-theme-loading-utils.js +47 -0
- package/dist/cjs/utils/custom-theme-token-contrast-check.js +74 -0
- package/dist/cjs/utils/generate-custom-color-ramp.js +222 -0
- package/dist/cjs/utils/hash.js +17 -0
- package/dist/cjs/utils/hct-color-utils/color-utils.js +310 -0
- package/dist/cjs/utils/hct-color-utils/contrast.js +188 -0
- package/dist/cjs/utils/hct-color-utils/hct.js +1036 -0
- package/dist/cjs/utils/hct-color-utils/index.js +32 -0
- package/dist/cjs/utils/hct-color-utils/math-utils.js +159 -0
- package/dist/cjs/utils/theme-loading.js +1 -1
- package/dist/cjs/utils/theme-state-transformer.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +18 -0
- package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +18 -0
- package/dist/es2019/artifacts/generated-pairs.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-dark.js +7 -1
- package/dist/es2019/artifacts/themes/atlassian-legacy-dark.js +7 -1
- package/dist/es2019/artifacts/themes/atlassian-legacy-light.js +7 -1
- package/dist/es2019/artifacts/themes/atlassian-light.js +7 -1
- package/dist/es2019/artifacts/token-default-values.js +7 -1
- package/dist/es2019/artifacts/token-names.js +7 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +137 -5
- package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
- package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +137 -5
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/custom-theme.js +77 -0
- package/dist/es2019/get-token-value.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/set-global-theme.js +67 -13
- package/dist/es2019/tokens/atlassian-dark/color/background.js +22 -0
- package/dist/es2019/tokens/atlassian-legacy-dark/color/background.js +22 -0
- package/dist/es2019/tokens/atlassian-legacy-light/color/background.js +22 -0
- package/dist/es2019/tokens/atlassian-light/color/background.js +22 -0
- package/dist/es2019/tokens/default/color/background.js +54 -2
- package/dist/es2019/utils/color-utils.js +154 -0
- package/dist/es2019/utils/custom-theme-loading-utils.js +31 -0
- package/dist/es2019/utils/custom-theme-token-contrast-check.js +68 -0
- package/dist/es2019/utils/generate-custom-color-ramp.js +198 -0
- package/dist/es2019/utils/hash.js +10 -0
- package/dist/es2019/utils/hct-color-utils/color-utils.js +286 -0
- package/dist/es2019/utils/hct-color-utils/contrast.js +161 -0
- package/dist/es2019/utils/hct-color-utils/hct.js +931 -0
- package/dist/es2019/utils/hct-color-utils/index.js +3 -0
- package/dist/es2019/utils/hct-color-utils/math-utils.js +145 -0
- package/dist/es2019/utils/theme-loading.js +2 -2
- package/dist/es2019/utils/theme-state-transformer.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +18 -0
- package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +18 -0
- package/dist/esm/artifacts/generated-pairs.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-legacy-dark.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-legacy-light.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-light.js +2 -2
- package/dist/esm/artifacts/token-default-values.js +7 -1
- package/dist/esm/artifacts/token-names.js +7 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +137 -5
- package/dist/esm/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
- package/dist/esm/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +137 -5
- package/dist/esm/constants.js +1 -0
- package/dist/esm/custom-theme.js +98 -0
- package/dist/esm/get-token-value.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/set-global-theme.js +149 -60
- package/dist/esm/tokens/atlassian-dark/color/background.js +22 -0
- package/dist/esm/tokens/atlassian-legacy-dark/color/background.js +22 -0
- package/dist/esm/tokens/atlassian-legacy-light/color/background.js +22 -0
- package/dist/esm/tokens/atlassian-light/color/background.js +22 -0
- package/dist/esm/tokens/default/color/background.js +54 -2
- package/dist/esm/utils/color-utils.js +162 -0
- package/dist/esm/utils/custom-theme-loading-utils.js +38 -0
- package/dist/esm/utils/custom-theme-token-contrast-check.js +65 -0
- package/dist/esm/utils/generate-custom-color-ramp.js +211 -0
- package/dist/esm/utils/hash.js +10 -0
- package/dist/esm/utils/hct-color-utils/color-utils.js +285 -0
- package/dist/esm/utils/hct-color-utils/contrast.js +181 -0
- package/dist/esm/utils/hct-color-utils/hct.js +1029 -0
- package/dist/esm/utils/hct-color-utils/index.js +3 -0
- package/dist/esm/utils/hct-color-utils/math-utils.js +145 -0
- package/dist/esm/utils/theme-loading.js +2 -2
- package/dist/esm/utils/theme-state-transformer.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +18 -0
- package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +18 -0
- package/dist/types/artifacts/generated-pairs.d.ts +1 -1
- package/dist/types/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-legacy-dark.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types/artifacts/token-default-values.d.ts +7 -1
- package/dist/types/artifacts/token-names.d.ts +13 -1
- package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-legacy-dark.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
- package/dist/types/artifacts/types-internal.d.ts +2 -2
- package/dist/types/artifacts/types.d.ts +2 -2
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/custom-theme.d.ts +30 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/set-global-theme.d.ts +9 -3
- package/dist/types/types.d.ts +10 -0
- package/dist/types/utils/color-utils.d.ts +10 -0
- package/dist/types/utils/custom-theme-loading-utils.d.ts +11 -0
- package/dist/types/utils/custom-theme-token-contrast-check.d.ts +20 -0
- package/dist/types/utils/generate-custom-color-ramp.d.ts +19 -0
- package/dist/types/utils/hash.d.ts +1 -0
- package/dist/types/utils/hct-color-utils/color-utils.d.ts +131 -0
- package/dist/types/utils/hct-color-utils/contrast.d.ts +78 -0
- package/dist/types/utils/hct-color-utils/hct.d.ts +137 -0
- package/dist/types/utils/hct-color-utils/index.d.ts +3 -0
- package/dist/types/utils/hct-color-utils/math-utils.d.ts +86 -0
- package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +18 -0
- package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +18 -0
- package/dist/types-ts4.5/artifacts/generated-pairs.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-dark.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/token-default-values.d.ts +7 -1
- package/dist/types-ts4.5/artifacts/token-names.d.ts +13 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-dark.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/types-internal.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
- package/dist/types-ts4.5/constants.d.ts +1 -0
- package/dist/types-ts4.5/custom-theme.d.ts +30 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/set-global-theme.d.ts +9 -3
- package/dist/types-ts4.5/types.d.ts +10 -0
- package/dist/types-ts4.5/utils/color-utils.d.ts +27 -0
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +11 -0
- package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +20 -0
- package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +19 -0
- package/dist/types-ts4.5/utils/hash.d.ts +1 -0
- package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +131 -0
- package/dist/types-ts4.5/utils/hct-color-utils/contrast.d.ts +78 -0
- package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +137 -0
- package/dist/types-ts4.5/utils/hct-color-utils/index.d.ts +3 -0
- package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +86 -0
- package/figma/atlassian-dark.json +56 -2
- package/figma/atlassian-legacy-dark.json +56 -2
- package/figma/atlassian-legacy-light.json +56 -2
- package/figma/atlassian-light.json +56 -2
- package/package.json +36 -37
- package/report.api.md +48 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -902
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -895
- package/dist/esm/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -895
- package/dist/types/artifacts/tokens-raw/atlassian-dark-iteration.d.ts +0 -91
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark-iteration.d.ts +0 -91
- package/tmp/api-report-tmp.d.ts +0 -1132
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::8b7aab21b157bced2314e03774c8445e>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
6
|
const tokens = [{
|
|
@@ -3127,6 +3127,72 @@ const tokens = [{
|
|
|
3127
3127
|
"name": "color.background.selected.bold.pressed",
|
|
3128
3128
|
"path": ["color", "background", "selected", "bold", "pressed"],
|
|
3129
3129
|
"cleanName": "color.background.selected.bold.pressed"
|
|
3130
|
+
}, {
|
|
3131
|
+
"attributes": {
|
|
3132
|
+
"group": "paint",
|
|
3133
|
+
"state": "active",
|
|
3134
|
+
"introduced": "1.13.0",
|
|
3135
|
+
"description": "Use for the background of elements used to reinforce our brand, but with less emphasis."
|
|
3136
|
+
},
|
|
3137
|
+
"value": "#B3D4FF",
|
|
3138
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3139
|
+
"isSource": true,
|
|
3140
|
+
"original": {
|
|
3141
|
+
"attributes": {
|
|
3142
|
+
"group": "paint",
|
|
3143
|
+
"state": "active",
|
|
3144
|
+
"introduced": "1.13.0",
|
|
3145
|
+
"description": "Use for the background of elements used to reinforce our brand, but with less emphasis."
|
|
3146
|
+
},
|
|
3147
|
+
"value": "B75"
|
|
3148
|
+
},
|
|
3149
|
+
"name": "color.background.brand.subtlest.[default]",
|
|
3150
|
+
"path": ["color", "background", "brand", "subtlest", "[default]"],
|
|
3151
|
+
"cleanName": "color.background.brand.subtlest"
|
|
3152
|
+
}, {
|
|
3153
|
+
"attributes": {
|
|
3154
|
+
"group": "paint",
|
|
3155
|
+
"state": "active",
|
|
3156
|
+
"introduced": "1.13.0",
|
|
3157
|
+
"description": "Hovered state of color.background.brand.subtlest."
|
|
3158
|
+
},
|
|
3159
|
+
"value": "#DEEBFF",
|
|
3160
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3161
|
+
"isSource": true,
|
|
3162
|
+
"original": {
|
|
3163
|
+
"attributes": {
|
|
3164
|
+
"group": "paint",
|
|
3165
|
+
"state": "active",
|
|
3166
|
+
"introduced": "1.13.0",
|
|
3167
|
+
"description": "Hovered state of color.background.brand.subtlest."
|
|
3168
|
+
},
|
|
3169
|
+
"value": "B50"
|
|
3170
|
+
},
|
|
3171
|
+
"name": "color.background.brand.subtlest.hovered",
|
|
3172
|
+
"path": ["color", "background", "brand", "subtlest", "hovered"],
|
|
3173
|
+
"cleanName": "color.background.brand.subtlest.hovered"
|
|
3174
|
+
}, {
|
|
3175
|
+
"attributes": {
|
|
3176
|
+
"group": "paint",
|
|
3177
|
+
"state": "active",
|
|
3178
|
+
"introduced": "1.13.0",
|
|
3179
|
+
"description": "Pressed state of color.background.brand.subtlest"
|
|
3180
|
+
},
|
|
3181
|
+
"value": "#4C9AFF",
|
|
3182
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3183
|
+
"isSource": true,
|
|
3184
|
+
"original": {
|
|
3185
|
+
"attributes": {
|
|
3186
|
+
"group": "paint",
|
|
3187
|
+
"state": "active",
|
|
3188
|
+
"introduced": "1.13.0",
|
|
3189
|
+
"description": "Pressed state of color.background.brand.subtlest"
|
|
3190
|
+
},
|
|
3191
|
+
"value": "B100"
|
|
3192
|
+
},
|
|
3193
|
+
"name": "color.background.brand.subtlest.pressed",
|
|
3194
|
+
"path": ["color", "background", "brand", "subtlest", "pressed"],
|
|
3195
|
+
"cleanName": "color.background.brand.subtlest.pressed"
|
|
3130
3196
|
}, {
|
|
3131
3197
|
"attributes": {
|
|
3132
3198
|
"group": "paint",
|
|
@@ -3154,7 +3220,7 @@ const tokens = [{
|
|
|
3154
3220
|
"group": "paint",
|
|
3155
3221
|
"state": "active",
|
|
3156
3222
|
"introduced": "0.6.0",
|
|
3157
|
-
"description": "Hovered state of color.background.brand.bold"
|
|
3223
|
+
"description": "Hovered state of color.background.brand.bold."
|
|
3158
3224
|
},
|
|
3159
3225
|
"value": "#0065FF",
|
|
3160
3226
|
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
@@ -3164,7 +3230,7 @@ const tokens = [{
|
|
|
3164
3230
|
"group": "paint",
|
|
3165
3231
|
"state": "active",
|
|
3166
3232
|
"introduced": "0.6.0",
|
|
3167
|
-
"description": "Hovered state of color.background.brand.bold"
|
|
3233
|
+
"description": "Hovered state of color.background.brand.bold."
|
|
3168
3234
|
},
|
|
3169
3235
|
"value": "B300"
|
|
3170
3236
|
},
|
|
@@ -3176,7 +3242,7 @@ const tokens = [{
|
|
|
3176
3242
|
"group": "paint",
|
|
3177
3243
|
"state": "active",
|
|
3178
3244
|
"introduced": "0.6.0",
|
|
3179
|
-
"description": "Pressed state of color.background.brand.bold"
|
|
3245
|
+
"description": "Pressed state of color.background.brand.bold."
|
|
3180
3246
|
},
|
|
3181
3247
|
"value": "#0747A6",
|
|
3182
3248
|
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
@@ -3186,13 +3252,79 @@ const tokens = [{
|
|
|
3186
3252
|
"group": "paint",
|
|
3187
3253
|
"state": "active",
|
|
3188
3254
|
"introduced": "0.6.0",
|
|
3189
|
-
"description": "Pressed state of color.background.brand.bold"
|
|
3255
|
+
"description": "Pressed state of color.background.brand.bold."
|
|
3190
3256
|
},
|
|
3191
3257
|
"value": "B500"
|
|
3192
3258
|
},
|
|
3193
3259
|
"name": "color.background.brand.bold.pressed",
|
|
3194
3260
|
"path": ["color", "background", "brand", "bold", "pressed"],
|
|
3195
3261
|
"cleanName": "color.background.brand.bold.pressed"
|
|
3262
|
+
}, {
|
|
3263
|
+
"attributes": {
|
|
3264
|
+
"group": "paint",
|
|
3265
|
+
"state": "active",
|
|
3266
|
+
"introduced": "1.13.0",
|
|
3267
|
+
"description": "Use for the background of elements used to reinforce our brand, that need to stand out a lot."
|
|
3268
|
+
},
|
|
3269
|
+
"value": "#0747A6",
|
|
3270
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3271
|
+
"isSource": true,
|
|
3272
|
+
"original": {
|
|
3273
|
+
"attributes": {
|
|
3274
|
+
"group": "paint",
|
|
3275
|
+
"state": "active",
|
|
3276
|
+
"introduced": "1.13.0",
|
|
3277
|
+
"description": "Use for the background of elements used to reinforce our brand, that need to stand out a lot."
|
|
3278
|
+
},
|
|
3279
|
+
"value": "B500"
|
|
3280
|
+
},
|
|
3281
|
+
"name": "color.background.brand.boldest.[default]",
|
|
3282
|
+
"path": ["color", "background", "brand", "boldest", "[default]"],
|
|
3283
|
+
"cleanName": "color.background.brand.boldest"
|
|
3284
|
+
}, {
|
|
3285
|
+
"attributes": {
|
|
3286
|
+
"group": "paint",
|
|
3287
|
+
"state": "active",
|
|
3288
|
+
"introduced": "1.13.0",
|
|
3289
|
+
"description": "Hovered state of color.background.brand.boldest."
|
|
3290
|
+
},
|
|
3291
|
+
"value": "#0052CC",
|
|
3292
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3293
|
+
"isSource": true,
|
|
3294
|
+
"original": {
|
|
3295
|
+
"attributes": {
|
|
3296
|
+
"group": "paint",
|
|
3297
|
+
"state": "active",
|
|
3298
|
+
"introduced": "1.13.0",
|
|
3299
|
+
"description": "Hovered state of color.background.brand.boldest."
|
|
3300
|
+
},
|
|
3301
|
+
"value": "B400"
|
|
3302
|
+
},
|
|
3303
|
+
"name": "color.background.brand.boldest.hovered",
|
|
3304
|
+
"path": ["color", "background", "brand", "boldest", "hovered"],
|
|
3305
|
+
"cleanName": "color.background.brand.boldest.hovered"
|
|
3306
|
+
}, {
|
|
3307
|
+
"attributes": {
|
|
3308
|
+
"group": "paint",
|
|
3309
|
+
"state": "active",
|
|
3310
|
+
"introduced": "1.13.0",
|
|
3311
|
+
"description": "Pressed state of color.background.brand.boldest."
|
|
3312
|
+
},
|
|
3313
|
+
"value": "#0747A6",
|
|
3314
|
+
"filePath": "src/tokens/atlassian-legacy-light/color/background.tsx",
|
|
3315
|
+
"isSource": true,
|
|
3316
|
+
"original": {
|
|
3317
|
+
"attributes": {
|
|
3318
|
+
"group": "paint",
|
|
3319
|
+
"state": "active",
|
|
3320
|
+
"introduced": "1.13.0",
|
|
3321
|
+
"description": "Pressed state of color.background.brand.boldest."
|
|
3322
|
+
},
|
|
3323
|
+
"value": "B500"
|
|
3324
|
+
},
|
|
3325
|
+
"name": "color.background.brand.boldest.pressed",
|
|
3326
|
+
"path": ["color", "background", "brand", "boldest", "pressed"],
|
|
3327
|
+
"cleanName": "color.background.brand.boldest.pressed"
|
|
3196
3328
|
}, {
|
|
3197
3329
|
"attributes": {
|
|
3198
3330
|
"group": "paint",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::c96324369c8a09e129803eff1f33d1e8>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
6
|
const tokens = [{
|
|
@@ -3127,6 +3127,72 @@ const tokens = [{
|
|
|
3127
3127
|
"name": "color.background.selected.bold.pressed",
|
|
3128
3128
|
"path": ["color", "background", "selected", "bold", "pressed"],
|
|
3129
3129
|
"cleanName": "color.background.selected.bold.pressed"
|
|
3130
|
+
}, {
|
|
3131
|
+
"attributes": {
|
|
3132
|
+
"group": "paint",
|
|
3133
|
+
"state": "active",
|
|
3134
|
+
"introduced": "1.13.0",
|
|
3135
|
+
"description": "Use for the background of elements used to reinforce our brand, but with less emphasis."
|
|
3136
|
+
},
|
|
3137
|
+
"value": "#E9F2FF",
|
|
3138
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3139
|
+
"isSource": true,
|
|
3140
|
+
"original": {
|
|
3141
|
+
"attributes": {
|
|
3142
|
+
"group": "paint",
|
|
3143
|
+
"state": "active",
|
|
3144
|
+
"introduced": "1.13.0",
|
|
3145
|
+
"description": "Use for the background of elements used to reinforce our brand, but with less emphasis."
|
|
3146
|
+
},
|
|
3147
|
+
"value": "Blue100"
|
|
3148
|
+
},
|
|
3149
|
+
"name": "color.background.brand.subtlest.[default]",
|
|
3150
|
+
"path": ["color", "background", "brand", "subtlest", "[default]"],
|
|
3151
|
+
"cleanName": "color.background.brand.subtlest"
|
|
3152
|
+
}, {
|
|
3153
|
+
"attributes": {
|
|
3154
|
+
"group": "paint",
|
|
3155
|
+
"state": "active",
|
|
3156
|
+
"introduced": "1.13.0",
|
|
3157
|
+
"description": "Hovered state of color.background.brand.subtlest."
|
|
3158
|
+
},
|
|
3159
|
+
"value": "#CCE0FF",
|
|
3160
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3161
|
+
"isSource": true,
|
|
3162
|
+
"original": {
|
|
3163
|
+
"attributes": {
|
|
3164
|
+
"group": "paint",
|
|
3165
|
+
"state": "active",
|
|
3166
|
+
"introduced": "1.13.0",
|
|
3167
|
+
"description": "Hovered state of color.background.brand.subtlest."
|
|
3168
|
+
},
|
|
3169
|
+
"value": "Blue200"
|
|
3170
|
+
},
|
|
3171
|
+
"name": "color.background.brand.subtlest.hovered",
|
|
3172
|
+
"path": ["color", "background", "brand", "subtlest", "hovered"],
|
|
3173
|
+
"cleanName": "color.background.brand.subtlest.hovered"
|
|
3174
|
+
}, {
|
|
3175
|
+
"attributes": {
|
|
3176
|
+
"group": "paint",
|
|
3177
|
+
"state": "active",
|
|
3178
|
+
"introduced": "1.13.0",
|
|
3179
|
+
"description": "Pressed state of color.background.brand.subtlest"
|
|
3180
|
+
},
|
|
3181
|
+
"value": "#85B8FF",
|
|
3182
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3183
|
+
"isSource": true,
|
|
3184
|
+
"original": {
|
|
3185
|
+
"attributes": {
|
|
3186
|
+
"group": "paint",
|
|
3187
|
+
"state": "active",
|
|
3188
|
+
"introduced": "1.13.0",
|
|
3189
|
+
"description": "Pressed state of color.background.brand.subtlest"
|
|
3190
|
+
},
|
|
3191
|
+
"value": "Blue300"
|
|
3192
|
+
},
|
|
3193
|
+
"name": "color.background.brand.subtlest.pressed",
|
|
3194
|
+
"path": ["color", "background", "brand", "subtlest", "pressed"],
|
|
3195
|
+
"cleanName": "color.background.brand.subtlest.pressed"
|
|
3130
3196
|
}, {
|
|
3131
3197
|
"attributes": {
|
|
3132
3198
|
"group": "paint",
|
|
@@ -3154,7 +3220,7 @@ const tokens = [{
|
|
|
3154
3220
|
"group": "paint",
|
|
3155
3221
|
"state": "active",
|
|
3156
3222
|
"introduced": "0.6.0",
|
|
3157
|
-
"description": "Hovered state of color.background.brand.bold"
|
|
3223
|
+
"description": "Hovered state of color.background.brand.bold."
|
|
3158
3224
|
},
|
|
3159
3225
|
"value": "#0055CC",
|
|
3160
3226
|
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
@@ -3164,7 +3230,7 @@ const tokens = [{
|
|
|
3164
3230
|
"group": "paint",
|
|
3165
3231
|
"state": "active",
|
|
3166
3232
|
"introduced": "0.6.0",
|
|
3167
|
-
"description": "Hovered state of color.background.brand.bold"
|
|
3233
|
+
"description": "Hovered state of color.background.brand.bold."
|
|
3168
3234
|
},
|
|
3169
3235
|
"value": "Blue800"
|
|
3170
3236
|
},
|
|
@@ -3176,7 +3242,7 @@ const tokens = [{
|
|
|
3176
3242
|
"group": "paint",
|
|
3177
3243
|
"state": "active",
|
|
3178
3244
|
"introduced": "0.6.0",
|
|
3179
|
-
"description": "Pressed state of color.background.brand.bold"
|
|
3245
|
+
"description": "Pressed state of color.background.brand.bold."
|
|
3180
3246
|
},
|
|
3181
3247
|
"value": "#09326C",
|
|
3182
3248
|
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
@@ -3186,13 +3252,79 @@ const tokens = [{
|
|
|
3186
3252
|
"group": "paint",
|
|
3187
3253
|
"state": "active",
|
|
3188
3254
|
"introduced": "0.6.0",
|
|
3189
|
-
"description": "Pressed state of color.background.brand.bold"
|
|
3255
|
+
"description": "Pressed state of color.background.brand.bold."
|
|
3190
3256
|
},
|
|
3191
3257
|
"value": "Blue900"
|
|
3192
3258
|
},
|
|
3193
3259
|
"name": "color.background.brand.bold.pressed",
|
|
3194
3260
|
"path": ["color", "background", "brand", "bold", "pressed"],
|
|
3195
3261
|
"cleanName": "color.background.brand.bold.pressed"
|
|
3262
|
+
}, {
|
|
3263
|
+
"attributes": {
|
|
3264
|
+
"group": "paint",
|
|
3265
|
+
"state": "active",
|
|
3266
|
+
"introduced": "1.13.0",
|
|
3267
|
+
"description": "Use for the background of elements used to reinforce our brand, that need to stand out a lot."
|
|
3268
|
+
},
|
|
3269
|
+
"value": "#092957",
|
|
3270
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3271
|
+
"isSource": true,
|
|
3272
|
+
"original": {
|
|
3273
|
+
"attributes": {
|
|
3274
|
+
"group": "paint",
|
|
3275
|
+
"state": "active",
|
|
3276
|
+
"introduced": "1.13.0",
|
|
3277
|
+
"description": "Use for the background of elements used to reinforce our brand, that need to stand out a lot."
|
|
3278
|
+
},
|
|
3279
|
+
"value": "Blue1000"
|
|
3280
|
+
},
|
|
3281
|
+
"name": "color.background.brand.boldest.[default]",
|
|
3282
|
+
"path": ["color", "background", "brand", "boldest", "[default]"],
|
|
3283
|
+
"cleanName": "color.background.brand.boldest"
|
|
3284
|
+
}, {
|
|
3285
|
+
"attributes": {
|
|
3286
|
+
"group": "paint",
|
|
3287
|
+
"state": "active",
|
|
3288
|
+
"introduced": "1.13.0",
|
|
3289
|
+
"description": "Hovered state of color.background.brand.boldest."
|
|
3290
|
+
},
|
|
3291
|
+
"value": "#09326C",
|
|
3292
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3293
|
+
"isSource": true,
|
|
3294
|
+
"original": {
|
|
3295
|
+
"attributes": {
|
|
3296
|
+
"group": "paint",
|
|
3297
|
+
"state": "active",
|
|
3298
|
+
"introduced": "1.13.0",
|
|
3299
|
+
"description": "Hovered state of color.background.brand.boldest."
|
|
3300
|
+
},
|
|
3301
|
+
"value": "Blue900"
|
|
3302
|
+
},
|
|
3303
|
+
"name": "color.background.brand.boldest.hovered",
|
|
3304
|
+
"path": ["color", "background", "brand", "boldest", "hovered"],
|
|
3305
|
+
"cleanName": "color.background.brand.boldest.hovered"
|
|
3306
|
+
}, {
|
|
3307
|
+
"attributes": {
|
|
3308
|
+
"group": "paint",
|
|
3309
|
+
"state": "active",
|
|
3310
|
+
"introduced": "1.13.0",
|
|
3311
|
+
"description": "Pressed state of color.background.brand.boldest."
|
|
3312
|
+
},
|
|
3313
|
+
"value": "#0055CC",
|
|
3314
|
+
"filePath": "src/tokens/atlassian-light/color/background.tsx",
|
|
3315
|
+
"isSource": true,
|
|
3316
|
+
"original": {
|
|
3317
|
+
"attributes": {
|
|
3318
|
+
"group": "paint",
|
|
3319
|
+
"state": "active",
|
|
3320
|
+
"introduced": "1.13.0",
|
|
3321
|
+
"description": "Pressed state of color.background.brand.boldest."
|
|
3322
|
+
},
|
|
3323
|
+
"value": "Blue800"
|
|
3324
|
+
},
|
|
3325
|
+
"name": "color.background.brand.boldest.pressed",
|
|
3326
|
+
"path": ["color", "background", "brand", "boldest", "pressed"],
|
|
3327
|
+
"cleanName": "color.background.brand.boldest.pressed"
|
|
3196
3328
|
}, {
|
|
3197
3329
|
"attributes": {
|
|
3198
3330
|
"group": "paint",
|
package/dist/es2019/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const THEME_DATA_ATTRIBUTE = 'data-theme';
|
|
2
2
|
export const COLOR_MODE_ATTRIBUTE = 'data-color-mode';
|
|
3
|
+
export const CUSTOM_THEME_ATTRIBUTE = 'data-custom-theme';
|
|
3
4
|
export const DEFAULT_THEME = 'light';
|
|
4
5
|
export const CSS_PREFIX = 'ds';
|
|
5
6
|
export const CSS_VAR_FULL = ['opacity', 'font', 'space', 'border'];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
|
|
2
|
+
import { themeStateDefaults } from './set-global-theme';
|
|
3
|
+
import { limitSizeOfCustomStyleElements, reduceTokenMap } from './utils/custom-theme-loading-utils';
|
|
4
|
+
import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
|
|
5
|
+
import { hash } from './utils/hash';
|
|
6
|
+
export const CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param themeSchema The schema of available themes
|
|
10
|
+
* @returns a string with the CSS for the custom theme
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
14
|
+
* Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
17
|
+
* @param {string} themeState.colorMode Determines which color theme is applied
|
|
18
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
19
|
+
*
|
|
20
|
+
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
21
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
22
|
+
*/
|
|
23
|
+
export async function getCustomThemeStyles(themeState) {
|
|
24
|
+
var _themeState$UNSAFE_th;
|
|
25
|
+
const brandColor = themeState === null || themeState === void 0 ? void 0 : (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
|
|
26
|
+
const mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
|
|
27
|
+
const optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
28
|
+
const uniqueId = hash(optionString);
|
|
29
|
+
const themeRamp = generateColors(brandColor);
|
|
30
|
+
|
|
31
|
+
// outputs object to generate to CSS from
|
|
32
|
+
const themes = [];
|
|
33
|
+
const tokenMaps = generateTokenMapWithContrastCheck(brandColor, mode, themeRamp);
|
|
34
|
+
if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
|
|
35
|
+
// Light mode theming
|
|
36
|
+
themes.push({
|
|
37
|
+
id: 'light',
|
|
38
|
+
attrs: {
|
|
39
|
+
'data-theme': 'light',
|
|
40
|
+
'data-custom-theme': uniqueId
|
|
41
|
+
},
|
|
42
|
+
css: `
|
|
43
|
+
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="light"][data-theme~="light:light"] {
|
|
44
|
+
/* Branded tokens */
|
|
45
|
+
${reduceTokenMap(tokenMaps.light, themeRamp)}
|
|
46
|
+
}`
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
50
|
+
// Dark mode theming
|
|
51
|
+
themes.push({
|
|
52
|
+
id: 'dark',
|
|
53
|
+
attrs: {
|
|
54
|
+
'data-theme': 'dark',
|
|
55
|
+
'data-custom-theme': uniqueId
|
|
56
|
+
},
|
|
57
|
+
css: `
|
|
58
|
+
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][data-theme~="dark:dark"] {
|
|
59
|
+
/* Branded tokens */
|
|
60
|
+
${reduceTokenMap(tokenMaps.dark, themeRamp)}
|
|
61
|
+
}`
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return themes;
|
|
65
|
+
}
|
|
66
|
+
export async function loadAndAppendCustomThemeCss(themeState) {
|
|
67
|
+
getCustomThemeStyles(themeState).then(themes => {
|
|
68
|
+
limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
|
|
69
|
+
themes.map(theme => {
|
|
70
|
+
const styleTag = document.createElement('style');
|
|
71
|
+
document.head.appendChild(styleTag);
|
|
72
|
+
styleTag.dataset.theme = theme.attrs['data-theme'];
|
|
73
|
+
styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
|
|
74
|
+
styleTag.textContent = theme.css;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
const name = "@atlaskit/tokens";
|
|
4
|
-
const version = "
|
|
4
|
+
const version = "0.0.0-development";
|
|
5
5
|
/**
|
|
6
6
|
* Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
|
|
7
7
|
* resulting CSS Custom Property.
|
package/dist/es2019/get-token.js
CHANGED
|
@@ -2,7 +2,7 @@ import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
import { TOKEN_NOT_FOUND_CSS_VAR } from './constants';
|
|
4
4
|
const name = "@atlaskit/tokens";
|
|
5
|
-
const version = "
|
|
5
|
+
const version = "0.0.0-development";
|
|
6
6
|
/**
|
|
7
7
|
* Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
|
|
8
8
|
* This should be used to implement design decisions throughout your application.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { bind } from 'bind-event-listener';
|
|
2
2
|
import noop from '@atlaskit/ds-lib/noop';
|
|
3
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
4
|
+
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
5
5
|
import { themeIdsWithOverrides } from './theme-config';
|
|
6
|
+
import { isValidBrandHex } from './utils/color-utils';
|
|
7
|
+
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
8
|
+
import { hash } from './utils/hash';
|
|
6
9
|
import { loadAndAppendThemeCss, loadThemeCss } from './utils/theme-loading';
|
|
7
10
|
import { themeObjectToString } from './utils/theme-state-transformer';
|
|
8
11
|
|
|
@@ -13,13 +16,14 @@ const isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in w
|
|
|
13
16
|
const darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
|
14
17
|
const darkModeMql = isMatchMediaAvailable && window.matchMedia(darkModeMediaQuery);
|
|
15
18
|
let unbindThemeChangeListener = noop;
|
|
16
|
-
const themeStateDefaults = {
|
|
19
|
+
export const themeStateDefaults = {
|
|
17
20
|
colorMode: 'auto',
|
|
18
21
|
dark: 'dark',
|
|
19
22
|
light: 'light',
|
|
20
23
|
shape: undefined,
|
|
21
24
|
spacing: undefined,
|
|
22
|
-
typography: undefined
|
|
25
|
+
typography: undefined,
|
|
26
|
+
UNSAFE_themeOptions: undefined
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
/**
|
|
@@ -69,6 +73,7 @@ const getThemePreferences = themeState => {
|
|
|
69
73
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
70
74
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
71
75
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
76
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
72
77
|
* @param {function} themeLoader Callback function used to override the default theme loading functionality.
|
|
73
78
|
*
|
|
74
79
|
* @returns A Promise of an unbind function, that can be used to stop listening for changes to system theme.
|
|
@@ -84,7 +89,8 @@ const setGlobalTheme = async ({
|
|
|
84
89
|
light = themeStateDefaults['light'],
|
|
85
90
|
shape = themeStateDefaults['shape'],
|
|
86
91
|
spacing = themeStateDefaults['spacing'],
|
|
87
|
-
typography = themeStateDefaults['typography']
|
|
92
|
+
typography = themeStateDefaults['typography'],
|
|
93
|
+
UNSAFE_themeOptions = themeStateDefaults['UNSAFE_themeOptions']
|
|
88
94
|
} = {}, themeLoader) => {
|
|
89
95
|
const themePreferences = getThemePreferences({
|
|
90
96
|
colorMode,
|
|
@@ -95,7 +101,25 @@ const setGlobalTheme = async ({
|
|
|
95
101
|
typography
|
|
96
102
|
});
|
|
97
103
|
const loadingStrategy = themeLoader ? themeLoader : loadAndAppendThemeCss;
|
|
98
|
-
await Promise.all(themePreferences.map(async themeId => await loadingStrategy(themeId)))
|
|
104
|
+
await Promise.all([...themePreferences.map(async themeId => await loadingStrategy(themeId)), (async () => {
|
|
105
|
+
if (!themeLoader && UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions === null || UNSAFE_themeOptions === void 0 ? void 0 : UNSAFE_themeOptions.brandColor)) {
|
|
106
|
+
const mode = colorMode || themeStateDefaults['colorMode'];
|
|
107
|
+
const attrOfMissingCustomStyles = findMissingCustomStyleElements(UNSAFE_themeOptions, mode);
|
|
108
|
+
if (attrOfMissingCustomStyles.length === 0) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const {
|
|
112
|
+
loadAndAppendCustomThemeCss
|
|
113
|
+
} = await import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
114
|
+
'./custom-theme');
|
|
115
|
+
await loadAndAppendCustomThemeCss({
|
|
116
|
+
colorMode: attrOfMissingCustomStyles.length === 2 ? 'auto' :
|
|
117
|
+
// only load the missing custom theme styles
|
|
118
|
+
attrOfMissingCustomStyles[0],
|
|
119
|
+
UNSAFE_themeOptions
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
})()]);
|
|
99
123
|
if (colorMode === 'auto' && darkModeMql) {
|
|
100
124
|
colorMode = darkModeMql.matches ? 'dark' : 'light';
|
|
101
125
|
// Add an event listener for changes to the system theme.
|
|
@@ -113,7 +137,8 @@ const setGlobalTheme = async ({
|
|
|
113
137
|
light,
|
|
114
138
|
shape,
|
|
115
139
|
spacing,
|
|
116
|
-
typography
|
|
140
|
+
typography,
|
|
141
|
+
UNSAFE_themeOptions: themeLoader ? undefined : UNSAFE_themeOptions
|
|
117
142
|
});
|
|
118
143
|
Object.entries(themeAttributes).forEach(([key, value]) => {
|
|
119
144
|
document.documentElement.setAttribute(key, value);
|
|
@@ -131,9 +156,10 @@ const setGlobalTheme = async ({
|
|
|
131
156
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
132
157
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
133
158
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
159
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
134
160
|
*
|
|
135
161
|
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
136
|
-
* If an error is encountered while loading themes, the themes
|
|
162
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
137
163
|
*/
|
|
138
164
|
export const getThemeStyles = async preferences => {
|
|
139
165
|
let themePreferences;
|
|
@@ -149,7 +175,7 @@ export const getThemeStyles = async preferences => {
|
|
|
149
175
|
typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
|
|
150
176
|
});
|
|
151
177
|
}
|
|
152
|
-
const results = await Promise.all(themePreferences.map(async themeId => {
|
|
178
|
+
const results = await Promise.all([...themePreferences.map(async themeId => {
|
|
153
179
|
try {
|
|
154
180
|
const css = await loadThemeCss(themeId);
|
|
155
181
|
return {
|
|
@@ -160,11 +186,31 @@ export const getThemeStyles = async preferences => {
|
|
|
160
186
|
css
|
|
161
187
|
};
|
|
162
188
|
} catch {
|
|
163
|
-
// Return
|
|
189
|
+
// Return undefined if there's an error loading it, will be filtered out later.
|
|
164
190
|
return undefined;
|
|
165
191
|
}
|
|
166
|
-
})
|
|
167
|
-
|
|
192
|
+
}),
|
|
193
|
+
// Add custom themes if they're present
|
|
194
|
+
(async () => {
|
|
195
|
+
var _preferences$UNSAFE_t;
|
|
196
|
+
if (preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && isValidBrandHex(preferences === null || preferences === void 0 ? void 0 : (_preferences$UNSAFE_t = preferences.UNSAFE_themeOptions) === null || _preferences$UNSAFE_t === void 0 ? void 0 : _preferences$UNSAFE_t.brandColor)) {
|
|
197
|
+
try {
|
|
198
|
+
const {
|
|
199
|
+
getCustomThemeStyles
|
|
200
|
+
} = await import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
201
|
+
'./custom-theme');
|
|
202
|
+
const customThemeStyles = await getCustomThemeStyles({
|
|
203
|
+
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
204
|
+
UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
|
|
205
|
+
});
|
|
206
|
+
return customThemeStyles;
|
|
207
|
+
} catch {
|
|
208
|
+
// Return undefined if there's an error loading it, will be filtered out later.
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})()]);
|
|
213
|
+
return results.flat().filter(theme => theme !== undefined);
|
|
168
214
|
};
|
|
169
215
|
|
|
170
216
|
/**
|
|
@@ -177,6 +223,7 @@ export const getThemeStyles = async preferences => {
|
|
|
177
223
|
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
178
224
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
179
225
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
226
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
180
227
|
*
|
|
181
228
|
* @returns {Object} Object of HTML attributes to be applied to the document root
|
|
182
229
|
*/
|
|
@@ -186,7 +233,8 @@ export const getThemeHtmlAttrs = ({
|
|
|
186
233
|
light = themeStateDefaults['light'],
|
|
187
234
|
shape = themeStateDefaults['shape'],
|
|
188
235
|
spacing = themeStateDefaults['spacing'],
|
|
189
|
-
typography = themeStateDefaults['typography']
|
|
236
|
+
typography = themeStateDefaults['typography'],
|
|
237
|
+
UNSAFE_themeOptions = themeStateDefaults['UNSAFE_themeOptions']
|
|
190
238
|
} = {}) => {
|
|
191
239
|
let themePreferences = {
|
|
192
240
|
dark,
|
|
@@ -207,10 +255,16 @@ export const getThemeHtmlAttrs = ({
|
|
|
207
255
|
};
|
|
208
256
|
}
|
|
209
257
|
const themeAttribute = themeObjectToString(themePreferences);
|
|
210
|
-
|
|
258
|
+
const result = {
|
|
211
259
|
[THEME_DATA_ATTRIBUTE]: themeAttribute,
|
|
212
260
|
[COLOR_MODE_ATTRIBUTE]: colorMode === 'auto' ? defaultColorMode : colorMode
|
|
213
261
|
};
|
|
262
|
+
if (UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions.brandColor)) {
|
|
263
|
+
const optionString = JSON.stringify(UNSAFE_themeOptions);
|
|
264
|
+
const uniqueId = hash(optionString);
|
|
265
|
+
result[CUSTOM_THEME_ATTRIBUTE] = uniqueId;
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
214
268
|
};
|
|
215
269
|
|
|
216
270
|
/**
|