@atlaskit/tokens 1.13.0 → 1.13.2
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 +12 -0
- package/dist/cjs/artifacts/themes/atlassian-legacy-light.js +2 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
- package/dist/cjs/custom-theme.js +17 -13
- package/dist/cjs/get-global-theme.js +4 -3
- package/dist/cjs/get-ssr-auto-script.js +21 -0
- package/dist/cjs/get-theme-html-attrs.js +76 -0
- package/dist/cjs/get-theme-styles.js +139 -0
- package/dist/cjs/get-token-value.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/index.js +15 -15
- package/dist/cjs/set-global-theme.js +9 -242
- package/dist/cjs/theme-config.js +23 -1
- package/dist/cjs/theme-mutation-observer.js +4 -4
- package/dist/cjs/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
- package/dist/cjs/tokens/atlassian-legacy-light/color/border.js +1 -1
- package/dist/cjs/use-theme-observer.js +7 -6
- package/dist/cjs/utils/get-theme-preferences.js +35 -0
- package/dist/cjs/utils/theme-loading.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/artifacts/themes/atlassian-legacy-light.js +2 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
- package/dist/es2019/custom-theme.js +10 -10
- package/dist/es2019/get-global-theme.js +4 -3
- package/dist/es2019/get-ssr-auto-script.js +23 -0
- package/dist/es2019/get-theme-html-attrs.js +62 -0
- package/dist/es2019/get-theme-styles.js +72 -0
- package/dist/es2019/get-token-value.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/index.js +9 -6
- package/dist/es2019/set-global-theme.js +5 -185
- package/dist/es2019/theme-config.js +21 -0
- package/dist/es2019/theme-mutation-observer.js +2 -2
- package/dist/es2019/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
- package/dist/es2019/tokens/atlassian-legacy-light/color/border.js +1 -1
- package/dist/es2019/use-theme-observer.js +5 -4
- package/dist/es2019/utils/get-theme-preferences.js +28 -0
- package/dist/es2019/utils/theme-loading.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/artifacts/themes/atlassian-legacy-light.js +2 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
- package/dist/esm/custom-theme.js +15 -11
- package/dist/esm/get-global-theme.js +4 -3
- package/dist/esm/get-ssr-auto-script.js +15 -0
- package/dist/esm/get-theme-html-attrs.js +68 -0
- package/dist/esm/get-theme-styles.js +126 -0
- package/dist/esm/get-token-value.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/index.js +9 -6
- package/dist/esm/set-global-theme.js +6 -233
- package/dist/esm/theme-config.js +21 -0
- package/dist/esm/theme-mutation-observer.js +4 -3
- package/dist/esm/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
- package/dist/esm/tokens/atlassian-legacy-light/color/border.js +1 -1
- package/dist/esm/use-theme-observer.js +5 -4
- package/dist/esm/utils/get-theme-preferences.js +27 -0
- package/dist/esm/utils/theme-loading.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
- package/dist/types/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
- package/dist/types/custom-theme.d.ts +4 -9
- package/dist/types/get-global-theme.d.ts +2 -1
- package/dist/types/get-ssr-auto-script.d.ts +11 -0
- package/dist/types/get-theme-html-attrs.d.ts +17 -0
- package/dist/types/get-theme-styles.d.ts +24 -0
- package/dist/types/index.d.ts +10 -9
- package/dist/types/set-global-theme.d.ts +1 -58
- package/dist/types/theme-config.d.ts +24 -0
- package/dist/types/theme-mutation-observer.d.ts +1 -1
- package/dist/{types-ts4.5/utils → types}/theme-state-transformer.d.ts +1 -1
- package/dist/types/use-theme-observer.d.ts +2 -1
- package/dist/types/utils/custom-theme-loading-utils.d.ts +2 -3
- package/dist/types/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types/utils/get-theme-preferences.d.ts +2 -0
- package/dist/types/utils/theme-loading.d.ts +1 -0
- package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
- package/dist/types-ts4.5/custom-theme.d.ts +4 -9
- package/dist/types-ts4.5/get-global-theme.d.ts +2 -1
- package/dist/types-ts4.5/get-ssr-auto-script.d.ts +11 -0
- package/dist/types-ts4.5/get-theme-html-attrs.d.ts +17 -0
- package/dist/types-ts4.5/get-theme-styles.d.ts +24 -0
- package/dist/types-ts4.5/index.d.ts +10 -9
- package/dist/types-ts4.5/set-global-theme.d.ts +1 -58
- package/dist/types-ts4.5/theme-config.d.ts +24 -0
- package/dist/types-ts4.5/theme-mutation-observer.d.ts +1 -1
- package/dist/{types/utils → types-ts4.5}/theme-state-transformer.d.ts +1 -1
- package/dist/types-ts4.5/use-theme-observer.d.ts +2 -1
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +2 -3
- package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +2 -0
- package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -0
- package/figma/atlassian-legacy-light.json +1 -1
- package/package.json +1 -1
- package/report.api.md +8 -8
- package/tmp/api-report-tmp.d.ts +1158 -0
package/dist/esm/custom-theme.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
|
|
4
|
-
import { themeStateDefaults } from './
|
|
4
|
+
import { themeStateDefaults } from './theme-config';
|
|
5
5
|
import { limitSizeOfCustomStyleElements, reduceTokenMap } from './utils/custom-theme-loading-utils';
|
|
6
6
|
import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
|
|
7
7
|
import { hash } from './utils/hash';
|
|
8
8
|
export var CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
11
12
|
* @param themeSchema The schema of available themes
|
|
@@ -75,20 +76,23 @@ export function loadAndAppendCustomThemeCss(_x2) {
|
|
|
75
76
|
}
|
|
76
77
|
function _loadAndAppendCustomThemeCss() {
|
|
77
78
|
_loadAndAppendCustomThemeCss = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(themeState) {
|
|
79
|
+
var themes;
|
|
78
80
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
79
81
|
while (1) switch (_context2.prev = _context2.next) {
|
|
80
82
|
case 0:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
_context2.next = 2;
|
|
84
|
+
return getCustomThemeStyles(themeState);
|
|
85
|
+
case 2:
|
|
86
|
+
themes = _context2.sent;
|
|
87
|
+
limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
|
|
88
|
+
themes.map(function (theme) {
|
|
89
|
+
var styleTag = document.createElement('style');
|
|
90
|
+
document.head.appendChild(styleTag);
|
|
91
|
+
styleTag.dataset.theme = theme.attrs['data-theme'];
|
|
92
|
+
styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
|
|
93
|
+
styleTag.textContent = theme.css;
|
|
90
94
|
});
|
|
91
|
-
case
|
|
95
|
+
case 5:
|
|
92
96
|
case "end":
|
|
93
97
|
return _context2.stop();
|
|
94
98
|
}
|
|
@@ -3,13 +3,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
5
5
|
import { themeColorModes } from './theme-config';
|
|
6
|
-
import { themeStringToObject } from './
|
|
6
|
+
import { themeStringToObject } from './theme-state-transformer';
|
|
7
7
|
var isThemeColorMode = function isThemeColorMode(colorMode) {
|
|
8
8
|
return themeColorModes.find(function (mode) {
|
|
9
9
|
return mode === colorMode;
|
|
10
10
|
}) !== undefined;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
var getGlobalTheme = function getGlobalTheme() {
|
|
13
13
|
if (typeof document === 'undefined') {
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
@@ -19,4 +19,5 @@ export var getGlobalTheme = function getGlobalTheme() {
|
|
|
19
19
|
return _objectSpread(_objectSpread({}, themeStringToObject(theme)), isThemeColorMode(colorMode) && {
|
|
20
20
|
colorMode: colorMode
|
|
21
21
|
});
|
|
22
|
-
};
|
|
22
|
+
};
|
|
23
|
+
export default getGlobalTheme;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { COLOR_MODE_ATTRIBUTE } from './constants';
|
|
2
|
+
import { darkModeMediaQuery } from './utils/theme-loading';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Provides a script that, when executed before paint, sets the `data-color-mode` attribute based on the current system theme,
|
|
6
|
+
* to enable SSR support for automatic theme switching, avoid a flash of un-themed content on first paint.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} A string to be added to the innerHTML of a script tag in the document head
|
|
11
|
+
*/
|
|
12
|
+
var getSSRAutoScript = function getSSRAutoScript(colorMode) {
|
|
13
|
+
return colorMode === 'auto' ? "(\n () => {\n try {\n const mql = window.matchMedia('".concat(darkModeMediaQuery, "');\n const colorMode = mql.matches ? 'dark' : 'light';\n document.documentElement.setAttribute('").concat(COLOR_MODE_ATTRIBUTE, "', colorMode);\n } catch (e) {}\n }\n)()") : undefined;
|
|
14
|
+
};
|
|
15
|
+
export default getSSRAutoScript;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
4
|
+
import { themeStateDefaults } from './theme-config';
|
|
5
|
+
import { themeObjectToString } from './theme-state-transformer';
|
|
6
|
+
import { isValidBrandHex } from './utils/color-utils';
|
|
7
|
+
import { hash } from './utils/hash';
|
|
8
|
+
var defaultColorMode = 'light';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Server-side rendering utility. Generates the valid HTML attributes for a given theme.
|
|
12
|
+
* Note: this utility does not handle automatic theme switching.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object<string, string>} themeOptions - Theme options object
|
|
15
|
+
* @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
16
|
+
* @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
|
|
17
|
+
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
18
|
+
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
19
|
+
* @param {string} themeState.typography The typography theme to be applied.
|
|
20
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
21
|
+
*
|
|
22
|
+
* @returns {Object} Object of HTML attributes to be applied to the document root
|
|
23
|
+
*/
|
|
24
|
+
var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
|
|
25
|
+
var _result;
|
|
26
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
27
|
+
_ref$colorMode = _ref.colorMode,
|
|
28
|
+
colorMode = _ref$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref$colorMode,
|
|
29
|
+
_ref$dark = _ref.dark,
|
|
30
|
+
dark = _ref$dark === void 0 ? themeStateDefaults['dark'] : _ref$dark,
|
|
31
|
+
_ref$light = _ref.light,
|
|
32
|
+
light = _ref$light === void 0 ? themeStateDefaults['light'] : _ref$light,
|
|
33
|
+
_ref$shape = _ref.shape,
|
|
34
|
+
shape = _ref$shape === void 0 ? themeStateDefaults['shape'] : _ref$shape,
|
|
35
|
+
_ref$spacing = _ref.spacing,
|
|
36
|
+
spacing = _ref$spacing === void 0 ? themeStateDefaults['spacing'] : _ref$spacing,
|
|
37
|
+
_ref$typography = _ref.typography,
|
|
38
|
+
typography = _ref$typography === void 0 ? themeStateDefaults['typography'] : _ref$typography,
|
|
39
|
+
_ref$UNSAFE_themeOpti = _ref.UNSAFE_themeOptions,
|
|
40
|
+
UNSAFE_themeOptions = _ref$UNSAFE_themeOpti === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref$UNSAFE_themeOpti;
|
|
41
|
+
var themePreferences = {
|
|
42
|
+
dark: dark,
|
|
43
|
+
light: light,
|
|
44
|
+
shape: shape,
|
|
45
|
+
spacing: spacing,
|
|
46
|
+
typography: typography
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Load spacing by default, currently behind a feature flag
|
|
50
|
+
if (getBooleanFF('platform.design-system-team.space-and-shape-tokens_q5me6')) {
|
|
51
|
+
themePreferences = {
|
|
52
|
+
dark: dark,
|
|
53
|
+
light: light,
|
|
54
|
+
shape: shape,
|
|
55
|
+
spacing: 'spacing',
|
|
56
|
+
typography: typography
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var themeAttribute = themeObjectToString(themePreferences);
|
|
60
|
+
var result = (_result = {}, _defineProperty(_result, THEME_DATA_ATTRIBUTE, themeAttribute), _defineProperty(_result, COLOR_MODE_ATTRIBUTE, colorMode === 'auto' ? defaultColorMode : colorMode), _result);
|
|
61
|
+
if (UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions.brandColor)) {
|
|
62
|
+
var optionString = JSON.stringify(UNSAFE_themeOptions);
|
|
63
|
+
var uniqueId = hash(optionString);
|
|
64
|
+
result[CUSTOM_THEME_ATTRIBUTE] = uniqueId;
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
export default getThemeHtmlAttrs;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import { themeIdsWithOverrides, themeStateDefaults } from './theme-config';
|
|
5
|
+
import { isValidBrandHex } from './utils/color-utils';
|
|
6
|
+
import { getThemePreferences } from './utils/get-theme-preferences';
|
|
7
|
+
import { loadThemeCss } from './utils/theme-loading';
|
|
8
|
+
/**
|
|
9
|
+
* Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
|
|
10
|
+
* 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.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
13
|
+
* @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
14
|
+
* @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
|
|
15
|
+
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
16
|
+
* @param {string} themeState.shape The shape theme to be applied.
|
|
17
|
+
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
18
|
+
* @param {string} themeState.typography The typography theme to be applied.
|
|
19
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
20
|
+
*
|
|
21
|
+
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
22
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
23
|
+
*/
|
|
24
|
+
var getThemeStyles = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(preferences) {
|
|
26
|
+
var themePreferences, results;
|
|
27
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
28
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
if (preferences === 'all') {
|
|
31
|
+
themePreferences = themeIdsWithOverrides;
|
|
32
|
+
} else {
|
|
33
|
+
themePreferences = getThemePreferences({
|
|
34
|
+
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
35
|
+
dark: (preferences === null || preferences === void 0 ? void 0 : preferences.dark) || themeStateDefaults['dark'],
|
|
36
|
+
light: (preferences === null || preferences === void 0 ? void 0 : preferences.light) || themeStateDefaults['light'],
|
|
37
|
+
shape: (preferences === null || preferences === void 0 ? void 0 : preferences.shape) || themeStateDefaults['shape'],
|
|
38
|
+
spacing: (preferences === null || preferences === void 0 ? void 0 : preferences.spacing) || themeStateDefaults['spacing'],
|
|
39
|
+
typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
_context3.next = 3;
|
|
43
|
+
return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
|
|
44
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
45
|
+
var css;
|
|
46
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
_context.prev = 0;
|
|
50
|
+
_context.next = 3;
|
|
51
|
+
return loadThemeCss(themeId);
|
|
52
|
+
case 3:
|
|
53
|
+
css = _context.sent;
|
|
54
|
+
return _context.abrupt("return", {
|
|
55
|
+
id: themeId,
|
|
56
|
+
attrs: {
|
|
57
|
+
'data-theme': themeId
|
|
58
|
+
},
|
|
59
|
+
css: css
|
|
60
|
+
});
|
|
61
|
+
case 7:
|
|
62
|
+
_context.prev = 7;
|
|
63
|
+
_context.t0 = _context["catch"](0);
|
|
64
|
+
return _context.abrupt("return", undefined);
|
|
65
|
+
case 10:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee, null, [[0, 7]]);
|
|
70
|
+
}));
|
|
71
|
+
return function (_x2) {
|
|
72
|
+
return _ref2.apply(this, arguments);
|
|
73
|
+
};
|
|
74
|
+
}())), [
|
|
75
|
+
// Add custom themes if they're present
|
|
76
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
77
|
+
var _preferences$UNSAFE_t;
|
|
78
|
+
var _yield$import, getCustomThemeStyles, customThemeStyles;
|
|
79
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
80
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
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))) {
|
|
83
|
+
_context2.next = 15;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
_context2.prev = 1;
|
|
87
|
+
_context2.next = 4;
|
|
88
|
+
return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
89
|
+
'./custom-theme');
|
|
90
|
+
case 4:
|
|
91
|
+
_yield$import = _context2.sent;
|
|
92
|
+
getCustomThemeStyles = _yield$import.getCustomThemeStyles;
|
|
93
|
+
_context2.next = 8;
|
|
94
|
+
return getCustomThemeStyles({
|
|
95
|
+
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
96
|
+
UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
|
|
97
|
+
});
|
|
98
|
+
case 8:
|
|
99
|
+
customThemeStyles = _context2.sent;
|
|
100
|
+
return _context2.abrupt("return", customThemeStyles);
|
|
101
|
+
case 12:
|
|
102
|
+
_context2.prev = 12;
|
|
103
|
+
_context2.t0 = _context2["catch"](1);
|
|
104
|
+
return _context2.abrupt("return", undefined);
|
|
105
|
+
case 15:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context2.stop();
|
|
108
|
+
}
|
|
109
|
+
}, _callee2, null, [[1, 12]]);
|
|
110
|
+
}))()]));
|
|
111
|
+
case 3:
|
|
112
|
+
results = _context3.sent;
|
|
113
|
+
return _context3.abrupt("return", results.flat().filter(function (theme) {
|
|
114
|
+
return theme !== undefined;
|
|
115
|
+
}));
|
|
116
|
+
case 5:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context3.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee3);
|
|
121
|
+
}));
|
|
122
|
+
return function getThemeStyles(_x) {
|
|
123
|
+
return _ref.apply(this, arguments);
|
|
124
|
+
};
|
|
125
|
+
}();
|
|
126
|
+
export default getThemeStyles;
|
|
@@ -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 = "1.13.2";
|
|
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 = "1.13.2";
|
|
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.
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export { default as themeConfig } from './theme-config';
|
|
1
2
|
export { default as token } from './get-token';
|
|
2
3
|
export { default as getTokenValue } from './get-token-value';
|
|
3
|
-
export { default as setGlobalTheme
|
|
4
|
-
export { default as
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
4
|
+
export { default as setGlobalTheme } from './set-global-theme';
|
|
5
|
+
export { default as getThemeStyles } from './get-theme-styles';
|
|
6
|
+
export { default as getThemeHtmlAttrs } from './get-theme-html-attrs';
|
|
7
|
+
export { default as getSSRAutoScript } from './get-ssr-auto-script';
|
|
8
|
+
export { default as useThemeObserver } from './use-theme-observer';
|
|
9
|
+
export { default as ThemeMutationObserver } from './theme-mutation-observer';
|
|
10
|
+
export { default as getGlobalTheme } from './get-global-theme';
|
|
11
|
+
export { themeStringToObject, themeObjectToString } from './theme-state-transformer';
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
5
|
import { bind } from 'bind-event-listener';
|
|
7
6
|
import noop from '@atlaskit/ds-lib/noop';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
7
|
+
import { COLOR_MODE_ATTRIBUTE } from './constants';
|
|
8
|
+
import getThemeHtmlAttrs from './get-theme-html-attrs';
|
|
9
|
+
import { themeStateDefaults } from './theme-config';
|
|
11
10
|
import { isValidBrandHex } from './utils/color-utils';
|
|
12
11
|
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { themeObjectToString } from './utils/theme-state-transformer';
|
|
12
|
+
import { getThemePreferences } from './utils/get-theme-preferences';
|
|
13
|
+
import { darkModeMediaQuery, loadAndAppendThemeCss } from './utils/theme-loading';
|
|
16
14
|
|
|
17
15
|
// Represents theme state once mounted to the page (auto is hidden from observers)
|
|
18
16
|
|
|
19
|
-
var defaultColorMode = 'light';
|
|
20
17
|
var isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in window;
|
|
21
|
-
var darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
|
22
18
|
var darkModeMql = isMatchMediaAvailable && window.matchMedia(darkModeMediaQuery);
|
|
23
19
|
var unbindThemeChangeListener = noop;
|
|
24
|
-
export var themeStateDefaults = {
|
|
25
|
-
colorMode: 'auto',
|
|
26
|
-
dark: 'dark',
|
|
27
|
-
light: 'light',
|
|
28
|
-
shape: undefined,
|
|
29
|
-
spacing: undefined,
|
|
30
|
-
typography: undefined,
|
|
31
|
-
UNSAFE_themeOptions: undefined
|
|
32
|
-
};
|
|
33
20
|
|
|
34
21
|
/**
|
|
35
22
|
* Updates the current theme when the system theme changes. Should be bound
|
|
@@ -40,31 +27,6 @@ var checkNativeListener = function checkNativeListener(e) {
|
|
|
40
27
|
var element = document.documentElement;
|
|
41
28
|
element.setAttribute(COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
|
|
42
29
|
};
|
|
43
|
-
var getThemePreferences = function getThemePreferences(themeState) {
|
|
44
|
-
var colorMode = themeState.colorMode,
|
|
45
|
-
dark = themeState.dark,
|
|
46
|
-
light = themeState.light,
|
|
47
|
-
shape = themeState.shape,
|
|
48
|
-
spacing = themeState.spacing,
|
|
49
|
-
typography = themeState.typography;
|
|
50
|
-
var themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
|
|
51
|
-
[shape, spacing, typography].forEach(function (themeId) {
|
|
52
|
-
if (themeId) {
|
|
53
|
-
themePreferences.push(themeId);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
if (getBooleanFF('platform.design-system-team.border-checkbox_nyoiu')) {
|
|
57
|
-
themePreferences.push("".concat(themePreferences.includes('dark') ? 'dark' : 'light', "-new-input-border"));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Load shape and spacing by default, currently behind a feature flag
|
|
61
|
-
if (getBooleanFF('platform.design-system-team.space-and-shape-tokens_q5me6')) {
|
|
62
|
-
if (!themePreferences.includes('spacing')) {
|
|
63
|
-
themePreferences.push('spacing');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return _toConsumableArray(new Set(themePreferences));
|
|
67
|
-
};
|
|
68
30
|
|
|
69
31
|
/**
|
|
70
32
|
* Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
|
|
@@ -215,193 +177,4 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
215
177
|
return _ref.apply(this, arguments);
|
|
216
178
|
};
|
|
217
179
|
}();
|
|
218
|
-
/**
|
|
219
|
-
* Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
|
|
220
|
-
* 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.
|
|
221
|
-
*
|
|
222
|
-
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
223
|
-
* @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
224
|
-
* @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
|
|
225
|
-
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
226
|
-
* @param {string} themeState.shape The shape theme to be applied.
|
|
227
|
-
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
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
|
|
230
|
-
*
|
|
231
|
-
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
232
|
-
* If an error is encountered while loading themes, the themes array will be empty.
|
|
233
|
-
*/
|
|
234
|
-
export var getThemeStyles = /*#__PURE__*/function () {
|
|
235
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(preferences) {
|
|
236
|
-
var themePreferences, results;
|
|
237
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
238
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
239
|
-
case 0:
|
|
240
|
-
if (preferences === 'all') {
|
|
241
|
-
themePreferences = themeIdsWithOverrides;
|
|
242
|
-
} else {
|
|
243
|
-
themePreferences = getThemePreferences({
|
|
244
|
-
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
245
|
-
dark: (preferences === null || preferences === void 0 ? void 0 : preferences.dark) || themeStateDefaults['dark'],
|
|
246
|
-
light: (preferences === null || preferences === void 0 ? void 0 : preferences.light) || themeStateDefaults['light'],
|
|
247
|
-
shape: (preferences === null || preferences === void 0 ? void 0 : preferences.shape) || themeStateDefaults['shape'],
|
|
248
|
-
spacing: (preferences === null || preferences === void 0 ? void 0 : preferences.spacing) || themeStateDefaults['spacing'],
|
|
249
|
-
typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
_context6.next = 3;
|
|
253
|
-
return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
|
|
254
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(themeId) {
|
|
255
|
-
var css;
|
|
256
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
257
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
258
|
-
case 0:
|
|
259
|
-
_context4.prev = 0;
|
|
260
|
-
_context4.next = 3;
|
|
261
|
-
return loadThemeCss(themeId);
|
|
262
|
-
case 3:
|
|
263
|
-
css = _context4.sent;
|
|
264
|
-
return _context4.abrupt("return", {
|
|
265
|
-
id: themeId,
|
|
266
|
-
attrs: {
|
|
267
|
-
'data-theme': themeId
|
|
268
|
-
},
|
|
269
|
-
css: css
|
|
270
|
-
});
|
|
271
|
-
case 7:
|
|
272
|
-
_context4.prev = 7;
|
|
273
|
-
_context4.t0 = _context4["catch"](0);
|
|
274
|
-
return _context4.abrupt("return", undefined);
|
|
275
|
-
case 10:
|
|
276
|
-
case "end":
|
|
277
|
-
return _context4.stop();
|
|
278
|
-
}
|
|
279
|
-
}, _callee4, null, [[0, 7]]);
|
|
280
|
-
}));
|
|
281
|
-
return function (_x3) {
|
|
282
|
-
return _ref8.apply(this, arguments);
|
|
283
|
-
};
|
|
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
|
-
}))()]));
|
|
321
|
-
case 3:
|
|
322
|
-
results = _context6.sent;
|
|
323
|
-
return _context6.abrupt("return", results.flat().filter(function (theme) {
|
|
324
|
-
return theme !== undefined;
|
|
325
|
-
}));
|
|
326
|
-
case 5:
|
|
327
|
-
case "end":
|
|
328
|
-
return _context6.stop();
|
|
329
|
-
}
|
|
330
|
-
}, _callee6);
|
|
331
|
-
}));
|
|
332
|
-
return function getThemeStyles(_x2) {
|
|
333
|
-
return _ref7.apply(this, arguments);
|
|
334
|
-
};
|
|
335
|
-
}();
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Server-side rendering utility. Generates the valid HTML attributes for a given theme.
|
|
339
|
-
* Note: this utility does not handle automatic theme switching.
|
|
340
|
-
*
|
|
341
|
-
* @param {Object<string, string>} themeOptions - Theme options object
|
|
342
|
-
* @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
343
|
-
* @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
|
|
344
|
-
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
345
|
-
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
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
|
|
348
|
-
*
|
|
349
|
-
* @returns {Object} Object of HTML attributes to be applied to the document root
|
|
350
|
-
*/
|
|
351
|
-
export var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
|
|
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;
|
|
368
|
-
var themePreferences = {
|
|
369
|
-
dark: dark,
|
|
370
|
-
light: light,
|
|
371
|
-
shape: shape,
|
|
372
|
-
spacing: spacing,
|
|
373
|
-
typography: typography
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
// Load spacing by default, currently behind a feature flag
|
|
377
|
-
if (getBooleanFF('platform.design-system-team.space-and-shape-tokens_q5me6')) {
|
|
378
|
-
themePreferences = {
|
|
379
|
-
dark: dark,
|
|
380
|
-
light: light,
|
|
381
|
-
shape: shape,
|
|
382
|
-
spacing: 'spacing',
|
|
383
|
-
typography: typography
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
var themeAttribute = themeObjectToString(themePreferences);
|
|
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;
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Provides a script that, when executed before paint, sets the `data-color-mode` attribute based on the current system theme,
|
|
398
|
-
* to enable SSR support for automatic theme switching, avoid a flash of un-themed content on first paint.
|
|
399
|
-
*
|
|
400
|
-
* @param {string} colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
|
|
401
|
-
*
|
|
402
|
-
* @returns {string} A string to be added to the innerHTML of a script tag in the document head
|
|
403
|
-
*/
|
|
404
|
-
export var getSSRAutoScript = function getSSRAutoScript(colorMode) {
|
|
405
|
-
return colorMode === 'auto' ? "(\n () => {\n try {\n const mql = window.matchMedia('".concat(darkModeMediaQuery, "');\n const colorMode = mql.matches ? 'dark' : 'light';\n document.documentElement.setAttribute('").concat(COLOR_MODE_ATTRIBUTE, "', colorMode);\n } catch (e) {}\n }\n)()") : undefined;
|
|
406
|
-
};
|
|
407
180
|
export default setGlobalTheme;
|
package/dist/esm/theme-config.js
CHANGED
|
@@ -141,4 +141,25 @@ var themeConfig = {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* ThemeOptionsSchema: additional configuration options used to customize Atlassian's themes
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* ThemeState: the standard representation of an app's current theme and preferences
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
155
|
+
*/
|
|
156
|
+
export var themeStateDefaults = {
|
|
157
|
+
colorMode: 'auto',
|
|
158
|
+
dark: 'dark',
|
|
159
|
+
light: 'light',
|
|
160
|
+
shape: undefined,
|
|
161
|
+
spacing: undefined,
|
|
162
|
+
typography: undefined,
|
|
163
|
+
UNSAFE_themeOptions: undefined
|
|
164
|
+
};
|
|
144
165
|
export default themeConfig;
|
|
@@ -2,7 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
5
|
-
import
|
|
5
|
+
import getGlobalTheme from './get-global-theme';
|
|
6
6
|
/**
|
|
7
7
|
* A MutationObserver which watches the `<html>` element for changes to the theme.
|
|
8
8
|
*
|
|
@@ -16,7 +16,7 @@ import { getGlobalTheme } from './get-global-theme';
|
|
|
16
16
|
* observer.observe();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
var ThemeMutationObserver = /*#__PURE__*/function () {
|
|
20
20
|
function ThemeMutationObserver(callback) {
|
|
21
21
|
_classCallCheck(this, ThemeMutationObserver);
|
|
22
22
|
_defineProperty(this, "observer", null);
|
|
@@ -43,4 +43,5 @@ export var ThemeMutationObserver = /*#__PURE__*/function () {
|
|
|
43
43
|
}
|
|
44
44
|
}]);
|
|
45
45
|
return ThemeMutationObserver;
|
|
46
|
-
}();
|
|
46
|
+
}();
|
|
47
|
+
export { ThemeMutationObserver as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import { themeIds } from '
|
|
2
|
+
import { themeIds } from './theme-config';
|
|
3
3
|
var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape'];
|
|
4
4
|
var isThemeKind = function isThemeKind(themeKind) {
|
|
5
5
|
return themeKinds.find(function (kind) {
|