@atlaskit/tokens 1.11.2 → 1.12.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 +20 -0
- package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +24 -0
- package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +24 -0
- package/dist/cjs/artifacts/themes/atlassian-dark-new-input-border.js +2 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark-new-input-border.js +3 -3
- 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-new-input-border/color/border.js +1 -1
- 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 +213 -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 +17 -0
- package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +17 -0
- package/dist/es2019/artifacts/themes/atlassian-dark-new-input-border.js +2 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark-new-input-border.js +3 -3
- 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-new-input-border/color/border.js +1 -1
- 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 +187 -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 +17 -0
- package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +17 -0
- package/dist/esm/artifacts/themes/atlassian-dark-new-input-border.js +2 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-dark-new-input-border.js +3 -3
- 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-new-input-border/color/border.js +1 -1
- 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 +202 -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 +17 -0
- package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +17 -0
- package/dist/types/artifacts/themes/atlassian-dark-new-input-border.d.ts +2 -2
- package/dist/types/artifacts/tokens-raw/atlassian-dark-new-input-border.d.ts +1 -1
- 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/tokens/atlassian-dark/utility/utility.d.ts +1 -1
- package/dist/types/tokens/atlassian-light/utility/utility.d.ts +1 -1
- package/dist/types/tokens/default/utility/utility.d.ts +1 -1
- 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 +17 -0
- package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +17 -0
- package/dist/types-ts4.5/artifacts/themes/atlassian-dark-new-input-border.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark-new-input-border.d.ts +1 -1
- 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/tokens/atlassian-dark/utility/utility.d.ts +1 -1
- package/dist/types-ts4.5/tokens/atlassian-light/utility/utility.d.ts +1 -1
- package/dist/types-ts4.5/tokens/default/utility/utility.d.ts +1 -1
- 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-new-input-border.json +1 -1
- package/package.json +35 -40
- package/report.api.md +24 -1
- package/tmp/api-report-tmp.d.ts +0 -1132
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Below lines are copied from @material/material-color-utilities.
|
|
3
|
+
* Do not modify it.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @license
|
|
8
|
+
* Copyright 2021 Google LLC
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// This file is automatically generated. Do not modify it.
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Utility methods for mathematical operations.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The signum function.
|
|
31
|
+
*
|
|
32
|
+
* @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
|
|
33
|
+
*/
|
|
34
|
+
export function signum(num) {
|
|
35
|
+
if (num < 0) {
|
|
36
|
+
return -1;
|
|
37
|
+
} else if (num === 0) {
|
|
38
|
+
return 0;
|
|
39
|
+
} else {
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The linear interpolation function.
|
|
46
|
+
*
|
|
47
|
+
* @return start if amount = 0 and stop if amount = 1
|
|
48
|
+
*/
|
|
49
|
+
export function lerp(start, stop, amount) {
|
|
50
|
+
return (1.0 - amount) * start + amount * stop;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Clamps an integer between two integers.
|
|
55
|
+
*
|
|
56
|
+
* @return input when min <= input <= max, and either min or max
|
|
57
|
+
* otherwise.
|
|
58
|
+
*/
|
|
59
|
+
export function clampInt(min, max, input) {
|
|
60
|
+
if (input < min) {
|
|
61
|
+
return min;
|
|
62
|
+
} else if (input > max) {
|
|
63
|
+
return max;
|
|
64
|
+
}
|
|
65
|
+
return input;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Clamps an integer between two floating-point numbers.
|
|
70
|
+
*
|
|
71
|
+
* @return input when min <= input <= max, and either min or max
|
|
72
|
+
* otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export function clampDouble(min, max, input) {
|
|
75
|
+
if (input < min) {
|
|
76
|
+
return min;
|
|
77
|
+
} else if (input > max) {
|
|
78
|
+
return max;
|
|
79
|
+
}
|
|
80
|
+
return input;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Sanitizes a degree measure as an integer.
|
|
85
|
+
*
|
|
86
|
+
* @return a degree measure between 0 (inclusive) and 360
|
|
87
|
+
* (exclusive).
|
|
88
|
+
*/
|
|
89
|
+
export function sanitizeDegreesInt(degrees) {
|
|
90
|
+
degrees = degrees % 360;
|
|
91
|
+
if (degrees < 0) {
|
|
92
|
+
degrees = degrees + 360;
|
|
93
|
+
}
|
|
94
|
+
return degrees;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Sanitizes a degree measure as a floating-point number.
|
|
99
|
+
*
|
|
100
|
+
* @return a degree measure between 0.0 (inclusive) and 360.0
|
|
101
|
+
* (exclusive).
|
|
102
|
+
*/
|
|
103
|
+
export function sanitizeDegreesDouble(degrees) {
|
|
104
|
+
degrees = degrees % 360.0;
|
|
105
|
+
if (degrees < 0) {
|
|
106
|
+
degrees = degrees + 360.0;
|
|
107
|
+
}
|
|
108
|
+
return degrees;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Sign of direction change needed to travel from one angle to
|
|
113
|
+
* another.
|
|
114
|
+
*
|
|
115
|
+
* For angles that are 180 degrees apart from each other, both
|
|
116
|
+
* directions have the same travel distance, so either direction is
|
|
117
|
+
* shortest. The value 1.0 is returned in this case.
|
|
118
|
+
*
|
|
119
|
+
* @param from The angle travel starts from, in degrees.
|
|
120
|
+
* @param to The angle travel ends at, in degrees.
|
|
121
|
+
* @return -1 if decreasing from leads to the shortest travel
|
|
122
|
+
* distance, 1 if increasing from leads to the shortest travel
|
|
123
|
+
* distance.
|
|
124
|
+
*/
|
|
125
|
+
export function rotationDirection(from, to) {
|
|
126
|
+
var increasingDifference = sanitizeDegreesDouble(to - from);
|
|
127
|
+
return increasingDifference <= 180.0 ? 1.0 : -1.0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Distance of two points on a circle, represented using degrees.
|
|
132
|
+
*/
|
|
133
|
+
export function differenceDegrees(a, b) {
|
|
134
|
+
return 180.0 - Math.abs(Math.abs(a - b) - 180.0);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Multiplies a 1x3 row vector with a 3x3 matrix.
|
|
139
|
+
*/
|
|
140
|
+
export function matrixMultiply(row, matrix) {
|
|
141
|
+
var a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
|
|
142
|
+
var b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
|
|
143
|
+
var c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
|
|
144
|
+
return [a, b, c];
|
|
145
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import themeImportMap from '../artifacts/theme-import-map';
|
|
4
|
-
import { THEME_DATA_ATTRIBUTE } from '../constants';
|
|
4
|
+
import { CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from '../constants';
|
|
5
5
|
export var loadAndAppendThemeCss = /*#__PURE__*/function () {
|
|
6
6
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
7
7
|
var themeCss, style;
|
|
8
8
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
9
|
while (1) switch (_context.prev = _context.next) {
|
|
10
10
|
case 0:
|
|
11
|
-
if (!document.head.querySelector("style[".concat(THEME_DATA_ATTRIBUTE, "=\"").concat(themeId, "\"]"))) {
|
|
11
|
+
if (!document.head.querySelector("style[".concat(THEME_DATA_ATTRIBUTE, "=\"").concat(themeId, "\"]:not([").concat(CUSTOM_THEME_ATTRIBUTE, "])"))) {
|
|
12
12
|
_context.next = 2;
|
|
13
13
|
break;
|
|
14
14
|
}
|
|
@@ -60,6 +60,6 @@ export var themeObjectToString = function themeObjectToString(themeState) {
|
|
|
60
60
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
61
61
|
kind = _ref4[0],
|
|
62
62
|
id = _ref4[1];
|
|
63
|
-
return (kind === 'colorMode' || isThemeKind(kind)) && (isThemeIds(id) || isColorMode(id)) ? themeString + "".concat(themeString ? ' ' : '') + "".concat(kind, ":").concat(id) : themeString;
|
|
63
|
+
return (kind === 'colorMode' || isThemeKind(kind)) && typeof id === 'string' && (isThemeIds(id) || isColorMode(id)) ? themeString + "".concat(themeString ? ' ' : '') + "".concat(kind, ":").concat(id) : themeString;
|
|
64
64
|
}, '');
|
|
65
65
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Token names mapped to their values, used for contrast checking when generating custom themes
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::1ddd5cd744975e8df5a191332ec8a42c>>
|
|
7
|
+
* @codegenCommand yarn build tokens
|
|
8
|
+
*/
|
|
9
|
+
declare const tokenValues: {
|
|
10
|
+
readonly 'color.text.brand': "#579DFF";
|
|
11
|
+
readonly 'elevation.surface.overlay': "#282E33";
|
|
12
|
+
readonly 'color.text.selected': "#579DFF";
|
|
13
|
+
readonly 'color.background.selected': "#092957";
|
|
14
|
+
readonly 'color.border.brand': "#579DFF";
|
|
15
|
+
readonly 'color.chart.brand': "#388BFF";
|
|
16
|
+
};
|
|
17
|
+
export default tokenValues;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Token names mapped to their values, used for contrast checking when generating custom themes
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::b59877585fad151840dbf6c212c56e34>>
|
|
7
|
+
* @codegenCommand yarn build tokens
|
|
8
|
+
*/
|
|
9
|
+
declare const tokenValues: {
|
|
10
|
+
readonly 'color.text.brand': "#0C66E4";
|
|
11
|
+
readonly 'elevation.surface.sunken': "#F7F8F9";
|
|
12
|
+
readonly 'color.text.selected': "#0C66E4";
|
|
13
|
+
readonly 'color.background.selected': "#E9F2FF";
|
|
14
|
+
readonly 'color.border.brand': "#0C66E4";
|
|
15
|
+
readonly 'color.chart.brand': "#1D7AFC";
|
|
16
|
+
};
|
|
17
|
+
export default tokenValues;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::cadad94754b78a066c340ab42eca9721>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "\nhtml[data-color-mode=\"light\"][data-theme~=\"light:dark\"],\nhtml[data-color-mode=\"dark\"][data-theme~=\"dark:dark\"] {\n color-scheme: dark;\n --ds-border-input: #
|
|
6
|
+
declare const _default: "\nhtml[data-color-mode=\"light\"][data-theme~=\"light:dark\"],\nhtml[data-color-mode=\"dark\"][data-theme~=\"dark:dark\"] {\n color-scheme: dark;\n --ds-border-input: #738496;\n}\n";
|
|
7
7
|
export default _default;
|
|
@@ -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::a87638614efbe4415e8ffd370dd4ce76>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
6
|
declare const tokens: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const THEME_DATA_ATTRIBUTE = "data-theme";
|
|
2
2
|
export declare const COLOR_MODE_ATTRIBUTE = "data-color-mode";
|
|
3
|
+
export declare const CUSTOM_THEME_ATTRIBUTE = "data-custom-theme";
|
|
3
4
|
export declare const DEFAULT_THEME = "light";
|
|
4
5
|
export declare const CSS_PREFIX = "ds";
|
|
5
6
|
export declare const CSS_VAR_FULL: string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ThemeState, ThemeStyles } from './set-global-theme';
|
|
2
|
+
export declare const CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
|
|
3
|
+
type HEX = `#${string}`;
|
|
4
|
+
export type CSSColor = HEX;
|
|
5
|
+
export interface CustomBrandSchema {
|
|
6
|
+
brandColor: CSSColor;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param themeSchema The schema of available themes
|
|
11
|
+
* @returns a string with the CSS for the custom theme
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
15
|
+
* 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.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
18
|
+
* @param {string} themeState.colorMode Determines which color theme is 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
|
+
export declare function getCustomThemeStyles(themeState: Partial<ThemeState> & {
|
|
25
|
+
UNSAFE_themeOptions: CustomBrandSchema;
|
|
26
|
+
}): Promise<ThemeStyles[]>;
|
|
27
|
+
export declare function loadAndAppendCustomThemeCss(themeState: Partial<ThemeState> & {
|
|
28
|
+
UNSAFE_themeOptions: CustomBrandSchema;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { CSSToken } from './artifacts/token-names';
|
|
|
6
6
|
export type { ActiveTokens } from './artifacts/types';
|
|
7
7
|
export type { ThemeColorModes, Themes, ThemeIds } from './theme-config';
|
|
8
8
|
export type { Groups, OpacityToken, PaintToken, RawToken, ShadowToken, SpacingToken, ShapeToken, } from './types';
|
|
9
|
+
export type { CustomBrandSchema } from './custom-theme';
|
|
9
10
|
export { default as themeConfig } from './theme-config';
|
|
10
11
|
export { useThemeObserver } from './use-theme-observer';
|
|
11
12
|
export { ThemeMutationObserver } from './theme-mutation-observer';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UnbindFn } from 'bind-event-listener';
|
|
2
|
+
import { CustomBrandSchema } from './custom-theme';
|
|
2
3
|
import { ThemeColorModes, ThemeIds, ThemeIdsWithOverrides } from './theme-config';
|
|
3
4
|
export interface ThemeState {
|
|
4
5
|
light: Extract<ThemeIds, 'light' | 'dark' | 'legacy-dark' | 'legacy-light'>;
|
|
@@ -7,10 +8,12 @@ export interface ThemeState {
|
|
|
7
8
|
shape?: Extract<ThemeIds, 'shape'>;
|
|
8
9
|
spacing?: Extract<ThemeIds, 'spacing'>;
|
|
9
10
|
typography?: Extract<ThemeIds, 'typography'>;
|
|
11
|
+
UNSAFE_themeOptions?: CustomBrandSchema;
|
|
10
12
|
}
|
|
11
13
|
export interface ActiveThemeState extends ThemeState {
|
|
12
14
|
colorMode: Exclude<ThemeColorModes, 'auto'>;
|
|
13
15
|
}
|
|
16
|
+
export declare const themeStateDefaults: ThemeState;
|
|
14
17
|
/**
|
|
15
18
|
* Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
|
|
16
19
|
*
|
|
@@ -21,6 +24,7 @@ export interface ActiveThemeState extends ThemeState {
|
|
|
21
24
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
22
25
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
23
26
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
27
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
24
28
|
* @param {function} themeLoader Callback function used to override the default theme loading functionality.
|
|
25
29
|
*
|
|
26
30
|
* @returns A Promise of an unbind function, that can be used to stop listening for changes to system theme.
|
|
@@ -30,7 +34,7 @@ export interface ActiveThemeState extends ThemeState {
|
|
|
30
34
|
* setGlobalTheme({colorMode: 'auto', light: 'light', dark: 'dark', spacing: 'spacing'});
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
|
-
declare const setGlobalTheme: ({ colorMode, dark, light, shape, spacing, typography, }?: Partial<ThemeState>, themeLoader?: ((id: ThemeIdsWithOverrides) => void | Promise<void>) | undefined) => Promise<UnbindFn>;
|
|
37
|
+
declare const setGlobalTheme: ({ colorMode, dark, light, shape, spacing, typography, UNSAFE_themeOptions, }?: Partial<ThemeState>, themeLoader?: ((id: ThemeIdsWithOverrides) => void | Promise<void>) | undefined) => Promise<UnbindFn>;
|
|
34
38
|
export interface ThemeStyles {
|
|
35
39
|
id: ThemeIdsWithOverrides;
|
|
36
40
|
attrs: Record<string, string>;
|
|
@@ -47,9 +51,10 @@ export interface ThemeStyles {
|
|
|
47
51
|
* @param {string} themeState.shape The shape theme to be applied.
|
|
48
52
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
49
53
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
54
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
50
55
|
*
|
|
51
56
|
* @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
52
|
-
* If an error is encountered while loading themes, the themes
|
|
57
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
53
58
|
*/
|
|
54
59
|
export declare const getThemeStyles: (preferences?: Partial<ThemeState> | 'all') => Promise<ThemeStyles[]>;
|
|
55
60
|
/**
|
|
@@ -62,10 +67,11 @@ export declare const getThemeStyles: (preferences?: Partial<ThemeState> | 'all')
|
|
|
62
67
|
* @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
|
|
63
68
|
* @param {string} themeState.spacing The spacing theme to be applied.
|
|
64
69
|
* @param {string} themeState.typography The typography theme to be applied.
|
|
70
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
65
71
|
*
|
|
66
72
|
* @returns {Object} Object of HTML attributes to be applied to the document root
|
|
67
73
|
*/
|
|
68
|
-
export declare const getThemeHtmlAttrs: ({ colorMode, dark, light, shape, spacing, typography, }?: Partial<ThemeState>) => Record<string, string>;
|
|
74
|
+
export declare const getThemeHtmlAttrs: ({ colorMode, dark, light, shape, spacing, typography, UNSAFE_themeOptions, }?: Partial<ThemeState>) => Record<string, string>;
|
|
69
75
|
/**
|
|
70
76
|
* Provides a script that, when executed before paint, sets the `data-color-mode` attribute based on the current system theme,
|
|
71
77
|
* to enable SSR support for automatic theme switching, avoid a flash of un-themed content on first paint.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UtilTokenSchema, ValueSchema } from '../../../types';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
utility: ValueSchema<UtilTokenSchema<"
|
|
3
|
+
utility: ValueSchema<UtilTokenSchema<"DarkNeutral900" | "Lime300" | "Lime200" | "Red300" | "Red200" | "Orange300" | "Orange200" | "Yellow300" | "Yellow200" | "Green300" | "Green200" | "Teal300" | "Teal200" | "Blue300" | "Blue200" | "Purple300" | "Purple200" | "Magenta300" | "Magenta200" | "DarkNeutral800" | "DarkNeutral1100" | "DarkNeutral400A" | "DarkNeutral100" | "Blue400" | "DarkNeutral700" | "Lime500" | "Red500" | "Orange500" | "Yellow500" | "Green500" | "Teal500" | "Blue500" | "Purple500" | "Magenta500" | "DarkNeutral600" | "DarkNeutral300A" | "DarkNeutral200A" | "DarkNeutral0" | "Lime1000" | "Lime900" | "Lime800" | "Lime400" | "Red1000" | "Red900" | "Red800" | "Red400" | "Orange1000" | "Orange900" | "Orange800" | "Orange400" | "Yellow1000" | "Yellow900" | "Yellow800" | "Yellow400" | "Green1000" | "Green900" | "Green800" | "Green400" | "Teal1000" | "Teal900" | "Teal800" | "Teal400" | "Blue1000" | "Blue900" | "Blue800" | "Purple1000" | "Purple900" | "Purple800" | "Purple400" | "Magenta1000" | "Magenta900" | "Magenta800" | "Magenta400" | "DarkNeutral300" | "DarkNeutral400" | "DarkNeutral500" | "DarkNeutral100A" | "DarkNeutral200" | "DarkNeutral250" | "DarkNeutral1000" | "Teal600" | "Orange600" | "Blue100" | "Purple600" | "Magenta100" | "Red600" | "Blue600" | "Magenta600" | "DarkNeutral350" | "DarkNeutral-100A" | "Lime100" | "Lime600" | "Lime700" | "Red100" | "Red700" | "Orange100" | "Orange700" | "Yellow100" | "Yellow600" | "Yellow700" | "Green100" | "Green600" | "Green700" | "Teal100" | "Teal700" | "Blue700" | "Purple100" | "Purple700" | "Magenta700" | "Neutral0" | "Neutral100" | "Neutral200" | "Neutral300" | "Neutral400" | "Neutral500" | "Neutral600" | "Neutral700" | "Neutral800" | "Neutral900" | "Neutral1000" | "Neutral1100" | "Neutral100A" | "Neutral200A" | "Neutral300A" | "Neutral400A" | "Neutral500A" | "DarkNeutral-100" | "DarkNeutral250A" | "DarkNeutral350A" | "DarkNeutral500A">>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UtilTokenSchema, ValueSchema } from '../../../types';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
utility: ValueSchema<UtilTokenSchema<"
|
|
3
|
+
utility: ValueSchema<UtilTokenSchema<"DarkNeutral900" | "Lime300" | "Lime200" | "Red300" | "Red200" | "Orange300" | "Orange200" | "Yellow300" | "Yellow200" | "Green300" | "Green200" | "Teal300" | "Teal200" | "Blue300" | "Blue200" | "Purple300" | "Purple200" | "Magenta300" | "Magenta200" | "DarkNeutral800" | "DarkNeutral1100" | "DarkNeutral400A" | "DarkNeutral100" | "Blue400" | "DarkNeutral700" | "Lime500" | "Red500" | "Orange500" | "Yellow500" | "Green500" | "Teal500" | "Blue500" | "Purple500" | "Magenta500" | "DarkNeutral600" | "DarkNeutral300A" | "DarkNeutral200A" | "DarkNeutral0" | "Lime1000" | "Lime900" | "Lime800" | "Lime400" | "Red1000" | "Red900" | "Red800" | "Red400" | "Orange1000" | "Orange900" | "Orange800" | "Orange400" | "Yellow1000" | "Yellow900" | "Yellow800" | "Yellow400" | "Green1000" | "Green900" | "Green800" | "Green400" | "Teal1000" | "Teal900" | "Teal800" | "Teal400" | "Blue1000" | "Blue900" | "Blue800" | "Purple1000" | "Purple900" | "Purple800" | "Purple400" | "Magenta1000" | "Magenta900" | "Magenta800" | "Magenta400" | "DarkNeutral300" | "DarkNeutral400" | "DarkNeutral500" | "DarkNeutral100A" | "DarkNeutral200" | "DarkNeutral250" | "DarkNeutral1000" | "Teal600" | "Orange600" | "Blue100" | "Purple600" | "Magenta100" | "Red600" | "Blue600" | "Magenta600" | "DarkNeutral350" | "DarkNeutral-100A" | "Lime100" | "Lime600" | "Lime700" | "Red100" | "Red700" | "Orange100" | "Orange700" | "Yellow100" | "Yellow600" | "Yellow700" | "Green100" | "Green600" | "Green700" | "Teal100" | "Teal700" | "Blue700" | "Purple100" | "Purple700" | "Magenta700" | "Neutral0" | "Neutral100" | "Neutral200" | "Neutral300" | "Neutral400" | "Neutral500" | "Neutral600" | "Neutral700" | "Neutral800" | "Neutral900" | "Neutral1000" | "Neutral1100" | "Neutral100A" | "Neutral200A" | "Neutral300A" | "Neutral400A" | "Neutral500A" | "DarkNeutral-100" | "DarkNeutral250A" | "DarkNeutral350A" | "DarkNeutral500A">>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AttributeSchema, UtilTokenSchema } from '../../../types';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
utility: AttributeSchema<UtilTokenSchema<"
|
|
3
|
+
utility: AttributeSchema<UtilTokenSchema<"DarkNeutral900" | "Lime300" | "Lime200" | "Red300" | "Red200" | "Orange300" | "Orange200" | "Yellow300" | "Yellow200" | "Green300" | "Green200" | "Teal300" | "Teal200" | "Blue300" | "Blue200" | "Purple300" | "Purple200" | "Magenta300" | "Magenta200" | "DarkNeutral800" | "DarkNeutral1100" | "DarkNeutral400A" | "DarkNeutral100" | "Blue400" | "DarkNeutral700" | "Lime500" | "Red500" | "Orange500" | "Yellow500" | "Green500" | "Teal500" | "Blue500" | "Purple500" | "Magenta500" | "DarkNeutral600" | "DarkNeutral300A" | "DarkNeutral200A" | "DarkNeutral0" | "Lime1000" | "Lime900" | "Lime800" | "Lime400" | "Red1000" | "Red900" | "Red800" | "Red400" | "Orange1000" | "Orange900" | "Orange800" | "Orange400" | "Yellow1000" | "Yellow900" | "Yellow800" | "Yellow400" | "Green1000" | "Green900" | "Green800" | "Green400" | "Teal1000" | "Teal900" | "Teal800" | "Teal400" | "Blue1000" | "Blue900" | "Blue800" | "Purple1000" | "Purple900" | "Purple800" | "Purple400" | "Magenta1000" | "Magenta900" | "Magenta800" | "Magenta400" | "DarkNeutral300" | "DarkNeutral400" | "DarkNeutral500" | "DarkNeutral100A" | "DarkNeutral200" | "DarkNeutral250" | "DarkNeutral1000" | "Teal600" | "Orange600" | "Blue100" | "Purple600" | "Magenta100" | "Red600" | "Blue600" | "Magenta600" | "DarkNeutral350" | "DarkNeutral-100A" | "Lime100" | "Lime600" | "Lime700" | "Red100" | "Red700" | "Orange100" | "Orange700" | "Yellow100" | "Yellow600" | "Yellow700" | "Green100" | "Green600" | "Green700" | "Teal100" | "Teal700" | "Blue700" | "Purple100" | "Purple700" | "Magenta700" | "Neutral0" | "Neutral100" | "Neutral200" | "Neutral300" | "Neutral400" | "Neutral500" | "Neutral600" | "Neutral700" | "Neutral800" | "Neutral900" | "Neutral1000" | "Neutral1100" | "Neutral100A" | "Neutral200A" | "Neutral300A" | "Neutral400A" | "Neutral500A" | "DarkNeutral-100" | "DarkNeutral250A" | "DarkNeutral350A" | "DarkNeutral500A">>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const isValidBrandHex: (hex: string) => boolean;
|
|
2
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
3
|
+
export declare function getAlpha(hex: string): number;
|
|
4
|
+
export declare function hexToRgbA(hex: string): [number, number, number, number];
|
|
5
|
+
export declare function hexToRgb(hex: string): [number, number, number];
|
|
6
|
+
export declare function hexToHSL(hex: string): [number, number, number];
|
|
7
|
+
export declare function HSLToRGB(h: number, s: number, l: number): [number, number, number];
|
|
8
|
+
export declare function relativeLuminanceW3C(r: number, g: number, b: number): number;
|
|
9
|
+
export declare function getContrastRatio(foreground: string, background: string): number;
|
|
10
|
+
export declare function deltaE(rgbA: number[], rgbB: number[]): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import tokens from '../artifacts/token-names';
|
|
2
|
+
import { CustomBrandSchema } from '../custom-theme';
|
|
3
|
+
import { ThemeColorModes } from '../theme-config';
|
|
4
|
+
type Token = keyof typeof tokens;
|
|
5
|
+
type ThemeAttributeId = 'light' | 'dark';
|
|
6
|
+
export declare function findMissingCustomStyleElements(UNSAFE_themeOptions: CustomBrandSchema, mode: ThemeColorModes): ThemeAttributeId[];
|
|
7
|
+
export declare function limitSizeOfCustomStyleElements(sizeThreshold: number): void;
|
|
8
|
+
export declare function reduceTokenMap(tokenMap: {
|
|
9
|
+
[key in Token]?: number;
|
|
10
|
+
}, themeRamp: string[]): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import tokens from '../artifacts/token-names';
|
|
2
|
+
type Token = keyof typeof tokens;
|
|
3
|
+
interface AdditionalContrastCheck {
|
|
4
|
+
foreground: Token;
|
|
5
|
+
backgroundLight: Token;
|
|
6
|
+
backgroundDark: Token;
|
|
7
|
+
desiredContrast: number;
|
|
8
|
+
updatedTokens: Token[];
|
|
9
|
+
}
|
|
10
|
+
export declare const additionalChecks: AdditionalContrastCheck[];
|
|
11
|
+
export declare const additionalContrastChecker: ({ customThemeTokenMap, mode, themeRamp, }: {
|
|
12
|
+
customThemeTokenMap: {
|
|
13
|
+
[key: string]: number;
|
|
14
|
+
};
|
|
15
|
+
mode: 'light' | 'dark';
|
|
16
|
+
themeRamp: string[];
|
|
17
|
+
}) => {
|
|
18
|
+
[key: string]: number;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import tokens from '../artifacts/token-names';
|
|
2
|
+
import { CSSColor } from '../custom-theme';
|
|
3
|
+
import { ThemeColorModes } from '../theme-config';
|
|
4
|
+
type Token = keyof typeof tokens;
|
|
5
|
+
type TokenMap = {
|
|
6
|
+
[key in Token]?: number;
|
|
7
|
+
};
|
|
8
|
+
type Mode = 'light' | 'dark';
|
|
9
|
+
export declare const getClosestColorIndex: (themeRamp: CSSColor[], brandColor: CSSColor) => number;
|
|
10
|
+
export declare const generateColors: (brandColor: CSSColor) => CSSColor[];
|
|
11
|
+
export declare const generateTokenMap: (brandColor: CSSColor, mode: ThemeColorModes, themeRamp?: CSSColor[]) => {
|
|
12
|
+
light?: TokenMap | undefined;
|
|
13
|
+
dark?: TokenMap | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const generateTokenMapWithContrastCheck: (brandColor: CSSColor, mode: ThemeColorModes, themeRamp?: CSSColor[]) => {
|
|
16
|
+
light?: TokenMap | undefined;
|
|
17
|
+
dark?: TokenMap | undefined;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hash: (str: string) => string;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Below lines are copied from @material/material-color-utilities.
|
|
3
|
+
* Do not modify it.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Converts a color from RGB components to ARGB format.
|
|
7
|
+
*/
|
|
8
|
+
export declare function argbFromRgb(red: number, green: number, blue: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a color from linear RGB components to ARGB format.
|
|
11
|
+
*/
|
|
12
|
+
export declare function argbFromLinrgb(linrgb: number[]): number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the alpha component of a color in ARGB format.
|
|
15
|
+
*/
|
|
16
|
+
export declare function alphaFromArgb(argb: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the red component of a color in ARGB format.
|
|
19
|
+
*/
|
|
20
|
+
export declare function redFromArgb(argb: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the green component of a color in ARGB format.
|
|
23
|
+
*/
|
|
24
|
+
export declare function greenFromArgb(argb: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the blue component of a color in ARGB format.
|
|
27
|
+
*/
|
|
28
|
+
export declare function blueFromArgb(argb: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether a color in ARGB format is opaque.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isOpaque(argb: number): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a color from ARGB to XYZ.
|
|
35
|
+
*/
|
|
36
|
+
export declare function argbFromXyz(x: number, y: number, z: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a color from XYZ to ARGB.
|
|
39
|
+
*/
|
|
40
|
+
export declare function xyzFromArgb(argb: number): number[];
|
|
41
|
+
/**
|
|
42
|
+
* Converts an L* value to an ARGB representation.
|
|
43
|
+
*
|
|
44
|
+
* @param lstar L* in L*a*b*
|
|
45
|
+
* @return ARGB representation of grayscale color with lightness
|
|
46
|
+
* matching L*
|
|
47
|
+
*/
|
|
48
|
+
export declare function argbFromLstar(lstar: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* Computes the L* value of a color in ARGB representation.
|
|
51
|
+
*
|
|
52
|
+
* @param argb ARGB representation of a color
|
|
53
|
+
* @return L*, from L*a*b*, coordinate of the color
|
|
54
|
+
*/
|
|
55
|
+
export declare function lstarFromArgb(argb: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Converts an L* value to a Y value.
|
|
58
|
+
*
|
|
59
|
+
* L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
|
|
60
|
+
*
|
|
61
|
+
* L* measures perceptual luminance, a linear scale. Y in XYZ
|
|
62
|
+
* measures relative luminance, a logarithmic scale.
|
|
63
|
+
*
|
|
64
|
+
* @param lstar L* in L*a*b*
|
|
65
|
+
* @return Y in XYZ
|
|
66
|
+
*/
|
|
67
|
+
export declare function yFromLstar(lstar: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* Converts a Y value to an L* value.
|
|
70
|
+
*
|
|
71
|
+
* L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
|
|
72
|
+
*
|
|
73
|
+
* L* measures perceptual luminance, a linear scale. Y in XYZ
|
|
74
|
+
* measures relative luminance, a logarithmic scale.
|
|
75
|
+
*
|
|
76
|
+
* @param y Y in XYZ
|
|
77
|
+
* @return L* in L*a*b*
|
|
78
|
+
*/
|
|
79
|
+
export declare function lstarFromY(y: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* Linearizes an RGB component.
|
|
82
|
+
*
|
|
83
|
+
* @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B
|
|
84
|
+
* channel
|
|
85
|
+
* @return 0.0 <= output <= 100.0, color channel converted to
|
|
86
|
+
* linear RGB space
|
|
87
|
+
*/
|
|
88
|
+
export declare function linearized(rgbComponent: number): number;
|
|
89
|
+
/**
|
|
90
|
+
* Delinearizes an RGB component.
|
|
91
|
+
*
|
|
92
|
+
* @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
|
|
93
|
+
* linear R/G/B channel
|
|
94
|
+
* @return 0 <= output <= 255, color channel converted to regular
|
|
95
|
+
* RGB space
|
|
96
|
+
*/
|
|
97
|
+
export declare function delinearized(rgbComponent: number): number;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the standard white point; white on a sunny day.
|
|
100
|
+
*
|
|
101
|
+
* @return The white point
|
|
102
|
+
*/
|
|
103
|
+
export declare function whitePointD65(): number[];
|
|
104
|
+
/**
|
|
105
|
+
* RGBA component
|
|
106
|
+
*
|
|
107
|
+
* @param r Red value should be between 0-255
|
|
108
|
+
* @param g Green value should be between 0-255
|
|
109
|
+
* @param b Blue value should be between 0-255
|
|
110
|
+
* @param a Alpha value should be between 0-255
|
|
111
|
+
*/
|
|
112
|
+
export interface Rgba {
|
|
113
|
+
r: number;
|
|
114
|
+
g: number;
|
|
115
|
+
b: number;
|
|
116
|
+
a: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Return RGBA from a given int32 color
|
|
120
|
+
*
|
|
121
|
+
* @param argb ARGB representation of a int32 color.
|
|
122
|
+
* @return RGBA representation of a int32 color.
|
|
123
|
+
*/
|
|
124
|
+
export declare function rgbaFromArgb(argb: number): Rgba;
|
|
125
|
+
/**
|
|
126
|
+
* Return int32 color from a given RGBA component
|
|
127
|
+
*
|
|
128
|
+
* @param rgba RGBA representation of a int32 color.
|
|
129
|
+
* @returns ARGB representation of a int32 color.
|
|
130
|
+
*/
|
|
131
|
+
export declare function argbFromRgba({ r, g, b, a }: Rgba): number;
|