@wordpress/theme 0.4.1-next.8fd3f8831.0 → 0.5.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 +29 -1
- package/LICENSE.md +1 -1
- package/README.md +72 -18
- package/build/color-ramps/index.cjs +1 -1
- package/build/color-ramps/index.cjs.map +2 -2
- package/build/color-ramps/lib/color-utils.cjs +2 -1
- package/build/color-ramps/lib/color-utils.cjs.map +2 -2
- package/build/color-ramps/lib/default-ramps.cjs +2 -2
- package/build/color-ramps/lib/default-ramps.cjs.map +1 -1
- package/build/color-ramps/lib/index.cjs +1 -1
- package/build/color-ramps/lib/index.cjs.map +2 -2
- package/build/color-ramps/lib/taper-chroma.cjs +2 -2
- package/build/color-ramps/lib/taper-chroma.cjs.map +2 -2
- package/build/prebuilt/js/design-tokens.cjs +16 -29
- package/build/prebuilt/js/design-tokens.cjs.map +3 -3
- package/build/prebuilt/ts/color-tokens.cjs +4 -24
- package/build/prebuilt/ts/color-tokens.cjs.map +2 -2
- package/build/prebuilt/ts/token-types.cjs.map +1 -1
- package/build/stylelint-plugins/no-setting-wpds-custom-properties.cjs +69 -0
- package/build/stylelint-plugins/no-setting-wpds-custom-properties.cjs.map +7 -0
- package/build/stylelint-plugins/no-unknown-ds-tokens.cjs +98 -0
- package/build/stylelint-plugins/no-unknown-ds-tokens.cjs.map +7 -0
- package/build/use-theme-provider-styles.cjs +19 -43
- package/build/use-theme-provider-styles.cjs.map +2 -2
- package/build-module/color-ramps/{index.js → index.mjs} +10 -10
- package/build-module/color-ramps/index.mjs.map +7 -0
- package/build-module/color-ramps/lib/{color-utils.js → color-utils.mjs} +4 -3
- package/build-module/color-ramps/lib/color-utils.mjs.map +7 -0
- package/build-module/color-ramps/lib/{constants.js → constants.mjs} +2 -2
- package/build-module/color-ramps/lib/{default-ramps.js → default-ramps.mjs} +3 -3
- package/build-module/color-ramps/lib/{default-ramps.js.map → default-ramps.mjs.map} +1 -1
- package/build-module/color-ramps/lib/{find-color-with-constraints.js → find-color-with-constraints.mjs} +6 -6
- package/build-module/color-ramps/lib/{index.js → index.mjs} +7 -8
- package/build-module/color-ramps/lib/index.mjs.map +7 -0
- package/build-module/color-ramps/lib/{ramp-configs.js → ramp-configs.mjs} +1 -1
- package/build-module/color-ramps/lib/{register-color-spaces.js → register-color-spaces.mjs} +1 -1
- package/build-module/color-ramps/lib/{taper-chroma.js → taper-chroma.mjs} +4 -4
- package/build-module/color-ramps/lib/{taper-chroma.js.map → taper-chroma.mjs.map} +2 -2
- package/build-module/color-ramps/lib/types.mjs +1 -0
- package/build-module/color-ramps/lib/{utils.js → utils.mjs} +4 -4
- package/build-module/{context.js → context.mjs} +1 -1
- package/build-module/index.mjs +6 -0
- package/build-module/{lock-unlock.js → lock-unlock.mjs} +1 -1
- package/build-module/prebuilt/js/{design-tokens.js → design-tokens.mjs} +17 -30
- package/build-module/prebuilt/js/design-tokens.mjs.map +7 -0
- package/build-module/prebuilt/ts/{color-tokens.js → color-tokens.mjs} +5 -25
- package/build-module/prebuilt/ts/color-tokens.mjs.map +7 -0
- package/build-module/prebuilt/ts/token-types.mjs +1 -0
- package/build-module/{private-apis.js → private-apis.mjs} +4 -4
- package/build-module/stylelint-plugins/no-setting-wpds-custom-properties.mjs +39 -0
- package/build-module/stylelint-plugins/no-setting-wpds-custom-properties.mjs.map +7 -0
- package/build-module/stylelint-plugins/no-unknown-ds-tokens.mjs +68 -0
- package/build-module/stylelint-plugins/no-unknown-ds-tokens.mjs.map +7 -0
- package/build-module/{theme-provider.js → theme-provider.mjs} +3 -3
- package/build-module/types.mjs +1 -0
- package/build-module/{use-theme-provider-styles.js → use-theme-provider-styles.mjs} +24 -49
- package/build-module/use-theme-provider-styles.mjs.map +7 -0
- package/build-types/color-ramps/lib/color-utils.d.ts +1 -1
- package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -1
- package/build-types/color-ramps/lib/constants.d.ts +2 -2
- package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
- package/build-types/color-ramps/lib/index.d.ts.map +1 -1
- package/build-types/color-ramps/stories/index.story.d.ts +1 -1
- package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
- package/build-types/prebuilt/js/{design-tokens.d.ts → design-tokens.d.mts} +1 -1
- package/build-types/prebuilt/js/design-tokens.d.mts.map +1 -0
- package/build-types/prebuilt/ts/color-tokens.d.ts +0 -4
- package/build-types/prebuilt/ts/color-tokens.d.ts.map +1 -1
- package/build-types/prebuilt/ts/token-types.d.ts +21 -5
- package/build-types/prebuilt/ts/token-types.d.ts.map +1 -1
- package/build-types/stories/index.story.d.ts +1 -1
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/build-types/stylelint-plugins/no-setting-wpds-custom-properties.d.mts +4 -0
- package/build-types/stylelint-plugins/no-setting-wpds-custom-properties.d.mts.map +1 -0
- package/build-types/stylelint-plugins/no-unknown-ds-tokens.d.mts +4 -0
- package/build-types/stylelint-plugins/no-unknown-ds-tokens.d.mts.map +1 -0
- package/build-types/use-theme-provider-styles.d.ts.map +1 -1
- package/package.json +42 -13
- package/src/color-ramps/index.ts +2 -2
- package/src/color-ramps/lib/color-utils.ts +2 -1
- package/src/color-ramps/lib/default-ramps.ts +2 -2
- package/src/color-ramps/lib/index.ts +1 -2
- package/src/color-ramps/lib/taper-chroma.ts +2 -2
- package/src/color-ramps/stories/index.story.tsx +2 -2
- package/src/color-ramps/test/__snapshots__/index.test.ts.snap +7136 -7117
- package/src/color-ramps/test/index.test.ts +8 -33
- package/src/prebuilt/css/design-tokens.css +22 -35
- package/src/prebuilt/js/{design-tokens.js → design-tokens.mjs} +17 -30
- package/src/prebuilt/ts/color-tokens.ts +5 -25
- package/src/prebuilt/ts/token-types.ts +51 -3
- package/src/stories/index.story.tsx +4 -4
- package/src/stories/introduction.mdx +6 -0
- package/src/stylelint-plugins/no-setting-wpds-custom-properties.mjs +45 -0
- package/src/stylelint-plugins/no-unknown-ds-tokens.mjs +101 -0
- package/src/stylelint-plugins/test/.stylelintignore +1 -0
- package/src/stylelint-plugins/test/.stylelintrc.json +10 -0
- package/src/stylelint-plugins/test/__snapshots__/no-setting-wpds-custom-properties.test.ts.snap +24 -0
- package/src/stylelint-plugins/test/__snapshots__/no-unknown-ds-tokens.test.ts.snap +24 -0
- package/src/stylelint-plugins/test/fixtures/no-setting-wpds-custom-properties-invalid.css +9 -0
- package/src/stylelint-plugins/test/fixtures/no-setting-wpds-custom-properties-valid.css +12 -0
- package/src/stylelint-plugins/test/fixtures/no-unknown-ds-tokens-invalid.css +9 -0
- package/src/stylelint-plugins/test/fixtures/no-unknown-ds-tokens-valid.css +19 -0
- package/src/stylelint-plugins/test/no-setting-wpds-custom-properties.test.ts +47 -0
- package/src/stylelint-plugins/test/no-unknown-ds-tokens.test.ts +47 -0
- package/src/stylelint-plugins/test/utils/index.ts +29 -0
- package/src/use-theme-provider-styles.ts +22 -42
- package/build-module/color-ramps/index.js.map +0 -7
- package/build-module/color-ramps/lib/color-utils.js.map +0 -7
- package/build-module/color-ramps/lib/index.js.map +0 -7
- package/build-module/color-ramps/lib/types.js +0 -1
- package/build-module/index.js +0 -6
- package/build-module/prebuilt/js/design-tokens.js.map +0 -7
- package/build-module/prebuilt/ts/color-tokens.js.map +0 -7
- package/build-module/prebuilt/ts/token-types.js +0 -1
- package/build-module/types.js +0 -1
- package/build-module/use-theme-provider-styles.js.map +0 -7
- package/build-types/prebuilt/js/design-tokens.d.ts.map +0 -1
- /package/build-module/color-ramps/lib/{constants.js.map → constants.mjs.map} +0 -0
- /package/build-module/color-ramps/lib/{find-color-with-constraints.js.map → find-color-with-constraints.mjs.map} +0 -0
- /package/build-module/color-ramps/lib/{ramp-configs.js.map → ramp-configs.mjs.map} +0 -0
- /package/build-module/color-ramps/lib/{register-color-spaces.js.map → register-color-spaces.mjs.map} +0 -0
- /package/build-module/color-ramps/lib/{types.js.map → types.mjs.map} +0 -0
- /package/build-module/color-ramps/lib/{utils.js.map → utils.mjs.map} +0 -0
- /package/build-module/{context.js.map → context.mjs.map} +0 -0
- /package/build-module/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/{lock-unlock.js.map → lock-unlock.mjs.map} +0 -0
- /package/build-module/prebuilt/ts/{token-types.js.map → token-types.mjs.map} +0 -0
- /package/build-module/{private-apis.js.map → private-apis.mjs.map} +0 -0
- /package/build-module/{theme-provider.js.map → theme-provider.mjs.map} +0 -0
- /package/build-module/{types.js.map → types.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.5.0 (2026-01-16)
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- Removed the following tokens ([#74470](https://github.com/WordPress/gutenberg/pull/74470)):
|
|
10
|
+
- `--wpds-color-bg-interactive-neutral`: use `--wpds-color-bg-interactive-neutral-weak` instead.
|
|
11
|
+
- `--wpds-color-bg-interactive-neutral-active`: use `--wpds-color-bg-interactive-neutral-weak-active` instead.
|
|
12
|
+
- `--wpds-color-bg-interactive-neutral-disabled`: use `--wpds-color-bg-interactive-neutral-weak-disabled` instead.
|
|
13
|
+
- `--wpds-color-bg-interactive-brand`: use `--wpds-color-bg-interactive-brand-weak` instead.
|
|
14
|
+
- `--wpds-color-bg-interactive-brand-active`: use `--wpds-color-bg-interactive-brand-weak-active` instead.
|
|
15
|
+
- `--wpds-color-bg-interactive-brand-disabled`: use `--wpds-color-bg-interactive-neutral-weak-disabled` instead.
|
|
16
|
+
- `--wpds-color-bg-interactive-brand-strong-disabled`: use `--wpds-color-bg-interactive-neutral-strong-disabled` instead.
|
|
17
|
+
- `--wpds-color-bg-interactive-brand-weak-disabled`: use `--wpds-color-bg-interactive-neutral-weak-disabled` instead.
|
|
18
|
+
- `--wpds-color-bg-interactive-error-disabled`: use `--wpds-color-bg-interactive-neutral-weak-disabled` instead.
|
|
19
|
+
- `--wpds-color-bg-interactive-error-strong-disabled`: use `--wpds-color-bg-interactive-neutral-strong-disabled` instead.
|
|
20
|
+
- `--wpds-color-bg-interactive-error-weak-disabled`: use `--wpds-color-bg-interactive-neutral-weak-disabled` instead.
|
|
21
|
+
- `--wpds-color-fg-interactive-brand-disabled`: use `--wpds-color-fg-interactive-neutral-disabled` instead.
|
|
22
|
+
- `--wpds-color-fg-interactive-brand-strong-disabled`: use `--wpds-color-fg-interactive-neutral-strong-disabled` instead.
|
|
23
|
+
- `--wpds-color-fg-interactive-error-disabled`: use `--wpds-color-fg-interactive-neutral-disabled` instead.
|
|
24
|
+
- `--wpds-color-fg-interactive-error-strong-disabled`: use `--wpds-color-fg-interactive-neutral-strong-disabled` instead.
|
|
25
|
+
- `--wpds-color-bg-thumb-brand-disabled`: use the newly added `--wpds-color-bg-thumb-neutral-disabled` instead.
|
|
26
|
+
|
|
27
|
+
### Enhancements
|
|
28
|
+
|
|
29
|
+
- Tweaked the values of the following tokens ([#74470](https://github.com/WordPress/gutenberg/pull/74470)):
|
|
30
|
+
- `--wpds-color-bg-interactive-neutral-strong-disabled` from `#d2d2d2` to `#e2e2e2`.
|
|
31
|
+
- `--wpds-color-bg-interactive-neutral-weak-disabled` from `#e2e2e2` to `#00000000`.
|
|
32
|
+
- `--wpds-color-fg-interactive-neutral-strong-disabled` from `#6d6d6d` to `#8a8a8a`.
|
|
6
33
|
|
|
7
34
|
### New Features
|
|
8
35
|
|
|
36
|
+
- Added stylelint plugins for design token linting: `no-unknown-ds-tokens` to catch references to non-existent design tokens, and `no-setting-wpds-custom-properties` to prevent reassignments of design token variables ([#74226](https://github.com/WordPress/gutenberg/pull/74226)).
|
|
9
37
|
- Expose `ThemeProvider` TypeScript type from package. While the component is still experimental, this makes it easier to use TypeScript typings in your code, which would otherwise be inaccessible. ([#74011](https://github.com/WordPress/gutenberg/pull/74011))
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -11,14 +11,14 @@ A theming package that's part of the WordPress Design System. It has two parts:
|
|
|
11
11
|
|
|
12
12
|
## Design Tokens
|
|
13
13
|
|
|
14
|
-
In the **[Design Tokens Reference](docs/
|
|
14
|
+
In the **[Design Tokens Reference](https://github.com/WordPress/gutenberg/blob/trunk/packages/theme/docs/tokens.md)** document there is a complete reference of all available design tokens including colors, spacing, typography, and more.
|
|
15
15
|
|
|
16
16
|
### Architecture
|
|
17
17
|
|
|
18
18
|
Internally, the design system uses a tiered token architecture:
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
20
|
+
- **Primitive tokens**: Raw values like hex colors or pixel dimensions which are what the browsers eventually interpret. These live in the `/tokens` directory as JSON source files and are an internal implementation detail.
|
|
21
|
+
- **Semantic tokens**: Purpose-driven tokens with meaningful names that reference primitives and describe their intended use. These are what get exported as CSS custom properties.
|
|
22
22
|
|
|
23
23
|
This separation allows the design system to maintain consistency while providing flexibility, since primitive values can be updated without changing the semantic token names that developers use in their code.
|
|
24
24
|
|
|
@@ -62,17 +62,17 @@ Semantic tokens follow a consistent naming pattern:
|
|
|
62
62
|
|
|
63
63
|
**Property** is the specific design property being defined.
|
|
64
64
|
|
|
65
|
-
| Value
|
|
66
|
-
|
|
|
67
|
-
| `bg`
|
|
68
|
-
| `fg`
|
|
69
|
-
| `stroke`
|
|
70
|
-
| `padding
|
|
71
|
-
| `gap`
|
|
72
|
-
| `radius`
|
|
73
|
-
| `width`
|
|
74
|
-
| `size`
|
|
75
|
-
| `family`
|
|
65
|
+
| Value | Description |
|
|
66
|
+
| --------- | ---------------------------------- |
|
|
67
|
+
| `bg` | Background color |
|
|
68
|
+
| `fg` | Foreground color (text and icons) |
|
|
69
|
+
| `stroke` | Border and outline color |
|
|
70
|
+
| `padding` | Internal spacing within an element |
|
|
71
|
+
| `gap` | Spacing between elements |
|
|
72
|
+
| `radius` | Border radius for rounded corners |
|
|
73
|
+
| `width` | Border width |
|
|
74
|
+
| `size` | Font size |
|
|
75
|
+
| `family` | Font family |
|
|
76
76
|
|
|
77
77
|
**Target** is the component or element type the token applies to.
|
|
78
78
|
|
|
@@ -117,10 +117,10 @@ Color tokens extend the base pattern with additional modifiers for tone, emphasi
|
|
|
117
117
|
|
|
118
118
|
**Emphasis** adjusts color strength relative to the base tone, if specified. The default is a normal emphasis.
|
|
119
119
|
|
|
120
|
-
| Value
|
|
121
|
-
|
|
|
122
|
-
| `strong`
|
|
123
|
-
| `weak`
|
|
120
|
+
| Value | Description |
|
|
121
|
+
| -------- | ---------------------------------------------- |
|
|
122
|
+
| `strong` | Higher contrast and/or elevated emphasis |
|
|
123
|
+
| `weak` | Subtle variant for secondary or muted elements |
|
|
124
124
|
|
|
125
125
|
**State** represents the interactive state of the element, if specified. The default is an idle state.
|
|
126
126
|
|
|
@@ -196,6 +196,60 @@ The files generated in this step will all be committed to the repo.
|
|
|
196
196
|
|
|
197
197
|
After the prebuild step, the package will be built into its final form via the repo's standard package build script.
|
|
198
198
|
|
|
199
|
+
## Stylelint Plugins
|
|
200
|
+
|
|
201
|
+
This package provides Stylelint plugins to help enforce consistent usage of design tokens. To use them, add the plugins to your Stylelint configuration:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"plugins": [
|
|
206
|
+
"@wordpress/theme/stylelint-plugins/no-unknown-ds-tokens",
|
|
207
|
+
"@wordpress/theme/stylelint-plugins/no-setting-wpds-custom-properties"
|
|
208
|
+
],
|
|
209
|
+
"rules": {
|
|
210
|
+
"plugin-wpds/no-unknown-ds-tokens": true,
|
|
211
|
+
"plugin-wpds/no-setting-wpds-custom-properties": true
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `plugin-wpds/no-unknown-ds-tokens`
|
|
217
|
+
|
|
218
|
+
This rule reports an error when a CSS value references a `--wpds-*` custom property that is not a valid design token. This helps catch typos and ensures that only valid design tokens are used.
|
|
219
|
+
|
|
220
|
+
```css
|
|
221
|
+
/* ✗ Error: '--wpds-unknown-token' is not a valid Design System token */
|
|
222
|
+
.example {
|
|
223
|
+
color: var(--wpds-unknown-token);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* ✓ OK */
|
|
227
|
+
.example {
|
|
228
|
+
color: var(--wpds-color-fg-content-neutral);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### `plugin-wpds/no-setting-wpds-custom-properties`
|
|
233
|
+
|
|
234
|
+
This rule reports an error when a CSS declaration sets (defines) a custom property in the `--wpds-*` namespace. The design system tokens should only be consumed, not defined or overridden in consuming code.
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
/* ✗ Error: Do not set CSS custom properties using the Design System tokens namespace */
|
|
238
|
+
.example {
|
|
239
|
+
--wpds-my-token: red;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* ✗ Error: Overriding existing tokens is also not allowed */
|
|
243
|
+
.example {
|
|
244
|
+
--wpds-color-fg-content-neutral: red;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* ✓ OK */
|
|
248
|
+
.example {
|
|
249
|
+
--my-custom-token: red;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
199
253
|
## Contributing to this package
|
|
200
254
|
|
|
201
255
|
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
|
@@ -46,7 +46,7 @@ function getBgRampInfo(ramp) {
|
|
|
46
46
|
pinLightness: {
|
|
47
47
|
stepName: STEP_TO_PIN,
|
|
48
48
|
value: (0, import_utils.clampAccentScaleReferenceLightness)(
|
|
49
|
-
(0, import_fn.get)(
|
|
49
|
+
(0, import_fn.get)(ramp.ramp[STEP_TO_PIN], [import_fn.OKLCH, "l"]),
|
|
50
50
|
ramp.direction
|
|
51
51
|
)
|
|
52
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/color-ramps/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './lib/register-color-spaces';\nimport { buildRamp } from './lib/index';\nimport { clampAccentScaleReferenceLightness } from './lib/utils';\nimport { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';\nimport type {\n\tRampResult as InternalRampResult,\n\tRampDirection,\n\tRamp,\n} from './lib/types';\nimport { getContrast } from './lib/color-utils';\nimport { CONTRAST_COMBINATIONS } from './lib/constants';\nexport { DEFAULT_SEED_COLORS } from './lib/constants';\n\n/**\n * Creates a background ramp.\n * @param seed The seed color for the background ramp.\n */\nexport function buildBgRamp( seed: string ) {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\treturn buildRamp( seed, BG_RAMP_CONFIG );\n}\n\nconst STEP_TO_PIN = 'surface2';\nfunction getBgRampInfo( ramp: InternalRampResult ): {\n\tmainDirection: RampDirection;\n\tpinLightness: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} {\n\treturn {\n\t\tmainDirection: ramp.direction,\n\t\tpinLightness: {\n\t\t\tstepName: STEP_TO_PIN,\n\t\t\tvalue: clampAccentScaleReferenceLightness(\n\t\t\t\tget( ramp.ramp[ STEP_TO_PIN ], [ OKLCH, 'l' ] ),\n\t\t\t\tramp.direction\n\t\t\t),\n\t\t},\n\t};\n}\n\n/**\n * Creates an accent ramp (ie used by primary, success, info, warning and error\n * ramps).\n * @param seed The seed color for the accent ramp.\n * @param bgRamp The ramp of the background on which the accent is shown.\n */\nexport function buildAccentRamp(\n\tseed: string,\n\tbgRamp?: InternalRampResult\n): InternalRampResult {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\tconst bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;\n\treturn buildRamp( seed, ACCENT_RAMP_CONFIG, bgRampInfo );\n}\n\n/**\n * Checks that all bg/fg combinations generated by the ramps meet contrast\n * targets.\n * @param params\n * @param params.bgRamp\n * @param params.accentRamps\n */\nexport function checkAccessibleCombinations( {\n\tbgRamp,\n\taccentRamps = [],\n}: {\n\tbgRamp: InternalRampResult;\n\taccentRamps?: InternalRampResult[];\n} ) {\n\tconst unmetTargets: {\n\t\tbgName: keyof Ramp;\n\t\tbgColor: string;\n\t\tfgName: keyof Ramp;\n\t\tfgColor: string;\n\t\tunmetContrast: number;\n\t\tachievedContrast: number;\n\t}[] = [];\n\n\t// Assess combinations within each ramp\n\t[ bgRamp, ...accentRamps ].forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = ramp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\t// Assess each accent ramp's fg color against bg ramp\n\taccentRamps.forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = bgRamp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\n\treturn unmetTargets;\n}\n\nexport type RampResult = InternalRampResult;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAA2B;AAK3B,mCAAO;AACP,iBAA0B;AAC1B,mBAAmD;AACnD,0BAAmD;AAMnD,yBAA4B;AAC5B,uBAAsC;AACtC,IAAAA,oBAAoC;AAM7B,SAAS,YAAa,MAAe;AAC3C,MAAK,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,IAAK;AACrD,UAAM,IAAI,MAAO,uCAAwC;AAAA,EAC1D;AAEA,aAAO,sBAAW,MAAM,kCAAe;AACxC;AAEA,IAAM,cAAc;AACpB,SAAS,cAAe,MAMtB;AACD,SAAO;AAAA,IACN,eAAe,KAAK;AAAA,IACpB,cAAc;AAAA,MACb,UAAU;AAAA,MACV,WAAO;AAAA,YACN,eAAK,KAAK,KAAM,WAAY,GAAG,CAAE,iBAAO,GAAI,CAAE;AAAA,QAC9C,KAAK;AAAA,MACN;AAAA,IACD;AAAA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;AAAA,QACD;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,SAAO;AACR;",
|
|
6
6
|
"names": ["import_constants"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,8 @@ module.exports = __toCommonJS(color_utils_exports);
|
|
|
27
27
|
var import_fn = require("colorjs.io/fn");
|
|
28
28
|
var import_register_color_spaces = require("./register-color-spaces.cjs");
|
|
29
29
|
function getColorString(color) {
|
|
30
|
-
|
|
30
|
+
const rgbRounded = (0, import_fn.serialize)((0, import_fn.to)(color, import_fn.sRGB));
|
|
31
|
+
return (0, import_fn.serialize)(rgbRounded, { format: "hex" });
|
|
31
32
|
}
|
|
32
33
|
function getContrast(colorA, colorB) {
|
|
33
34
|
return (0, import_fn.contrastWCAG21)(colorA, colorB);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/color-utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tto,\n\ttoGamut,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\tOKLCH,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAQO;AAKP,mCAAO;AAOA,SAAS,eAAgB,OAA4B;AAC3D,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tto,\n\ttoGamut,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\tOKLCH,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\tconst rgbRounded = serialize( to( color, sRGB ) );\n\treturn serialize( rgbRounded, { format: 'hex' } );\n}\n\n/**\n * Get contrast value between two colors\n * @param colorA First color\n * @param colorB Second color\n * @return WCAG 2.1 contrast ratio\n */\nexport function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {\n\treturn contrastWCAG21( colorA, colorB );\n}\n\n/**\n * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.\n * @param c\n */\nexport function clampToGamut( c: ColorTypes ) {\n\t// map into sRGB using CSS OKLCH method\n\treturn to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAQO;AAKP,mCAAO;AAOA,SAAS,eAAgB,OAA4B;AAC3D,QAAM,iBAAa,yBAAW,cAAI,OAAO,cAAK,CAAE;AAChD,aAAO,qBAAW,YAAY,EAAE,QAAQ,MAAM,CAAE;AACjD;AAQO,SAAS,YAAa,QAAoB,QAA6B;AAC7E,aAAO,0BAAgB,QAAQ,MAAO;AACvC;AAMO,SAAS,aAAc,GAAgB;AAE7C,aAAO,kBAAI,mBAAS,GAAG,EAAE,OAAO,gBAAM,QAAQ,MAAM,CAAE,GAAG,eAAM;AAChE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/default-ramps.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampResult } from './types';\nimport type { DEFAULT_SEED_COLORS } from './constants';\n\nexport const DEFAULT_RAMPS: Record<\n\tkeyof typeof DEFAULT_SEED_COLORS,\n\tRampResult\n> = {\n\tbg: {\n\t\tramp: {\n\t\t\tsurface2: '#f8f8f8',\n\t\t\tbgFill1: '#555',\n\t\t\tfgFill: '#f0f0f0',\n\t\t\tbgFill2: '#484848',\n\t\t\tsurface6: '#d2d2d2',\n\t\t\tsurface5: '#e2e2e2',\n\t\t\tsurface4: '#eaeaea',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#1e1e1e',\n\t\t\tfgSurface3: '#6d6d6d',\n\t\t\tfgSurface2: '#8a8a8a',\n\t\t\tfgSurface1: '#aaa',\n\t\t\tstroke3: '#8a8a8a',\n\t\t\tstroke4: '#6c6c6c',\n\t\t\tstroke2: '#d8d8d8',\n\t\t\tstroke1: '#e0e0e0',\n\t\t\tbgFillDark: '#1e1e1e',\n\t\t\tfgFillDark: '#f0f0f0',\n\t\t\tbgFillInverted2: '#1e1e1e',\n\t\t\tbgFillInverted1: '#2d2d2d',\n\t\t\tfgFillInverted: '#f0f0f0',\n\t\t\tsurface1: '#f0f0f0',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tprimary: {\n\t\tramp: {\n\t\t\tbgFill1: '#3858e9',\n\t\t\tfgFill: '#eff0f2',\n\t\t\tbgFill2: '#2e49d9',\n\t\t\tsurface2: '#f6f8fd',\n\t\t\tsurface6: '#c7d2ed',\n\t\t\tsurface5: '#dbe2f4',\n\t\t\tsurface4: '#e6eaf4',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#0b0070',\n\t\t\tfgSurface3: '#3858e9',\n\t\t\tfgSurface2: '#5b82ff',\n\t\t\tfgSurface1: '#85a9ff',\n\t\t\tstroke3: '#3858e9',\n\t\t\tstroke4: '#2337c8',\n\t\t\tstroke2: '#9caacc',\n\t\t\tstroke1: '#a3b1d4',\n\t\t\tbgFillDark: '#1a1e27',\n\t\t\tfgFillDark: '#eff0f2',\n\t\t\tbgFillInverted2: '#1a1e27',\n\t\t\tbgFillInverted1: '#13009f',\n\t\t\tfgFillInverted: '#eff0f2',\n\t\t\tsurface1: '#ecf0f9',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tinfo: {\n\t\tramp: {\n\t\t\tbgFill1: '#0090ff',\n\t\t\tfgFill: '#1a1f24',\n\t\t\tbgFill2: '#007fed',\n\t\t\tsurface2: '#
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampResult } from './types';\nimport type { DEFAULT_SEED_COLORS } from './constants';\n\nexport const DEFAULT_RAMPS: Record<\n\tkeyof typeof DEFAULT_SEED_COLORS,\n\tRampResult\n> = {\n\tbg: {\n\t\tramp: {\n\t\t\tsurface2: '#f8f8f8',\n\t\t\tbgFill1: '#555',\n\t\t\tfgFill: '#f0f0f0',\n\t\t\tbgFill2: '#484848',\n\t\t\tsurface6: '#d2d2d2',\n\t\t\tsurface5: '#e2e2e2',\n\t\t\tsurface4: '#eaeaea',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#1e1e1e',\n\t\t\tfgSurface3: '#6d6d6d',\n\t\t\tfgSurface2: '#8a8a8a',\n\t\t\tfgSurface1: '#aaa',\n\t\t\tstroke3: '#8a8a8a',\n\t\t\tstroke4: '#6c6c6c',\n\t\t\tstroke2: '#d8d8d8',\n\t\t\tstroke1: '#e0e0e0',\n\t\t\tbgFillDark: '#1e1e1e',\n\t\t\tfgFillDark: '#f0f0f0',\n\t\t\tbgFillInverted2: '#1e1e1e',\n\t\t\tbgFillInverted1: '#2d2d2d',\n\t\t\tfgFillInverted: '#f0f0f0',\n\t\t\tsurface1: '#f0f0f0',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tprimary: {\n\t\tramp: {\n\t\t\tbgFill1: '#3858e9',\n\t\t\tfgFill: '#eff0f2',\n\t\t\tbgFill2: '#2e49d9',\n\t\t\tsurface2: '#f6f8fd',\n\t\t\tsurface6: '#c7d2ed',\n\t\t\tsurface5: '#dbe2f4',\n\t\t\tsurface4: '#e6eaf4',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#0b0070',\n\t\t\tfgSurface3: '#3858e9',\n\t\t\tfgSurface2: '#5b82ff',\n\t\t\tfgSurface1: '#85a9ff',\n\t\t\tstroke3: '#3858e9',\n\t\t\tstroke4: '#2337c8',\n\t\t\tstroke2: '#9caacc',\n\t\t\tstroke1: '#a3b1d4',\n\t\t\tbgFillDark: '#1a1e27',\n\t\t\tfgFillDark: '#eff0f2',\n\t\t\tbgFillInverted2: '#1a1e27',\n\t\t\tbgFillInverted1: '#13009f',\n\t\t\tfgFillInverted: '#eff0f2',\n\t\t\tsurface1: '#ecf0f9',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tinfo: {\n\t\tramp: {\n\t\t\tbgFill1: '#0090ff',\n\t\t\tfgFill: '#1a1f24',\n\t\t\tbgFill2: '#007fed',\n\t\t\tsurface2: '#f2f9ff',\n\t\t\tsurface6: '#bcd5f2',\n\t\t\tsurface5: '#d3e4f7',\n\t\t\tsurface4: '#deebfa',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#001b4f',\n\t\t\tfgSurface3: '#006bd7',\n\t\t\tfgSurface2: '#008bfa',\n\t\t\tfgSurface1: '#58b0ff',\n\t\t\tstroke3: '#006bd7',\n\t\t\tstroke4: '#004fa9',\n\t\t\tstroke2: '#95b5d9',\n\t\t\tstroke1: '#9fbcdc',\n\t\t\tbgFillDark: '#1a1f24',\n\t\t\tfgFillDark: '#eef0f3',\n\t\t\tbgFillInverted2: '#1a1f24',\n\t\t\tbgFillInverted1: '#002a69',\n\t\t\tfgFillInverted: '#eef0f3',\n\t\t\tsurface1: '#e4f1ff',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tsuccess: {\n\t\tramp: {\n\t\t\tbgFill1: '#4ab866',\n\t\t\tfgFill: '#1b1f1c',\n\t\t\tbgFill2: '#37a756',\n\t\t\tsurface2: '#eaffed',\n\t\t\tsurface6: '#88e89b',\n\t\t\tsurface5: '#aff3bb',\n\t\t\tsurface4: '#c5f7cc',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#002900',\n\t\t\tfgSurface3: '#007f30',\n\t\t\tfgSurface2: '#2b9e4e',\n\t\t\tfgSurface1: '#53c16e',\n\t\t\tstroke3: '#007f30',\n\t\t\tstroke4: '#006013',\n\t\t\tstroke2: '#84c08e',\n\t\t\tstroke1: '#8ac894',\n\t\t\tbgFillDark: '#1b1f1c',\n\t\t\tfgFillDark: '#eaf3eb',\n\t\t\tbgFillInverted2: '#1b1f1c',\n\t\t\tbgFillInverted1: '#003701',\n\t\t\tfgFillInverted: '#eaf3eb',\n\t\t\tsurface1: '#cbfdd2',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tcaution: {\n\t\tramp: {\n\t\t\tbgFill1: '#f0d149',\n\t\t\tfgFill: '#1f1e1b',\n\t\t\tbgFill2: '#dcbe2f',\n\t\t\tsurface2: '#fff9c9',\n\t\t\tsurface6: '#e8d172',\n\t\t\tsurface5: '#f7e18a',\n\t\t\tsurface4: '#fee994',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#281d00',\n\t\t\tfgSurface3: '#826a00',\n\t\t\tfgSurface2: '#a48600',\n\t\t\tfgSurface1: '#c6a800',\n\t\t\tstroke3: '#826a00',\n\t\t\tstroke4: '#624f00',\n\t\t\tstroke2: '#bdb17e',\n\t\t\tstroke1: '#c5b883',\n\t\t\tbgFillDark: '#1f1e1b',\n\t\t\tfgFillDark: '#fdf1bf',\n\t\t\tbgFillInverted2: '#1f1e1b',\n\t\t\tbgFillInverted1: '#392c00',\n\t\t\tfgFillInverted: '#fdf1bf',\n\t\t\tsurface1: '#ffef9b',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\twarning: {\n\t\tramp: {\n\t\t\tbgFill1: '#f0b849',\n\t\t\tfgFill: '#1f1e1b',\n\t\t\tbgFill2: '#dda633',\n\t\t\tsurface2: '#fff7e0',\n\t\t\tsurface6: '#f4cc84',\n\t\t\tsurface5: '#faddac',\n\t\t\tsurface4: '#fde6bd',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#2e1900',\n\t\t\tfgSurface3: '#926300',\n\t\t\tfgSurface2: '#b47f00',\n\t\t\tfgSurface1: '#d7a02a',\n\t\t\tstroke3: '#926300',\n\t\t\tstroke4: '#6f4900',\n\t\t\tstroke2: '#c7ad7e',\n\t\t\tstroke1: '#d0b381',\n\t\t\tbgFillDark: '#1f1e1b',\n\t\t\tfgFillDark: '#f7efe2',\n\t\t\tbgFillInverted2: '#1f1e1b',\n\t\t\tbgFillInverted1: '#422800',\n\t\t\tfgFillInverted: '#f7efe2',\n\t\t\tsurface1: '#ffecc4',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\terror: {\n\t\tramp: {\n\t\t\tbgFill1: '#cc1818',\n\t\t\tfgFill: '#f2efef',\n\t\t\tbgFill2: '#b90000',\n\t\t\tsurface2: '#fff6f4',\n\t\t\tsurface6: '#f3c8c2',\n\t\t\tsurface5: '#f8dcd7',\n\t\t\tsurface4: '#f6e6e3',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#470000',\n\t\t\tfgSurface3: '#cc1818',\n\t\t\tfgSurface2: '#f74c40',\n\t\t\tfgSurface1: '#ff8879',\n\t\t\tstroke3: '#cc1818',\n\t\t\tstroke4: '#9d0000',\n\t\t\tstroke2: '#d39c95',\n\t\t\tstroke1: '#daa39b',\n\t\t\tbgFillDark: '#231c1b',\n\t\t\tfgFillDark: '#f2efef',\n\t\t\tbgFillInverted2: '#231c1b',\n\t\t\tbgFillInverted1: '#640000',\n\t\t\tfgFillInverted: '#f2efef',\n\t\t\tsurface1: '#fcece9',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,gBAGT;AAAA,EACH,IAAI;AAAA,IACH,MAAM;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAA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AAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACN,MAAM;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -143,7 +143,7 @@ function buildRamp(seedArg, config, {
|
|
|
143
143
|
} = {}) {
|
|
144
144
|
let seed;
|
|
145
145
|
try {
|
|
146
|
-
seed = (0, import_color_utils.clampToGamut)(
|
|
146
|
+
seed = (0, import_color_utils.clampToGamut)(seedArg);
|
|
147
147
|
} catch (error) {
|
|
148
148
|
throw new Error(
|
|
149
149
|
`Invalid seed color "${seedArg}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -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 {\n\tclone,\n\tget,\n\tOKLCH,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tclone,\n\tget,\n\tOKLCH,\n\tset,\n\ttype ColorTypes,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { clampToGamut, getContrast, getColorString } from './color-utils';\nimport { findColorMeetingRequirements } from './find-color-with-constraints';\nimport {\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: PlainColorObject;\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< keyof Ramp, string >;\n\tlet warnings: string[] | undefined;\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', PlainColorObject >();\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 ] = getColorString( candidateColor );\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 ] = getColorString( searchResults.color );\n\n\t\tif ( ! searchResults.reached && ! contrast.ignoreWhenAdjustingSeed ) {\n\t\t\twarnings ??= [];\n\t\t\twarnings.push( stepName );\n\t\t}\n\t}\n\n\treturn {\n\t\trampResults,\n\t\twarnings,\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( 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\twarnings,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t} = calculateRamp( {\n\t\tseed,\n\t\tsortedSteps,\n\t\tconfig,\n\t\tmainDir,\n\t\toppDir,\n\t\tpinLightness,\n\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 ): PlainColorObject {\n\t\t\treturn clampToGamut( set( clone( seed ), [ OKLCH, 'l' ], l ) );\n\t\t}\n\n\t\tfunction getDeficitForSeed( s: PlainColorObject ): 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\twarnings,\n\t\tdirection: mainDir,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,WAAW;AAAA,EACrB;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": ["adjustedTarget"]
|
|
7
7
|
}
|
|
@@ -35,9 +35,9 @@ function taperChroma(seed, lTarget, options = {}) {
|
|
|
35
35
|
const kDark = options.kDark ?? 0.85;
|
|
36
36
|
const achromaEpsilon = options.achromaEpsilon ?? 5e-3;
|
|
37
37
|
const cSeed = Math.max(0, (0, import_fn.get)(seed, [import_fn.OKLCH, "c"]));
|
|
38
|
-
let hSeed =
|
|
38
|
+
let hSeed = (0, import_fn.get)(seed, [import_fn.OKLCH, "h"]);
|
|
39
39
|
const chromaIsTiny = cSeed < achromaEpsilon;
|
|
40
|
-
const hueIsInvalid = !Number.isFinite(hSeed);
|
|
40
|
+
const hueIsInvalid = hSeed === null || !Number.isFinite(hSeed);
|
|
41
41
|
if (chromaIsTiny || hueIsInvalid) {
|
|
42
42
|
if (typeof options.hueFallback === "number") {
|
|
43
43
|
hSeed = normalizeHue(options.hueFallback);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/taper-chroma.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tget,\n\ttoGamut,\n\tOKLCH,\n\tsRGB,\n\ttype PlainColorObject,\n\ttype ColorSpace,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\nexport interface TaperChromaOptions {\n\tgamut?: ColorSpace; // target gamut (default `sRGB`)\n\talpha?: number; // base fraction of Cmax at target (default 0.62)\n\tcarry?: number; // seed vividness carry exponent \u03B2 in [0..1] (default 0.5)\n\tcUpperBound?: number; // hard search cap for C (default 0.45)\n\t// Continuous taper around the seed (desaturate both sides slightly)\n\tradiusLight?: number; // distance in L where kLight is reached (default 0.20)\n\tradiusDark?: number; // distance in L where kDark is reached (default 0.20)\n\tkLight?: number; // floor multiplier near lighter side (default 0.85)\n\tkDark?: number; // floor multiplier near darker side (default 0.85)\n\t// Achromatic handling\n\thueFallback?: number; // degrees: if seed is achromatic and you still want color\n\tachromaEpsilon?: number; // \u2264 this chroma \u2192 treat as achromatic (default 0.005)\n}\n\n/**\n * Given the seed and the target lightness, tapers the chroma smoothly.\n * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)\n * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors\n * - Downward-only clamp on C (preserve L & H)\n * @param seed\n * @param lTarget\n * @param options\n */\nexport function taperChroma(\n\tseed: PlainColorObject, // already OKLCH\n\tlTarget: number, // [0..1]\n\toptions: TaperChromaOptions = {}\n): { l: number; c: number } | PlainColorObject {\n\tconst gamut = options.gamut ?? sRGB;\n\tconst alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface\n\tconst carry = options.carry ?? 0.5;\n\tconst cUpperBound = options.cUpperBound ?? 0.45;\n\tconst radiusLight = options.radiusLight ?? 0.2;\n\tconst radiusDark = options.radiusDark ?? 0.2;\n\tconst kLight = options.kLight ?? 0.85;\n\tconst kDark = options.kDark ?? 0.85;\n\tconst achromaEpsilon = options.achromaEpsilon ?? 0.005;\n\n\tconst cSeed = Math.max( 0, get( seed, [ OKLCH, 'c' ] ) );\n\tlet hSeed =
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAOO;AAKP,mCAAO;AA0BA,SAAS,YACf,MACA,SACA,UAA8B,CAAC,GACe;AAC9C,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,iBAAiB,QAAQ,kBAAkB;AAEjD,QAAM,QAAQ,KAAK,IAAK,OAAG,eAAK,MAAM,CAAE,iBAAO,GAAI,CAAE,CAAE;AACvD,MAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tget,\n\ttoGamut,\n\tOKLCH,\n\tsRGB,\n\ttype PlainColorObject,\n\ttype ColorSpace,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\nexport interface TaperChromaOptions {\n\tgamut?: ColorSpace; // target gamut (default `sRGB`)\n\talpha?: number; // base fraction of Cmax at target (default 0.62)\n\tcarry?: number; // seed vividness carry exponent \u03B2 in [0..1] (default 0.5)\n\tcUpperBound?: number; // hard search cap for C (default 0.45)\n\t// Continuous taper around the seed (desaturate both sides slightly)\n\tradiusLight?: number; // distance in L where kLight is reached (default 0.20)\n\tradiusDark?: number; // distance in L where kDark is reached (default 0.20)\n\tkLight?: number; // floor multiplier near lighter side (default 0.85)\n\tkDark?: number; // floor multiplier near darker side (default 0.85)\n\t// Achromatic handling\n\thueFallback?: number; // degrees: if seed is achromatic and you still want color\n\tachromaEpsilon?: number; // \u2264 this chroma \u2192 treat as achromatic (default 0.005)\n}\n\n/**\n * Given the seed and the target lightness, tapers the chroma smoothly.\n * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)\n * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors\n * - Downward-only clamp on C (preserve L & H)\n * @param seed\n * @param lTarget\n * @param options\n */\nexport function taperChroma(\n\tseed: PlainColorObject, // already OKLCH\n\tlTarget: number, // [0..1]\n\toptions: TaperChromaOptions = {}\n): { l: number; c: number } | PlainColorObject {\n\tconst gamut = options.gamut ?? sRGB;\n\tconst alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface\n\tconst carry = options.carry ?? 0.5;\n\tconst cUpperBound = options.cUpperBound ?? 0.45;\n\tconst radiusLight = options.radiusLight ?? 0.2;\n\tconst radiusDark = options.radiusDark ?? 0.2;\n\tconst kLight = options.kLight ?? 0.85;\n\tconst kDark = options.kDark ?? 0.85;\n\tconst achromaEpsilon = options.achromaEpsilon ?? 0.005;\n\n\tconst cSeed = Math.max( 0, get( seed, [ OKLCH, 'c' ] ) );\n\tlet hSeed = get( seed, [ OKLCH, 'h' ] );\n\n\tconst chromaIsTiny = cSeed < achromaEpsilon;\n\tconst hueIsInvalid = hSeed === null || ! Number.isFinite( hSeed );\n\n\tif ( chromaIsTiny || hueIsInvalid ) {\n\t\tif ( typeof options.hueFallback === 'number' ) {\n\t\t\thSeed = normalizeHue( options.hueFallback );\n\t\t} else {\n\t\t\t// Respect achromatic intent: grayscale at target L\n\t\t\treturn {\n\t\t\t\tspace: OKLCH,\n\t\t\t\tcoords: [ clamp01( lTarget ), 0, 0 ],\n\t\t\t\talpha: 1,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Capacity at seed and target\n\tconst lSeed = clamp01( get( seed, [ OKLCH, 'l' ] ) );\n\tconst cmaxSeed = getCachedMaxChromaAtLH( lSeed, hSeed, gamut, cUpperBound );\n\tconst cmaxTarget = getCachedMaxChromaAtLH(\n\t\tclamp01( lTarget ),\n\t\thSeed,\n\t\tgamut,\n\t\tcUpperBound\n\t);\n\n\t// Seed vividness ratio (hue-fair normalization)\n\tlet seedRelative = 0;\n\tconst denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;\n\tseedRelative = clamp01( cSeed / denom );\n\n\t// Intended chroma from local capacity, tempered by seed vividness\n\tconst cIntendedBase = alpha * cmaxTarget;\n\tconst cWithCarry =\n\t\tcIntendedBase * Math.pow( seedRelative, clamp01( carry ) );\n\n\t// Gentle, symmetric desaturation vs distance in L\n\tconst t = continuousTaper( lSeed, lTarget, {\n\t\tradiusLight,\n\t\tradiusDark,\n\t\tkLight,\n\t\tkDark,\n\t} );\n\tconst cPlanned = cWithCarry * t;\n\n\t// Downward-only clamp (preserve L & H)\n\tconst lOut = clamp01( lTarget );\n\n\treturn { l: lOut, c: cPlanned };\n}\n\n/* ---------------- helpers & caches ---------------- */\n\nfunction clamp01( x: number ): number {\n\tif ( x < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( x > 1 ) {\n\t\treturn 1;\n\t}\n\treturn x;\n}\nfunction normalizeHue( h: number ): number {\n\tlet hue = h % 360;\n\tif ( hue < 0 ) {\n\t\thue += 360;\n\t}\n\treturn hue;\n}\nfunction raisedCosine( u: number ): number {\n\tconst x = clamp01( u );\n\treturn 0.5 - 0.5 * Math.cos( Math.PI * x );\n}\n\n/**\n * smooth, distance-from-seed chroma taper (raised-cosine per side)\n * @param seedL\n * @param targetL\n * @param opts\n * @param opts.radiusLight\n * @param opts.radiusDark\n * @param opts.kLight\n * @param opts.kDark\n */\nfunction continuousTaper(\n\tseedL: number,\n\ttargetL: number,\n\topts: {\n\t\tradiusLight: number;\n\t\tradiusDark: number;\n\t\tkLight: number;\n\t\tkDark: number;\n\t}\n): number {\n\tconst d = targetL - seedL;\n\tif ( d >= 0 ) {\n\t\tconst u = opts.radiusLight > 0 ? Math.abs( d ) / opts.radiusLight : 1;\n\t\tconst w = raisedCosine( u > 1 ? 1 : u );\n\t\treturn 1 - ( 1 - opts.kLight ) * w;\n\t}\n\tconst u = opts.radiusDark > 0 ? Math.abs( d ) / opts.radiusDark : 1;\n\tconst w = raisedCosine( u > 1 ? 1 : u );\n\treturn 1 - ( 1 - opts.kDark ) * w;\n}\n\n/* ---- chroma-capacity queries with small caches ---- */\n\nconst maxChromaCache = new Map< string, number >();\nfunction keyMax( l: number, h: number, gamut: string, cap: number ): string {\n\t// Quantize to keep cache compact\n\tconst lq = quantize( l, 0.05 );\n\tconst hq = quantize( normalizeHue( h ), 10 );\n\tconst cq = quantize( cap, 0.05 );\n\treturn `${ gamut }|L:${ lq }|H:${ hq }|cap:${ cq }`;\n}\n\nfunction quantize( x: number, step: number ): number {\n\tconst k = Math.round( x / step );\n\treturn k * step;\n}\n\nfunction getCachedMaxChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\tconst gamut = gamutSpace.id;\n\tconst key = keyMax( l, h, gamut, cap );\n\tconst hit = maxChromaCache.get( key );\n\tif ( typeof hit === 'number' ) {\n\t\treturn hit;\n\t}\n\n\tconst computed = maxInGamutChromaAtLH( l, h, gamutSpace, cap );\n\tmaxChromaCache.set( key, computed );\n\treturn computed;\n}\n\n/**\n * Find the max in-gamut chroma at fixed (L,H) in the target gamut\n * @param l\n * @param h\n * @param gamutSpace\n * @param cap\n */\nfunction maxInGamutChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\t// Construct a color with maximum chroma.\n\tconst probe: PlainColorObject = {\n\t\tspace: OKLCH,\n\t\tcoords: [ l, cap, h ],\n\t\talpha: 1,\n\t};\n\n\t// Let `toGamut` reduce the chroma to the gamut maximum.\n\tconst clamped = toGamut( probe, { space: gamutSpace, method: 'css' } );\n\n\treturn get( clamped, [ OKLCH, 'c' ] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAOO;AAKP,mCAAO;AA0BA,SAAS,YACf,MACA,SACA,UAA8B,CAAC,GACe;AAC9C,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,iBAAiB,QAAQ,kBAAkB;AAEjD,QAAM,QAAQ,KAAK,IAAK,OAAG,eAAK,MAAM,CAAE,iBAAO,GAAI,CAAE,CAAE;AACvD,MAAI,YAAQ,eAAK,MAAM,CA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AC/B,OAAO;AAAA,IACP,QAAQ,CAAE,GAAG,KAAK,CAAE;AAAA,IACpB,OAAO;AAAA,EACR;AAGA,QAAM,cAAU,mBAAS,OAAO,EAAE,OAAO,YAAY,QAAQ,MAAM,CAAE;AAErE,aAAO,eAAK,SAAS,CAAE,iBAAO,GAAI,CAAE;AACrC;",
|
|
6
6
|
"names": ["u", "w"]
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/theme/src/prebuilt/js/design-tokens.
|
|
19
|
+
// packages/theme/src/prebuilt/js/design-tokens.mjs
|
|
20
20
|
var design_tokens_exports = {};
|
|
21
21
|
__export(design_tokens_exports, {
|
|
22
22
|
default: () => design_tokens_default
|
|
@@ -46,40 +46,29 @@ var design_tokens_default = [
|
|
|
46
46
|
"--wpds-color-bg-surface-caution-weak",
|
|
47
47
|
"--wpds-color-bg-surface-error",
|
|
48
48
|
"--wpds-color-bg-surface-error-weak",
|
|
49
|
-
"--wpds-color-bg-interactive-neutral",
|
|
50
|
-
"--wpds-color-bg-interactive-neutral-active",
|
|
51
|
-
"--wpds-color-bg-interactive-neutral-disabled",
|
|
52
49
|
"--wpds-color-bg-interactive-neutral-strong",
|
|
53
50
|
"--wpds-color-bg-interactive-neutral-strong-active",
|
|
54
51
|
"--wpds-color-bg-interactive-neutral-strong-disabled",
|
|
55
52
|
"--wpds-color-bg-interactive-neutral-weak",
|
|
56
53
|
"--wpds-color-bg-interactive-neutral-weak-active",
|
|
57
54
|
"--wpds-color-bg-interactive-neutral-weak-disabled",
|
|
58
|
-
"--wpds-color-bg-interactive-brand",
|
|
59
|
-
"--wpds-color-bg-interactive-brand-active",
|
|
60
|
-
"--wpds-color-bg-interactive-brand-disabled",
|
|
61
55
|
"--wpds-color-bg-interactive-brand-strong",
|
|
62
56
|
"--wpds-color-bg-interactive-brand-strong-active",
|
|
63
|
-
"--wpds-color-bg-interactive-brand-strong-disabled",
|
|
64
57
|
"--wpds-color-bg-interactive-brand-weak",
|
|
65
58
|
"--wpds-color-bg-interactive-brand-weak-active",
|
|
66
|
-
"--wpds-color-bg-interactive-brand-weak-disabled",
|
|
67
59
|
"--wpds-color-bg-interactive-error",
|
|
68
60
|
"--wpds-color-bg-interactive-error-active",
|
|
69
|
-
"--wpds-color-bg-interactive-error-disabled",
|
|
70
61
|
"--wpds-color-bg-interactive-error-strong",
|
|
71
62
|
"--wpds-color-bg-interactive-error-strong-active",
|
|
72
|
-
"--wpds-color-bg-interactive-error-strong-disabled",
|
|
73
63
|
"--wpds-color-bg-interactive-error-weak",
|
|
74
64
|
"--wpds-color-bg-interactive-error-weak-active",
|
|
75
|
-
"--wpds-color-bg-interactive-error-weak-disabled",
|
|
76
65
|
"--wpds-color-bg-track-neutral-weak",
|
|
77
66
|
"--wpds-color-bg-track-neutral",
|
|
78
67
|
"--wpds-color-bg-thumb-neutral-weak",
|
|
79
68
|
"--wpds-color-bg-thumb-neutral-weak-active",
|
|
80
69
|
"--wpds-color-bg-thumb-brand",
|
|
81
70
|
"--wpds-color-bg-thumb-brand-active",
|
|
82
|
-
"--wpds-color-bg-thumb-
|
|
71
|
+
"--wpds-color-bg-thumb-neutral-disabled",
|
|
83
72
|
"--wpds-color-fg-content-neutral",
|
|
84
73
|
"--wpds-color-fg-content-neutral-weak",
|
|
85
74
|
"--wpds-color-fg-content-success",
|
|
@@ -102,16 +91,12 @@ var design_tokens_default = [
|
|
|
102
91
|
"--wpds-color-fg-interactive-neutral-weak-disabled",
|
|
103
92
|
"--wpds-color-fg-interactive-brand",
|
|
104
93
|
"--wpds-color-fg-interactive-brand-active",
|
|
105
|
-
"--wpds-color-fg-interactive-brand-disabled",
|
|
106
94
|
"--wpds-color-fg-interactive-brand-strong",
|
|
107
95
|
"--wpds-color-fg-interactive-brand-strong-active",
|
|
108
|
-
"--wpds-color-fg-interactive-brand-strong-disabled",
|
|
109
96
|
"--wpds-color-fg-interactive-error",
|
|
110
97
|
"--wpds-color-fg-interactive-error-active",
|
|
111
|
-
"--wpds-color-fg-interactive-error-disabled",
|
|
112
98
|
"--wpds-color-fg-interactive-error-strong",
|
|
113
99
|
"--wpds-color-fg-interactive-error-strong-active",
|
|
114
|
-
"--wpds-color-fg-interactive-error-strong-disabled",
|
|
115
100
|
"--wpds-color-stroke-surface-neutral",
|
|
116
101
|
"--wpds-color-stroke-surface-neutral-weak",
|
|
117
102
|
"--wpds-color-stroke-surface-neutral-strong",
|
|
@@ -154,17 +139,19 @@ var design_tokens_default = [
|
|
|
154
139
|
"--wpds-font-family-heading",
|
|
155
140
|
"--wpds-font-family-body",
|
|
156
141
|
"--wpds-font-family-mono",
|
|
157
|
-
"--wpds-font-size-
|
|
158
|
-
"--wpds-font-size-
|
|
159
|
-
"--wpds-font-size-
|
|
160
|
-
"--wpds-font-size-
|
|
161
|
-
"--wpds-font-size-
|
|
162
|
-
"--wpds-font-size-
|
|
163
|
-
"--wpds-font-line-height-
|
|
164
|
-
"--wpds-font-line-height-
|
|
165
|
-
"--wpds-font-line-height-
|
|
166
|
-
"--wpds-font-line-height-
|
|
167
|
-
"--wpds-font-line-height-
|
|
168
|
-
"--wpds-font-line-height-
|
|
142
|
+
"--wpds-font-size-xs",
|
|
143
|
+
"--wpds-font-size-sm",
|
|
144
|
+
"--wpds-font-size-md",
|
|
145
|
+
"--wpds-font-size-lg",
|
|
146
|
+
"--wpds-font-size-xl",
|
|
147
|
+
"--wpds-font-size-2xl",
|
|
148
|
+
"--wpds-font-line-height-xs",
|
|
149
|
+
"--wpds-font-line-height-sm",
|
|
150
|
+
"--wpds-font-line-height-md",
|
|
151
|
+
"--wpds-font-line-height-lg",
|
|
152
|
+
"--wpds-font-line-height-xl",
|
|
153
|
+
"--wpds-font-line-height-2xl",
|
|
154
|
+
"--wpds-font-weight-regular",
|
|
155
|
+
"--wpds-font-weight-medium"
|
|
169
156
|
];
|
|
170
157
|
//# sourceMappingURL=design-tokens.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/prebuilt/js/design-tokens.
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAO,wBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;
|
|
3
|
+
"sources": ["../../../src/prebuilt/js/design-tokens.mjs"],
|
|
4
|
+
"sourcesContent": ["/*\n * This file is generated by the @wordpress/terrazzo-plugin-known-wpds-css-variables plugin.\n * Do not edit this file directly.\n */\n\nexport default [\n\t'--wpds-border-radius-surface-xs',\n\t'--wpds-border-radius-surface-sm',\n\t'--wpds-border-radius-surface-md',\n\t'--wpds-border-radius-surface-lg',\n\t'--wpds-border-width-surface-xs',\n\t'--wpds-border-width-surface-sm',\n\t'--wpds-border-width-surface-md',\n\t'--wpds-border-width-surface-lg',\n\t'--wpds-border-width-interactive-focus',\n\t'--wpds-color-bg-surface-neutral',\n\t'--wpds-color-bg-surface-neutral-strong',\n\t'--wpds-color-bg-surface-neutral-weak',\n\t'--wpds-color-bg-surface-brand',\n\t'--wpds-color-bg-surface-success',\n\t'--wpds-color-bg-surface-success-weak',\n\t'--wpds-color-bg-surface-info',\n\t'--wpds-color-bg-surface-info-weak',\n\t'--wpds-color-bg-surface-warning',\n\t'--wpds-color-bg-surface-warning-weak',\n\t'--wpds-color-bg-surface-caution',\n\t'--wpds-color-bg-surface-caution-weak',\n\t'--wpds-color-bg-surface-error',\n\t'--wpds-color-bg-surface-error-weak',\n\t'--wpds-color-bg-interactive-neutral-strong',\n\t'--wpds-color-bg-interactive-neutral-strong-active',\n\t'--wpds-color-bg-interactive-neutral-strong-disabled',\n\t'--wpds-color-bg-interactive-neutral-weak',\n\t'--wpds-color-bg-interactive-neutral-weak-active',\n\t'--wpds-color-bg-interactive-neutral-weak-disabled',\n\t'--wpds-color-bg-interactive-brand-strong',\n\t'--wpds-color-bg-interactive-brand-strong-active',\n\t'--wpds-color-bg-interactive-brand-weak',\n\t'--wpds-color-bg-interactive-brand-weak-active',\n\t'--wpds-color-bg-interactive-error',\n\t'--wpds-color-bg-interactive-error-active',\n\t'--wpds-color-bg-interactive-error-strong',\n\t'--wpds-color-bg-interactive-error-strong-active',\n\t'--wpds-color-bg-interactive-error-weak',\n\t'--wpds-color-bg-interactive-error-weak-active',\n\t'--wpds-color-bg-track-neutral-weak',\n\t'--wpds-color-bg-track-neutral',\n\t'--wpds-color-bg-thumb-neutral-weak',\n\t'--wpds-color-bg-thumb-neutral-weak-active',\n\t'--wpds-color-bg-thumb-brand',\n\t'--wpds-color-bg-thumb-brand-active',\n\t'--wpds-color-bg-thumb-neutral-disabled',\n\t'--wpds-color-fg-content-neutral',\n\t'--wpds-color-fg-content-neutral-weak',\n\t'--wpds-color-fg-content-success',\n\t'--wpds-color-fg-content-success-weak',\n\t'--wpds-color-fg-content-info',\n\t'--wpds-color-fg-content-info-weak',\n\t'--wpds-color-fg-content-warning',\n\t'--wpds-color-fg-content-warning-weak',\n\t'--wpds-color-fg-content-caution',\n\t'--wpds-color-fg-content-caution-weak',\n\t'--wpds-color-fg-content-error',\n\t'--wpds-color-fg-content-error-weak',\n\t'--wpds-color-fg-interactive-neutral',\n\t'--wpds-color-fg-interactive-neutral-active',\n\t'--wpds-color-fg-interactive-neutral-disabled',\n\t'--wpds-color-fg-interactive-neutral-strong',\n\t'--wpds-color-fg-interactive-neutral-strong-active',\n\t'--wpds-color-fg-interactive-neutral-strong-disabled',\n\t'--wpds-color-fg-interactive-neutral-weak',\n\t'--wpds-color-fg-interactive-neutral-weak-disabled',\n\t'--wpds-color-fg-interactive-brand',\n\t'--wpds-color-fg-interactive-brand-active',\n\t'--wpds-color-fg-interactive-brand-strong',\n\t'--wpds-color-fg-interactive-brand-strong-active',\n\t'--wpds-color-fg-interactive-error',\n\t'--wpds-color-fg-interactive-error-active',\n\t'--wpds-color-fg-interactive-error-strong',\n\t'--wpds-color-fg-interactive-error-strong-active',\n\t'--wpds-color-stroke-surface-neutral',\n\t'--wpds-color-stroke-surface-neutral-weak',\n\t'--wpds-color-stroke-surface-neutral-strong',\n\t'--wpds-color-stroke-surface-brand',\n\t'--wpds-color-stroke-surface-brand-strong',\n\t'--wpds-color-stroke-surface-success',\n\t'--wpds-color-stroke-surface-success-strong',\n\t'--wpds-color-stroke-surface-info',\n\t'--wpds-color-stroke-surface-info-strong',\n\t'--wpds-color-stroke-surface-warning',\n\t'--wpds-color-stroke-surface-warning-strong',\n\t'--wpds-color-stroke-surface-error',\n\t'--wpds-color-stroke-surface-error-strong',\n\t'--wpds-color-stroke-interactive-neutral',\n\t'--wpds-color-stroke-interactive-neutral-active',\n\t'--wpds-color-stroke-interactive-neutral-disabled',\n\t'--wpds-color-stroke-interactive-neutral-strong',\n\t'--wpds-color-stroke-interactive-brand',\n\t'--wpds-color-stroke-interactive-brand-active',\n\t'--wpds-color-stroke-interactive-error',\n\t'--wpds-color-stroke-interactive-error-active',\n\t'--wpds-color-stroke-interactive-error-strong',\n\t'--wpds-color-stroke-focus-brand',\n\t'--wpds-dimension-base',\n\t'--wpds-dimension-padding-surface-2xs',\n\t'--wpds-dimension-padding-surface-xs',\n\t'--wpds-dimension-padding-surface-sm',\n\t'--wpds-dimension-padding-surface-md',\n\t'--wpds-dimension-padding-surface-lg',\n\t'--wpds-dimension-gap-2xs',\n\t'--wpds-dimension-gap-xs',\n\t'--wpds-dimension-gap-sm',\n\t'--wpds-dimension-gap-md',\n\t'--wpds-dimension-gap-lg',\n\t'--wpds-dimension-gap-xl',\n\t'--wpds-elevation-x-small',\n\t'--wpds-elevation-small',\n\t'--wpds-elevation-medium',\n\t'--wpds-elevation-large',\n\t'--wpds-font-family-heading',\n\t'--wpds-font-family-body',\n\t'--wpds-font-family-mono',\n\t'--wpds-font-size-xs',\n\t'--wpds-font-size-sm',\n\t'--wpds-font-size-md',\n\t'--wpds-font-size-lg',\n\t'--wpds-font-size-xl',\n\t'--wpds-font-size-2xl',\n\t'--wpds-font-line-height-xs',\n\t'--wpds-font-line-height-sm',\n\t'--wpds-font-line-height-md',\n\t'--wpds-font-line-height-lg',\n\t'--wpds-font-line-height-xl',\n\t'--wpds-font-line-height-2xl',\n\t'--wpds-font-weight-regular',\n\t'--wpds-font-weight-medium',\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAO,wBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|