@atlaskit/tokens 1.22.1 → 1.24.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 +15 -0
- package/custom-themes/package.json +17 -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 +2 -1
- package/dist/cjs/artifacts/token-names.js +2 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +23 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-dark.js +23 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-light.js +23 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +23 -1
- package/dist/cjs/constants.js +3 -1
- package/dist/cjs/custom-theme.js +45 -79
- package/dist/cjs/enable-global-theme.js +70 -0
- package/dist/cjs/entry-points/custom-themes.js +13 -0
- package/dist/cjs/get-token-value.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/load-custom-theme-styles.js +45 -0
- package/dist/cjs/set-global-theme.js +50 -94
- package/dist/cjs/theme-config.js +5 -0
- package/dist/cjs/tokens/atlassian-dark/color/text.js +3 -0
- package/dist/cjs/tokens/atlassian-legacy-dark/color/text.js +3 -0
- package/dist/cjs/tokens/atlassian-legacy-light/color/text.js +3 -0
- package/dist/cjs/tokens/atlassian-light/color/text.js +3 -0
- package/dist/cjs/tokens/default/color/text.js +8 -0
- package/dist/cjs/utils/color-mode-listeners.js +66 -0
- package/dist/cjs/utils/configure-page.js +34 -0
- package/dist/es2019/artifacts/generated-pairs.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-dark.js +2 -1
- package/dist/es2019/artifacts/themes/atlassian-legacy-dark.js +2 -1
- package/dist/es2019/artifacts/themes/atlassian-legacy-light.js +2 -1
- package/dist/es2019/artifacts/themes/atlassian-light.js +2 -1
- package/dist/es2019/artifacts/token-default-values.js +2 -1
- package/dist/es2019/artifacts/token-names.js +2 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +23 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-dark.js +23 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-light.js +23 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +23 -1
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/custom-theme.js +4 -4
- package/dist/es2019/enable-global-theme.js +53 -0
- package/dist/es2019/entry-points/custom-themes.js +1 -0
- package/dist/es2019/get-token-value.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/load-custom-theme-styles.js +37 -0
- package/dist/es2019/set-global-theme.js +34 -65
- package/dist/es2019/theme-config.js +6 -0
- package/dist/es2019/tokens/atlassian-dark/color/text.js +3 -0
- package/dist/es2019/tokens/atlassian-legacy-dark/color/text.js +3 -0
- package/dist/es2019/tokens/atlassian-legacy-light/color/text.js +3 -0
- package/dist/es2019/tokens/atlassian-light/color/text.js +3 -0
- package/dist/es2019/tokens/default/color/text.js +8 -0
- package/dist/es2019/utils/color-mode-listeners.js +48 -0
- package/dist/es2019/utils/configure-page.js +22 -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 +2 -1
- package/dist/esm/artifacts/token-names.js +2 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +23 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-legacy-dark.js +23 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-legacy-light.js +23 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +23 -1
- package/dist/esm/constants.js +1 -0
- package/dist/esm/custom-theme.js +45 -78
- package/dist/esm/enable-global-theme.js +63 -0
- package/dist/esm/entry-points/custom-themes.js +1 -0
- package/dist/esm/get-token-value.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/load-custom-theme-styles.js +39 -0
- package/dist/esm/set-global-theme.js +49 -93
- package/dist/esm/theme-config.js +6 -0
- package/dist/esm/tokens/atlassian-dark/color/text.js +3 -0
- package/dist/esm/tokens/atlassian-legacy-dark/color/text.js +3 -0
- package/dist/esm/tokens/atlassian-legacy-light/color/text.js +3 -0
- package/dist/esm/tokens/atlassian-light/color/text.js +3 -0
- package/dist/esm/tokens/default/color/text.js +8 -0
- package/dist/esm/utils/color-mode-listeners.js +58 -0
- package/dist/esm/utils/configure-page.js +28 -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 +2 -1
- package/dist/types/artifacts/token-names.d.ts +3 -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 +3 -3
- package/dist/types/enable-global-theme.d.ts +25 -0
- package/dist/types/entry-points/custom-themes.d.ts +1 -0
- package/dist/types/get-global-theme.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/load-custom-theme-styles.d.ts +17 -0
- package/dist/types/set-global-theme.d.ts +1 -4
- package/dist/types/theme-config.d.ts +7 -0
- package/dist/types/theme-mutation-observer.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/use-theme-observer.d.ts +1 -1
- package/dist/types/utils/color-mode-listeners.d.ts +13 -0
- package/dist/types/utils/configure-page.d.ts +6 -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 +2 -1
- package/dist/types-ts4.5/artifacts/token-names.d.ts +3 -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 +3 -3
- package/dist/types-ts4.5/enable-global-theme.d.ts +25 -0
- package/dist/types-ts4.5/entry-points/custom-themes.d.ts +1 -0
- package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/load-custom-theme-styles.d.ts +17 -0
- package/dist/types-ts4.5/set-global-theme.d.ts +1 -4
- package/dist/types-ts4.5/theme-config.d.ts +7 -0
- package/dist/types-ts4.5/theme-mutation-observer.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/use-theme-observer.d.ts +1 -1
- package/dist/types-ts4.5/utils/color-mode-listeners.d.ts +13 -0
- package/dist/types-ts4.5/utils/configure-page.d.ts +6 -0
- package/figma/atlassian-dark.json +9 -0
- package/figma/atlassian-legacy-dark.json +9 -0
- package/figma/atlassian-legacy-light.json +9 -0
- package/figma/atlassian-light.json +9 -0
- package/package.json +3 -2
- package/report.api.md +20 -2
- package/tmp/api-report-tmp.d.ts +9 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _bindEventListener = require("bind-event-listener");
|
|
12
|
+
var _constants = require("../constants");
|
|
13
|
+
var _themeLoading = require("./theme-loading");
|
|
14
|
+
var isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in window;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Updates the current theme when the system theme changes. Should be bound
|
|
18
|
+
* to an event listener listening on the '(prefers-color-scheme: dark)' query
|
|
19
|
+
* @param e The event representing a change in system theme.
|
|
20
|
+
*/
|
|
21
|
+
function checkNativeListener(e) {
|
|
22
|
+
var element = document.documentElement;
|
|
23
|
+
element.setAttribute(_constants.COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
|
|
24
|
+
}
|
|
25
|
+
var darkModeMql = isMatchMediaAvailable && window.matchMedia(_themeLoading.darkModeMediaQuery);
|
|
26
|
+
var ColorModeObserver = /*#__PURE__*/function () {
|
|
27
|
+
function ColorModeObserver() {
|
|
28
|
+
(0, _classCallCheck2.default)(this, ColorModeObserver);
|
|
29
|
+
(0, _defineProperty2.default)(this, "unbindThemeChangeListener", null);
|
|
30
|
+
}
|
|
31
|
+
(0, _createClass2.default)(ColorModeObserver, [{
|
|
32
|
+
key: "getColorMode",
|
|
33
|
+
value: function getColorMode() {
|
|
34
|
+
if (!darkModeMql) {
|
|
35
|
+
return 'light';
|
|
36
|
+
}
|
|
37
|
+
return darkModeMql !== null && darkModeMql !== void 0 && darkModeMql.matches ? 'dark' : 'light';
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "bind",
|
|
41
|
+
value: function bind() {
|
|
42
|
+
if (darkModeMql && this.unbindThemeChangeListener === null) {
|
|
43
|
+
this.unbindThemeChangeListener = (0, _bindEventListener.bind)(darkModeMql, {
|
|
44
|
+
type: 'change',
|
|
45
|
+
listener: checkNativeListener
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "unbind",
|
|
51
|
+
value: function unbind() {
|
|
52
|
+
if (this.unbindThemeChangeListener) {
|
|
53
|
+
this.unbindThemeChangeListener();
|
|
54
|
+
this.unbindThemeChangeListener = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}]);
|
|
58
|
+
return ColorModeObserver;
|
|
59
|
+
}();
|
|
60
|
+
/**
|
|
61
|
+
* A singleton color mode observer - binds "auto" switching logic to a single `mediaQueryList` listener
|
|
62
|
+
* that can be unbound by any consumer when no longer needed.
|
|
63
|
+
*/
|
|
64
|
+
var SingletonColorModeObserver = new ColorModeObserver();
|
|
65
|
+
var _default = SingletonColorModeObserver;
|
|
66
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = configurePage;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _getThemeHtmlAttrs = _interopRequireDefault(require("../get-theme-html-attrs"));
|
|
10
|
+
var _colorModeListeners = _interopRequireDefault(require("./color-mode-listeners"));
|
|
11
|
+
/**
|
|
12
|
+
* Given ThemeState, sets appropriate html attributes on the documentElement,
|
|
13
|
+
* adds a listener to keep colorMode updated, and returns a function to unbind.
|
|
14
|
+
*/
|
|
15
|
+
function configurePage(themeState) {
|
|
16
|
+
if (themeState.colorMode === 'auto') {
|
|
17
|
+
// Set colorMode based on the user preference
|
|
18
|
+
themeState.colorMode = _colorModeListeners.default.getColorMode();
|
|
19
|
+
// Bind a listener (if one doesn't already exist) to keep colorMode updated
|
|
20
|
+
_colorModeListeners.default.bind();
|
|
21
|
+
} else {
|
|
22
|
+
_colorModeListeners.default.unbind();
|
|
23
|
+
}
|
|
24
|
+
var themeAttributes = (0, _getThemeHtmlAttrs.default)(themeState);
|
|
25
|
+
Object.entries(themeAttributes).forEach(function (_ref) {
|
|
26
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
27
|
+
key = _ref2[0],
|
|
28
|
+
value = _ref2[1];
|
|
29
|
+
document.documentElement.setAttribute(key, value);
|
|
30
|
+
});
|
|
31
|
+
return function () {
|
|
32
|
+
return _colorModeListeners.default.unbind;
|
|
33
|
+
};
|
|
34
|
+
}
|