@udixio/theme 2.0.0 → 2.1.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 +16 -0
- package/dist/bin.cjs +1 -1
- package/dist/bin.js +1 -1
- package/dist/browser.cjs +3 -2
- package/dist/browser.js +24 -23
- package/dist/color/color.api.d.ts +5 -1
- package/dist/color/color.api.d.ts.map +1 -1
- package/dist/color/color.d.ts +1 -0
- package/dist/color/color.d.ts.map +1 -1
- package/dist/color/color.manager.d.ts +1 -2
- package/dist/color/color.manager.d.ts.map +1 -1
- package/dist/color/default-color.d.ts +5 -1
- package/dist/color/default-color.d.ts.map +1 -1
- package/dist/{font.plugin-DZtMajJV.js → font.plugin-5Xpo-ntw.js} +1 -1
- package/dist/{font.plugin-BZ-TTeTo.cjs → font.plugin-FPU_gL1Y.cjs} +1 -1
- package/dist/{load-from-path-Dobe0beV.js → load-from-path-CBnO8ESw.js} +1 -1
- package/dist/{load-from-path-DZ35yiXK.cjs → load-from-path-kuofMGN3.cjs} +2 -2
- package/dist/loader/loader.d.ts.map +1 -1
- package/dist/{loader-C8LnOoqg.cjs → loader-BzsrGBu-.cjs} +1166 -458
- package/dist/{loader-BS_Esfwg.js → loader-CoayTlSl.js} +1186 -478
- package/dist/node.cjs +4 -3
- package/dist/node.js +26 -25
- package/dist/palette/palette.d.ts.map +1 -1
- package/dist/variant/variant.d.ts +2 -0
- package/dist/variant/variant.d.ts.map +1 -1
- package/dist/variant/variants/expressive.variant.d.ts.map +1 -1
- package/dist/variant/variants/index.d.ts +1 -1
- package/dist/variant/variants/neutral.variant.d.ts.map +1 -1
- package/dist/variant/variants/tonal-spot.variant.d.ts.map +1 -1
- package/dist/variant/variants/udixio.variant.d.ts +3 -0
- package/dist/variant/variants/udixio.variant.d.ts.map +1 -0
- package/dist/variant/variants/vibrant.variant.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/color/color.api.ts +24 -3
- package/src/color/color.manager.ts +4 -16
- package/src/color/color.ts +4 -0
- package/src/color/default-color.ts +34 -68
- package/src/loader/loader.ts +0 -4
- package/src/palette/palette.ts +1 -2
- package/src/variant/variant.ts +3 -0
- package/src/variant/variants/expressive.variant.ts +2 -0
- package/src/variant/variants/index.ts +2 -2
- package/src/variant/variants/neutral.variant.ts +2 -0
- package/src/variant/variants/tonal-spot.variant.ts +2 -0
- package/src/variant/variants/udixio.variant.ts +846 -0
- package/src/variant/variants/vibrant.variant.ts +2 -0
- package/dist/variant/variants/fidelity.variant.d.ts +0 -3
- package/dist/variant/variants/fidelity.variant.d.ts.map +0 -1
- package/src/variant/variants/fidelity.variant.ts +0 -46
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { lerp, argbFromLstar, sanitizeDegreesDouble, yFromLstar, argbFromLinrgb, Cam16, signum, matrixMultiply, ViewingConditions, lstarFromArgb, lstarFromY, Contrast, clampDouble, DynamicColor as DynamicColor$1, argbFromHex, hexFromArgb, TonalPalette } from "@material/material-color-utilities";
|
|
5
4
|
import { asClass, createContainer, InjectionMode } from "awilix";
|
|
5
|
+
import { argbFromLstar, sanitizeDegreesDouble, yFromLstar, argbFromLinrgb, Cam16, signum, matrixMultiply, ViewingConditions, lstarFromArgb, lstarFromY, lerp, clampDouble, Contrast, DynamicColor as DynamicColor$1, argbFromHex, hexFromArgb, TonalPalette } from "@material/material-color-utilities";
|
|
6
6
|
class API {
|
|
7
7
|
constructor({
|
|
8
8
|
colorApi,
|
|
@@ -24,58 +24,6 @@ class API {
|
|
|
24
24
|
return this.plugins.loadPlugins();
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* @license
|
|
29
|
-
* Copyright 2023 Google LLC
|
|
30
|
-
*
|
|
31
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
-
* you may not use this file except in compliance with the License.
|
|
33
|
-
* You may obtain a copy of the License at
|
|
34
|
-
*
|
|
35
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
-
*
|
|
37
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
-
* See the License for the specific language governing permissions and
|
|
41
|
-
* limitations under the License.
|
|
42
|
-
*/
|
|
43
|
-
class ContrastCurve {
|
|
44
|
-
/**
|
|
45
|
-
* Creates a `ContrastCurve` object.
|
|
46
|
-
*
|
|
47
|
-
* @param low Value for contrast level -1.0
|
|
48
|
-
* @param normal Value for contrast level 0.0
|
|
49
|
-
* @param medium Value for contrast level 0.5
|
|
50
|
-
* @param high Value for contrast level 1.0
|
|
51
|
-
*/
|
|
52
|
-
constructor(low, normal, medium, high) {
|
|
53
|
-
this.low = low;
|
|
54
|
-
this.normal = normal;
|
|
55
|
-
this.medium = medium;
|
|
56
|
-
this.high = high;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns the value at a given contrast level.
|
|
60
|
-
*
|
|
61
|
-
* @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
|
|
62
|
-
* is the lowest; 1.0 is the highest.
|
|
63
|
-
* @return The value. For contrast ratios, a number between 1.0 and 21.0.
|
|
64
|
-
*/
|
|
65
|
-
get(contrastLevel) {
|
|
66
|
-
if (contrastLevel <= -1) {
|
|
67
|
-
return this.low;
|
|
68
|
-
} else if (contrastLevel < 0) {
|
|
69
|
-
return lerp(this.low, this.normal, (contrastLevel - -1) / 1);
|
|
70
|
-
} else if (contrastLevel < 0.5) {
|
|
71
|
-
return lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
|
|
72
|
-
} else if (contrastLevel < 1) {
|
|
73
|
-
return lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
|
|
74
|
-
} else {
|
|
75
|
-
return this.high;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
27
|
/**
|
|
80
28
|
* @license
|
|
81
29
|
* Copyright 2021 Google LLC
|
|
@@ -862,6 +810,125 @@ class Hct {
|
|
|
862
810
|
this.argb = argb;
|
|
863
811
|
}
|
|
864
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* @license
|
|
815
|
+
* Copyright 2023 Google LLC
|
|
816
|
+
*
|
|
817
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
818
|
+
* you may not use this file except in compliance with the License.
|
|
819
|
+
* You may obtain a copy of the License at
|
|
820
|
+
*
|
|
821
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
822
|
+
*
|
|
823
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
824
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
825
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
826
|
+
* See the License for the specific language governing permissions and
|
|
827
|
+
* limitations under the License.
|
|
828
|
+
*/
|
|
829
|
+
class ContrastCurve {
|
|
830
|
+
/**
|
|
831
|
+
* Creates a `ContrastCurve` object.
|
|
832
|
+
*
|
|
833
|
+
* @param low Value for contrast level -1.0
|
|
834
|
+
* @param normal Value for contrast level 0.0
|
|
835
|
+
* @param medium Value for contrast level 0.5
|
|
836
|
+
* @param high Value for contrast level 1.0
|
|
837
|
+
*/
|
|
838
|
+
constructor(low, normal, medium, high) {
|
|
839
|
+
this.low = low;
|
|
840
|
+
this.normal = normal;
|
|
841
|
+
this.medium = medium;
|
|
842
|
+
this.high = high;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Returns the value at a given contrast level.
|
|
846
|
+
*
|
|
847
|
+
* @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
|
|
848
|
+
* is the lowest; 1.0 is the highest.
|
|
849
|
+
* @return The value. For contrast ratios, a number between 1.0 and 21.0.
|
|
850
|
+
*/
|
|
851
|
+
get(contrastLevel) {
|
|
852
|
+
if (contrastLevel <= -1) {
|
|
853
|
+
return this.low;
|
|
854
|
+
} else if (contrastLevel < 0) {
|
|
855
|
+
return lerp(this.low, this.normal, (contrastLevel - -1) / 1);
|
|
856
|
+
} else if (contrastLevel < 0.5) {
|
|
857
|
+
return lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
|
|
858
|
+
} else if (contrastLevel < 1) {
|
|
859
|
+
return lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
|
|
860
|
+
} else {
|
|
861
|
+
return this.high;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
function getCurve(defaultContrast) {
|
|
866
|
+
if (defaultContrast === 1.5) {
|
|
867
|
+
return new ContrastCurve(1.5, 1.5, 3, 4.5);
|
|
868
|
+
} else if (defaultContrast === 3) {
|
|
869
|
+
return new ContrastCurve(3, 3, 4.5, 7);
|
|
870
|
+
} else if (defaultContrast === 4.5) {
|
|
871
|
+
return new ContrastCurve(4.5, 4.5, 7, 11);
|
|
872
|
+
} else if (defaultContrast === 6) {
|
|
873
|
+
return new ContrastCurve(6, 6, 7, 11);
|
|
874
|
+
} else if (defaultContrast === 7) {
|
|
875
|
+
return new ContrastCurve(7, 7, 11, 21);
|
|
876
|
+
} else if (defaultContrast === 9) {
|
|
877
|
+
return new ContrastCurve(9, 9, 11, 21);
|
|
878
|
+
} else if (defaultContrast === 11) {
|
|
879
|
+
return new ContrastCurve(11, 11, 21, 21);
|
|
880
|
+
} else if (defaultContrast === 21) {
|
|
881
|
+
return new ContrastCurve(21, 21, 21, 21);
|
|
882
|
+
} else {
|
|
883
|
+
return new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
|
|
887
|
+
const answer = findBestToneForChroma(
|
|
888
|
+
palette.hue,
|
|
889
|
+
palette.chroma * chromaMultiplier,
|
|
890
|
+
100,
|
|
891
|
+
true
|
|
892
|
+
);
|
|
893
|
+
return clampDouble(lowerBound, upperBound, answer);
|
|
894
|
+
}
|
|
895
|
+
function tMinC(palette, lowerBound = 0, upperBound = 100) {
|
|
896
|
+
const answer = findBestToneForChroma(palette.hue, palette.chroma, 0, false);
|
|
897
|
+
return clampDouble(lowerBound, upperBound, answer);
|
|
898
|
+
}
|
|
899
|
+
function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
|
|
900
|
+
let answer = tone;
|
|
901
|
+
let bestCandidate = Hct.from(hue, chroma, answer);
|
|
902
|
+
while (bestCandidate.chroma < chroma) {
|
|
903
|
+
if (tone < 0 || tone > 100) {
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
tone += byDecreasingTone ? -1 : 1;
|
|
907
|
+
const newCandidate = Hct.from(hue, chroma, tone);
|
|
908
|
+
if (bestCandidate.chroma < newCandidate.chroma) {
|
|
909
|
+
bestCandidate = newCandidate;
|
|
910
|
+
answer = tone;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return answer;
|
|
914
|
+
}
|
|
915
|
+
function calculateToneAdjustmentPercentage(toneA, toneB, desiredRatio) {
|
|
916
|
+
const currentRatio = Contrast.ratioOfTones(toneA, toneB);
|
|
917
|
+
if (currentRatio >= desiredRatio) {
|
|
918
|
+
return 0;
|
|
919
|
+
}
|
|
920
|
+
const lighterTone = Contrast.lighter(toneA, desiredRatio);
|
|
921
|
+
const darkerTone = Contrast.darker(toneA, desiredRatio);
|
|
922
|
+
if (lighterTone !== -1 && toneB < lighterTone) {
|
|
923
|
+
const percentageToAdjust = (toneB - lighterTone) / (toneA - lighterTone);
|
|
924
|
+
return clampDouble(0, 1, percentageToAdjust);
|
|
925
|
+
}
|
|
926
|
+
if (darkerTone !== -1 && toneB > darkerTone) {
|
|
927
|
+
const percentageToAdjust = (toneB - darkerTone) / (toneA - darkerTone);
|
|
928
|
+
return clampDouble(0, 1, percentageToAdjust);
|
|
929
|
+
}
|
|
930
|
+
return 0;
|
|
931
|
+
}
|
|
865
932
|
/**
|
|
866
933
|
* @license
|
|
867
934
|
* Copyright 2022 Google LLC
|
|
@@ -1249,6 +1316,9 @@ class Color {
|
|
|
1249
1316
|
constructor(name) {
|
|
1250
1317
|
this.name = name;
|
|
1251
1318
|
}
|
|
1319
|
+
static maxChroma(hue, tone = 50) {
|
|
1320
|
+
return Hct.from(hue, 200, tone).chroma;
|
|
1321
|
+
}
|
|
1252
1322
|
getHex() {
|
|
1253
1323
|
return hexFromArgb(this.getArgb());
|
|
1254
1324
|
}
|
|
@@ -1397,349 +1467,71 @@ class ColorFromPalette extends Color {
|
|
|
1397
1467
|
}
|
|
1398
1468
|
}
|
|
1399
1469
|
}
|
|
1400
|
-
const highestSurface = (context, colorService) => {
|
|
1470
|
+
const highestSurface$1 = (context, colorService) => {
|
|
1401
1471
|
if (colorService instanceof ColorApi) {
|
|
1402
1472
|
return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
|
|
1403
1473
|
} else {
|
|
1404
1474
|
return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
|
|
1405
1475
|
}
|
|
1406
1476
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1477
|
+
const defaultColors = ({
|
|
1478
|
+
colors,
|
|
1479
|
+
context: c,
|
|
1480
|
+
palettes
|
|
1481
|
+
}) => {
|
|
1482
|
+
const getColor = (key) => {
|
|
1483
|
+
return colors.get(key);
|
|
1484
|
+
};
|
|
1485
|
+
return {
|
|
1486
|
+
////////////////////////////////////////////////////////////////
|
|
1487
|
+
// Surfaces [S] //
|
|
1488
|
+
////////////////////////////////////////////////////////////////
|
|
1489
|
+
surface: {
|
|
1490
|
+
palette: () => palettes.get("neutral"),
|
|
1491
|
+
tone: () => {
|
|
1492
|
+
if (c.isDark) {
|
|
1493
|
+
return 4;
|
|
1423
1494
|
} else {
|
|
1424
|
-
|
|
1495
|
+
if (Hct.isYellow(palettes.get("neutral").hue)) {
|
|
1496
|
+
return 99;
|
|
1497
|
+
} else if (c.variant.name === "vibrant") {
|
|
1498
|
+
return 97;
|
|
1499
|
+
} else {
|
|
1500
|
+
return 98;
|
|
1501
|
+
}
|
|
1425
1502
|
}
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
} else if (defaultContrast === 7) {
|
|
1459
|
-
return new ContrastCurve(7, 7, 11, 21);
|
|
1460
|
-
} else if (defaultContrast === 9) {
|
|
1461
|
-
return new ContrastCurve(9, 9, 11, 21);
|
|
1462
|
-
} else if (defaultContrast === 11) {
|
|
1463
|
-
return new ContrastCurve(11, 11, 21, 21);
|
|
1464
|
-
} else if (defaultContrast === 21) {
|
|
1465
|
-
return new ContrastCurve(21, 21, 21, 21);
|
|
1466
|
-
} else {
|
|
1467
|
-
return new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
|
|
1471
|
-
const answer = findBestToneForChroma(
|
|
1472
|
-
palette.hue,
|
|
1473
|
-
palette.chroma * chromaMultiplier,
|
|
1474
|
-
100,
|
|
1475
|
-
true
|
|
1476
|
-
);
|
|
1477
|
-
return clampDouble(lowerBound, upperBound, answer);
|
|
1478
|
-
}
|
|
1479
|
-
function tMinC(palette, lowerBound = 0, upperBound = 100) {
|
|
1480
|
-
const answer = findBestToneForChroma(palette.hue, palette.chroma, 0, false);
|
|
1481
|
-
return clampDouble(lowerBound, upperBound, answer);
|
|
1482
|
-
}
|
|
1483
|
-
function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
|
|
1484
|
-
let answer = tone;
|
|
1485
|
-
let bestCandidate = Hct.from(hue, chroma, answer);
|
|
1486
|
-
while (bestCandidate.chroma < chroma) {
|
|
1487
|
-
if (tone < 0 || tone > 100) {
|
|
1488
|
-
break;
|
|
1489
|
-
}
|
|
1490
|
-
tone += byDecreasingTone ? -1 : 1;
|
|
1491
|
-
const newCandidate = Hct.from(hue, chroma, tone);
|
|
1492
|
-
if (bestCandidate.chroma < newCandidate.chroma) {
|
|
1493
|
-
bestCandidate = newCandidate;
|
|
1494
|
-
answer = tone;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
return answer;
|
|
1498
|
-
}
|
|
1499
|
-
function calculateToneAdjustmentPercentage(toneA, toneB, desiredRatio) {
|
|
1500
|
-
const currentRatio = Contrast.ratioOfTones(toneA, toneB);
|
|
1501
|
-
if (currentRatio >= desiredRatio) {
|
|
1502
|
-
return 0;
|
|
1503
|
-
}
|
|
1504
|
-
const lighterTone = Contrast.lighter(toneA, desiredRatio);
|
|
1505
|
-
const darkerTone = Contrast.darker(toneA, desiredRatio);
|
|
1506
|
-
if (lighterTone !== -1 && toneB < lighterTone) {
|
|
1507
|
-
const percentageToAdjust = (toneB - lighterTone) / (toneA - lighterTone);
|
|
1508
|
-
return clampDouble(0, 1, percentageToAdjust);
|
|
1509
|
-
}
|
|
1510
|
-
if (darkerTone !== -1 && toneB > darkerTone) {
|
|
1511
|
-
const percentageToAdjust = (toneB - darkerTone) / (toneA - darkerTone);
|
|
1512
|
-
return clampDouble(0, 1, percentageToAdjust);
|
|
1513
|
-
}
|
|
1514
|
-
return 0;
|
|
1515
|
-
}
|
|
1516
|
-
function capitalizeFirstLetter(string) {
|
|
1517
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1518
|
-
}
|
|
1519
|
-
class ColorApi {
|
|
1520
|
-
constructor({ colorManager }) {
|
|
1521
|
-
__publicField(this, "colorManager");
|
|
1522
|
-
__publicField(this, "api");
|
|
1523
|
-
this.colorManager = colorManager;
|
|
1524
|
-
}
|
|
1525
|
-
getAll() {
|
|
1526
|
-
return this.colorManager.getAll();
|
|
1527
|
-
}
|
|
1528
|
-
addColor(key, color) {
|
|
1529
|
-
return this.colorManager.createOrUpdate(key, color);
|
|
1530
|
-
}
|
|
1531
|
-
addColors(args) {
|
|
1532
|
-
if (!this.api)
|
|
1533
|
-
throw new Error(
|
|
1534
|
-
"The API is not initialized. Please call bootstrap() before calling addColors()."
|
|
1535
|
-
);
|
|
1536
|
-
if (typeof args === "function") {
|
|
1537
|
-
args = args(this.api);
|
|
1538
|
-
}
|
|
1539
|
-
if (args) {
|
|
1540
|
-
Object.entries(args).forEach(([name, colorOption]) => {
|
|
1541
|
-
this.addColor(name, colorOption);
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
get(key) {
|
|
1546
|
-
return this.colorManager.get(key);
|
|
1547
|
-
}
|
|
1548
|
-
remove(key) {
|
|
1549
|
-
return this.colorManager.remove(key);
|
|
1550
|
-
}
|
|
1551
|
-
update(key, newColor) {
|
|
1552
|
-
return this.colorManager.createOrUpdate(key, newColor);
|
|
1553
|
-
}
|
|
1554
|
-
addFromCustomPalette(key) {
|
|
1555
|
-
const colorKey = key;
|
|
1556
|
-
const colorDimKey = colorKey + "Dim";
|
|
1557
|
-
const ColorKey = capitalizeFirstLetter(key);
|
|
1558
|
-
const onColorKey = "on" + ColorKey;
|
|
1559
|
-
const colorContainerKey = colorKey + "Container";
|
|
1560
|
-
const onColorContainerKey = "on" + ColorKey + "Container";
|
|
1561
|
-
const colorFixedKey = colorKey + "Fixed";
|
|
1562
|
-
const colorFixedDimKey = colorKey + "FixedDim";
|
|
1563
|
-
const onColorFixedKey = "on" + ColorKey + "Fixed";
|
|
1564
|
-
const onColorFixedVariantKey = "on" + ColorKey + "FixedVariant";
|
|
1565
|
-
const colors = ({ palettes, colors: colors2, context: ctx }) => ({
|
|
1566
|
-
[colorKey]: {
|
|
1567
|
-
palette: () => palettes.get(colorKey),
|
|
1568
|
-
tone: () => {
|
|
1569
|
-
if (ctx.variant.name === "neutral") {
|
|
1570
|
-
return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
|
|
1571
|
-
} else if (ctx.variant.name === "vibrant") {
|
|
1572
|
-
return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
|
|
1573
|
-
} else {
|
|
1574
|
-
return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
|
|
1575
|
-
}
|
|
1576
|
-
},
|
|
1577
|
-
isBackground: true,
|
|
1578
|
-
background: () => highestSurface(ctx, this),
|
|
1579
|
-
contrastCurve: () => getCurve(4.5),
|
|
1580
|
-
adjustTone: () => toneDeltaPair(
|
|
1581
|
-
colors2.get(colorContainerKey),
|
|
1582
|
-
colors2.get(colorKey),
|
|
1583
|
-
5,
|
|
1584
|
-
"relative_lighter",
|
|
1585
|
-
true,
|
|
1586
|
-
"farther"
|
|
1587
|
-
)
|
|
1588
|
-
},
|
|
1589
|
-
[colorDimKey]: {
|
|
1590
|
-
palette: () => palettes.get(colorKey),
|
|
1591
|
-
tone: () => {
|
|
1592
|
-
if (ctx.variant.name === "neutral") {
|
|
1593
|
-
return 85;
|
|
1594
|
-
} else {
|
|
1595
|
-
return tMaxC(palettes.get(colorKey), 0, 90);
|
|
1596
|
-
}
|
|
1597
|
-
},
|
|
1598
|
-
isBackground: true,
|
|
1599
|
-
background: () => this.get("surfaceContainerHigh"),
|
|
1600
|
-
contrastCurve: () => getCurve(4.5),
|
|
1601
|
-
adjustTone: () => toneDeltaPair(
|
|
1602
|
-
this.get(colorDimKey),
|
|
1603
|
-
this.get(colorKey),
|
|
1604
|
-
5,
|
|
1605
|
-
"darker",
|
|
1606
|
-
true,
|
|
1607
|
-
"farther"
|
|
1608
|
-
)
|
|
1609
|
-
},
|
|
1610
|
-
[onColorKey]: {
|
|
1611
|
-
palette: () => palettes.get(colorKey),
|
|
1612
|
-
background: () => this.get(colorKey),
|
|
1613
|
-
contrastCurve: () => getCurve(6)
|
|
1614
|
-
},
|
|
1615
|
-
[colorContainerKey]: {
|
|
1616
|
-
palette: () => palettes.get(colorKey),
|
|
1617
|
-
tone: () => {
|
|
1618
|
-
if (ctx.variant.name === "vibrant") {
|
|
1619
|
-
return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
|
|
1620
|
-
} else if (ctx.variant.name === "expressive") {
|
|
1621
|
-
return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
|
|
1622
|
-
} else {
|
|
1623
|
-
return ctx.isDark ? 25 : 90;
|
|
1624
|
-
}
|
|
1625
|
-
},
|
|
1626
|
-
isBackground: true,
|
|
1627
|
-
background: () => highestSurface(ctx, this),
|
|
1628
|
-
adjustTone: () => void 0,
|
|
1629
|
-
contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
1630
|
-
},
|
|
1631
|
-
[onColorContainerKey]: {
|
|
1632
|
-
palette: () => palettes.get(colorKey),
|
|
1633
|
-
background: () => this.get(colorContainerKey),
|
|
1634
|
-
contrastCurve: () => getCurve(6)
|
|
1635
|
-
},
|
|
1636
|
-
[colorFixedKey]: {
|
|
1637
|
-
palette: () => palettes.get(colorKey),
|
|
1638
|
-
tone: () => {
|
|
1639
|
-
return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
|
|
1640
|
-
const color = this.get(colorContainerKey);
|
|
1641
|
-
return color.getTone();
|
|
1642
|
-
});
|
|
1643
|
-
},
|
|
1644
|
-
isBackground: true,
|
|
1645
|
-
background: () => highestSurface(ctx, this),
|
|
1646
|
-
contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
1647
|
-
},
|
|
1648
|
-
[colorFixedDimKey]: {
|
|
1649
|
-
palette: () => palettes.get(colorKey),
|
|
1650
|
-
tone: () => this.get(colorFixedKey).getTone(),
|
|
1651
|
-
isBackground: true,
|
|
1652
|
-
adjustTone: () => toneDeltaPair(
|
|
1653
|
-
this.get(colorFixedDimKey),
|
|
1654
|
-
this.get(colorFixedKey),
|
|
1655
|
-
5,
|
|
1656
|
-
"darker",
|
|
1657
|
-
true,
|
|
1658
|
-
"exact"
|
|
1659
|
-
)
|
|
1660
|
-
},
|
|
1661
|
-
[onColorFixedKey]: {
|
|
1662
|
-
palette: () => palettes.get(colorKey),
|
|
1663
|
-
background: () => this.get(colorFixedDimKey),
|
|
1664
|
-
contrastCurve: () => getCurve(7)
|
|
1665
|
-
},
|
|
1666
|
-
[onColorFixedVariantKey]: {
|
|
1667
|
-
palette: () => palettes.get(colorKey),
|
|
1668
|
-
background: () => this.get(colorFixedDimKey),
|
|
1669
|
-
contrastCurve: () => getCurve(4.5)
|
|
1670
|
-
}
|
|
1671
|
-
});
|
|
1672
|
-
this.addColors(colors);
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
const ColorModule = {
|
|
1676
|
-
colorManager: asClass(ColorManager).singleton(),
|
|
1677
|
-
colorApi: asClass(ColorApi).singleton()
|
|
1678
|
-
};
|
|
1679
|
-
const inverseTone = (tone) => {
|
|
1680
|
-
return 100 - tone;
|
|
1681
|
-
};
|
|
1682
|
-
const defaultColors = ({
|
|
1683
|
-
colors,
|
|
1684
|
-
context: c,
|
|
1685
|
-
palettes
|
|
1686
|
-
}) => {
|
|
1687
|
-
const getColor = (key) => {
|
|
1688
|
-
return colors.get(key);
|
|
1689
|
-
};
|
|
1690
|
-
return {
|
|
1691
|
-
////////////////////////////////////////////////////////////////
|
|
1692
|
-
// Surfaces [S] //
|
|
1693
|
-
////////////////////////////////////////////////////////////////
|
|
1694
|
-
surface: {
|
|
1695
|
-
palette: () => palettes.get("neutral"),
|
|
1696
|
-
tone: () => {
|
|
1697
|
-
if (c.isDark) {
|
|
1698
|
-
return 4;
|
|
1699
|
-
} else {
|
|
1700
|
-
if (c.variant.name == "fidelity") {
|
|
1701
|
-
return 100;
|
|
1702
|
-
}
|
|
1703
|
-
if (Hct.isYellow(palettes.get("neutral").hue)) {
|
|
1704
|
-
return 99;
|
|
1705
|
-
} else if (c.variant.name === "vibrant") {
|
|
1706
|
-
return 97;
|
|
1707
|
-
} else {
|
|
1708
|
-
return 98;
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
},
|
|
1712
|
-
isBackground: true
|
|
1713
|
-
},
|
|
1714
|
-
surfaceDim: {
|
|
1715
|
-
palette: () => palettes.get("neutral"),
|
|
1716
|
-
tone: () => {
|
|
1717
|
-
if (c.isDark) {
|
|
1718
|
-
return 4;
|
|
1719
|
-
} else {
|
|
1720
|
-
if (Hct.isYellow(palettes.get("neutral").hue)) {
|
|
1721
|
-
return 90;
|
|
1722
|
-
} else if (c.variant.name === "vibrant") {
|
|
1723
|
-
return 85;
|
|
1724
|
-
} else {
|
|
1725
|
-
return 87;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
},
|
|
1729
|
-
isBackground: true,
|
|
1730
|
-
chromaMultiplier: () => {
|
|
1731
|
-
if (!c.isDark) {
|
|
1732
|
-
if (c.variant.name === "neutral") {
|
|
1733
|
-
return 2.5;
|
|
1734
|
-
} else if (c.variant.name === "tonalSpot") {
|
|
1735
|
-
return 1.7;
|
|
1736
|
-
} else if (c.variant.name === "expressive") {
|
|
1737
|
-
return Hct.isYellow(palettes.get("neutral").hue) ? 2.7 : 1.75;
|
|
1738
|
-
} else if (c.variant.name === "vibrant") {
|
|
1739
|
-
return 1.36;
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
return 1;
|
|
1503
|
+
},
|
|
1504
|
+
isBackground: true
|
|
1505
|
+
},
|
|
1506
|
+
surfaceDim: {
|
|
1507
|
+
palette: () => palettes.get("neutral"),
|
|
1508
|
+
tone: () => {
|
|
1509
|
+
if (c.isDark) {
|
|
1510
|
+
return 4;
|
|
1511
|
+
} else {
|
|
1512
|
+
if (Hct.isYellow(palettes.get("neutral").hue)) {
|
|
1513
|
+
return 90;
|
|
1514
|
+
} else if (c.variant.name === "vibrant") {
|
|
1515
|
+
return 85;
|
|
1516
|
+
} else {
|
|
1517
|
+
return 87;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
isBackground: true,
|
|
1522
|
+
chromaMultiplier: () => {
|
|
1523
|
+
if (!c.isDark) {
|
|
1524
|
+
if (c.variant.name === "neutral") {
|
|
1525
|
+
return 2.5;
|
|
1526
|
+
} else if (c.variant.name === "tonalSpot") {
|
|
1527
|
+
return 1.7;
|
|
1528
|
+
} else if (c.variant.name === "expressive") {
|
|
1529
|
+
return Hct.isYellow(palettes.get("neutral").hue) ? 2.7 : 1.75;
|
|
1530
|
+
} else if (c.variant.name === "vibrant") {
|
|
1531
|
+
return 1.36;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return 1;
|
|
1743
1535
|
}
|
|
1744
1536
|
},
|
|
1745
1537
|
surfaceBright: {
|
|
@@ -1901,7 +1693,7 @@ const defaultColors = ({
|
|
|
1901
1693
|
if (c.variant.name === "vibrant") {
|
|
1902
1694
|
return tMaxC(palettes.get("neutral"), 0, 100, 1.1);
|
|
1903
1695
|
} else {
|
|
1904
|
-
return getInitialToneFromBackground(highestSurface(c, colors));
|
|
1696
|
+
return getInitialToneFromBackground(highestSurface$1(c, colors));
|
|
1905
1697
|
}
|
|
1906
1698
|
},
|
|
1907
1699
|
chromaMultiplier: () => {
|
|
@@ -1914,7 +1706,7 @@ const defaultColors = ({
|
|
|
1914
1706
|
}
|
|
1915
1707
|
return 1;
|
|
1916
1708
|
},
|
|
1917
|
-
background: () => highestSurface(c, colors),
|
|
1709
|
+
background: () => highestSurface$1(c, colors),
|
|
1918
1710
|
contrastCurve: () => c.isDark ? getCurve(11) : getCurve(9)
|
|
1919
1711
|
},
|
|
1920
1712
|
onSurfaceVariant: {
|
|
@@ -1929,7 +1721,7 @@ const defaultColors = ({
|
|
|
1929
1721
|
}
|
|
1930
1722
|
return 1;
|
|
1931
1723
|
},
|
|
1932
|
-
background: () => highestSurface(c, colors),
|
|
1724
|
+
background: () => highestSurface$1(c, colors),
|
|
1933
1725
|
contrastCurve: () => c.isDark ? getCurve(6) : getCurve(4.5)
|
|
1934
1726
|
},
|
|
1935
1727
|
outline: {
|
|
@@ -1944,7 +1736,7 @@ const defaultColors = ({
|
|
|
1944
1736
|
}
|
|
1945
1737
|
return 1;
|
|
1946
1738
|
},
|
|
1947
|
-
background: () => highestSurface(c, colors),
|
|
1739
|
+
background: () => highestSurface$1(c, colors),
|
|
1948
1740
|
contrastCurve: () => getCurve(3)
|
|
1949
1741
|
},
|
|
1950
1742
|
outlineVariant: {
|
|
@@ -1959,7 +1751,7 @@ const defaultColors = ({
|
|
|
1959
1751
|
}
|
|
1960
1752
|
return 1;
|
|
1961
1753
|
},
|
|
1962
|
-
background: () => highestSurface(c, colors),
|
|
1754
|
+
background: () => highestSurface$1(c, colors),
|
|
1963
1755
|
contrastCurve: () => getCurve(1.5)
|
|
1964
1756
|
},
|
|
1965
1757
|
inverseSurface: {
|
|
@@ -1993,8 +1785,6 @@ const defaultColors = ({
|
|
|
1993
1785
|
0,
|
|
1994
1786
|
Hct.isYellow(palettes.get("primary").hue) ? 25 : Hct.isCyan(palettes.get("primary").hue) ? 88 : 98
|
|
1995
1787
|
);
|
|
1996
|
-
} else if (c.variant.name == "fidelity") {
|
|
1997
|
-
return c.sourceColor.tone;
|
|
1998
1788
|
} else {
|
|
1999
1789
|
return tMaxC(
|
|
2000
1790
|
palettes.get("primary"),
|
|
@@ -2004,23 +1794,9 @@ const defaultColors = ({
|
|
|
2004
1794
|
}
|
|
2005
1795
|
},
|
|
2006
1796
|
isBackground: true,
|
|
2007
|
-
background: () => highestSurface(c, colors),
|
|
1797
|
+
background: () => highestSurface$1(c, colors),
|
|
2008
1798
|
contrastCurve: () => getCurve(4.5),
|
|
2009
|
-
adjustTone: () =>
|
|
2010
|
-
const surfaceTone = colors.get("surface").getTone();
|
|
2011
|
-
const primaryTone = colors.get("primary").options.tone;
|
|
2012
|
-
let selfTone = primaryTone;
|
|
2013
|
-
if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
|
|
2014
|
-
const ratio = calculateToneAdjustmentPercentage(
|
|
2015
|
-
surfaceTone,
|
|
2016
|
-
selfTone,
|
|
2017
|
-
3
|
|
2018
|
-
);
|
|
2019
|
-
const inverseT = inverseTone(primaryTone);
|
|
2020
|
-
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
2021
|
-
}
|
|
2022
|
-
return selfTone;
|
|
2023
|
-
} : toneDeltaPair(
|
|
1799
|
+
adjustTone: () => toneDeltaPair(
|
|
2024
1800
|
colors.get("primaryContainer"),
|
|
2025
1801
|
colors.get("primary"),
|
|
2026
1802
|
5,
|
|
@@ -2071,26 +1847,14 @@ const defaultColors = ({
|
|
|
2071
1847
|
Hct.isCyan(palettes.get("primary").hue) ? 88 : 90
|
|
2072
1848
|
);
|
|
2073
1849
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
66,
|
|
2080
|
-
Hct.isCyan(palettes.get("primary").hue) ? 88 : 93
|
|
2081
|
-
);
|
|
2082
|
-
}
|
|
1850
|
+
return c.isDark ? tMinC(palettes.get("primary"), 66, 93) : tMaxC(
|
|
1851
|
+
palettes.get("primary"),
|
|
1852
|
+
66,
|
|
1853
|
+
Hct.isCyan(palettes.get("primary").hue) ? 88 : 93
|
|
1854
|
+
);
|
|
2083
1855
|
},
|
|
2084
1856
|
isBackground: true,
|
|
2085
|
-
background: () => highestSurface(c, colors),
|
|
2086
|
-
adjustTone: () => c.variant.name == "fidelity" ? toneDeltaPair(
|
|
2087
|
-
colors.get("primary"),
|
|
2088
|
-
colors.get("primaryContainer"),
|
|
2089
|
-
15,
|
|
2090
|
-
"relative_darker",
|
|
2091
|
-
true,
|
|
2092
|
-
"farther"
|
|
2093
|
-
) : void 0,
|
|
1857
|
+
background: () => highestSurface$1(c, colors),
|
|
2094
1858
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2095
1859
|
},
|
|
2096
1860
|
onPrimaryContainer: {
|
|
@@ -2113,7 +1877,7 @@ const defaultColors = ({
|
|
|
2113
1877
|
);
|
|
2114
1878
|
},
|
|
2115
1879
|
isBackground: true,
|
|
2116
|
-
background: () => highestSurface(c, colors),
|
|
1880
|
+
background: () => highestSurface$1(c, colors),
|
|
2117
1881
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2118
1882
|
},
|
|
2119
1883
|
primaryFixedDim: {
|
|
@@ -2160,7 +1924,7 @@ const defaultColors = ({
|
|
|
2160
1924
|
}
|
|
2161
1925
|
},
|
|
2162
1926
|
isBackground: true,
|
|
2163
|
-
background: () => highestSurface(c, colors),
|
|
1927
|
+
background: () => highestSurface$1(c, colors),
|
|
2164
1928
|
contrastCurve: () => getCurve(4.5),
|
|
2165
1929
|
adjustTone: () => toneDeltaPair(
|
|
2166
1930
|
getColor("secondaryContainer"),
|
|
@@ -2209,7 +1973,7 @@ const defaultColors = ({
|
|
|
2209
1973
|
}
|
|
2210
1974
|
},
|
|
2211
1975
|
isBackground: true,
|
|
2212
|
-
background: () => highestSurface(c, colors),
|
|
1976
|
+
background: () => highestSurface$1(c, colors),
|
|
2213
1977
|
adjustTone: () => void 0,
|
|
2214
1978
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2215
1979
|
},
|
|
@@ -2233,7 +1997,7 @@ const defaultColors = ({
|
|
|
2233
1997
|
);
|
|
2234
1998
|
},
|
|
2235
1999
|
isBackground: true,
|
|
2236
|
-
background: () => highestSurface(c, colors),
|
|
2000
|
+
background: () => highestSurface$1(c, colors),
|
|
2237
2001
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2238
2002
|
},
|
|
2239
2003
|
secondaryFixedDim: {
|
|
@@ -2276,7 +2040,7 @@ const defaultColors = ({
|
|
|
2276
2040
|
}
|
|
2277
2041
|
},
|
|
2278
2042
|
isBackground: true,
|
|
2279
|
-
background: () => highestSurface(c, colors),
|
|
2043
|
+
background: () => highestSurface$1(c, colors),
|
|
2280
2044
|
contrastCurve: () => getCurve(4.5),
|
|
2281
2045
|
adjustTone: () => toneDeltaPair(
|
|
2282
2046
|
getColor("tertiaryContainer"),
|
|
@@ -2331,7 +2095,7 @@ const defaultColors = ({
|
|
|
2331
2095
|
}
|
|
2332
2096
|
},
|
|
2333
2097
|
isBackground: true,
|
|
2334
|
-
background: () => highestSurface(c, colors),
|
|
2098
|
+
background: () => highestSurface$1(c, colors),
|
|
2335
2099
|
adjustTone: () => void 0,
|
|
2336
2100
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2337
2101
|
},
|
|
@@ -2355,7 +2119,7 @@ const defaultColors = ({
|
|
|
2355
2119
|
);
|
|
2356
2120
|
},
|
|
2357
2121
|
isBackground: true,
|
|
2358
|
-
background: () => highestSurface(c, colors),
|
|
2122
|
+
background: () => highestSurface$1(c, colors),
|
|
2359
2123
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2360
2124
|
},
|
|
2361
2125
|
tertiaryFixedDim: {
|
|
@@ -2390,7 +2154,7 @@ const defaultColors = ({
|
|
|
2390
2154
|
return c.isDark ? tMinC(palettes.get("error"), 0, 98) : tMaxC(palettes.get("error"));
|
|
2391
2155
|
},
|
|
2392
2156
|
isBackground: true,
|
|
2393
|
-
background: () => highestSurface(c, colors),
|
|
2157
|
+
background: () => highestSurface$1(c, colors),
|
|
2394
2158
|
contrastCurve: () => getCurve(4.5),
|
|
2395
2159
|
adjustTone: () => toneDeltaPair(
|
|
2396
2160
|
colors.get("errorContainer"),
|
|
@@ -2427,7 +2191,7 @@ const defaultColors = ({
|
|
|
2427
2191
|
return c.isDark ? tMinC(palettes.get("error"), 30, 93) : tMaxC(palettes.get("error"), 0, 90);
|
|
2428
2192
|
},
|
|
2429
2193
|
isBackground: true,
|
|
2430
|
-
background: () => highestSurface(c, colors),
|
|
2194
|
+
background: () => highestSurface$1(c, colors),
|
|
2431
2195
|
adjustTone: () => void 0,
|
|
2432
2196
|
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2433
2197
|
},
|
|
@@ -2451,7 +2215,229 @@ const defaultColors = ({
|
|
|
2451
2215
|
onBackground: {
|
|
2452
2216
|
alias: "onSurface"
|
|
2453
2217
|
}
|
|
2454
|
-
};
|
|
2218
|
+
};
|
|
2219
|
+
};
|
|
2220
|
+
function capitalizeFirstLetter(string) {
|
|
2221
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
2222
|
+
}
|
|
2223
|
+
class ColorApi {
|
|
2224
|
+
constructor({
|
|
2225
|
+
colorManager,
|
|
2226
|
+
context
|
|
2227
|
+
}) {
|
|
2228
|
+
__publicField(this, "colorManager");
|
|
2229
|
+
__publicField(this, "context");
|
|
2230
|
+
__publicField(this, "api");
|
|
2231
|
+
this.context = context;
|
|
2232
|
+
this.colorManager = colorManager;
|
|
2233
|
+
this.context.onUpdate((changed) => {
|
|
2234
|
+
if (changed.includes("variant")) {
|
|
2235
|
+
this.colorManager.clear();
|
|
2236
|
+
this.addColors(this.context.variant.colors);
|
|
2237
|
+
}
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
getAll() {
|
|
2241
|
+
return this.colorManager.getAll();
|
|
2242
|
+
}
|
|
2243
|
+
addColor(key, color) {
|
|
2244
|
+
return this.colorManager.createOrUpdate(key, color);
|
|
2245
|
+
}
|
|
2246
|
+
addColors(args) {
|
|
2247
|
+
if (!this.api)
|
|
2248
|
+
throw new Error(
|
|
2249
|
+
"The API is not initialized. Please call bootstrap() before calling addColors()."
|
|
2250
|
+
);
|
|
2251
|
+
if (typeof args === "function") {
|
|
2252
|
+
args = args(this.api);
|
|
2253
|
+
}
|
|
2254
|
+
if (args) {
|
|
2255
|
+
Object.entries(args).forEach(([name, colorOption]) => {
|
|
2256
|
+
this.addColor(name, colorOption);
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
get(key) {
|
|
2261
|
+
return this.colorManager.get(key);
|
|
2262
|
+
}
|
|
2263
|
+
remove(key) {
|
|
2264
|
+
return this.colorManager.remove(key);
|
|
2265
|
+
}
|
|
2266
|
+
update(key, newColor) {
|
|
2267
|
+
return this.colorManager.createOrUpdate(key, newColor);
|
|
2268
|
+
}
|
|
2269
|
+
addFromCustomPalette(key) {
|
|
2270
|
+
if (this.context.variant.colorsFromCustomPalette) {
|
|
2271
|
+
return this.addColors(this.context.variant.colorsFromCustomPalette(key));
|
|
2272
|
+
}
|
|
2273
|
+
const colorKey = key;
|
|
2274
|
+
const colorDimKey = colorKey + "Dim";
|
|
2275
|
+
const ColorKey = capitalizeFirstLetter(key);
|
|
2276
|
+
const onColorKey = "on" + ColorKey;
|
|
2277
|
+
const colorContainerKey = colorKey + "Container";
|
|
2278
|
+
const onColorContainerKey = "on" + ColorKey + "Container";
|
|
2279
|
+
const colorFixedKey = colorKey + "Fixed";
|
|
2280
|
+
const colorFixedDimKey = colorKey + "FixedDim";
|
|
2281
|
+
const onColorFixedKey = "on" + ColorKey + "Fixed";
|
|
2282
|
+
const onColorFixedVariantKey = "on" + ColorKey + "FixedVariant";
|
|
2283
|
+
const colors = ({ palettes, colors: colors2, context: ctx }) => ({
|
|
2284
|
+
[colorKey]: {
|
|
2285
|
+
palette: () => palettes.get(colorKey),
|
|
2286
|
+
tone: () => {
|
|
2287
|
+
if (ctx.variant.name === "neutral") {
|
|
2288
|
+
return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
|
|
2289
|
+
} else if (ctx.variant.name === "vibrant") {
|
|
2290
|
+
return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
|
|
2291
|
+
} else {
|
|
2292
|
+
return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
|
|
2293
|
+
}
|
|
2294
|
+
},
|
|
2295
|
+
isBackground: true,
|
|
2296
|
+
background: () => highestSurface$1(ctx, this),
|
|
2297
|
+
contrastCurve: () => getCurve(4.5),
|
|
2298
|
+
adjustTone: () => toneDeltaPair(
|
|
2299
|
+
colors2.get(colorContainerKey),
|
|
2300
|
+
colors2.get(colorKey),
|
|
2301
|
+
5,
|
|
2302
|
+
"relative_lighter",
|
|
2303
|
+
true,
|
|
2304
|
+
"farther"
|
|
2305
|
+
)
|
|
2306
|
+
},
|
|
2307
|
+
[colorDimKey]: {
|
|
2308
|
+
palette: () => palettes.get(colorKey),
|
|
2309
|
+
tone: () => {
|
|
2310
|
+
if (ctx.variant.name === "neutral") {
|
|
2311
|
+
return 85;
|
|
2312
|
+
} else {
|
|
2313
|
+
return tMaxC(palettes.get(colorKey), 0, 90);
|
|
2314
|
+
}
|
|
2315
|
+
},
|
|
2316
|
+
isBackground: true,
|
|
2317
|
+
background: () => this.get("surfaceContainerHigh"),
|
|
2318
|
+
contrastCurve: () => getCurve(4.5),
|
|
2319
|
+
adjustTone: () => toneDeltaPair(
|
|
2320
|
+
this.get(colorDimKey),
|
|
2321
|
+
this.get(colorKey),
|
|
2322
|
+
5,
|
|
2323
|
+
"darker",
|
|
2324
|
+
true,
|
|
2325
|
+
"farther"
|
|
2326
|
+
)
|
|
2327
|
+
},
|
|
2328
|
+
[onColorKey]: {
|
|
2329
|
+
palette: () => palettes.get(colorKey),
|
|
2330
|
+
background: () => this.get(colorKey),
|
|
2331
|
+
contrastCurve: () => getCurve(6)
|
|
2332
|
+
},
|
|
2333
|
+
[colorContainerKey]: {
|
|
2334
|
+
palette: () => palettes.get(colorKey),
|
|
2335
|
+
tone: () => {
|
|
2336
|
+
if (ctx.variant.name === "vibrant") {
|
|
2337
|
+
return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
|
|
2338
|
+
} else if (ctx.variant.name === "expressive") {
|
|
2339
|
+
return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
|
|
2340
|
+
} else {
|
|
2341
|
+
return ctx.isDark ? 25 : 90;
|
|
2342
|
+
}
|
|
2343
|
+
},
|
|
2344
|
+
isBackground: true,
|
|
2345
|
+
background: () => highestSurface$1(ctx, this),
|
|
2346
|
+
adjustTone: () => void 0,
|
|
2347
|
+
contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2348
|
+
},
|
|
2349
|
+
[onColorContainerKey]: {
|
|
2350
|
+
palette: () => palettes.get(colorKey),
|
|
2351
|
+
background: () => this.get(colorContainerKey),
|
|
2352
|
+
contrastCurve: () => getCurve(6)
|
|
2353
|
+
},
|
|
2354
|
+
[colorFixedKey]: {
|
|
2355
|
+
palette: () => palettes.get(colorKey),
|
|
2356
|
+
tone: () => {
|
|
2357
|
+
return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
|
|
2358
|
+
const color = this.get(colorContainerKey);
|
|
2359
|
+
return color.getTone();
|
|
2360
|
+
});
|
|
2361
|
+
},
|
|
2362
|
+
isBackground: true,
|
|
2363
|
+
background: () => highestSurface$1(ctx, this),
|
|
2364
|
+
contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2365
|
+
},
|
|
2366
|
+
[colorFixedDimKey]: {
|
|
2367
|
+
palette: () => palettes.get(colorKey),
|
|
2368
|
+
tone: () => this.get(colorFixedKey).getTone(),
|
|
2369
|
+
isBackground: true,
|
|
2370
|
+
adjustTone: () => toneDeltaPair(
|
|
2371
|
+
this.get(colorFixedDimKey),
|
|
2372
|
+
this.get(colorFixedKey),
|
|
2373
|
+
5,
|
|
2374
|
+
"darker",
|
|
2375
|
+
true,
|
|
2376
|
+
"exact"
|
|
2377
|
+
)
|
|
2378
|
+
},
|
|
2379
|
+
[onColorFixedKey]: {
|
|
2380
|
+
palette: () => palettes.get(colorKey),
|
|
2381
|
+
background: () => this.get(colorFixedDimKey),
|
|
2382
|
+
contrastCurve: () => getCurve(7)
|
|
2383
|
+
},
|
|
2384
|
+
[onColorFixedVariantKey]: {
|
|
2385
|
+
palette: () => palettes.get(colorKey),
|
|
2386
|
+
background: () => this.get(colorFixedDimKey),
|
|
2387
|
+
contrastCurve: () => getCurve(4.5)
|
|
2388
|
+
}
|
|
2389
|
+
});
|
|
2390
|
+
this.addColors(colors);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
class ColorManager {
|
|
2394
|
+
constructor(args) {
|
|
2395
|
+
__publicField(this, "colorMap", /* @__PURE__ */ new Map());
|
|
2396
|
+
__publicField(this, "context");
|
|
2397
|
+
this.context = args.context;
|
|
2398
|
+
}
|
|
2399
|
+
createOrUpdate(key, args) {
|
|
2400
|
+
let colorEntity = this.colorMap.get(key);
|
|
2401
|
+
if ("alias" in args) {
|
|
2402
|
+
colorEntity = new ColorAlias(key, args.alias, this);
|
|
2403
|
+
} else if ("hex" in args) {
|
|
2404
|
+
colorEntity = new ColorFromHex(key, args.hex);
|
|
2405
|
+
} else {
|
|
2406
|
+
try {
|
|
2407
|
+
if (colorEntity instanceof ColorFromPalette) {
|
|
2408
|
+
colorEntity.update(args);
|
|
2409
|
+
} else {
|
|
2410
|
+
colorEntity = new ColorFromPalette(key, args, this.context);
|
|
2411
|
+
}
|
|
2412
|
+
} catch (e) {
|
|
2413
|
+
console.error(e);
|
|
2414
|
+
throw new Error(`Invalid color options provided for ${key}`);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
this.colorMap.set(key, colorEntity);
|
|
2418
|
+
return colorEntity;
|
|
2419
|
+
}
|
|
2420
|
+
remove(key) {
|
|
2421
|
+
return this.colorMap.delete(key);
|
|
2422
|
+
}
|
|
2423
|
+
clear() {
|
|
2424
|
+
this.colorMap.clear();
|
|
2425
|
+
}
|
|
2426
|
+
get(key) {
|
|
2427
|
+
const colorEntity = this.colorMap.get(key);
|
|
2428
|
+
if (colorEntity) {
|
|
2429
|
+
return colorEntity;
|
|
2430
|
+
} else {
|
|
2431
|
+
throw new Error(`Color ${key} does not exist`);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
getAll() {
|
|
2435
|
+
return this.colorMap;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
const ColorModule = {
|
|
2439
|
+
colorManager: asClass(ColorManager).singleton(),
|
|
2440
|
+
colorApi: asClass(ColorApi).singleton()
|
|
2455
2441
|
};
|
|
2456
2442
|
const AppModule = {
|
|
2457
2443
|
api: asClass(API).singleton()
|
|
@@ -2665,7 +2651,7 @@ class Palette {
|
|
|
2665
2651
|
})) {
|
|
2666
2652
|
result = this.callback(this.context);
|
|
2667
2653
|
}
|
|
2668
|
-
if (result && this.hueCache !== result.hue
|
|
2654
|
+
if (result && (this.hueCache !== result.hue || this.chromaCache !== result.chroma)) {
|
|
2669
2655
|
this.clearCache();
|
|
2670
2656
|
this.hueCache = result.hue;
|
|
2671
2657
|
this.chromaCache = result.chroma;
|
|
@@ -2855,6 +2841,7 @@ class Variant {
|
|
|
2855
2841
|
constructor(options) {
|
|
2856
2842
|
__publicField(this, "_palettes");
|
|
2857
2843
|
__publicField(this, "customPalettes");
|
|
2844
|
+
__publicField(this, "colorsFromCustomPalette");
|
|
2858
2845
|
__publicField(this, "colors");
|
|
2859
2846
|
__publicField(this, "name");
|
|
2860
2847
|
__publicField(this, "context");
|
|
@@ -2862,6 +2849,7 @@ class Variant {
|
|
|
2862
2849
|
this.customPalettes = options.customPalettes;
|
|
2863
2850
|
this.colors = options.colors || {};
|
|
2864
2851
|
this.name = options.name;
|
|
2852
|
+
this.colorsFromCustomPalette = options.colorsFromCustomPalette;
|
|
2865
2853
|
}
|
|
2866
2854
|
get palettes() {
|
|
2867
2855
|
if (!this._palettes) {
|
|
@@ -2948,7 +2936,8 @@ const expressiveVariant = variant({
|
|
|
2948
2936
|
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
2949
2937
|
),
|
|
2950
2938
|
isDark ? 16 : 24
|
|
2951
|
-
)
|
|
2939
|
+
),
|
|
2940
|
+
colors: defaultColors
|
|
2952
2941
|
});
|
|
2953
2942
|
const neutralVariant = variant({
|
|
2954
2943
|
name: "neutral",
|
|
@@ -2983,7 +2972,8 @@ const neutralVariant = variant({
|
|
|
2983
2972
|
customPalettes: (_, colorHct) => TonalPalette.fromHueAndChroma(
|
|
2984
2973
|
colorHct.hue,
|
|
2985
2974
|
Hct.isBlue(colorHct.hue) ? 6 : 4
|
|
2986
|
-
)
|
|
2975
|
+
),
|
|
2976
|
+
colors: defaultColors
|
|
2987
2977
|
});
|
|
2988
2978
|
const tonalSpotVariant = variant({
|
|
2989
2979
|
name: "tonalSpot",
|
|
@@ -3009,7 +2999,8 @@ const tonalSpotVariant = variant({
|
|
|
3009
2999
|
return TonalPalette.fromHueAndChroma(errorHue, 60);
|
|
3010
3000
|
}
|
|
3011
3001
|
},
|
|
3012
|
-
customPalettes: (_, colorHct) => TonalPalette.fromHueAndChroma(colorHct.hue, 16)
|
|
3002
|
+
customPalettes: (_, colorHct) => TonalPalette.fromHueAndChroma(colorHct.hue, 16),
|
|
3003
|
+
colors: defaultColors
|
|
3013
3004
|
});
|
|
3014
3005
|
const getVibrantNeutralHue = (sourceColor) => {
|
|
3015
3006
|
return getRotatedHue(
|
|
@@ -3069,10 +3060,33 @@ const vibrantVariant = variant({
|
|
|
3069
3060
|
[-14, 10, -14, 10, -14]
|
|
3070
3061
|
),
|
|
3071
3062
|
56
|
|
3072
|
-
)
|
|
3063
|
+
),
|
|
3064
|
+
colors: defaultColors
|
|
3073
3065
|
});
|
|
3074
|
-
const
|
|
3075
|
-
|
|
3066
|
+
const surfaceContainerToneDelta = 2.5;
|
|
3067
|
+
const inverseTone = (tone) => {
|
|
3068
|
+
return 100 - tone;
|
|
3069
|
+
};
|
|
3070
|
+
const surfaceContainerTone = (layer, api) => {
|
|
3071
|
+
const t = surfaceContainerToneDelta * layer * (1 + api.context.contrastLevel);
|
|
3072
|
+
if (api.context.isDark) {
|
|
3073
|
+
return t * 1.5;
|
|
3074
|
+
} else {
|
|
3075
|
+
if (Hct.isYellow(api.palettes.get("neutral").hue)) {
|
|
3076
|
+
return 100 - t - surfaceContainerToneDelta;
|
|
3077
|
+
}
|
|
3078
|
+
return 100 - t;
|
|
3079
|
+
}
|
|
3080
|
+
};
|
|
3081
|
+
const highestSurface = (context, colorService) => {
|
|
3082
|
+
if (colorService instanceof ColorApi) {
|
|
3083
|
+
return colorService.get("surface");
|
|
3084
|
+
} else {
|
|
3085
|
+
return colorService.get("surface");
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
const udixioVariant = variant({
|
|
3089
|
+
name: "udixio",
|
|
3076
3090
|
palettes: {
|
|
3077
3091
|
primary: ({ sourceColor }) => ({
|
|
3078
3092
|
hue: sourceColor.hue,
|
|
@@ -3090,14 +3104,19 @@ const fidelityVariant = variant({
|
|
|
3090
3104
|
),
|
|
3091
3105
|
chroma: sourceColor.chroma
|
|
3092
3106
|
}),
|
|
3093
|
-
neutral: ({ sourceColor }) =>
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3107
|
+
neutral: ({ sourceColor }) => {
|
|
3108
|
+
return {
|
|
3109
|
+
hue: sourceColor.hue,
|
|
3110
|
+
chroma: 5
|
|
3111
|
+
};
|
|
3112
|
+
},
|
|
3113
|
+
neutralVariant: ({ sourceColor }) => {
|
|
3114
|
+
const neutral = 5;
|
|
3115
|
+
return {
|
|
3116
|
+
hue: sourceColor.hue,
|
|
3117
|
+
chroma: neutral * 1.7
|
|
3118
|
+
};
|
|
3119
|
+
},
|
|
3101
3120
|
error: ({ sourceColor }) => {
|
|
3102
3121
|
const errorHue = getPiecewiseHue(
|
|
3103
3122
|
sourceColor,
|
|
@@ -3113,14 +3132,703 @@ const fidelityVariant = variant({
|
|
|
3113
3132
|
customPalettes: ({ sourceColor }, colorHct) => ({
|
|
3114
3133
|
hue: colorHct.hue,
|
|
3115
3134
|
chroma: sourceColor.chroma
|
|
3116
|
-
})
|
|
3135
|
+
}),
|
|
3136
|
+
colorsFromCustomPalette: (key) => {
|
|
3137
|
+
const colorKey = key;
|
|
3138
|
+
const ColorKey = capitalizeFirstLetter(key);
|
|
3139
|
+
const onColorKey = "on" + ColorKey;
|
|
3140
|
+
const colorContainerKey = colorKey + "Container";
|
|
3141
|
+
const onColorContainerKey = "on" + ColorKey + "Container";
|
|
3142
|
+
const colors = ({ palettes, colors: colors2, context: ctx }) => ({
|
|
3143
|
+
[colorKey]: {
|
|
3144
|
+
palette: () => palettes.get(colorKey),
|
|
3145
|
+
tone: () => {
|
|
3146
|
+
if (ctx.variant.name === "neutral") {
|
|
3147
|
+
return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
|
|
3148
|
+
} else if (ctx.variant.name === "vibrant") {
|
|
3149
|
+
return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
|
|
3150
|
+
} else {
|
|
3151
|
+
return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
|
|
3152
|
+
}
|
|
3153
|
+
},
|
|
3154
|
+
isBackground: true,
|
|
3155
|
+
background: () => highestSurface(ctx, colors2),
|
|
3156
|
+
contrastCurve: () => getCurve(4.5),
|
|
3157
|
+
adjustTone: () => toneDeltaPair(
|
|
3158
|
+
colors2.get(colorContainerKey),
|
|
3159
|
+
colors2.get(colorKey),
|
|
3160
|
+
5,
|
|
3161
|
+
"relative_lighter",
|
|
3162
|
+
true,
|
|
3163
|
+
"farther"
|
|
3164
|
+
)
|
|
3165
|
+
},
|
|
3166
|
+
// [colorDimKey]: {
|
|
3167
|
+
// palette: () => palettes.get(colorKey),
|
|
3168
|
+
// tone: () => {
|
|
3169
|
+
// if (ctx.variant.name === 'neutral') {
|
|
3170
|
+
// return 85;
|
|
3171
|
+
// } else {
|
|
3172
|
+
// return tMaxC(palettes.get(colorKey), 0, 90);
|
|
3173
|
+
// }
|
|
3174
|
+
// },
|
|
3175
|
+
// isBackground: true,
|
|
3176
|
+
// background: () => colors.get('surfaceContainerHigh'),
|
|
3177
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3178
|
+
// adjustTone: () =>
|
|
3179
|
+
// toneDeltaPair(
|
|
3180
|
+
// colors.get(colorDimKey),
|
|
3181
|
+
// colors.get(colorKey),
|
|
3182
|
+
// 5,
|
|
3183
|
+
// 'darker',
|
|
3184
|
+
// true,
|
|
3185
|
+
// 'farther',
|
|
3186
|
+
// ),
|
|
3187
|
+
// },
|
|
3188
|
+
[onColorKey]: {
|
|
3189
|
+
palette: () => palettes.get(colorKey),
|
|
3190
|
+
background: () => colors2.get(colorKey),
|
|
3191
|
+
contrastCurve: () => getCurve(6)
|
|
3192
|
+
},
|
|
3193
|
+
[colorContainerKey]: {
|
|
3194
|
+
palette: () => palettes.get(colorKey),
|
|
3195
|
+
tone: () => {
|
|
3196
|
+
if (ctx.variant.name === "vibrant") {
|
|
3197
|
+
return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
|
|
3198
|
+
} else if (ctx.variant.name === "expressive") {
|
|
3199
|
+
return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
|
|
3200
|
+
} else {
|
|
3201
|
+
return ctx.isDark ? 25 : 90;
|
|
3202
|
+
}
|
|
3203
|
+
},
|
|
3204
|
+
isBackground: true,
|
|
3205
|
+
background: () => highestSurface(ctx, colors2),
|
|
3206
|
+
adjustTone: () => void 0,
|
|
3207
|
+
contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
3208
|
+
},
|
|
3209
|
+
[onColorContainerKey]: {
|
|
3210
|
+
palette: () => palettes.get(colorKey),
|
|
3211
|
+
background: () => colors2.get(colorContainerKey),
|
|
3212
|
+
contrastCurve: () => getCurve(6)
|
|
3213
|
+
}
|
|
3214
|
+
// [colorFixedKey]: {
|
|
3215
|
+
// palette: () => palettes.get(colorKey),
|
|
3216
|
+
// tone: () => {
|
|
3217
|
+
// return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
|
|
3218
|
+
// const color = colors.get(colorContainerKey);
|
|
3219
|
+
// return color.getTone();
|
|
3220
|
+
// });
|
|
3221
|
+
// },
|
|
3222
|
+
// isBackground: true,
|
|
3223
|
+
// background: () => highestSurface(ctx, colors),
|
|
3224
|
+
// contrastCurve: () =>
|
|
3225
|
+
// ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
|
|
3226
|
+
// },
|
|
3227
|
+
// [colorFixedDimKey]: {
|
|
3228
|
+
// palette: () => palettes.get(colorKey),
|
|
3229
|
+
// tone: () => colors.get(colorFixedKey).getTone(),
|
|
3230
|
+
// isBackground: true,
|
|
3231
|
+
// adjustTone: () =>
|
|
3232
|
+
// toneDeltaPair(
|
|
3233
|
+
// colors.get(colorFixedDimKey),
|
|
3234
|
+
// colors.get(colorFixedKey),
|
|
3235
|
+
// 5,
|
|
3236
|
+
// 'darker',
|
|
3237
|
+
// true,
|
|
3238
|
+
// 'exact',
|
|
3239
|
+
// ),
|
|
3240
|
+
// },
|
|
3241
|
+
// [onColorFixedKey]: {
|
|
3242
|
+
// palette: () => palettes.get(colorKey),
|
|
3243
|
+
// background: () => this.get(colorFixedDimKey),
|
|
3244
|
+
// contrastCurve: () => getCurve(7),
|
|
3245
|
+
// },
|
|
3246
|
+
// [onColorFixedVariantKey]: {
|
|
3247
|
+
// palette: () => palettes.get(colorKey),
|
|
3248
|
+
// background: () => colors.get(colorFixedDimKey),
|
|
3249
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3250
|
+
// },
|
|
3251
|
+
});
|
|
3252
|
+
return colors;
|
|
3253
|
+
},
|
|
3254
|
+
colors: ({ colors, context: c, palettes }) => {
|
|
3255
|
+
const getColor = (key) => {
|
|
3256
|
+
return colors.get(key);
|
|
3257
|
+
};
|
|
3258
|
+
return {
|
|
3259
|
+
////////////////////////////////////////////////////////////////
|
|
3260
|
+
// Surfaces [S] //
|
|
3261
|
+
////////////////////////////////////////////////////////////////
|
|
3262
|
+
surface: {
|
|
3263
|
+
palette: () => palettes.get("neutral"),
|
|
3264
|
+
tone: () => {
|
|
3265
|
+
if (c.isDark) {
|
|
3266
|
+
return 2;
|
|
3267
|
+
} else {
|
|
3268
|
+
return 99;
|
|
3269
|
+
}
|
|
3270
|
+
},
|
|
3271
|
+
isBackground: true
|
|
3272
|
+
},
|
|
3273
|
+
// surfaceDim: {
|
|
3274
|
+
// palette: () => palettes.get('neutral'),
|
|
3275
|
+
// tone: () => {
|
|
3276
|
+
// if (c.isDark) {
|
|
3277
|
+
// return 4;
|
|
3278
|
+
// } else {
|
|
3279
|
+
// if (Hct.isYellow(palettes.get('neutral').hue)) {
|
|
3280
|
+
// return 90;
|
|
3281
|
+
// } else if (c.variant.name === 'vibrant') {
|
|
3282
|
+
// return 85;
|
|
3283
|
+
// } else {
|
|
3284
|
+
// return 87;
|
|
3285
|
+
// }
|
|
3286
|
+
// }
|
|
3287
|
+
// },
|
|
3288
|
+
// isBackground: true,
|
|
3289
|
+
// chromaMultiplier: () => {
|
|
3290
|
+
// if (!c.isDark) {
|
|
3291
|
+
// if (c.variant.name === 'neutral') {
|
|
3292
|
+
// return 2.5;
|
|
3293
|
+
// } else if (c.variant.name === 'tonalSpot') {
|
|
3294
|
+
// return 1.7;
|
|
3295
|
+
// } else if (c.variant.name === 'expressive') {
|
|
3296
|
+
// return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
|
|
3297
|
+
// } else if (c.variant.name === 'vibrant') {
|
|
3298
|
+
// return 1.36;
|
|
3299
|
+
// }
|
|
3300
|
+
// }
|
|
3301
|
+
// return 1;
|
|
3302
|
+
// },
|
|
3303
|
+
// },
|
|
3304
|
+
// surfaceBright: {
|
|
3305
|
+
// palette: () => palettes.get('neutral'),
|
|
3306
|
+
// tone: () => {
|
|
3307
|
+
// if (c.isDark) {
|
|
3308
|
+
// return 18;
|
|
3309
|
+
// } else {
|
|
3310
|
+
// if (Hct.isYellow(palettes.get('neutral').hue)) {
|
|
3311
|
+
// return 99;
|
|
3312
|
+
// } else if (c.variant.name === 'vibrant') {
|
|
3313
|
+
// return 97;
|
|
3314
|
+
// } else {
|
|
3315
|
+
// return 98;
|
|
3316
|
+
// }
|
|
3317
|
+
// }
|
|
3318
|
+
// },
|
|
3319
|
+
// isBackground: true,
|
|
3320
|
+
// chromaMultiplier: () => {
|
|
3321
|
+
// if (c.isDark) {
|
|
3322
|
+
// if (c.variant.name === 'neutral') {
|
|
3323
|
+
// return 2.5;
|
|
3324
|
+
// } else if (c.variant.name === 'tonalSpot') {
|
|
3325
|
+
// return 1.7;
|
|
3326
|
+
// } else if (c.variant.name === 'expressive') {
|
|
3327
|
+
// return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
|
|
3328
|
+
// } else if (c.variant.name === 'vibrant') {
|
|
3329
|
+
// return 1.36;
|
|
3330
|
+
// }
|
|
3331
|
+
// }
|
|
3332
|
+
// return 1;
|
|
3333
|
+
// },
|
|
3334
|
+
// },
|
|
3335
|
+
surfaceContainerLowest: {
|
|
3336
|
+
palette: () => palettes.get("neutral"),
|
|
3337
|
+
tone: () => surfaceContainerTone(0, { palettes, context: c }),
|
|
3338
|
+
isBackground: true
|
|
3339
|
+
},
|
|
3340
|
+
surfaceContainerLow: {
|
|
3341
|
+
palette: () => palettes.get("neutral"),
|
|
3342
|
+
tone: () => surfaceContainerTone(1, { palettes, context: c }),
|
|
3343
|
+
isBackground: true,
|
|
3344
|
+
chromaMultiplier: () => {
|
|
3345
|
+
return 1.25;
|
|
3346
|
+
}
|
|
3347
|
+
},
|
|
3348
|
+
surfaceContainer: {
|
|
3349
|
+
palette: () => palettes.get("neutral"),
|
|
3350
|
+
tone: () => surfaceContainerTone(2, { palettes, context: c }),
|
|
3351
|
+
isBackground: true,
|
|
3352
|
+
chromaMultiplier: () => {
|
|
3353
|
+
return 1.4;
|
|
3354
|
+
}
|
|
3355
|
+
},
|
|
3356
|
+
surfaceContainerHigh: {
|
|
3357
|
+
palette: () => palettes.get("neutral"),
|
|
3358
|
+
tone: () => surfaceContainerTone(3, { palettes, context: c }),
|
|
3359
|
+
isBackground: true,
|
|
3360
|
+
chromaMultiplier: () => {
|
|
3361
|
+
return 1.5;
|
|
3362
|
+
}
|
|
3363
|
+
},
|
|
3364
|
+
surfaceContainerHighest: {
|
|
3365
|
+
palette: () => palettes.get("neutral"),
|
|
3366
|
+
tone: () => surfaceContainerTone(4, { palettes, context: c }),
|
|
3367
|
+
isBackground: true,
|
|
3368
|
+
chromaMultiplier: () => {
|
|
3369
|
+
return 1.7;
|
|
3370
|
+
}
|
|
3371
|
+
},
|
|
3372
|
+
onSurface: {
|
|
3373
|
+
palette: () => palettes.get("neutral"),
|
|
3374
|
+
tone: () => {
|
|
3375
|
+
return getInitialToneFromBackground(highestSurface(c, colors));
|
|
3376
|
+
},
|
|
3377
|
+
chromaMultiplier: () => {
|
|
3378
|
+
return 1.7;
|
|
3379
|
+
},
|
|
3380
|
+
background: () => highestSurface(c, colors),
|
|
3381
|
+
contrastCurve: () => c.isDark ? getCurve(11) : getCurve(9)
|
|
3382
|
+
},
|
|
3383
|
+
onSurfaceVariant: {
|
|
3384
|
+
palette: () => palettes.get("neutralVariant"),
|
|
3385
|
+
chromaMultiplier: () => {
|
|
3386
|
+
return 1.7;
|
|
3387
|
+
},
|
|
3388
|
+
background: () => highestSurface(c, colors),
|
|
3389
|
+
contrastCurve: () => c.isDark ? getCurve(6) : getCurve(4.5)
|
|
3390
|
+
},
|
|
3391
|
+
outline: {
|
|
3392
|
+
palette: () => palettes.get("neutralVariant"),
|
|
3393
|
+
chromaMultiplier: () => {
|
|
3394
|
+
return 1.7;
|
|
3395
|
+
},
|
|
3396
|
+
background: () => highestSurface(c, colors),
|
|
3397
|
+
contrastCurve: () => getCurve(3)
|
|
3398
|
+
},
|
|
3399
|
+
outlineVariant: {
|
|
3400
|
+
palette: () => palettes.get("neutralVariant"),
|
|
3401
|
+
chromaMultiplier: () => {
|
|
3402
|
+
return 1.7;
|
|
3403
|
+
},
|
|
3404
|
+
background: () => highestSurface(c, colors),
|
|
3405
|
+
contrastCurve: () => getCurve(1.5)
|
|
3406
|
+
},
|
|
3407
|
+
inverseSurface: {
|
|
3408
|
+
palette: () => palettes.get("neutral"),
|
|
3409
|
+
tone: () => 100 - colors.get("surface").getTone(),
|
|
3410
|
+
isBackground: true
|
|
3411
|
+
},
|
|
3412
|
+
inverseOnSurface: {
|
|
3413
|
+
palette: () => palettes.get("neutral"),
|
|
3414
|
+
tone: () => c.isDark ? 20 : 95,
|
|
3415
|
+
background: () => colors.get("inverseSurface"),
|
|
3416
|
+
contrastCurve: () => getCurve(7)
|
|
3417
|
+
},
|
|
3418
|
+
////////////////////////////////////////////////////////////////
|
|
3419
|
+
// Primaries [P] //
|
|
3420
|
+
////////////////////////////////////////////////////////////////
|
|
3421
|
+
primary: {
|
|
3422
|
+
palette: () => palettes.get("primary"),
|
|
3423
|
+
tone: () => {
|
|
3424
|
+
return c.sourceColor.tone;
|
|
3425
|
+
},
|
|
3426
|
+
isBackground: true,
|
|
3427
|
+
background: () => highestSurface(c, colors),
|
|
3428
|
+
contrastCurve: () => getCurve(4.5),
|
|
3429
|
+
adjustTone: () => () => {
|
|
3430
|
+
const surfaceTone = colors.get("surface").getTone();
|
|
3431
|
+
const primaryTone = colors.get("primary").options.tone;
|
|
3432
|
+
let selfTone = primaryTone;
|
|
3433
|
+
if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
|
|
3434
|
+
const ratio = calculateToneAdjustmentPercentage(
|
|
3435
|
+
surfaceTone,
|
|
3436
|
+
selfTone,
|
|
3437
|
+
3
|
|
3438
|
+
);
|
|
3439
|
+
const inverseT = inverseTone(primaryTone);
|
|
3440
|
+
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
3441
|
+
}
|
|
3442
|
+
return selfTone;
|
|
3443
|
+
}
|
|
3444
|
+
},
|
|
3445
|
+
// primaryDim: {
|
|
3446
|
+
// palette: () => palettes.get('primary'),
|
|
3447
|
+
// tone: () => {
|
|
3448
|
+
// if (c.variant.name === 'neutral') {
|
|
3449
|
+
// return 85;
|
|
3450
|
+
// } else if (c.variant.name === 'tonalSpot') {
|
|
3451
|
+
// return tMaxC(palettes.get('primary'), 0, 90);
|
|
3452
|
+
// } else {
|
|
3453
|
+
// return tMaxC(palettes.get('primary'));
|
|
3454
|
+
// }
|
|
3455
|
+
// },
|
|
3456
|
+
// isBackground: true,
|
|
3457
|
+
// background: () => getColor('surfaceContainerHigh'),
|
|
3458
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3459
|
+
// adjustTone: () =>
|
|
3460
|
+
// toneDeltaPair(
|
|
3461
|
+
// colors.get('primaryDim'),
|
|
3462
|
+
// colors.get('primary'),
|
|
3463
|
+
// 5,
|
|
3464
|
+
// 'darker',
|
|
3465
|
+
// true,
|
|
3466
|
+
// 'farther',
|
|
3467
|
+
// ),
|
|
3468
|
+
// },
|
|
3469
|
+
onPrimary: {
|
|
3470
|
+
palette: () => palettes.get("primary"),
|
|
3471
|
+
background: () => colors.get("primary"),
|
|
3472
|
+
contrastCurve: () => getCurve(6)
|
|
3473
|
+
},
|
|
3474
|
+
primaryContainer: {
|
|
3475
|
+
palette: () => palettes.get("primary"),
|
|
3476
|
+
tone: () => {
|
|
3477
|
+
return c.isDark ? tMinC(palettes.get("primary"), 35, 93) : tMaxC(palettes.get("primary"), 0, 90);
|
|
3478
|
+
},
|
|
3479
|
+
isBackground: true,
|
|
3480
|
+
background: () => highestSurface(c, colors),
|
|
3481
|
+
adjustTone: () => c.variant.name == "fidelity" ? toneDeltaPair(
|
|
3482
|
+
colors.get("primary"),
|
|
3483
|
+
colors.get("primaryContainer"),
|
|
3484
|
+
15,
|
|
3485
|
+
"relative_darker",
|
|
3486
|
+
true,
|
|
3487
|
+
"farther"
|
|
3488
|
+
) : void 0,
|
|
3489
|
+
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
3490
|
+
},
|
|
3491
|
+
onPrimaryContainer: {
|
|
3492
|
+
palette: () => palettes.get("primary"),
|
|
3493
|
+
background: () => colors.get("primaryContainer"),
|
|
3494
|
+
contrastCurve: () => getCurve(6)
|
|
3495
|
+
},
|
|
3496
|
+
// primaryFixed: {
|
|
3497
|
+
// palette: () => palettes.get('primary'),
|
|
3498
|
+
// tone: () => {
|
|
3499
|
+
// return c.temp(
|
|
3500
|
+
// {
|
|
3501
|
+
// isDark: false,
|
|
3502
|
+
// contrastLevel: 0,
|
|
3503
|
+
// },
|
|
3504
|
+
// () => {
|
|
3505
|
+
// const color = getColor('primaryContainer');
|
|
3506
|
+
// return color.getTone();
|
|
3507
|
+
// },
|
|
3508
|
+
// );
|
|
3509
|
+
// },
|
|
3510
|
+
// isBackground: true,
|
|
3511
|
+
// background: () => highestSurface(c, colors),
|
|
3512
|
+
// contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
|
|
3513
|
+
// },
|
|
3514
|
+
// primaryFixedDim: {
|
|
3515
|
+
// palette: () => palettes.get('primary'),
|
|
3516
|
+
// tone: () => colors.get('primaryFixed').getTone(),
|
|
3517
|
+
// isBackground: true,
|
|
3518
|
+
// adjustTone: () =>
|
|
3519
|
+
// toneDeltaPair(
|
|
3520
|
+
// getColor('primaryFixedDim'),
|
|
3521
|
+
// getColor('primaryFixed'),
|
|
3522
|
+
// 5,
|
|
3523
|
+
// 'darker',
|
|
3524
|
+
// true,
|
|
3525
|
+
// 'exact',
|
|
3526
|
+
// ),
|
|
3527
|
+
// },
|
|
3528
|
+
// onPrimaryFixed: {
|
|
3529
|
+
// palette: () => palettes.get('primary'),
|
|
3530
|
+
// background: () => colors.get('primaryFixedDim'),
|
|
3531
|
+
// contrastCurve: () => getCurve(7),
|
|
3532
|
+
// },
|
|
3533
|
+
// onPrimaryFixedVariant: {
|
|
3534
|
+
// palette: () => palettes.get('primary'),
|
|
3535
|
+
// background: () => colors.get('primaryFixedDim'),
|
|
3536
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3537
|
+
// },
|
|
3538
|
+
inversePrimary: {
|
|
3539
|
+
palette: () => palettes.get("primary"),
|
|
3540
|
+
tone: () => tMaxC(palettes.get("primary")),
|
|
3541
|
+
background: () => colors.get("inverseSurface"),
|
|
3542
|
+
contrastCurve: () => getCurve(6)
|
|
3543
|
+
},
|
|
3544
|
+
////////////////////////////////////////////////////////////////
|
|
3545
|
+
// Secondaries [Q] //
|
|
3546
|
+
////////////////////////////////////////////////////////////////
|
|
3547
|
+
secondary: {
|
|
3548
|
+
palette: () => palettes.get("secondary"),
|
|
3549
|
+
tone: () => {
|
|
3550
|
+
return c.isDark ? 80 : tMaxC(palettes.get("secondary"));
|
|
3551
|
+
},
|
|
3552
|
+
isBackground: true,
|
|
3553
|
+
background: () => highestSurface(c, colors),
|
|
3554
|
+
contrastCurve: () => getCurve(4.5),
|
|
3555
|
+
adjustTone: () => toneDeltaPair(
|
|
3556
|
+
getColor("secondaryContainer"),
|
|
3557
|
+
getColor("secondary"),
|
|
3558
|
+
5,
|
|
3559
|
+
"relative_lighter",
|
|
3560
|
+
true,
|
|
3561
|
+
"farther"
|
|
3562
|
+
)
|
|
3563
|
+
},
|
|
3564
|
+
// secondaryDim: {
|
|
3565
|
+
// palette: () => palettes.get('secondary'),
|
|
3566
|
+
// tone: () => {
|
|
3567
|
+
// if (c.variant.name === 'neutral') {
|
|
3568
|
+
// return 85;
|
|
3569
|
+
// } else {
|
|
3570
|
+
// return tMaxC(palettes.get('secondary'), 0, 90);
|
|
3571
|
+
// }
|
|
3572
|
+
// },
|
|
3573
|
+
// isBackground: true,
|
|
3574
|
+
// background: () => getColor('surfaceContainerHigh'),
|
|
3575
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3576
|
+
// adjustTone: () =>
|
|
3577
|
+
// toneDeltaPair(
|
|
3578
|
+
// getColor('secondaryDim'),
|
|
3579
|
+
// getColor('secondary'),
|
|
3580
|
+
// 5,
|
|
3581
|
+
// 'darker',
|
|
3582
|
+
// true,
|
|
3583
|
+
// 'farther',
|
|
3584
|
+
// ),
|
|
3585
|
+
// },
|
|
3586
|
+
onSecondary: {
|
|
3587
|
+
palette: () => palettes.get("secondary"),
|
|
3588
|
+
background: () => getColor("secondary"),
|
|
3589
|
+
contrastCurve: () => getCurve(6)
|
|
3590
|
+
},
|
|
3591
|
+
secondaryContainer: {
|
|
3592
|
+
palette: () => palettes.get("secondary"),
|
|
3593
|
+
tone: () => {
|
|
3594
|
+
return c.isDark ? 25 : 90;
|
|
3595
|
+
},
|
|
3596
|
+
isBackground: true,
|
|
3597
|
+
background: () => highestSurface(c, colors),
|
|
3598
|
+
adjustTone: () => void 0,
|
|
3599
|
+
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
3600
|
+
},
|
|
3601
|
+
onSecondaryContainer: {
|
|
3602
|
+
palette: () => palettes.get("secondary"),
|
|
3603
|
+
background: () => getColor("secondaryContainer"),
|
|
3604
|
+
contrastCurve: () => getCurve(6)
|
|
3605
|
+
},
|
|
3606
|
+
// secondaryFixed: {
|
|
3607
|
+
// palette: () => palettes.get('secondary'),
|
|
3608
|
+
// tone: () => {
|
|
3609
|
+
// return c.temp(
|
|
3610
|
+
// {
|
|
3611
|
+
// isDark: false,
|
|
3612
|
+
// contrastLevel: 0,
|
|
3613
|
+
// },
|
|
3614
|
+
// () => {
|
|
3615
|
+
// const color = getColor('secondaryContainer');
|
|
3616
|
+
// return color.getTone();
|
|
3617
|
+
// },
|
|
3618
|
+
// );
|
|
3619
|
+
// },
|
|
3620
|
+
// isBackground: true,
|
|
3621
|
+
// background: () => highestSurface(c, colors),
|
|
3622
|
+
// contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
|
|
3623
|
+
// },
|
|
3624
|
+
// secondaryFixedDim: {
|
|
3625
|
+
// palette: () => palettes.get('secondary'),
|
|
3626
|
+
// tone: () => getColor('secondaryFixed').getTone(),
|
|
3627
|
+
// isBackground: true,
|
|
3628
|
+
// adjustTone: () =>
|
|
3629
|
+
// toneDeltaPair(
|
|
3630
|
+
// getColor('secondaryFixedDim'),
|
|
3631
|
+
// getColor('secondaryFixed'),
|
|
3632
|
+
// 5,
|
|
3633
|
+
// 'darker',
|
|
3634
|
+
// true,
|
|
3635
|
+
// 'exact',
|
|
3636
|
+
// ),
|
|
3637
|
+
// },
|
|
3638
|
+
// onSecondaryFixed: {
|
|
3639
|
+
// palette: () => palettes.get('secondary'),
|
|
3640
|
+
// background: () => getColor('secondaryFixedDim'),
|
|
3641
|
+
// contrastCurve: () => getCurve(7),
|
|
3642
|
+
// },
|
|
3643
|
+
// onSecondaryFixedVariant: {
|
|
3644
|
+
// palette: () => palettes.get('secondary'),
|
|
3645
|
+
// background: () => getColor('secondaryFixedDim'),
|
|
3646
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3647
|
+
// },
|
|
3648
|
+
////////////////////////////////////////////////////////////////
|
|
3649
|
+
// Tertiaries [T] //
|
|
3650
|
+
////////////////////////////////////////////////////////////////
|
|
3651
|
+
tertiary: {
|
|
3652
|
+
palette: () => palettes.get("tertiary"),
|
|
3653
|
+
tone: () => {
|
|
3654
|
+
return c.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
|
|
3655
|
+
},
|
|
3656
|
+
isBackground: true,
|
|
3657
|
+
background: () => highestSurface(c, colors),
|
|
3658
|
+
contrastCurve: () => getCurve(4.5),
|
|
3659
|
+
adjustTone: () => toneDeltaPair(
|
|
3660
|
+
getColor("tertiaryContainer"),
|
|
3661
|
+
getColor("tertiary"),
|
|
3662
|
+
5,
|
|
3663
|
+
"relative_lighter",
|
|
3664
|
+
true,
|
|
3665
|
+
"farther"
|
|
3666
|
+
)
|
|
3667
|
+
},
|
|
3668
|
+
// tertiaryDim: {
|
|
3669
|
+
// palette: () => palettes.get('tertiary'),
|
|
3670
|
+
// tone: () => {
|
|
3671
|
+
// if (c.variant.name === 'tonalSpot') {
|
|
3672
|
+
// return tMaxC(palettes.get('tertiary'), 0, 90);
|
|
3673
|
+
// } else {
|
|
3674
|
+
// return tMaxC(palettes.get('tertiary'));
|
|
3675
|
+
// }
|
|
3676
|
+
// },
|
|
3677
|
+
// isBackground: true,
|
|
3678
|
+
// background: () => getColor('surfaceContainerHigh'),
|
|
3679
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3680
|
+
// adjustTone: () =>
|
|
3681
|
+
// toneDeltaPair(
|
|
3682
|
+
// getColor('tertiaryDim'),
|
|
3683
|
+
// getColor('tertiary'),
|
|
3684
|
+
// 5,
|
|
3685
|
+
// 'darker',
|
|
3686
|
+
// true,
|
|
3687
|
+
// 'farther',
|
|
3688
|
+
// ),
|
|
3689
|
+
// },
|
|
3690
|
+
onTertiary: {
|
|
3691
|
+
palette: () => palettes.get("tertiary"),
|
|
3692
|
+
background: () => getColor("tertiary"),
|
|
3693
|
+
contrastCurve: () => getCurve(6)
|
|
3694
|
+
},
|
|
3695
|
+
tertiaryContainer: {
|
|
3696
|
+
palette: () => palettes.get("tertiary"),
|
|
3697
|
+
tone: () => {
|
|
3698
|
+
return tMaxC(palettes.get("tertiary"), 0, c.isDark ? 93 : 100);
|
|
3699
|
+
},
|
|
3700
|
+
isBackground: true,
|
|
3701
|
+
background: () => highestSurface(c, colors),
|
|
3702
|
+
adjustTone: () => void 0,
|
|
3703
|
+
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
3704
|
+
},
|
|
3705
|
+
onTertiaryContainer: {
|
|
3706
|
+
palette: () => palettes.get("tertiary"),
|
|
3707
|
+
background: () => getColor("tertiaryContainer"),
|
|
3708
|
+
contrastCurve: () => getCurve(6)
|
|
3709
|
+
},
|
|
3710
|
+
// tertiaryFixed: {
|
|
3711
|
+
// palette: () => palettes.get('tertiary'),
|
|
3712
|
+
// tone: () => {
|
|
3713
|
+
// return c.temp(
|
|
3714
|
+
// {
|
|
3715
|
+
// isDark: false,
|
|
3716
|
+
// contrastLevel: 0,
|
|
3717
|
+
// },
|
|
3718
|
+
// () => {
|
|
3719
|
+
// const color = getColor('tertiaryContainer');
|
|
3720
|
+
// return color.getTone();
|
|
3721
|
+
// },
|
|
3722
|
+
// );
|
|
3723
|
+
// },
|
|
3724
|
+
// isBackground: true,
|
|
3725
|
+
// background: () => highestSurface(c, colors),
|
|
3726
|
+
// contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
|
|
3727
|
+
// },
|
|
3728
|
+
// tertiaryFixedDim: {
|
|
3729
|
+
// palette: () => palettes.get('tertiary'),
|
|
3730
|
+
// tone: () => getColor('tertiaryFixed').getTone(),
|
|
3731
|
+
// isBackground: true,
|
|
3732
|
+
// adjustTone: () =>
|
|
3733
|
+
// toneDeltaPair(
|
|
3734
|
+
// getColor('tertiaryFixedDim'),
|
|
3735
|
+
// getColor('tertiaryFixed'),
|
|
3736
|
+
// 5,
|
|
3737
|
+
// 'darker',
|
|
3738
|
+
// true,
|
|
3739
|
+
// 'exact',
|
|
3740
|
+
// ),
|
|
3741
|
+
// },
|
|
3742
|
+
// onTertiaryFixed: {
|
|
3743
|
+
// palette: () => palettes.get('tertiary'),
|
|
3744
|
+
// background: () => getColor('tertiaryFixedDim'),
|
|
3745
|
+
// contrastCurve: () => getCurve(7),
|
|
3746
|
+
// },
|
|
3747
|
+
// onTertiaryFixedVariant: {
|
|
3748
|
+
// palette: () => palettes.get('tertiary'),
|
|
3749
|
+
// background: () => getColor('tertiaryFixedDim'),
|
|
3750
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3751
|
+
// },
|
|
3752
|
+
////////////////////////////////////////////////////////////////
|
|
3753
|
+
// Errors [E] //
|
|
3754
|
+
////////////////////////////////////////////////////////////////
|
|
3755
|
+
error: {
|
|
3756
|
+
palette: () => palettes.get("error"),
|
|
3757
|
+
tone: () => {
|
|
3758
|
+
return c.isDark ? tMinC(palettes.get("error"), 0, 98) : tMaxC(palettes.get("error"));
|
|
3759
|
+
},
|
|
3760
|
+
isBackground: true,
|
|
3761
|
+
background: () => highestSurface(c, colors),
|
|
3762
|
+
contrastCurve: () => getCurve(4.5),
|
|
3763
|
+
adjustTone: () => toneDeltaPair(
|
|
3764
|
+
colors.get("errorContainer"),
|
|
3765
|
+
colors.get("error"),
|
|
3766
|
+
5,
|
|
3767
|
+
"relative_lighter",
|
|
3768
|
+
true,
|
|
3769
|
+
"farther"
|
|
3770
|
+
)
|
|
3771
|
+
},
|
|
3772
|
+
// errorDim: {
|
|
3773
|
+
// palette: () => palettes.get('error'),
|
|
3774
|
+
// tone: () => tMinC(palettes.get('error')),
|
|
3775
|
+
// isBackground: true,
|
|
3776
|
+
// background: () => getColor('surfaceContainerHigh'),
|
|
3777
|
+
// contrastCurve: () => getCurve(4.5),
|
|
3778
|
+
// adjustTone: () =>
|
|
3779
|
+
// toneDeltaPair(
|
|
3780
|
+
// getColor('errorDim'),
|
|
3781
|
+
// getColor('error'),
|
|
3782
|
+
// 5,
|
|
3783
|
+
// 'darker',
|
|
3784
|
+
// true,
|
|
3785
|
+
// 'farther',
|
|
3786
|
+
// ),
|
|
3787
|
+
// },
|
|
3788
|
+
onError: {
|
|
3789
|
+
palette: () => palettes.get("error"),
|
|
3790
|
+
background: () => colors.get("error"),
|
|
3791
|
+
contrastCurve: () => getCurve(6)
|
|
3792
|
+
},
|
|
3793
|
+
errorContainer: {
|
|
3794
|
+
palette: () => palettes.get("error"),
|
|
3795
|
+
tone: () => {
|
|
3796
|
+
return c.isDark ? tMinC(palettes.get("error"), 30, 93) : tMaxC(palettes.get("error"), 0, 90);
|
|
3797
|
+
},
|
|
3798
|
+
isBackground: true,
|
|
3799
|
+
background: () => highestSurface(c, colors),
|
|
3800
|
+
adjustTone: () => void 0,
|
|
3801
|
+
contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
3802
|
+
},
|
|
3803
|
+
onErrorContainer: {
|
|
3804
|
+
palette: () => palettes.get("error"),
|
|
3805
|
+
background: () => colors.get("errorContainer"),
|
|
3806
|
+
contrastCurve: () => getCurve(4.5)
|
|
3807
|
+
},
|
|
3808
|
+
/////////////////////////////////////////////////////////////////
|
|
3809
|
+
// Remapped Colors //
|
|
3810
|
+
/////////////////////////////////////////////////////////////////
|
|
3811
|
+
surfaceVariant: {
|
|
3812
|
+
alias: "surfaceContainerHighest"
|
|
3813
|
+
},
|
|
3814
|
+
surfaceTint: {
|
|
3815
|
+
alias: "primary"
|
|
3816
|
+
},
|
|
3817
|
+
background: {
|
|
3818
|
+
alias: "surface"
|
|
3819
|
+
},
|
|
3820
|
+
onBackground: {
|
|
3821
|
+
alias: "onSurface"
|
|
3822
|
+
}
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3117
3825
|
});
|
|
3118
3826
|
const Variants = {
|
|
3119
3827
|
Expressive: expressiveVariant,
|
|
3120
3828
|
Neutral: neutralVariant,
|
|
3121
3829
|
TonalSpot: tonalSpotVariant,
|
|
3122
3830
|
Vibrant: vibrantVariant,
|
|
3123
|
-
|
|
3831
|
+
Udixio: udixioVariant
|
|
3124
3832
|
};
|
|
3125
3833
|
const loader = async (config, load = true) => {
|
|
3126
3834
|
const api = bootstrap();
|
|
@@ -3140,7 +3848,6 @@ const loader = async (config, load = true) => {
|
|
|
3140
3848
|
sourceColor,
|
|
3141
3849
|
variant: variant2
|
|
3142
3850
|
});
|
|
3143
|
-
api.colors.addColors(defaultColors);
|
|
3144
3851
|
if (palettes) {
|
|
3145
3852
|
api.palettes.add(palettes);
|
|
3146
3853
|
}
|
|
@@ -3162,37 +3869,38 @@ const loader = async (config, load = true) => {
|
|
|
3162
3869
|
};
|
|
3163
3870
|
export {
|
|
3164
3871
|
API as A,
|
|
3165
|
-
|
|
3872
|
+
tonalSpotVariant as B,
|
|
3166
3873
|
ColorApi as C,
|
|
3167
3874
|
DynamicColor as D,
|
|
3168
|
-
|
|
3169
|
-
|
|
3875
|
+
vibrantVariant as E,
|
|
3876
|
+
expressiveVariant as F,
|
|
3877
|
+
neutralVariant as G,
|
|
3170
3878
|
Palette as P,
|
|
3171
3879
|
Variant as V,
|
|
3172
3880
|
AppContainer as a,
|
|
3173
3881
|
AppModule as b,
|
|
3174
3882
|
bootstrap as c,
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3883
|
+
capitalizeFirstLetter as d,
|
|
3884
|
+
ColorManager as e,
|
|
3885
|
+
ColorModule as f,
|
|
3178
3886
|
getInitialToneFromBackground as g,
|
|
3179
|
-
|
|
3887
|
+
Color as h,
|
|
3180
3888
|
ColorAlias as i,
|
|
3181
3889
|
ColorFromHex as j,
|
|
3182
3890
|
ColorFromPalette as k,
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3891
|
+
highestSurface$1 as l,
|
|
3892
|
+
defaultColors as m,
|
|
3893
|
+
ContextModule as n,
|
|
3894
|
+
Context as o,
|
|
3895
|
+
loader as p,
|
|
3896
|
+
ContrastCurve as q,
|
|
3897
|
+
PaletteApi as r,
|
|
3898
|
+
PaletteModule as s,
|
|
3191
3899
|
toneDeltaPair as t,
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3900
|
+
PluginModule as u,
|
|
3901
|
+
PluginApi as v,
|
|
3902
|
+
getPiecewiseHue as w,
|
|
3903
|
+
getRotatedHue as x,
|
|
3904
|
+
variant as y,
|
|
3905
|
+
Variants as z
|
|
3198
3906
|
};
|