@wordpress/theme 0.1.0 → 0.2.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/README.md +69 -9
- package/bin/generate-default-ramps/index.ts +49 -0
- package/bin/generate-primitive-tokens/index.ts +14 -9
- package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +5 -24
- package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +11 -4
- package/bin/terrazzo-plugin-inline-alias-values/index.ts +84 -0
- package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +19 -39
- package/build/color-ramps/index.js +21 -39
- package/build/color-ramps/index.js.map +3 -3
- package/build/color-ramps/lib/color-utils.js +39 -0
- package/build/color-ramps/lib/color-utils.js.map +7 -0
- package/build/color-ramps/lib/constants.js +20 -27
- package/build/color-ramps/lib/constants.js.map +3 -3
- package/build/color-ramps/lib/default-ramps.js +220 -0
- package/build/color-ramps/lib/default-ramps.js.map +7 -0
- package/build/color-ramps/lib/find-color-with-constraints.js +60 -91
- package/build/color-ramps/lib/find-color-with-constraints.js.map +3 -3
- package/build/color-ramps/lib/index.js +77 -119
- package/build/color-ramps/lib/index.js.map +3 -3
- package/build/color-ramps/lib/ramp-configs.js +15 -14
- package/build/color-ramps/lib/ramp-configs.js.map +2 -2
- package/build/color-ramps/lib/register-color-spaces.js +7 -0
- package/build/color-ramps/lib/register-color-spaces.js.map +7 -0
- package/build/color-ramps/lib/taper-chroma.js +35 -27
- package/build/color-ramps/lib/taper-chroma.js.map +3 -3
- package/build/color-ramps/lib/types.js +2 -1
- package/build/color-ramps/lib/types.js.map +1 -1
- package/build/color-ramps/lib/utils.js +75 -11
- package/build/color-ramps/lib/utils.js.map +2 -2
- package/build/context.js +3 -2
- package/build/context.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/prebuilt/js/design-tokens.js +19 -11
- package/build/prebuilt/js/design-tokens.js.map +2 -2
- package/build/prebuilt/json/figma.json +165 -783
- package/build/prebuilt/ts/color-tokens.js +137 -0
- package/build/prebuilt/ts/color-tokens.js.map +7 -0
- package/build/private-apis.js +3 -2
- package/build/private-apis.js.map +1 -1
- package/build/theme-provider.js +19 -17
- package/build/theme-provider.js.map +4 -4
- package/build/token-id.js +30 -0
- package/build/token-id.js.map +7 -0
- package/build/types/css-modules.d.js +0 -1
- package/build/types.js +2 -1
- package/build/types.js.map +1 -1
- package/build/use-theme-provider-styles.js +67 -62
- package/build/use-theme-provider-styles.js.map +3 -3
- package/build-module/color-ramps/index.js +20 -28
- package/build-module/color-ramps/index.js.map +2 -2
- package/build-module/color-ramps/lib/color-utils.js +19 -0
- package/build-module/color-ramps/lib/color-utils.js.map +7 -0
- package/build-module/color-ramps/lib/constants.js +14 -11
- package/build-module/color-ramps/lib/constants.js.map +2 -2
- package/build-module/color-ramps/lib/default-ramps.js +196 -0
- package/build-module/color-ramps/lib/default-ramps.js.map +7 -0
- package/build-module/color-ramps/lib/find-color-with-constraints.js +61 -87
- package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
- package/build-module/color-ramps/lib/index.js +85 -109
- package/build-module/color-ramps/lib/index.js.map +3 -3
- package/build-module/color-ramps/lib/ramp-configs.js +14 -13
- package/build-module/color-ramps/lib/ramp-configs.js.map +2 -2
- package/build-module/color-ramps/lib/register-color-spaces.js +7 -0
- package/build-module/color-ramps/lib/register-color-spaces.js.map +7 -0
- package/build-module/color-ramps/lib/taper-chroma.js +40 -16
- package/build-module/color-ramps/lib/taper-chroma.js.map +2 -2
- package/build-module/color-ramps/lib/utils.js +70 -6
- package/build-module/color-ramps/lib/utils.js.map +2 -2
- package/build-module/context.js +2 -1
- package/build-module/context.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/prebuilt/js/design-tokens.js +18 -10
- package/build-module/prebuilt/js/design-tokens.js.map +2 -2
- package/build-module/prebuilt/json/figma.json +165 -783
- package/build-module/prebuilt/ts/color-tokens.js +117 -0
- package/build-module/prebuilt/ts/color-tokens.js.map +7 -0
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/theme-provider.js +18 -6
- package/build-module/theme-provider.js.map +3 -3
- package/build-module/token-id.js +6 -0
- package/build-module/token-id.js.map +7 -0
- package/build-module/use-theme-provider-styles.js +69 -57
- package/build-module/use-theme-provider-styles.js.map +2 -2
- package/build-types/color-ramps/index.d.ts +9 -16
- package/build-types/color-ramps/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/color-utils.d.ts +22 -0
- package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -0
- package/build-types/color-ramps/lib/constants.d.ts +7 -9
- package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
- package/build-types/color-ramps/lib/default-ramps.d.ts +7 -0
- package/build-types/color-ramps/lib/default-ramps.d.ts.map +1 -0
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +8 -7
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -1
- package/build-types/color-ramps/lib/index.d.ts +5 -2
- package/build-types/color-ramps/lib/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/register-color-spaces.d.ts +2 -0
- package/build-types/color-ramps/lib/register-color-spaces.d.ts.map +1 -0
- package/build-types/color-ramps/lib/taper-chroma.d.ts +7 -3
- package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -1
- package/build-types/color-ramps/lib/utils.d.ts +28 -5
- package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
- package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
- package/build-types/prebuilt/ts/color-tokens.d.ts +7 -0
- package/build-types/prebuilt/ts/color-tokens.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/build-types/theme-provider.d.ts.map +1 -1
- package/build-types/token-id.d.ts +9 -0
- package/build-types/token-id.d.ts.map +1 -0
- package/build-types/use-theme-provider-styles.d.ts +4 -0
- package/build-types/use-theme-provider-styles.d.ts.map +1 -1
- package/docs/ds-tokens.md +22 -156
- package/package.json +19 -9
- package/src/color-ramps/index.ts +24 -41
- package/src/color-ramps/lib/color-utils.ts +34 -0
- package/src/color-ramps/lib/constants.ts +13 -9
- package/src/color-ramps/lib/default-ramps.ts +200 -0
- package/src/color-ramps/lib/find-color-with-constraints.ts +83 -116
- package/src/color-ramps/lib/index.ts +107 -145
- package/src/color-ramps/lib/ramp-configs.ts +3 -3
- package/src/color-ramps/lib/register-color-spaces.ts +13 -0
- package/src/color-ramps/lib/taper-chroma.ts +47 -19
- package/src/color-ramps/lib/utils.ts +117 -14
- package/src/color-ramps/stories/index.story.tsx +16 -22
- package/src/color-ramps/test/__snapshots__/index.test.ts.snap +45722 -376
- package/src/color-ramps/test/index.test.ts +68 -29
- package/src/prebuilt/css/design-tokens.css +88 -355
- package/src/prebuilt/js/design-tokens.js +17 -10
- package/src/prebuilt/json/figma.json +165 -783
- package/src/prebuilt/ts/color-tokens.ts +117 -0
- package/src/stories/index.story.tsx +4 -18
- package/src/test/token-id.test.ts +12 -0
- package/src/token-id.ts +9 -0
- package/src/use-theme-provider-styles.ts +67 -60
- package/terrazzo.config.ts +15 -12
- package/tokens/color.json +221 -69
- package/tokens/dimension.json +75 -0
- package/tsconfig.bin.json +13 -0
- package/tsconfig.bin.tsbuildinfo +1 -0
- package/tsconfig.json +6 -4
- package/tsconfig.src.json +9 -0
- package/tsconfig.src.tsbuildinfo +1 -0
- package/bin/build-tokens.js +0 -83
- package/build/color-ramps/lib/cache-utils.js +0 -57
- package/build/color-ramps/lib/cache-utils.js.map +0 -7
- package/build/prebuilt/ts/design-tokens.js +0 -354
- package/build/prebuilt/ts/design-tokens.js.map +0 -7
- package/build/style.module.css.js +0 -2
- package/build-module/color-ramps/lib/cache-utils.js +0 -31
- package/build-module/color-ramps/lib/cache-utils.js.map +0 -7
- package/build-module/prebuilt/ts/design-tokens.js +0 -334
- package/build-module/prebuilt/ts/design-tokens.js.map +0 -7
- package/build-module/style.module.css.js +0 -1
- package/build-style/style.css +0 -3
- package/build-types/color-ramps/lib/cache-utils.d.ts +0 -22
- package/build-types/color-ramps/lib/cache-utils.d.ts.map +0 -1
- package/build-types/prebuilt/ts/design-tokens.d.ts +0 -7
- package/build-types/prebuilt/ts/design-tokens.d.ts.map +0 -1
- package/src/color-ramps/lib/cache-utils.ts +0 -56
- package/src/prebuilt/ts/design-tokens.ts +0 -335
- package/tokens/spacing.json +0 -45
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/find-color-with-constraints.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { clampToGamut, solveWithBisect } from './utils';\nimport { WHITE, BLACK, CONTRAST_EPSILON } from './constants';\nimport { getContrast } from './color-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Difference of contrast values that grows linearly with the Y luminance.\n * We get more precise linear interpolations when we use this.\n * @param c1 First contrast.\n * @param c2 Second contrast.\n * @return Difference of logarithms.\n */\nfunction cdiff( c1: number, c2: number ) {\n\treturn Math.log( c1 / c2 );\n}\n\n/**\n * Solve for L such that:\n * - the L applied to the seed meets the contrast target against the reference\n * - the search is performed in one direction (ie lighter / darker)\n * - more constraints can be applied around lightness\n * - chroma could be tapered\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: ColorTypes,\n\tseed: ColorTypes,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t} = {}\n): { color: ColorTypes; reached: boolean; achieved: number; deficit?: number } {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn {\n\t\t\tcolor: reference,\n\t\t\treached: true,\n\t\t\tachieved: 1,\n\t\t};\n\t}\n\n\tfunction getColorForL( l: number ): ColorTypes {\n\t\tlet newL = l;\n\t\tlet newC = get( seed, [ OKLCH, 'c' ] );\n\n\t\tif ( taperChromaOptions ) {\n\t\t\tconst tapered = taperChroma( seed, newL, taperChromaOptions );\n\t\t\t// taperChroma returns either { l, c } or a ColorObject\n\t\t\tif ( 'l' in tapered && 'c' in tapered ) {\n\t\t\t\tnewL = tapered.l;\n\t\t\t\tnewC = tapered.c;\n\t\t\t} else {\n\t\t\t\t// It's already a ColorObject, return it directly\n\t\t\t\treturn tapered;\n\t\t\t}\n\t\t}\n\n\t\treturn clampToGamut( {\n\t\t\tspaceId: 'oklch',\n\t\t\tcoords: [ newL, newC, get( seed, [ OKLCH, 'h' ] ) ],\n\t\t} );\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestContrast = getContrast( reference, mostContrastingColor );\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tconst colorWithExactL = getColorForL( lightnessConstraint.value );\n\t\tconst exactLContrast = getContrast( reference, colorWithExactL );\n\t\tconst exactLContrastMeetsTarget =\n\t\t\tcdiff( exactLContrast, target ) >= -CONTRAST_EPSILON;\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\texactLContrastMeetsTarget ||\n\t\t\tlightnessConstraint.type === 'force'\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrastMeetsTarget,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t\tdeficit: exactLContrastMeetsTarget\n\t\t\t\t\t? cdiff( exactLContrast, highestContrast )\n\t\t\t\t\t: cdiff( target, exactLContrast ),\n\t\t\t};\n\t\t}\n\t}\n\n\t// If even the most contrasting color can't reach the target, the target is unreachable.\n\t// On the other hand, if the contrast is very close to the target, we consider it reached.\n\tif ( cdiff( highestContrast, target ) <= CONTRAST_EPSILON ) {\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: cdiff( highestContrast, target ) >= -CONTRAST_EPSILON,\n\t\t\tachieved: highestContrast,\n\t\t\tdeficit: cdiff( target, highestContrast ),\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tconst lowerL = get( reference, [ OKLCH, 'l' ] );\n\tconst lowerContrast = cdiff( 1, target );\n\tconst upperL = mostContrastingL;\n\tconst upperContrast = cdiff( highestContrast, target );\n\n\tconst bestColor = solveWithBisect(\n\t\tgetColorForL,\n\t\t( c: ColorTypes ) => cdiff( getContrast( reference, c ), target ),\n\t\tlowerL,\n\t\tlowerContrast,\n\t\tupperL,\n\t\tupperContrast\n\t);\n\n\treturn {\n\t\tcolor: bestColor,\n\t\treached: true,\n\t\tachieved: target,\n\t\t// Negative number that specifies how much room we have.\n\t\tdeficit: cdiff( target, highestContrast ),\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;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N,MAAO,gBAAgB,eAAgB,IACvC,MAAO,QAAQ,cAAe;AAAA,MAClC;AAAA,IACD;AAAA,EACD;AAIA,MAAK,MAAO,iBAAiB,MAAO,KAAK,mCAAmB;AAC3D,WAAO;AAAA,MACN,OAAO;AAAA,MACP,SAAS,MAAO,iBAAiB,MAAO,KAAK,CAAC;AAAA,MAC9C,UAAU;AAAA,MACV,SAAS,MAAO,QAAQ,eAAgB;AAAA,IACzC;AAAA,EACD;AAMA,QAAM,aAAS,eAAK,WAAW,CAAE,iBAAO,GAAI,CAAE;AAC9C,QAAM,gBAAgB,MAAO,GAAG,MAAO;AACvC,QAAM,SAAS;AACf,QAAM,gBAAgB,MAAO,iBAAiB,MAAO;AAErD,QAAM,gBAAY;AAAA,IACjB;AAAA,IACA,CAAE,MAAmB,UAAO,gCAAa,WAAW,CAAE,GAAG,MAAO;AAAA,IAChE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA;AAAA,IAEV,SAAS,MAAO,QAAQ,eAAgB;AAAA,EACzC;AACD;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
@@ -17,22 +14,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
14
|
}
|
|
18
15
|
return to;
|
|
19
16
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/theme/src/color-ramps/lib/index.ts
|
|
29
20
|
var lib_exports = {};
|
|
30
21
|
__export(lib_exports, {
|
|
31
22
|
buildRamp: () => buildRamp
|
|
32
23
|
});
|
|
33
24
|
module.exports = __toCommonJS(lib_exports);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
25
|
+
var import_fn = require("colorjs.io/fn");
|
|
26
|
+
var import_register_color_spaces = require("./register-color-spaces");
|
|
27
|
+
var import_color_utils = require("./color-utils");
|
|
36
28
|
var import_find_color_with_constraints = require("./find-color-with-constraints");
|
|
37
29
|
var import_utils = require("./utils");
|
|
38
30
|
var import_constants = require("./constants");
|
|
@@ -42,17 +34,16 @@ function calculateRamp({
|
|
|
42
34
|
config,
|
|
43
35
|
mainDir,
|
|
44
36
|
oppDir,
|
|
45
|
-
pinLightness
|
|
46
|
-
debug = false
|
|
37
|
+
pinLightness
|
|
47
38
|
}) {
|
|
48
39
|
const rampResults = {};
|
|
49
|
-
let
|
|
50
|
-
let
|
|
51
|
-
let
|
|
40
|
+
let maxDeficit = -Infinity;
|
|
41
|
+
let maxDeficitDirection = "lighter";
|
|
42
|
+
let maxDeficitStep;
|
|
52
43
|
const calculatedColors = /* @__PURE__ */ new Map();
|
|
53
44
|
calculatedColors.set("seed", seed);
|
|
54
45
|
for (const stepName of sortedSteps) {
|
|
55
|
-
let
|
|
46
|
+
let computeDirection = function(color, followDirection) {
|
|
56
47
|
if (followDirection === "main") {
|
|
57
48
|
return mainDir;
|
|
58
49
|
}
|
|
@@ -67,7 +58,6 @@ function calculateRamp({
|
|
|
67
58
|
}
|
|
68
59
|
return followDirection;
|
|
69
60
|
};
|
|
70
|
-
var computeDirection = computeDirection2;
|
|
71
61
|
const {
|
|
72
62
|
contrast,
|
|
73
63
|
lightness: stepLightnessConstraint,
|
|
@@ -82,23 +72,26 @@ function calculateRamp({
|
|
|
82
72
|
}
|
|
83
73
|
if (sameAsIfPossible) {
|
|
84
74
|
const candidateColor = calculatedColors.get(sameAsIfPossible);
|
|
85
|
-
if (candidateColor) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
candidateColor
|
|
75
|
+
if (!candidateColor) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Same-as color for step ${stepName} not found: ${sameAsIfPossible}`
|
|
89
78
|
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
}
|
|
80
|
+
const candidateContrast = (0, import_color_utils.getContrast)(
|
|
81
|
+
referenceColor,
|
|
82
|
+
candidateColor
|
|
83
|
+
);
|
|
84
|
+
const adjustedTarget2 = (0, import_utils.adjustContrastTarget)(contrast.target);
|
|
85
|
+
if (candidateContrast >= adjustedTarget2) {
|
|
86
|
+
calculatedColors.set(stepName, candidateColor);
|
|
87
|
+
rampResults[stepName] = {
|
|
88
|
+
color: (0, import_color_utils.getColorString)(candidateColor),
|
|
89
|
+
warning: false
|
|
90
|
+
};
|
|
91
|
+
continue;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
|
-
const computedDir =
|
|
94
|
+
const computedDir = computeDirection(
|
|
102
95
|
referenceColor,
|
|
103
96
|
contrast.followDirection
|
|
104
97
|
);
|
|
@@ -121,43 +114,36 @@ function calculateRamp({
|
|
|
121
114
|
adjustedTarget,
|
|
122
115
|
computedDir,
|
|
123
116
|
{
|
|
124
|
-
strict: false,
|
|
125
117
|
lightnessConstraint,
|
|
126
|
-
taperChromaOptions
|
|
127
|
-
debug
|
|
118
|
+
taperChromaOptions
|
|
128
119
|
}
|
|
129
120
|
);
|
|
130
|
-
if (!searchResults.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const weightedDeficit = deficitVsTarget * impactWeight;
|
|
135
|
-
if (weightedDeficit > MAX_WEIGHTED_DEFICIT) {
|
|
136
|
-
MAX_WEIGHTED_DEFICIT = weightedDeficit;
|
|
137
|
-
UNSATISFIED_DIRECTION = computedDir;
|
|
138
|
-
}
|
|
121
|
+
if (!contrast.ignoreWhenAdjustingSeed && searchResults.deficit && searchResults.deficit > maxDeficit) {
|
|
122
|
+
maxDeficit = searchResults.deficit;
|
|
123
|
+
maxDeficitDirection = computedDir;
|
|
124
|
+
maxDeficitStep = stepName;
|
|
139
125
|
}
|
|
140
126
|
calculatedColors.set(stepName, searchResults.color);
|
|
141
127
|
rampResults[stepName] = {
|
|
142
|
-
color: (0,
|
|
128
|
+
color: (0, import_color_utils.getColorString)(searchResults.color),
|
|
143
129
|
warning: !contrast.ignoreWhenAdjustingSeed && !searchResults.reached
|
|
144
130
|
};
|
|
145
131
|
}
|
|
146
132
|
return {
|
|
147
133
|
rampResults,
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
maxDeficit,
|
|
135
|
+
maxDeficitDirection,
|
|
136
|
+
maxDeficitStep
|
|
150
137
|
};
|
|
151
138
|
}
|
|
152
139
|
function buildRamp(seedArg, config, {
|
|
153
140
|
mainDirection,
|
|
154
141
|
pinLightness,
|
|
155
|
-
debug = false,
|
|
156
142
|
rescaleToFitContrastTargets = true
|
|
157
143
|
} = {}) {
|
|
158
144
|
let seed;
|
|
159
145
|
try {
|
|
160
|
-
seed = (0, import_utils.clampToGamut)(
|
|
146
|
+
seed = (0, import_utils.clampToGamut)((0, import_fn.parse)(seedArg));
|
|
161
147
|
} catch (error) {
|
|
162
148
|
throw new Error(
|
|
163
149
|
`Invalid seed color "${seedArg}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -174,88 +160,60 @@ function buildRamp(seedArg, config, {
|
|
|
174
160
|
oppDir = worse;
|
|
175
161
|
}
|
|
176
162
|
const sortedSteps = (0, import_utils.sortByDependency)(config);
|
|
177
|
-
const {
|
|
178
|
-
rampResults,
|
|
179
|
-
SATISFIED_ALL_CONTRAST_REQUIREMENTS,
|
|
180
|
-
UNSATISFIED_DIRECTION
|
|
181
|
-
} = calculateRamp({
|
|
163
|
+
const { rampResults, maxDeficit, maxDeficitDirection, maxDeficitStep } = calculateRamp({
|
|
182
164
|
seed,
|
|
183
165
|
sortedSteps,
|
|
184
166
|
config,
|
|
185
167
|
mainDir,
|
|
186
168
|
oppDir,
|
|
187
|
-
pinLightness
|
|
188
|
-
debug
|
|
169
|
+
pinLightness
|
|
189
170
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
console.log(`First run`, {
|
|
196
|
-
SATISFIED_ALL_CONTRAST_REQUIREMENTS,
|
|
197
|
-
UNSATISFIED_DIRECTION,
|
|
198
|
-
seed: seed.toString(),
|
|
199
|
-
sortedSteps,
|
|
200
|
-
config,
|
|
201
|
-
mainDir,
|
|
202
|
-
oppDir,
|
|
203
|
-
pinLightness
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (!SATISFIED_ALL_CONTRAST_REQUIREMENTS && rescaleToFitContrastTargets) {
|
|
207
|
-
let worseSeedL = seed.oklch.l;
|
|
208
|
-
let betterSeedL = UNSATISFIED_DIRECTION === "lighter" ? 0 : 1;
|
|
209
|
-
for (let i = 0; i < import_constants.MAX_BISECTION_ITERATIONS && Math.abs(betterSeedL - worseSeedL) > import_constants.LIGHTNESS_EPSILON; i++) {
|
|
210
|
-
const newSeed = (0, import_utils.clampToGamut)(
|
|
211
|
-
seed.clone().set({
|
|
212
|
-
l: (worseSeedL + betterSeedL) / 2
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
if (debug) {
|
|
216
|
-
console.log(`Iteration ${i}`, {
|
|
217
|
-
worseSeedL,
|
|
218
|
-
newSeedL: (worseSeedL + betterSeedL) / 2,
|
|
219
|
-
betterSeedL
|
|
220
|
-
});
|
|
221
|
-
}
|
|
171
|
+
let bestRamp = rampResults;
|
|
172
|
+
if (maxDeficit > import_constants.CONTRAST_EPSILON && rescaleToFitContrastTargets) {
|
|
173
|
+
let getSeedForL = function(l) {
|
|
174
|
+
return (0, import_utils.clampToGamut)((0, import_fn.set)((0, import_fn.clone)(seed), [import_fn.OKLCH, "l"], l));
|
|
175
|
+
}, getDeficitForSeed = function(s) {
|
|
222
176
|
const iterationResults = calculateRamp({
|
|
223
|
-
seed:
|
|
224
|
-
sortedSteps,
|
|
177
|
+
seed: s,
|
|
178
|
+
sortedSteps: iterSteps,
|
|
225
179
|
config,
|
|
226
180
|
mainDir,
|
|
227
181
|
oppDir,
|
|
228
|
-
pinLightness
|
|
229
|
-
debug
|
|
182
|
+
pinLightness
|
|
230
183
|
});
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
184
|
+
return iterationResults.maxDeficitDirection === maxDeficitDirection ? iterationResults.maxDeficit : -maxDeficit;
|
|
185
|
+
};
|
|
186
|
+
const iterSteps = (0, import_utils.stepsForStep)(maxDeficitStep, config);
|
|
187
|
+
const lowerSeedL = maxDeficitDirection === "lighter" ? 0 : 1;
|
|
188
|
+
const lowerDeficit = -maxDeficit;
|
|
189
|
+
const upperSeedL = (0, import_fn.get)(seed, [import_fn.OKLCH, "l"]);
|
|
190
|
+
const upperDeficit = maxDeficit;
|
|
191
|
+
const bestSeed = (0, import_utils.solveWithBisect)(
|
|
192
|
+
getSeedForL,
|
|
193
|
+
getDeficitForSeed,
|
|
194
|
+
lowerSeedL,
|
|
195
|
+
lowerDeficit,
|
|
196
|
+
upperSeedL,
|
|
197
|
+
upperDeficit
|
|
198
|
+
);
|
|
199
|
+
bestRamp = calculateRamp({
|
|
200
|
+
seed: bestSeed,
|
|
201
|
+
sortedSteps,
|
|
202
|
+
config,
|
|
203
|
+
mainDir,
|
|
204
|
+
oppDir,
|
|
205
|
+
pinLightness
|
|
206
|
+
}).rampResults;
|
|
252
207
|
}
|
|
253
208
|
if (mainDir === "darker") {
|
|
254
|
-
const tmpSurface1 =
|
|
255
|
-
|
|
256
|
-
|
|
209
|
+
const tmpSurface1 = bestRamp.surface1;
|
|
210
|
+
bestRamp.surface1 = bestRamp.surface3;
|
|
211
|
+
bestRamp.surface3 = tmpSurface1;
|
|
257
212
|
}
|
|
258
|
-
return
|
|
213
|
+
return {
|
|
214
|
+
ramp: bestRamp,
|
|
215
|
+
direction: mainDir
|
|
216
|
+
};
|
|
259
217
|
}
|
|
260
218
|
// Annotate the CommonJS export names for ESM import in node:
|
|
261
219
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport Color from 'colorjs.io';\n\n/**\n * Internal dependencies\n */\nimport { getCachedContrast, getColorString } from './cache-utils';\nimport { findColorMeetingRequirements } from './find-color-with-constraints';\nimport {\n\tclampToGamut,\n\tsortByDependency,\n\tcomputeBetterFgColorDirection,\n\tadjustContrastTarget,\n} from './utils';\n\nimport type {\n\tFollowDirection,\n\tRamp,\n\tRampDirection,\n\tRampConfig,\n\tRampResult,\n} from './types';\nimport { LIGHTNESS_EPSILON, MAX_BISECTION_ITERATIONS } from './constants';\n\n/**\n * Calculate a complete color ramp based on the provided configuration.\n *\n * @param params - The calculation parameters\n * @param params.seed - The base color to build the ramp from\n * @param params.sortedSteps - Steps sorted in dependency order\n * @param params.config - Ramp configuration defining contrast requirements\n * @param params.mainDir - Primary direction for the ramp (lighter/darker)\n * @param params.oppDir - Opposite direction from mainDir\n * @param params.pinLightness - Optional lightness override for a given step\n * @param params.pinLightness.stepName\n * @param params.pinLightness.value\n * @param params.debug\n * @return Object containing ramp results and satisfaction status\n */\nfunction calculateRamp( {\n\tseed,\n\tsortedSteps,\n\tconfig,\n\tmainDir,\n\toppDir,\n\tpinLightness,\n\tdebug = false,\n}: {\n\tseed: Color;\n\tsortedSteps: ( keyof Ramp )[];\n\tconfig: RampConfig;\n\tmainDir: RampDirection;\n\toppDir: RampDirection;\n\tpinLightness?: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n\tdebug?: boolean;\n} ) {\n\tconst rampResults = {} as Record<\n\t\tkeyof Ramp,\n\t\t{ color: string; warning: boolean }\n\t>;\n\tlet SATISFIED_ALL_CONTRAST_REQUIREMENTS = true;\n\tlet UNSATISFIED_DIRECTION: RampDirection = 'lighter';\n\tlet MAX_WEIGHTED_DEFICIT = 0;\n\n\t// Keep track of the calculated colors, as they are going to be useful\n\t// when other colors reference them.\n\tconst calculatedColors = new Map< keyof Ramp | 'seed', Color >();\n\tcalculatedColors.set( 'seed', seed );\n\n\tfor ( const stepName of sortedSteps ) {\n\t\tconst {\n\t\t\tcontrast,\n\t\t\tlightness: stepLightnessConstraint,\n\t\t\ttaperChromaOptions,\n\t\t\tsameAsIfPossible,\n\t\t} = config[ stepName ];\n\t\tconst referenceColor = calculatedColors.get( contrast.reference );\n\n\t\tif ( ! referenceColor ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Reference color for step ${ stepName } not found: ${ contrast.reference }`\n\t\t\t);\n\t\t}\n\n\t\t// Check if we can reuse color from the `sameAsIfPossible` config option\n\t\tif ( sameAsIfPossible ) {\n\t\t\tconst candidateColor = calculatedColors.get( sameAsIfPossible );\n\t\t\tif ( candidateColor ) {\n\t\t\t\tconst candidateContrast = getCachedContrast(\n\t\t\t\t\treferenceColor,\n\t\t\t\t\tcandidateColor\n\t\t\t\t);\n\t\t\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\t\t\t\t// If the candidate meets the contrast requirement, use it\n\t\t\t\tif ( candidateContrast >= adjustedTarget ) {\n\t\t\t\t\t// Store the reused color\n\t\t\t\t\tcalculatedColors.set( stepName, candidateColor );\n\t\t\t\t\trampResults[ stepName ] = {\n\t\t\t\t\t\tcolor: getColorString( candidateColor ),\n\t\t\t\t\t\twarning: false,\n\t\t\t\t\t};\n\n\t\t\t\t\tcontinue; // Skip to next step\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction computeDirection(\n\t\t\tcolor: Color,\n\t\t\tfollowDirection: FollowDirection\n\t\t): RampDirection {\n\t\t\tif ( followDirection === 'main' ) {\n\t\t\t\treturn mainDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'opposite' ) {\n\t\t\t\treturn oppDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'best' ) {\n\t\t\t\treturn computeBetterFgColorDirection(\n\t\t\t\t\tcolor,\n\t\t\t\t\tcontrast.preferLighter\n\t\t\t\t).better;\n\t\t\t}\n\n\t\t\treturn followDirection;\n\t\t}\n\n\t\tconst computedDir = computeDirection(\n\t\t\treferenceColor,\n\t\t\tcontrast.followDirection\n\t\t);\n\n\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\n\t\t// Define the lightness constraint, if needed.\n\t\tlet lightnessConstraint;\n\t\tif ( pinLightness?.stepName === stepName ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: pinLightness.value,\n\t\t\t\ttype: 'force',\n\t\t\t} as const;\n\t\t} else if ( stepLightnessConstraint ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: stepLightnessConstraint( computedDir ),\n\t\t\t\ttype: 'onlyIfSucceeds',\n\t\t\t} as const;\n\t\t}\n\n\t\t// Calculate the color meeting the requirements\n\t\tconst searchResults = findColorMeetingRequirements(\n\t\t\treferenceColor,\n\t\t\tseed,\n\t\t\tadjustedTarget,\n\t\t\tcomputedDir,\n\t\t\t{\n\t\t\t\tstrict: false,\n\t\t\t\tlightnessConstraint,\n\t\t\t\ttaperChromaOptions,\n\t\t\t\tdebug,\n\t\t\t}\n\t\t);\n\n\t\t// When the target contrast is not met, take note of it and use\n\t\t// that information to guide the ramp calculation bisection.\n\t\tif ( ! searchResults.reached && ! contrast.ignoreWhenAdjustingSeed ) {\n\t\t\tSATISFIED_ALL_CONTRAST_REQUIREMENTS = false;\n\n\t\t\t// Calculate constraint failure severity for seed optimization\n\t\t\t// Use the relative deficit size, weighted by how changing the seed would impact this constraint\n\t\t\tconst deficitVsTarget = adjustedTarget - searchResults.achieved;\n\n\t\t\t// Weight the deficit by how much seed adjustment would help this constraint\n\t\t\t// If seed has low contrast vs reference, adjusting seed has high impact\n\t\t\t// If seed has high contrast vs reference, adjusting seed has low impact\n\t\t\tconst impactWeight = 1 / getCachedContrast( seed, referenceColor );\n\t\t\tconst weightedDeficit = deficitVsTarget * impactWeight;\n\n\t\t\t// Track the most impactful failure for seed optimization\n\t\t\tif ( weightedDeficit > MAX_WEIGHTED_DEFICIT ) {\n\t\t\t\tMAX_WEIGHTED_DEFICIT = weightedDeficit;\n\t\t\t\tUNSATISFIED_DIRECTION = computedDir;\n\t\t\t}\n\t\t}\n\n\t\t// Store calculated color for future dependencies\n\t\tcalculatedColors.set( stepName, searchResults.color );\n\n\t\t// Add to results\n\t\trampResults[ stepName ] = {\n\t\t\tcolor: getColorString( searchResults.color ),\n\t\t\twarning:\n\t\t\t\t! contrast.ignoreWhenAdjustingSeed && ! searchResults.reached,\n\t\t};\n\t}\n\n\treturn {\n\t\trampResults,\n\t\tSATISFIED_ALL_CONTRAST_REQUIREMENTS,\n\t\tUNSATISFIED_DIRECTION,\n\t};\n}\n\nexport function buildRamp(\n\tseedArg: string,\n\tconfig: RampConfig,\n\t{\n\t\tmainDirection,\n\t\tpinLightness,\n\t\tdebug = false,\n\t\trescaleToFitContrastTargets = true,\n\t}: {\n\t\tmainDirection?: RampDirection;\n\t\tpinLightness?: {\n\t\t\tstepName: keyof Ramp;\n\t\t\tvalue: number;\n\t\t};\n\t\trescaleToFitContrastTargets?: boolean;\n\t\tdebug?: boolean;\n\t} = {}\n): RampResult {\n\tlet seed: Color;\n\ttry {\n\t\tseed = clampToGamut( new Color( seedArg ) );\n\t} catch ( error ) {\n\t\tthrow new Error(\n\t\t\t`Invalid seed color \"${ seedArg }\": ${\n\t\t\t\terror instanceof Error ? error.message : 'Unknown error'\n\t\t\t}`\n\t\t);\n\t}\n\n\tlet mainDir: RampDirection = 'lighter';\n\tlet oppDir: RampDirection = 'darker';\n\n\tif ( mainDirection ) {\n\t\tmainDir = mainDirection;\n\t\toppDir = mainDirection === 'darker' ? 'lighter' : 'darker';\n\t} else {\n\t\tconst { better, worse } = computeBetterFgColorDirection( seed );\n\t\tmainDir = better;\n\t\toppDir = worse;\n\t}\n\n\t// Get the correct calculation order based on dependencies\n\tconst sortedSteps = sortByDependency( config );\n\n\t// Calculate the ramp with the initial seed.\n\tconst {\n\t\trampResults,\n\t\tSATISFIED_ALL_CONTRAST_REQUIREMENTS,\n\t\tUNSATISFIED_DIRECTION,\n\t} = calculateRamp( {\n\t\tseed,\n\t\tsortedSteps,\n\t\tconfig,\n\t\tmainDir,\n\t\toppDir,\n\t\tpinLightness,\n\t\tdebug,\n\t} );\n\tconst toReturn = {\n\t\tramp: rampResults,\n\t\tdirection: mainDir,\n\t} as RampResult;\n\n\tif ( debug ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log( `First run`, {\n\t\t\tSATISFIED_ALL_CONTRAST_REQUIREMENTS,\n\t\t\tUNSATISFIED_DIRECTION,\n\t\t\tseed: seed.toString(),\n\t\t\tsortedSteps,\n\t\t\tconfig,\n\t\t\tmainDir,\n\t\t\toppDir,\n\t\t\tpinLightness,\n\t\t} );\n\t}\n\n\tif (\n\t\t! SATISFIED_ALL_CONTRAST_REQUIREMENTS &&\n\t\trescaleToFitContrastTargets\n\t) {\n\t\tlet worseSeedL = seed.oklch.l;\n\t\t// For a scale with the \"lighter\" direction, the contrast can be improved\n\t\t// by darkening the seed. For \"darker\" direction, by lightening the seed.\n\t\tlet betterSeedL = UNSATISFIED_DIRECTION === 'lighter' ? 0 : 1;\n\n\t\t// Binary search: try a new seed and recompute the whole ramp\n\t\t// (TODO: try a smarter approach?)\n\t\tfor (\n\t\t\tlet i = 0;\n\t\t\ti < MAX_BISECTION_ITERATIONS &&\n\t\t\tMath.abs( betterSeedL - worseSeedL ) > LIGHTNESS_EPSILON;\n\t\t\ti++\n\t\t) {\n\t\t\tconst newSeed = clampToGamut(\n\t\t\t\tseed.clone().set( {\n\t\t\t\t\tl: ( worseSeedL + betterSeedL ) / 2,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( debug ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log( `Iteration ${ i }`, {\n\t\t\t\t\tworseSeedL,\n\t\t\t\t\tnewSeedL: ( worseSeedL + betterSeedL ) / 2,\n\t\t\t\t\tbetterSeedL,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tconst iterationResults = calculateRamp( {\n\t\t\t\tseed: newSeed,\n\t\t\t\tsortedSteps,\n\t\t\t\tconfig,\n\t\t\t\tmainDir,\n\t\t\t\toppDir,\n\t\t\t\tpinLightness,\n\t\t\t\tdebug,\n\t\t\t} );\n\n\t\t\tif ( iterationResults.SATISFIED_ALL_CONTRAST_REQUIREMENTS ) {\n\t\t\t\tbetterSeedL = newSeed.oklch.l;\n\t\t\t\t// Only update toReturn when the ramp satisfies all constraints.\n\t\t\t\ttoReturn.ramp = iterationResults.rampResults;\n\t\t\t} else if ( UNSATISFIED_DIRECTION !== mainDir ) {\n\t\t\t\t// Failing constraint is in opposite direction to main ramp direction\n\t\t\t\t// We've moved too far in mainDir, constrain the search\n\t\t\t\tbetterSeedL = newSeed.oklch.l;\n\t\t\t} else {\n\t\t\t\t// Failing constraint is in same direction as main ramp direction\n\t\t\t\t// We haven't moved far enough in mainDir, continue searching\n\t\t\t\tworseSeedL = newSeed.oklch.l;\n\t\t\t}\n\n\t\t\tif ( debug ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log( `Retry #${ i }`, {\n\t\t\t\t\tSATISFIED_ALL_CONTRAST_REQUIREMENTS,\n\t\t\t\t\tUNSATISFIED_DIRECTION,\n\t\t\t\t\tseed: newSeed.toString(),\n\t\t\t\t\tsortedSteps,\n\t\t\t\t\tconfig,\n\t\t\t\t\tmainDir,\n\t\t\t\t\toppDir,\n\t\t\t\t\tpinLightness,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Swap surface1 and surface3 for darker ramps to maintain visual elevation hierarchy.\n\t// This ensures surface1 appears \"behind\" surface2, and surface3 appears \"in front\",\n\t// regardless of the ramp's main direction.\n\tif ( mainDir === 'darker' ) {\n\t\tconst tmpSurface1 = toReturn.ramp.surface1;\n\t\ttoReturn.ramp.surface1 = toReturn.ramp.surface3;\n\t\ttoReturn.ramp.surface3 = tmpSurface1;\n\t}\n\n\treturn toReturn;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tclone,\n\tget,\n\tOKLCH,\n\tparse,\n\tset,\n\ttype ColorTypes,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { getContrast, getColorString } from './color-utils';\nimport { findColorMeetingRequirements } from './find-color-with-constraints';\nimport {\n\tclampToGamut,\n\tsortByDependency,\n\tcomputeBetterFgColorDirection,\n\tadjustContrastTarget,\n\tstepsForStep,\n\tsolveWithBisect,\n} from './utils';\n\nimport type {\n\tFollowDirection,\n\tRamp,\n\tRampDirection,\n\tRampConfig,\n\tRampResult,\n} from './types';\nimport { CONTRAST_EPSILON } from './constants';\n\n/**\n * Calculate a complete color ramp based on the provided configuration.\n *\n * @param params - The calculation parameters\n * @param params.seed - The base color to build the ramp from\n * @param params.sortedSteps - Steps sorted in dependency order\n * @param params.config - Ramp configuration defining contrast requirements\n * @param params.mainDir - Primary direction for the ramp (lighter/darker)\n * @param params.oppDir - Opposite direction from mainDir\n * @param params.pinLightness - Optional lightness override for a given step\n * @param params.pinLightness.stepName\n * @param params.pinLightness.value\n * @return Object containing ramp results and satisfaction status\n */\nfunction calculateRamp( {\n\tseed,\n\tsortedSteps,\n\tconfig,\n\tmainDir,\n\toppDir,\n\tpinLightness,\n}: {\n\tseed: ColorTypes;\n\tsortedSteps: ( keyof Ramp )[];\n\tconfig: RampConfig;\n\tmainDir: RampDirection;\n\toppDir: RampDirection;\n\tpinLightness?: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} ) {\n\tconst rampResults = {} as Record<\n\t\tkeyof Ramp,\n\t\t{ color: string; warning: boolean }\n\t>;\n\tlet maxDeficit = -Infinity;\n\tlet maxDeficitDirection: RampDirection = 'lighter';\n\tlet maxDeficitStep;\n\n\t// Keep track of the calculated colors, as they are going to be useful\n\t// when other colors reference them.\n\tconst calculatedColors = new Map< keyof Ramp | 'seed', ColorTypes >();\n\tcalculatedColors.set( 'seed', seed );\n\n\tfor ( const stepName of sortedSteps ) {\n\t\tconst {\n\t\t\tcontrast,\n\t\t\tlightness: stepLightnessConstraint,\n\t\t\ttaperChromaOptions,\n\t\t\tsameAsIfPossible,\n\t\t} = config[ stepName ];\n\n\t\tconst referenceColor = calculatedColors.get( contrast.reference );\n\t\tif ( ! referenceColor ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Reference color for step ${ stepName } not found: ${ contrast.reference }`\n\t\t\t);\n\t\t}\n\n\t\t// Check if we can reuse color from the `sameAsIfPossible` config option\n\t\tif ( sameAsIfPossible ) {\n\t\t\tconst candidateColor = calculatedColors.get( sameAsIfPossible );\n\t\t\tif ( ! candidateColor ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Same-as color for step ${ stepName } not found: ${ sameAsIfPossible }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst candidateContrast = getContrast(\n\t\t\t\treferenceColor,\n\t\t\t\tcandidateColor\n\t\t\t);\n\t\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\t\t\t// If the candidate meets the contrast requirement, use it\n\t\t\tif ( candidateContrast >= adjustedTarget ) {\n\t\t\t\t// Store the reused color\n\t\t\t\tcalculatedColors.set( stepName, candidateColor );\n\t\t\t\trampResults[ stepName ] = {\n\t\t\t\t\tcolor: getColorString( candidateColor ),\n\t\t\t\t\twarning: false,\n\t\t\t\t};\n\n\t\t\t\tcontinue; // Skip to next step\n\t\t\t}\n\t\t}\n\n\t\tfunction computeDirection(\n\t\t\tcolor: ColorTypes,\n\t\t\tfollowDirection: FollowDirection\n\t\t): RampDirection {\n\t\t\tif ( followDirection === 'main' ) {\n\t\t\t\treturn mainDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'opposite' ) {\n\t\t\t\treturn oppDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'best' ) {\n\t\t\t\treturn computeBetterFgColorDirection(\n\t\t\t\t\tcolor,\n\t\t\t\t\tcontrast.preferLighter\n\t\t\t\t).better;\n\t\t\t}\n\n\t\t\treturn followDirection;\n\t\t}\n\n\t\tconst computedDir = computeDirection(\n\t\t\treferenceColor,\n\t\t\tcontrast.followDirection\n\t\t);\n\n\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\n\t\t// Define the lightness constraint, if needed.\n\t\tlet lightnessConstraint;\n\t\tif ( pinLightness?.stepName === stepName ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: pinLightness.value,\n\t\t\t\ttype: 'force',\n\t\t\t} as const;\n\t\t} else if ( stepLightnessConstraint ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: stepLightnessConstraint( computedDir ),\n\t\t\t\ttype: 'onlyIfSucceeds',\n\t\t\t} as const;\n\t\t}\n\n\t\t// Calculate the color meeting the requirements\n\t\tconst searchResults = findColorMeetingRequirements(\n\t\t\treferenceColor,\n\t\t\tseed,\n\t\t\tadjustedTarget,\n\t\t\tcomputedDir,\n\t\t\t{\n\t\t\t\tlightnessConstraint,\n\t\t\t\ttaperChromaOptions,\n\t\t\t}\n\t\t);\n\n\t\t// When the target contrast is not met, take note of it and use\n\t\t// that information to guide the ramp calculation bisection.\n\t\tif (\n\t\t\t! contrast.ignoreWhenAdjustingSeed &&\n\t\t\tsearchResults.deficit &&\n\t\t\tsearchResults.deficit > maxDeficit\n\t\t) {\n\t\t\tmaxDeficit = searchResults.deficit;\n\t\t\tmaxDeficitDirection = computedDir;\n\t\t\tmaxDeficitStep = stepName;\n\t\t}\n\n\t\t// Store calculated color for future dependencies\n\t\tcalculatedColors.set( stepName, searchResults.color );\n\n\t\t// Add to results\n\t\trampResults[ stepName ] = {\n\t\t\tcolor: getColorString( searchResults.color ),\n\t\t\twarning:\n\t\t\t\t! contrast.ignoreWhenAdjustingSeed && ! searchResults.reached,\n\t\t};\n\t}\n\treturn {\n\t\trampResults,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t};\n}\n\nexport function buildRamp(\n\tseedArg: string,\n\tconfig: RampConfig,\n\t{\n\t\tmainDirection,\n\t\tpinLightness,\n\t\trescaleToFitContrastTargets = true,\n\t}: {\n\t\tmainDirection?: RampDirection;\n\t\tpinLightness?: {\n\t\t\tstepName: keyof Ramp;\n\t\t\tvalue: number;\n\t\t};\n\t\trescaleToFitContrastTargets?: boolean;\n\t} = {}\n): RampResult {\n\tlet seed: PlainColorObject;\n\ttry {\n\t\tseed = clampToGamut( parse( seedArg ) );\n\t} catch ( error ) {\n\t\tthrow new Error(\n\t\t\t`Invalid seed color \"${ seedArg }\": ${\n\t\t\t\terror instanceof Error ? error.message : 'Unknown error'\n\t\t\t}`\n\t\t);\n\t}\n\n\tlet mainDir: RampDirection = 'lighter';\n\tlet oppDir: RampDirection = 'darker';\n\n\tif ( mainDirection ) {\n\t\tmainDir = mainDirection;\n\t\toppDir = mainDirection === 'darker' ? 'lighter' : 'darker';\n\t} else {\n\t\tconst { better, worse } = computeBetterFgColorDirection( seed );\n\t\tmainDir = better;\n\t\toppDir = worse;\n\t}\n\n\t// Get the correct calculation order based on dependencies\n\tconst sortedSteps = sortByDependency( config );\n\n\t// Calculate the ramp with the initial seed.\n\tconst { rampResults, maxDeficit, maxDeficitDirection, maxDeficitStep } =\n\t\tcalculateRamp( {\n\t\t\tseed,\n\t\t\tsortedSteps,\n\t\t\tconfig,\n\t\t\tmainDir,\n\t\t\toppDir,\n\t\t\tpinLightness,\n\t\t} );\n\n\tlet bestRamp = rampResults;\n\n\tif ( maxDeficit > CONTRAST_EPSILON && rescaleToFitContrastTargets ) {\n\t\tconst iterSteps = stepsForStep( maxDeficitStep!, config );\n\n\t\tfunction getSeedForL( l: number ): ColorTypes {\n\t\t\treturn clampToGamut( set( clone( seed ), [ OKLCH, 'l' ], l ) );\n\t\t}\n\n\t\tfunction getDeficitForSeed( s: ColorTypes ): number {\n\t\t\tconst iterationResults = calculateRamp( {\n\t\t\t\tseed: s,\n\t\t\t\tsortedSteps: iterSteps,\n\t\t\t\tconfig,\n\t\t\t\tmainDir,\n\t\t\t\toppDir,\n\t\t\t\tpinLightness,\n\t\t\t} );\n\n\t\t\t// If the constraints start failing in the opposite direction to the original\n\t\t\t// iteration's direction, that means we've moved too far away from the target.\n\t\t\t// Don't use the `maxDeficit` value because it's not related to our search,\n\t\t\t// and might even be positive, which would confuse the bisection algorithm.\n\t\t\treturn iterationResults.maxDeficitDirection === maxDeficitDirection\n\t\t\t\t? iterationResults.maxDeficit\n\t\t\t\t: -maxDeficit;\n\t\t}\n\n\t\t// For a scale with the \"lighter\" direction, the contrast can be improved\n\t\t// by darkening the seed. For \"darker\" direction, by lightening the seed.\n\t\tconst lowerSeedL = maxDeficitDirection === 'lighter' ? 0 : 1;\n\t\tconst lowerDeficit = -maxDeficit;\n\t\tconst upperSeedL = get( seed, [ OKLCH, 'l' ] );\n\t\tconst upperDeficit = maxDeficit;\n\n\t\tconst bestSeed = solveWithBisect(\n\t\t\tgetSeedForL,\n\t\t\tgetDeficitForSeed,\n\t\t\tlowerSeedL,\n\t\t\tlowerDeficit,\n\t\t\tupperSeedL,\n\t\t\tupperDeficit\n\t\t);\n\n\t\t// Calculate the final ramp with adjusted seed.\n\t\tbestRamp = calculateRamp( {\n\t\t\tseed: bestSeed,\n\t\t\tsortedSteps,\n\t\t\tconfig,\n\t\t\tmainDir,\n\t\t\toppDir,\n\t\t\tpinLightness,\n\t\t} ).rampResults;\n\t}\n\n\t// Swap surface1 and surface3 for darker ramps to maintain visual elevation hierarchy.\n\t// This ensures surface1 appears \"behind\" surface2, and surface3 appears \"in front\",\n\t// regardless of the ramp's main direction.\n\tif ( mainDir === 'darker' ) {\n\t\tconst tmpSurface1 = bestRamp.surface1;\n\t\tbestRamp.surface1 = bestRamp.surface3;\n\t\tbestRamp.surface3 = tmpSurface1;\n\t}\n\n\treturn {\n\t\tramp: bestRamp,\n\t\tdirection: mainDir,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAQO;AAKP,mCAAO;AACP,yBAA4C;AAC5C,yCAA6C;AAC7C,mBAOO;AASP,uBAAiC;AAgBjC,SAAS,cAAe;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAUI;AACH,QAAM,cAAc,CAAC;AAIrB,MAAI,aAAa;AACjB,MAAI,sBAAqC;AACzC,MAAI;AAIJ,QAAM,mBAAmB,oBAAI,IAAuC;AACpE,mBAAiB,IAAK,QAAQ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E;AAEH,MAAI,WAAW;AAEf,MAAK,aAAa,qCAAoB,6BAA8B;AAGnE,QAAS,cAAT,SAAsB,GAAwB;AAC7C,iBAAO,+BAAc,mBAAK,iBAAO,IAAK,GAAG,CAAE,iBAAO,GAAI,GAAG,CAAE,CAAE;AAAA,IAC9D,GAES,oBAAT,SAA4B,GAAwB;AACnD,YAAM,mBAAmB,cAAe;AAAA,QACvC,MAAM;AAAA,QACN,aAAa;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAE;AAMF,aAAO,iBAAiB,wBAAwB,sBAC7C,iBAAiB,aACjB,CAAC;AAAA,IACL;AAvBA,UAAM,gBAAY,2BAAc,gBAAiB,MAAO;AA2BxD,UAAM,aAAa,wBAAwB,YAAY,IAAI;AAC3D,UAAM,eAAe,CAAC;AACtB,UAAM,iBAAa,eAAK,MAAM,CAAE,iBAAO,GAAI,CAAE;AAC7C,UAAM,eAAe;AAErB,UAAM,eAAW;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAGA,eAAW,cAAe;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE,EAAE;AAAA,EACL;AAKA,MAAK,YAAY,UAAW;AAC3B,UAAM,cAAc,SAAS;AAC7B,aAAS,WAAW,SAAS;AAC7B,aAAS,WAAW;AAAA,EACrB;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,EACZ;AACD;",
|
|
6
|
+
"names": ["adjustedTarget"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -16,36 +15,38 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
15
|
return to;
|
|
17
16
|
};
|
|
18
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/theme/src/color-ramps/lib/ramp-configs.ts
|
|
19
20
|
var ramp_configs_exports = {};
|
|
20
21
|
__export(ramp_configs_exports, {
|
|
21
22
|
ACCENT_RAMP_CONFIG: () => ACCENT_RAMP_CONFIG,
|
|
22
23
|
BG_RAMP_CONFIG: () => BG_RAMP_CONFIG
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(ramp_configs_exports);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
var lightnessConstraintForegroundHighContrast = (direction) => direction === "lighter" ? 0.9551 : 0.235;
|
|
27
|
+
var lightnessConstraintForegroundMediumContrast = (direction) => direction === "lighter" ? 0.77 : 0.56;
|
|
28
|
+
var lightnessConstraintBgFill = (direction) => direction === "lighter" ? 0.67 : 0.45;
|
|
29
|
+
var BG_SURFACE_TAPER_CHROMA = {
|
|
29
30
|
alpha: 0.7
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
+
var FG_TAPER_CHROMA = {
|
|
32
33
|
alpha: 0.6,
|
|
33
34
|
kLight: 0.2,
|
|
34
35
|
kDark: 0.2
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
+
var STROKE_TAPER_CHROMA = {
|
|
37
38
|
alpha: 0.6,
|
|
38
39
|
radiusDark: 0.01,
|
|
39
40
|
radiusLight: 0.01,
|
|
40
41
|
kLight: 0.8,
|
|
41
42
|
kDark: 0.8
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
var ACCENT_SURFACE_TAPER_CHROMA = {
|
|
44
45
|
alpha: 0.75,
|
|
45
46
|
radiusDark: 0.01,
|
|
46
47
|
radiusLight: 0.01
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
+
var fgSurface4Config = {
|
|
49
50
|
contrast: {
|
|
50
51
|
reference: "surface3",
|
|
51
52
|
followDirection: "main",
|
|
@@ -55,13 +56,13 @@ const fgSurface4Config = {
|
|
|
55
56
|
lightness: lightnessConstraintForegroundHighContrast,
|
|
56
57
|
taperChromaOptions: FG_TAPER_CHROMA
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
+
var BG_RAMP_CONFIG = {
|
|
59
60
|
// Surface
|
|
60
61
|
surface1: {
|
|
61
62
|
contrast: {
|
|
62
63
|
reference: "surface2",
|
|
63
64
|
followDirection: "opposite",
|
|
64
|
-
target: 1.
|
|
65
|
+
target: 1.06,
|
|
65
66
|
ignoreWhenAdjustingSeed: true
|
|
66
67
|
},
|
|
67
68
|
taperChromaOptions: BG_SURFACE_TAPER_CHROMA
|
|
@@ -77,7 +78,7 @@ const BG_RAMP_CONFIG = {
|
|
|
77
78
|
contrast: {
|
|
78
79
|
reference: "surface2",
|
|
79
80
|
followDirection: "main",
|
|
80
|
-
target: 1.
|
|
81
|
+
target: 1.06
|
|
81
82
|
},
|
|
82
83
|
taperChromaOptions: BG_SURFACE_TAPER_CHROMA
|
|
83
84
|
},
|
|
@@ -85,7 +86,7 @@ const BG_RAMP_CONFIG = {
|
|
|
85
86
|
contrast: {
|
|
86
87
|
reference: "surface2",
|
|
87
88
|
followDirection: "main",
|
|
88
|
-
target: 1.
|
|
89
|
+
target: 1.12
|
|
89
90
|
},
|
|
90
91
|
taperChromaOptions: BG_SURFACE_TAPER_CHROMA
|
|
91
92
|
},
|
|
@@ -235,7 +236,7 @@ const BG_RAMP_CONFIG = {
|
|
|
235
236
|
taperChromaOptions: FG_TAPER_CHROMA
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
|
-
|
|
239
|
+
var ACCENT_RAMP_CONFIG = {
|
|
239
240
|
...BG_RAMP_CONFIG,
|
|
240
241
|
surface1: {
|
|
241
242
|
...BG_RAMP_CONFIG.surface1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/ramp-configs.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampStepConfig, RampConfig, RampDirection } from './types';\nimport type { TaperChromaOptions } from './taper-chroma';\n\nconst lightnessConstraintForegroundHighContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.9551 // lightness of #f0f0f0 (ie $gray-100)\n\t\t: 0.235; // lightness of #1e1e1e (ie $gray-900)\nconst lightnessConstraintForegroundMediumContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.77 // lightness of #b4b4b4\n\t\t: 0.56; // lightness of #747474\nconst lightnessConstraintBgFill = ( direction: RampDirection ) =>\n\tdirection === 'lighter'\n\t\t? 0.67 // lightness of #969696 (7:1 vs black)\n\t\t: 0.45; // lightness of #555555 (7:1 vs white)\n\nconst BG_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.7,\n};\nconst FG_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tkLight: 0.2,\n\tkDark: 0.2,\n};\nconst STROKE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n\tkLight: 0.8,\n\tkDark: 0.8,\n};\nconst ACCENT_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.75,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n};\n\nconst fgSurface4Config: RampStepConfig = {\n\tcontrast: {\n\t\treference: 'surface3',\n\t\tfollowDirection: 'main',\n\t\ttarget: 7,\n\t\tpreferLighter: true,\n\t},\n\tlightness: lightnessConstraintForegroundHighContrast,\n\ttaperChromaOptions: FG_TAPER_CHROMA,\n};\n\nexport const BG_RAMP_CONFIG: RampConfig = {\n\t// Surface\n\tsurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampStepConfig, RampConfig, RampDirection } from './types';\nimport type { TaperChromaOptions } from './taper-chroma';\n\nconst lightnessConstraintForegroundHighContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.9551 // lightness of #f0f0f0 (ie $gray-100)\n\t\t: 0.235; // lightness of #1e1e1e (ie $gray-900)\nconst lightnessConstraintForegroundMediumContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.77 // lightness of #b4b4b4\n\t\t: 0.56; // lightness of #747474\nconst lightnessConstraintBgFill = ( direction: RampDirection ) =>\n\tdirection === 'lighter'\n\t\t? 0.67 // lightness of #969696 (7:1 vs black)\n\t\t: 0.45; // lightness of #555555 (7:1 vs white)\n\nconst BG_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.7,\n};\nconst FG_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tkLight: 0.2,\n\tkDark: 0.2,\n};\nconst STROKE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n\tkLight: 0.8,\n\tkDark: 0.8,\n};\nconst ACCENT_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.75,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n};\n\nconst fgSurface4Config: RampStepConfig = {\n\tcontrast: {\n\t\treference: 'surface3',\n\t\tfollowDirection: 'main',\n\t\ttarget: 7,\n\t\tpreferLighter: true,\n\t},\n\tlightness: lightnessConstraintForegroundHighContrast,\n\ttaperChromaOptions: FG_TAPER_CHROMA,\n};\n\nexport const BG_RAMP_CONFIG: RampConfig = {\n\t// Surface\n\tsurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.06,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tsurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.06,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.12,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.4,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\t// Bg fill\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4,\n\t\t},\n\t\tlightness: lightnessConstraintBgFill,\n\t},\n\tbgFill2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted1: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted2: fgSurface4Config,\n\tbgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'darker', // This is what causes the token to be always dark\n\t\t\ttarget: 7,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\t// Stroke\n\tstroke1: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 2.2,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke2: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.5,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke4: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.5,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\t// fgSurface\n\tfgSurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 2,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface2: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundMediumContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface4: fgSurface4Config,\n\t// fgFill\n\tfgFill: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillInverted: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillDark',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n};\n\n// BG_RAMP: seed => surface2 => {bgFill, surface3 => all other tokens}\n// ACCENT_RAMP: seed => bgFill1 => surface2 => surface3 => all other tokens\nexport const ACCENT_RAMP_CONFIG: RampConfig = {\n\t...BG_RAMP_CONFIG,\n\tsurface1: {\n\t\t...BG_RAMP_CONFIG.surface1,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: BG_RAMP_CONFIG.bgFill1.contrast.target,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface3: {\n\t\t...BG_RAMP_CONFIG.surface3,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\t...BG_RAMP_CONFIG.surface4,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\t...BG_RAMP_CONFIG.surface5,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\t...BG_RAMP_CONFIG.surface6,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tstroke1: {\n\t\t...BG_RAMP_CONFIG.stroke1,\n\t},\n\tstroke2: {\n\t\t...BG_RAMP_CONFIG.stroke2,\n\t},\n\tstroke3: {\n\t\t...BG_RAMP_CONFIG.stroke3,\n\t\tsameAsIfPossible: 'fgSurface3',\n\t\ttaperChromaOptions: undefined,\n\t},\n\tstroke4: {\n\t\t...BG_RAMP_CONFIG.stroke4,\n\t\ttaperChromaOptions: undefined,\n\t},\n\t// fgSurface: do not de-saturate\n\tfgSurface1: {\n\t\t...BG_RAMP_CONFIG.fgSurface1,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface2: {\n\t\t...BG_RAMP_CONFIG.fgSurface2,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface3: {\n\t\t...BG_RAMP_CONFIG.fgSurface3,\n\t\ttaperChromaOptions: undefined,\n\t\tsameAsIfPossible: 'bgFill1',\n\t},\n\tfgSurface4: {\n\t\t...BG_RAMP_CONFIG.fgSurface4,\n\t\ttaperChromaOptions: undefined,\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,IAAM,4CAA4C,CACjD,cAEA,cAAc,YACX,SACA;AACJ,IAAM,8CAA8C,CACnD,cAEA,cAAc,YACX,OACA;AACJ,IAAM,4BAA4B,CAAE,cACnC,cAAc,Y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;AAAA,IACT,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,IACT,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,IACT,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,IACT,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACR,UAAU;AAAA,MACT,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,QAAQ;AAAA,IACT;AAAA,EACD;AAAA,EACA,SAAS;AAAA,IACR,GAAG,eAAe;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACR,GAAG,eAAe;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACR,GAAG,eAAe;AAAA,IAClB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACR,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA;AAAA,EAEA,YAAY;AAAA,IACX,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACX,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACX,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,EACnB;AAAA,EACA,YAAY;AAAA,IACX,GAAG,eAAe;AAAA,IAClB,oBAAoB;AAAA,EACrB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// packages/theme/src/color-ramps/lib/register-color-spaces.ts
|
|
2
|
+
var import_fn = require("colorjs.io/fn");
|
|
3
|
+
import_fn.ColorSpace.register(import_fn.sRGB);
|
|
4
|
+
import_fn.ColorSpace.register(import_fn.OKLCH);
|
|
5
|
+
import_fn.ColorSpace.register(import_fn.P3);
|
|
6
|
+
import_fn.ColorSpace.register(import_fn.HSL);
|
|
7
|
+
//# sourceMappingURL=register-color-spaces.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/color-ramps/lib/register-color-spaces.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { ColorSpace, OKLCH, P3, sRGB, HSL } from 'colorjs.io/fn';\n\n// Ensures that all color spaces used in color ramps are registered globally, a\n// requirement for using colorjs.io's procedural API.\n//\n// See: https://colorjs.io/docs/procedural\nColorSpace.register( sRGB );\nColorSpace.register( OKLCH );\nColorSpace.register( P3 );\nColorSpace.register( HSL );\n"],
|
|
5
|
+
"mappings": ";AAGA,gBAAiD;AAMjD,qBAAW,SAAU,cAAK;AAC1B,qBAAW,SAAU,eAAM;AAC3B,qBAAW,SAAU,YAAG;AACxB,qBAAW,SAAU,aAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|