@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,7 +1,7 @@
|
|
|
1
1
|
import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
var name = "@atlaskit/tokens";
|
|
4
|
-
var version = "
|
|
4
|
+
var 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/esm/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
|
var name = "@atlaskit/tokens";
|
|
5
|
-
var version = "
|
|
5
|
+
var 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.
|
|
@@ -6,8 +6,11 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
9
|
+
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
10
10
|
import { themeIdsWithOverrides } from './theme-config';
|
|
11
|
+
import { isValidBrandHex } from './utils/color-utils';
|
|
12
|
+
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
13
|
+
import { hash } from './utils/hash';
|
|
11
14
|
import { loadAndAppendThemeCss, loadThemeCss } from './utils/theme-loading';
|
|
12
15
|
import { themeObjectToString } from './utils/theme-state-transformer';
|
|
13
16
|
|
|
@@ -18,13 +21,14 @@ var isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in win
|
|
|
18
21
|
var darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
|
19
22
|
var darkModeMql = isMatchMediaAvailable && window.matchMedia(darkModeMediaQuery);
|
|
20
23
|
var unbindThemeChangeListener = noop;
|
|
21
|
-
var themeStateDefaults = {
|
|
24
|
+
export var themeStateDefaults = {
|
|
22
25
|
colorMode: 'auto',
|
|
23
26
|
dark: 'dark',
|
|
24
27
|
light: 'light',
|
|
25
28
|
shape: undefined,
|
|
26
29
|
spacing: undefined,
|
|
27
|
-
typography: undefined
|
|
30
|
+
typography: undefined,
|
|
31
|
+
UNSAFE_themeOptions: undefined
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
/**
|
|
@@ -72,6 +76,7 @@ var getThemePreferences = function getThemePreferences(themeState) {
|
|
|
72
76
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
73
77
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
74
78
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
79
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
75
80
|
* @param {function} themeLoader Callback function used to override the default theme loading functionality.
|
|
76
81
|
*
|
|
77
82
|
* @returns A Promise of an unbind function, that can be used to stop listening for changes to system theme.
|
|
@@ -82,7 +87,7 @@ var getThemePreferences = function getThemePreferences(themeState) {
|
|
|
82
87
|
* ```
|
|
83
88
|
*/
|
|
84
89
|
var setGlobalTheme = /*#__PURE__*/function () {
|
|
85
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
90
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
86
91
|
var _ref2,
|
|
87
92
|
_ref2$colorMode,
|
|
88
93
|
colorMode,
|
|
@@ -96,16 +101,18 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
96
101
|
spacing,
|
|
97
102
|
_ref2$typography,
|
|
98
103
|
typography,
|
|
104
|
+
_ref2$UNSAFE_themeOpt,
|
|
105
|
+
UNSAFE_themeOptions,
|
|
99
106
|
themeLoader,
|
|
100
107
|
themePreferences,
|
|
101
108
|
loadingStrategy,
|
|
102
109
|
themeAttributes,
|
|
103
|
-
|
|
104
|
-
return _regeneratorRuntime.wrap(function
|
|
105
|
-
while (1) switch (
|
|
110
|
+
_args3 = arguments;
|
|
111
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
112
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
106
113
|
case 0:
|
|
107
|
-
_ref2 =
|
|
108
|
-
themeLoader =
|
|
114
|
+
_ref2 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref2$colorMode = _ref2.colorMode, colorMode = _ref2$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref2$colorMode, _ref2$dark = _ref2.dark, dark = _ref2$dark === void 0 ? themeStateDefaults['dark'] : _ref2$dark, _ref2$light = _ref2.light, light = _ref2$light === void 0 ? themeStateDefaults['light'] : _ref2$light, _ref2$shape = _ref2.shape, shape = _ref2$shape === void 0 ? themeStateDefaults['shape'] : _ref2$shape, _ref2$spacing = _ref2.spacing, spacing = _ref2$spacing === void 0 ? themeStateDefaults['spacing'] : _ref2$spacing, _ref2$typography = _ref2.typography, typography = _ref2$typography === void 0 ? themeStateDefaults['typography'] : _ref2$typography, _ref2$UNSAFE_themeOpt = _ref2.UNSAFE_themeOptions, UNSAFE_themeOptions = _ref2$UNSAFE_themeOpt === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref2$UNSAFE_themeOpt;
|
|
115
|
+
themeLoader = _args3.length > 1 ? _args3[1] : undefined;
|
|
109
116
|
themePreferences = getThemePreferences({
|
|
110
117
|
colorMode: colorMode,
|
|
111
118
|
dark: dark,
|
|
@@ -115,8 +122,8 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
115
122
|
typography: typography
|
|
116
123
|
});
|
|
117
124
|
loadingStrategy = themeLoader ? themeLoader : loadAndAppendThemeCss;
|
|
118
|
-
|
|
119
|
-
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
125
|
+
_context3.next = 6;
|
|
126
|
+
return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
|
|
120
127
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
121
128
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
122
129
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -134,7 +141,42 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
134
141
|
return function (_x) {
|
|
135
142
|
return _ref3.apply(this, arguments);
|
|
136
143
|
};
|
|
137
|
-
}()))
|
|
144
|
+
}())), [_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
145
|
+
var mode, attrOfMissingCustomStyles, _yield$import, loadAndAppendCustomThemeCss;
|
|
146
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
if (!(!themeLoader && UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions === null || UNSAFE_themeOptions === void 0 ? void 0 : UNSAFE_themeOptions.brandColor))) {
|
|
150
|
+
_context2.next = 11;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
mode = colorMode || themeStateDefaults['colorMode'];
|
|
154
|
+
attrOfMissingCustomStyles = findMissingCustomStyleElements(UNSAFE_themeOptions, mode);
|
|
155
|
+
if (!(attrOfMissingCustomStyles.length === 0)) {
|
|
156
|
+
_context2.next = 5;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return _context2.abrupt("return", false);
|
|
160
|
+
case 5:
|
|
161
|
+
_context2.next = 7;
|
|
162
|
+
return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
163
|
+
'./custom-theme');
|
|
164
|
+
case 7:
|
|
165
|
+
_yield$import = _context2.sent;
|
|
166
|
+
loadAndAppendCustomThemeCss = _yield$import.loadAndAppendCustomThemeCss;
|
|
167
|
+
_context2.next = 11;
|
|
168
|
+
return loadAndAppendCustomThemeCss({
|
|
169
|
+
colorMode: attrOfMissingCustomStyles.length === 2 ? 'auto' :
|
|
170
|
+
// only load the missing custom theme styles
|
|
171
|
+
attrOfMissingCustomStyles[0],
|
|
172
|
+
UNSAFE_themeOptions: UNSAFE_themeOptions
|
|
173
|
+
});
|
|
174
|
+
case 11:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context2.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee2);
|
|
179
|
+
}))()]));
|
|
138
180
|
case 6:
|
|
139
181
|
if (colorMode === 'auto' && darkModeMql) {
|
|
140
182
|
colorMode = darkModeMql.matches ? 'dark' : 'light';
|
|
@@ -153,20 +195,21 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
153
195
|
light: light,
|
|
154
196
|
shape: shape,
|
|
155
197
|
spacing: spacing,
|
|
156
|
-
typography: typography
|
|
198
|
+
typography: typography,
|
|
199
|
+
UNSAFE_themeOptions: themeLoader ? undefined : UNSAFE_themeOptions
|
|
157
200
|
});
|
|
158
|
-
Object.entries(themeAttributes).forEach(function (
|
|
159
|
-
var
|
|
160
|
-
key =
|
|
161
|
-
value =
|
|
201
|
+
Object.entries(themeAttributes).forEach(function (_ref5) {
|
|
202
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
203
|
+
key = _ref6[0],
|
|
204
|
+
value = _ref6[1];
|
|
162
205
|
document.documentElement.setAttribute(key, value);
|
|
163
206
|
});
|
|
164
|
-
return
|
|
207
|
+
return _context3.abrupt("return", unbindThemeChangeListener);
|
|
165
208
|
case 10:
|
|
166
209
|
case "end":
|
|
167
|
-
return
|
|
210
|
+
return _context3.stop();
|
|
168
211
|
}
|
|
169
|
-
},
|
|
212
|
+
}, _callee3);
|
|
170
213
|
}));
|
|
171
214
|
return function setGlobalTheme() {
|
|
172
215
|
return _ref.apply(this, arguments);
|
|
@@ -183,15 +226,16 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
183
226
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
184
227
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
185
228
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
229
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
186
230
|
*
|
|
187
231
|
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
188
|
-
* If an error is encountered while loading themes, the themes
|
|
232
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
189
233
|
*/
|
|
190
234
|
export var getThemeStyles = /*#__PURE__*/function () {
|
|
191
|
-
var
|
|
235
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(preferences) {
|
|
192
236
|
var themePreferences, results;
|
|
193
|
-
return _regeneratorRuntime.wrap(function
|
|
194
|
-
while (1) switch (
|
|
237
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
238
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
195
239
|
case 0:
|
|
196
240
|
if (preferences === 'all') {
|
|
197
241
|
themePreferences = themeIdsWithOverrides;
|
|
@@ -205,19 +249,19 @@ export var getThemeStyles = /*#__PURE__*/function () {
|
|
|
205
249
|
typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
|
|
206
250
|
});
|
|
207
251
|
}
|
|
208
|
-
|
|
209
|
-
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
210
|
-
var
|
|
252
|
+
_context6.next = 3;
|
|
253
|
+
return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
|
|
254
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(themeId) {
|
|
211
255
|
var css;
|
|
212
|
-
return _regeneratorRuntime.wrap(function
|
|
213
|
-
while (1) switch (
|
|
256
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
257
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
214
258
|
case 0:
|
|
215
|
-
|
|
216
|
-
|
|
259
|
+
_context4.prev = 0;
|
|
260
|
+
_context4.next = 3;
|
|
217
261
|
return loadThemeCss(themeId);
|
|
218
262
|
case 3:
|
|
219
|
-
css =
|
|
220
|
-
return
|
|
263
|
+
css = _context4.sent;
|
|
264
|
+
return _context4.abrupt("return", {
|
|
221
265
|
id: themeId,
|
|
222
266
|
attrs: {
|
|
223
267
|
'data-theme': themeId
|
|
@@ -225,32 +269,68 @@ export var getThemeStyles = /*#__PURE__*/function () {
|
|
|
225
269
|
css: css
|
|
226
270
|
});
|
|
227
271
|
case 7:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return
|
|
272
|
+
_context4.prev = 7;
|
|
273
|
+
_context4.t0 = _context4["catch"](0);
|
|
274
|
+
return _context4.abrupt("return", undefined);
|
|
231
275
|
case 10:
|
|
232
276
|
case "end":
|
|
233
|
-
return
|
|
277
|
+
return _context4.stop();
|
|
234
278
|
}
|
|
235
|
-
},
|
|
279
|
+
}, _callee4, null, [[0, 7]]);
|
|
236
280
|
}));
|
|
237
281
|
return function (_x3) {
|
|
238
|
-
return
|
|
282
|
+
return _ref8.apply(this, arguments);
|
|
239
283
|
};
|
|
240
|
-
}()))
|
|
284
|
+
}())), [
|
|
285
|
+
// Add custom themes if they're present
|
|
286
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
287
|
+
var _preferences$UNSAFE_t;
|
|
288
|
+
var _yield$import2, getCustomThemeStyles, customThemeStyles;
|
|
289
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
290
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
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))) {
|
|
293
|
+
_context5.next = 15;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
_context5.prev = 1;
|
|
297
|
+
_context5.next = 4;
|
|
298
|
+
return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
299
|
+
'./custom-theme');
|
|
300
|
+
case 4:
|
|
301
|
+
_yield$import2 = _context5.sent;
|
|
302
|
+
getCustomThemeStyles = _yield$import2.getCustomThemeStyles;
|
|
303
|
+
_context5.next = 8;
|
|
304
|
+
return getCustomThemeStyles({
|
|
305
|
+
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
306
|
+
UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
|
|
307
|
+
});
|
|
308
|
+
case 8:
|
|
309
|
+
customThemeStyles = _context5.sent;
|
|
310
|
+
return _context5.abrupt("return", customThemeStyles);
|
|
311
|
+
case 12:
|
|
312
|
+
_context5.prev = 12;
|
|
313
|
+
_context5.t0 = _context5["catch"](1);
|
|
314
|
+
return _context5.abrupt("return", undefined);
|
|
315
|
+
case 15:
|
|
316
|
+
case "end":
|
|
317
|
+
return _context5.stop();
|
|
318
|
+
}
|
|
319
|
+
}, _callee5, null, [[1, 12]]);
|
|
320
|
+
}))()]));
|
|
241
321
|
case 3:
|
|
242
|
-
results =
|
|
243
|
-
return
|
|
322
|
+
results = _context6.sent;
|
|
323
|
+
return _context6.abrupt("return", results.flat().filter(function (theme) {
|
|
244
324
|
return theme !== undefined;
|
|
245
325
|
}));
|
|
246
326
|
case 5:
|
|
247
327
|
case "end":
|
|
248
|
-
return
|
|
328
|
+
return _context6.stop();
|
|
249
329
|
}
|
|
250
|
-
},
|
|
330
|
+
}, _callee6);
|
|
251
331
|
}));
|
|
252
332
|
return function getThemeStyles(_x2) {
|
|
253
|
-
return
|
|
333
|
+
return _ref7.apply(this, arguments);
|
|
254
334
|
};
|
|
255
335
|
}();
|
|
256
336
|
|
|
@@ -264,24 +344,27 @@ export var getThemeStyles = /*#__PURE__*/function () {
|
|
|
264
344
|
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
265
345
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
266
346
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
347
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
267
348
|
*
|
|
268
349
|
* @returns {Object} Object of HTML attributes to be applied to the document root
|
|
269
350
|
*/
|
|
270
351
|
export var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
colorMode =
|
|
275
|
-
|
|
276
|
-
dark =
|
|
277
|
-
|
|
278
|
-
light =
|
|
279
|
-
|
|
280
|
-
shape =
|
|
281
|
-
|
|
282
|
-
spacing =
|
|
283
|
-
|
|
284
|
-
typography =
|
|
352
|
+
var _result;
|
|
353
|
+
var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
354
|
+
_ref10$colorMode = _ref10.colorMode,
|
|
355
|
+
colorMode = _ref10$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref10$colorMode,
|
|
356
|
+
_ref10$dark = _ref10.dark,
|
|
357
|
+
dark = _ref10$dark === void 0 ? themeStateDefaults['dark'] : _ref10$dark,
|
|
358
|
+
_ref10$light = _ref10.light,
|
|
359
|
+
light = _ref10$light === void 0 ? themeStateDefaults['light'] : _ref10$light,
|
|
360
|
+
_ref10$shape = _ref10.shape,
|
|
361
|
+
shape = _ref10$shape === void 0 ? themeStateDefaults['shape'] : _ref10$shape,
|
|
362
|
+
_ref10$spacing = _ref10.spacing,
|
|
363
|
+
spacing = _ref10$spacing === void 0 ? themeStateDefaults['spacing'] : _ref10$spacing,
|
|
364
|
+
_ref10$typography = _ref10.typography,
|
|
365
|
+
typography = _ref10$typography === void 0 ? themeStateDefaults['typography'] : _ref10$typography,
|
|
366
|
+
_ref10$UNSAFE_themeOp = _ref10.UNSAFE_themeOptions,
|
|
367
|
+
UNSAFE_themeOptions = _ref10$UNSAFE_themeOp === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref10$UNSAFE_themeOp;
|
|
285
368
|
var themePreferences = {
|
|
286
369
|
dark: dark,
|
|
287
370
|
light: light,
|
|
@@ -301,7 +384,13 @@ export var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
|
|
|
301
384
|
};
|
|
302
385
|
}
|
|
303
386
|
var themeAttribute = themeObjectToString(themePreferences);
|
|
304
|
-
|
|
387
|
+
var result = (_result = {}, _defineProperty(_result, THEME_DATA_ATTRIBUTE, themeAttribute), _defineProperty(_result, COLOR_MODE_ATTRIBUTE, colorMode === 'auto' ? defaultColorMode : colorMode), _result);
|
|
388
|
+
if (UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions.brandColor)) {
|
|
389
|
+
var optionString = JSON.stringify(UNSAFE_themeOptions);
|
|
390
|
+
var uniqueId = hash(optionString);
|
|
391
|
+
result[CUSTOM_THEME_ATTRIBUTE] = uniqueId;
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
305
394
|
};
|
|
306
395
|
|
|
307
396
|
/**
|
|
@@ -82,6 +82,17 @@ var color = {
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
brand: {
|
|
85
|
+
subtlest: {
|
|
86
|
+
'[default]': {
|
|
87
|
+
value: 'Blue1000'
|
|
88
|
+
},
|
|
89
|
+
hovered: {
|
|
90
|
+
value: 'Blue900'
|
|
91
|
+
},
|
|
92
|
+
pressed: {
|
|
93
|
+
value: 'Blue800'
|
|
94
|
+
}
|
|
95
|
+
},
|
|
85
96
|
bold: {
|
|
86
97
|
'[default]': {
|
|
87
98
|
value: 'Blue400'
|
|
@@ -92,6 +103,17 @@ var color = {
|
|
|
92
103
|
pressed: {
|
|
93
104
|
value: 'Blue200'
|
|
94
105
|
}
|
|
106
|
+
},
|
|
107
|
+
boldest: {
|
|
108
|
+
'[default]': {
|
|
109
|
+
value: 'Blue100'
|
|
110
|
+
},
|
|
111
|
+
hovered: {
|
|
112
|
+
value: 'Blue200'
|
|
113
|
+
},
|
|
114
|
+
pressed: {
|
|
115
|
+
value: 'Blue300'
|
|
116
|
+
}
|
|
95
117
|
}
|
|
96
118
|
},
|
|
97
119
|
selected: {
|
|
@@ -81,6 +81,17 @@ var color = {
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
brand: {
|
|
84
|
+
subtlest: {
|
|
85
|
+
'[default]': {
|
|
86
|
+
value: 'B500'
|
|
87
|
+
},
|
|
88
|
+
hovered: {
|
|
89
|
+
value: 'B400'
|
|
90
|
+
},
|
|
91
|
+
pressed: {
|
|
92
|
+
value: 'B500'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
84
95
|
bold: {
|
|
85
96
|
'[default]': {
|
|
86
97
|
value: 'B400'
|
|
@@ -91,6 +102,17 @@ var color = {
|
|
|
91
102
|
pressed: {
|
|
92
103
|
value: 'B500'
|
|
93
104
|
}
|
|
105
|
+
},
|
|
106
|
+
boldest: {
|
|
107
|
+
'[default]': {
|
|
108
|
+
value: 'B75'
|
|
109
|
+
},
|
|
110
|
+
hovered: {
|
|
111
|
+
value: 'B50'
|
|
112
|
+
},
|
|
113
|
+
pressed: {
|
|
114
|
+
value: 'B100'
|
|
115
|
+
}
|
|
94
116
|
}
|
|
95
117
|
},
|
|
96
118
|
selected: {
|
|
@@ -81,6 +81,17 @@ var color = {
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
brand: {
|
|
84
|
+
subtlest: {
|
|
85
|
+
'[default]': {
|
|
86
|
+
value: 'B75'
|
|
87
|
+
},
|
|
88
|
+
hovered: {
|
|
89
|
+
value: 'B50'
|
|
90
|
+
},
|
|
91
|
+
pressed: {
|
|
92
|
+
value: 'B100'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
84
95
|
bold: {
|
|
85
96
|
'[default]': {
|
|
86
97
|
value: 'B400'
|
|
@@ -91,6 +102,17 @@ var color = {
|
|
|
91
102
|
pressed: {
|
|
92
103
|
value: 'B500'
|
|
93
104
|
}
|
|
105
|
+
},
|
|
106
|
+
boldest: {
|
|
107
|
+
'[default]': {
|
|
108
|
+
value: 'B500'
|
|
109
|
+
},
|
|
110
|
+
hovered: {
|
|
111
|
+
value: 'B400'
|
|
112
|
+
},
|
|
113
|
+
pressed: {
|
|
114
|
+
value: 'B500'
|
|
115
|
+
}
|
|
94
116
|
}
|
|
95
117
|
},
|
|
96
118
|
selected: {
|
|
@@ -81,6 +81,17 @@ var color = {
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
brand: {
|
|
84
|
+
subtlest: {
|
|
85
|
+
'[default]': {
|
|
86
|
+
value: 'Blue100'
|
|
87
|
+
},
|
|
88
|
+
hovered: {
|
|
89
|
+
value: 'Blue200'
|
|
90
|
+
},
|
|
91
|
+
pressed: {
|
|
92
|
+
value: 'Blue300'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
84
95
|
bold: {
|
|
85
96
|
'[default]': {
|
|
86
97
|
value: 'Blue700'
|
|
@@ -91,6 +102,17 @@ var color = {
|
|
|
91
102
|
pressed: {
|
|
92
103
|
value: 'Blue900'
|
|
93
104
|
}
|
|
105
|
+
},
|
|
106
|
+
boldest: {
|
|
107
|
+
'[default]': {
|
|
108
|
+
value: 'Blue1000'
|
|
109
|
+
},
|
|
110
|
+
hovered: {
|
|
111
|
+
value: 'Blue900'
|
|
112
|
+
},
|
|
113
|
+
pressed: {
|
|
114
|
+
value: 'Blue800'
|
|
115
|
+
}
|
|
94
116
|
}
|
|
95
117
|
},
|
|
96
118
|
selected: {
|
|
@@ -170,6 +170,32 @@ var color = {
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
brand: {
|
|
173
|
+
subtlest: {
|
|
174
|
+
'[default]': {
|
|
175
|
+
attributes: {
|
|
176
|
+
group: 'paint',
|
|
177
|
+
state: 'active',
|
|
178
|
+
introduced: '1.13.0',
|
|
179
|
+
description: 'Use for the background of elements used to reinforce our brand, but with less emphasis.'
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
hovered: {
|
|
183
|
+
attributes: {
|
|
184
|
+
group: 'paint',
|
|
185
|
+
state: 'active',
|
|
186
|
+
introduced: '1.13.0',
|
|
187
|
+
description: 'Hovered state of color.background.brand.subtlest.'
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
pressed: {
|
|
191
|
+
attributes: {
|
|
192
|
+
group: 'paint',
|
|
193
|
+
state: 'active',
|
|
194
|
+
introduced: '1.13.0',
|
|
195
|
+
description: 'Pressed state of color.background.brand.subtlest'
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
173
199
|
bold: {
|
|
174
200
|
'[default]': {
|
|
175
201
|
attributes: {
|
|
@@ -184,7 +210,7 @@ var color = {
|
|
|
184
210
|
group: 'paint',
|
|
185
211
|
state: 'active',
|
|
186
212
|
introduced: '0.6.0',
|
|
187
|
-
description: 'Hovered state of color.background.brand.bold'
|
|
213
|
+
description: 'Hovered state of color.background.brand.bold.'
|
|
188
214
|
}
|
|
189
215
|
},
|
|
190
216
|
pressed: {
|
|
@@ -192,7 +218,33 @@ var color = {
|
|
|
192
218
|
group: 'paint',
|
|
193
219
|
state: 'active',
|
|
194
220
|
introduced: '0.6.0',
|
|
195
|
-
description: 'Pressed state of color.background.brand.bold'
|
|
221
|
+
description: 'Pressed state of color.background.brand.bold.'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
boldest: {
|
|
226
|
+
'[default]': {
|
|
227
|
+
attributes: {
|
|
228
|
+
group: 'paint',
|
|
229
|
+
state: 'active',
|
|
230
|
+
introduced: '1.13.0',
|
|
231
|
+
description: 'Use for the background of elements used to reinforce our brand, that need to stand out a lot.'
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
hovered: {
|
|
235
|
+
attributes: {
|
|
236
|
+
group: 'paint',
|
|
237
|
+
state: 'active',
|
|
238
|
+
introduced: '1.13.0',
|
|
239
|
+
description: 'Hovered state of color.background.brand.boldest.'
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
pressed: {
|
|
243
|
+
attributes: {
|
|
244
|
+
group: 'paint',
|
|
245
|
+
state: 'active',
|
|
246
|
+
introduced: '1.13.0',
|
|
247
|
+
description: 'Pressed state of color.background.brand.boldest.'
|
|
196
248
|
}
|
|
197
249
|
}
|
|
198
250
|
}
|