@pg-labs-incubator/cobweb 0.0.0-stage → 0.0.1
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/LICENSE +163 -0
- package/README.md +82 -2
- package/package.json +111 -3
- package/src/action/action.yaml +291 -0
- package/src/action/button-group.yaml +56 -0
- package/src/action/button.yaml +239 -0
- package/src/action/split-button.yaml +87 -0
- package/src/color/color.yaml +181 -0
- package/src/color/palette.yaml +147 -0
- package/src/container/card.yaml +170 -0
- package/src/container/corner-radius.yaml +50 -0
- package/src/container/elevation.yaml +19 -0
- package/src/design.yaml +41 -0
- package/src/feedback/feedback.yaml +225 -0
- package/src/icon/icon-font.yaml +28 -0
- package/src/icon/icon.yaml +31 -0
- package/src/input/date-picker.yaml +144 -0
- package/src/input/date-range-input.yaml +162 -0
- package/src/input/range-slider.yaml +161 -0
- package/src/input/select.yaml +230 -0
- package/src/input/slider.yaml +172 -0
- package/src/input/text-field.yaml +240 -0
- package/src/input/time-picker.yaml +220 -0
- package/src/motion/motion.yaml +371 -0
- package/src/navigation/app-bar.yaml +147 -0
- package/src/navigation/navigation.yaml +339 -0
- package/src/navigation/scroll.yaml +23 -0
- package/src/navigation/search.yaml +112 -0
- package/src/navigation/tabs.yaml +144 -0
- package/src/navigation/toolbar.yaml +130 -0
- package/src/selection/checkbox.yaml +162 -0
- package/src/selection/chip.yaml +219 -0
- package/src/selection/radio.yaml +125 -0
- package/src/selection/segmented-group.yaml +11 -0
- package/src/selection/segmented.yaml +69 -0
- package/src/selection/switch.yaml +209 -0
- package/src/spacing/measurement.yaml +80 -0
- package/src/state/state.yaml +38 -0
- package/src/surface/surface.yaml +483 -0
- package/src/text/line-height.yaml +144 -0
- package/src/text/typeface.yaml +31 -0
- package/src/text/typescale.yaml +726 -0
- package/target/esbuild/action/action.css +1 -0
- package/target/esbuild/action/base.jsx +1 -0
- package/target/esbuild/action/button.jsx +17 -0
- package/target/esbuild/action/fab-menu-context.jsx +1 -0
- package/target/esbuild/action/fab-menu.jsx +15 -0
- package/target/esbuild/action/fab.jsx +7 -0
- package/target/esbuild/action/group.jsx +22 -0
- package/target/esbuild/action/icon-button.jsx +5 -0
- package/target/esbuild/action/index.jsx +1 -0
- package/target/esbuild/action/split-button.jsx +12 -0
- package/target/esbuild/color/contrast.jsx +1 -0
- package/target/esbuild/color/dynamic.jsx +1 -0
- package/target/esbuild/color/hct.jsx +1 -0
- package/target/esbuild/color/index.css +1 -0
- package/target/esbuild/color/index.jsx +1 -0
- package/target/esbuild/color/palette.jsx +1 -0
- package/target/esbuild/color/scheme.jsx +1 -0
- package/target/esbuild/color/temperature.jsx +1 -0
- package/target/esbuild/container/card.css +1 -0
- package/target/esbuild/container/card.jsx +1 -0
- package/target/esbuild/container/elevation-shadow.css +1 -0
- package/target/esbuild/container/elevation-shadow.jsx +1 -0
- package/target/esbuild/container/index.jsx +1 -0
- package/target/esbuild/dom/client.jsx +1 -0
- package/target/esbuild/dom/index.jsx +1 -0
- package/target/esbuild/dom/server.jsx +1 -0
- package/target/esbuild/dom/types.jsx +1 -0
- package/target/esbuild/feedback/badge.jsx +15 -0
- package/target/esbuild/feedback/feedback.css +1 -0
- package/target/esbuild/feedback/focus.jsx +1 -0
- package/target/esbuild/feedback/index.jsx +1 -0
- package/target/esbuild/feedback/loading.jsx +7 -0
- package/target/esbuild/feedback/observe.jsx +1 -0
- package/target/esbuild/feedback/progress.jsx +35 -0
- package/target/esbuild/feedback/snackbar.jsx +23 -0
- package/target/esbuild/feedback/tooltip.jsx +24 -0
- package/target/esbuild/icon/icon.css +1 -0
- package/target/esbuild/icon/icon.jsx +1 -0
- package/target/esbuild/icon/index.jsx +1 -0
- package/target/esbuild/index.css +1 -0
- package/target/esbuild/index.jsx +1 -0
- package/target/esbuild/input/autocomplete.jsx +5 -0
- package/target/esbuild/input/base.jsx +4 -0
- package/target/esbuild/input/date-picker.css +1 -0
- package/target/esbuild/input/date-picker.jsx +104 -0
- package/target/esbuild/input/date-range-input.css +1 -0
- package/target/esbuild/input/date-time.jsx +21 -0
- package/target/esbuild/input/index.css +1 -0
- package/target/esbuild/input/index.jsx +1 -0
- package/target/esbuild/input/paired-input.jsx +1 -0
- package/target/esbuild/input/picker-dialog.css +1 -0
- package/target/esbuild/input/picker-dialog.jsx +14 -0
- package/target/esbuild/input/select.css +1 -0
- package/target/esbuild/input/select.jsx +63 -0
- package/target/esbuild/input/slider.css +1 -0
- package/target/esbuild/input/slider.jsx +51 -0
- package/target/esbuild/input/text-field.css +1 -0
- package/target/esbuild/input/text-field.jsx +67 -0
- package/target/esbuild/input/time-picker.css +1 -0
- package/target/esbuild/input/time-picker.jsx +29 -0
- package/target/esbuild/motion/frame.jsx +1 -0
- package/target/esbuild/motion/index.css +1 -0
- package/target/esbuild/motion/index.jsx +1 -0
- package/target/esbuild/motion/material.jsx +1 -0
- package/target/esbuild/motion/motion.jsx +1 -0
- package/target/esbuild/motion/spring.jsx +1 -0
- package/target/esbuild/motion/transition.css +1 -0
- package/target/esbuild/motion/transition.jsx +1 -0
- package/target/esbuild/motion/velocity.jsx +1 -0
- package/target/esbuild/navigation/app-bar.jsx +51 -0
- package/target/esbuild/navigation/base.jsx +1 -0
- package/target/esbuild/navigation/drawer.jsx +25 -0
- package/target/esbuild/navigation/index.jsx +1 -0
- package/target/esbuild/navigation/navigation.css +1 -0
- package/target/esbuild/navigation/navigation.jsx +29 -0
- package/target/esbuild/navigation/scroll.jsx +1 -0
- package/target/esbuild/navigation/search.jsx +29 -0
- package/target/esbuild/navigation/tabs.jsx +7 -0
- package/target/esbuild/navigation/toolbar.jsx +23 -0
- package/target/esbuild/selection/base.jsx +1 -0
- package/target/esbuild/selection/checkbox.jsx +14 -0
- package/target/esbuild/selection/chip.jsx +23 -0
- package/target/esbuild/selection/index.jsx +1 -0
- package/target/esbuild/selection/radio.jsx +9 -0
- package/target/esbuild/selection/segmented.jsx +15 -0
- package/target/esbuild/selection/selection.css +1 -0
- package/target/esbuild/selection/switch.jsx +14 -0
- package/target/esbuild/shape/corner-rounding.jsx +1 -0
- package/target/esbuild/shape/cubic.jsx +1 -0
- package/target/esbuild/shape/index.jsx +1 -0
- package/target/esbuild/shape/material-shapes.jsx +1 -0
- package/target/esbuild/shape/morph.jsx +1 -0
- package/target/esbuild/shape/path.jsx +1 -0
- package/target/esbuild/shape/point.jsx +1 -0
- package/target/esbuild/shape/rounded-polygon.jsx +1 -0
- package/target/esbuild/shape/shapes.jsx +1 -0
- package/target/esbuild/spacing/index.jsx +1 -0
- package/target/esbuild/state/component.css +1 -0
- package/target/esbuild/state/component.jsx +1 -0
- package/target/esbuild/state/controller.jsx +1 -0
- package/target/esbuild/state/index.jsx +1 -0
- package/target/esbuild/state/ripple.jsx +1 -0
- package/target/esbuild/state/state.jsx +1 -0
- package/target/esbuild/state/style.jsx +1 -0
- package/target/esbuild/surface/carousel-layout.jsx +1 -0
- package/target/esbuild/surface/carousel.css +1 -0
- package/target/esbuild/surface/carousel.jsx +10 -0
- package/target/esbuild/surface/dialog.jsx +35 -0
- package/target/esbuild/surface/divider.jsx +1 -0
- package/target/esbuild/surface/drag.jsx +1 -0
- package/target/esbuild/surface/gestures.css +1 -0
- package/target/esbuild/surface/gestures.jsx +7 -0
- package/target/esbuild/surface/index.css +1 -0
- package/target/esbuild/surface/index.jsx +1 -0
- package/target/esbuild/surface/interactive.jsx +1 -0
- package/target/esbuild/surface/list-patterns.jsx +26 -0
- package/target/esbuild/surface/list.css +1 -0
- package/target/esbuild/surface/list.jsx +9 -0
- package/target/esbuild/surface/menu.css +1 -0
- package/target/esbuild/surface/menu.jsx +12 -0
- package/target/esbuild/surface/scaffold.jsx +47 -0
- package/target/esbuild/surface/sheet.jsx +21 -0
- package/target/esbuild/surface/side-sheet.jsx +17 -0
- package/target/esbuild/surface/slots.jsx +1 -0
- package/target/esbuild/surface/surface.css +1 -0
- package/target/esbuild/surface/surface.jsx +1 -0
- package/target/esbuild/text/index.css +1 -0
- package/target/esbuild/text/index.jsx +1 -0
- package/target/esbuild/text/text.css +1 -0
- package/target/esbuild/text/text.jsx +3 -0
- package/target/esbuild/text/typography.css +1 -0
- package/target/esbuild/text/typography.jsx +1 -0
- package/target/esbuild/util/box-side.jsx +1 -0
- package/target/esbuild/util/debug.jsx +1 -0
- package/target/esbuild/util/dom.jsx +1 -0
- package/target/esbuild/util/event.jsx +1 -0
- package/target/esbuild/util/index.jsx +1 -0
- package/target/esbuild/util/preconditions.jsx +1 -0
- package/target/esbuild/util/reactive.jsx +1 -0
- package/target/tsc/action/action.css.d.ts +3 -0
- package/target/tsc/action/base.d.ts +211 -0
- package/target/tsc/action/button.d.ts +126 -0
- package/target/tsc/action/fab-menu-context.d.ts +16 -0
- package/target/tsc/action/fab-menu.d.ts +112 -0
- package/target/tsc/action/fab.d.ts +98 -0
- package/target/tsc/action/group.d.ts +166 -0
- package/target/tsc/action/icon-button.d.ts +79 -0
- package/target/tsc/action/index.d.ts +24 -0
- package/target/tsc/action/split-button.d.ts +78 -0
- package/target/tsc/color/contrast.d.ts +48 -0
- package/target/tsc/color/dynamic.d.ts +203 -0
- package/target/tsc/color/hct.d.ts +114 -0
- package/target/tsc/color/index.css.d.ts +3 -0
- package/target/tsc/color/index.d.ts +23 -0
- package/target/tsc/color/palette.d.ts +30 -0
- package/target/tsc/color/scheme.d.ts +446 -0
- package/target/tsc/color/temperature.d.ts +24 -0
- package/target/tsc/container/card.css.d.ts +3 -0
- package/target/tsc/container/card.d.ts +110 -0
- package/target/tsc/container/elevation-shadow.css.d.ts +3 -0
- package/target/tsc/container/elevation-shadow.d.ts +23 -0
- package/target/tsc/container/index.d.ts +44 -0
- package/target/tsc/dom/client.d.ts +387 -0
- package/target/tsc/dom/index.d.ts +93 -0
- package/target/tsc/dom/server.d.ts +65 -0
- package/target/tsc/dom/types.d.ts +134 -0
- package/target/tsc/feedback/badge.d.ts +116 -0
- package/target/tsc/feedback/feedback.css.d.ts +3 -0
- package/target/tsc/feedback/focus.d.ts +20 -0
- package/target/tsc/feedback/index.d.ts +17 -0
- package/target/tsc/feedback/loading.d.ts +194 -0
- package/target/tsc/feedback/observe.d.ts +75 -0
- package/target/tsc/feedback/progress.d.ts +281 -0
- package/target/tsc/feedback/snackbar.d.ts +398 -0
- package/target/tsc/feedback/tooltip.d.ts +326 -0
- package/target/tsc/icon/icon.css.d.ts +3 -0
- package/target/tsc/icon/icon.d.ts +69 -0
- package/target/tsc/icon/index.d.ts +13 -0
- package/target/tsc/index.css.d.ts +3 -0
- package/target/tsc/index.d.ts +7 -0
- package/target/tsc/input/autocomplete.d.ts +119 -0
- package/target/tsc/input/base.d.ts +282 -0
- package/target/tsc/input/date-picker.css.d.ts +3 -0
- package/target/tsc/input/date-picker.d.ts +351 -0
- package/target/tsc/input/date-range-input.css.d.ts +3 -0
- package/target/tsc/input/date-time.d.ts +171 -0
- package/target/tsc/input/index.css.d.ts +3 -0
- package/target/tsc/input/index.d.ts +27 -0
- package/target/tsc/input/paired-input.d.ts +435 -0
- package/target/tsc/input/picker-dialog.css.d.ts +3 -0
- package/target/tsc/input/picker-dialog.d.ts +84 -0
- package/target/tsc/input/select.css.d.ts +3 -0
- package/target/tsc/input/select.d.ts +267 -0
- package/target/tsc/input/slider.css.d.ts +3 -0
- package/target/tsc/input/slider.d.ts +372 -0
- package/target/tsc/input/text-field.css.d.ts +3 -0
- package/target/tsc/input/text-field.d.ts +415 -0
- package/target/tsc/input/time-picker.css.d.ts +3 -0
- package/target/tsc/input/time-picker.d.ts +212 -0
- package/target/tsc/motion/frame.d.ts +36 -0
- package/target/tsc/motion/index.css.d.ts +3 -0
- package/target/tsc/motion/index.d.ts +34 -0
- package/target/tsc/motion/material.d.ts +110 -0
- package/target/tsc/motion/motion.d.ts +235 -0
- package/target/tsc/motion/spring.d.ts +223 -0
- package/target/tsc/motion/transition.css.d.ts +3 -0
- package/target/tsc/motion/transition.d.ts +597 -0
- package/target/tsc/motion/velocity.d.ts +54 -0
- package/target/tsc/navigation/app-bar.d.ts +473 -0
- package/target/tsc/navigation/base.d.ts +320 -0
- package/target/tsc/navigation/drawer.d.ts +301 -0
- package/target/tsc/navigation/index.d.ts +25 -0
- package/target/tsc/navigation/navigation.css.d.ts +3 -0
- package/target/tsc/navigation/navigation.d.ts +537 -0
- package/target/tsc/navigation/scroll.d.ts +218 -0
- package/target/tsc/navigation/search.d.ts +332 -0
- package/target/tsc/navigation/tabs.d.ts +497 -0
- package/target/tsc/navigation/toolbar.d.ts +248 -0
- package/target/tsc/selection/base.d.ts +100 -0
- package/target/tsc/selection/checkbox.d.ts +194 -0
- package/target/tsc/selection/chip.d.ts +358 -0
- package/target/tsc/selection/index.d.ts +21 -0
- package/target/tsc/selection/radio.d.ts +198 -0
- package/target/tsc/selection/segmented.d.ts +333 -0
- package/target/tsc/selection/selection.css.d.ts +3 -0
- package/target/tsc/selection/switch.d.ts +165 -0
- package/target/tsc/shape/corner-rounding.d.ts +36 -0
- package/target/tsc/shape/cubic.d.ts +215 -0
- package/target/tsc/shape/index.d.ts +35 -0
- package/target/tsc/shape/material-shapes.d.ts +176 -0
- package/target/tsc/shape/morph.d.ts +91 -0
- package/target/tsc/shape/path.d.ts +177 -0
- package/target/tsc/shape/point.d.ts +165 -0
- package/target/tsc/shape/rounded-polygon.d.ts +289 -0
- package/target/tsc/shape/shapes.d.ts +76 -0
- package/target/tsc/spacing/index.d.ts +19 -0
- package/target/tsc/state/component.css.d.ts +3 -0
- package/target/tsc/state/component.d.ts +276 -0
- package/target/tsc/state/controller.d.ts +257 -0
- package/target/tsc/state/index.d.ts +19 -0
- package/target/tsc/state/ripple.d.ts +50 -0
- package/target/tsc/state/state.d.ts +129 -0
- package/target/tsc/state/style.d.ts +22 -0
- package/target/tsc/surface/carousel-layout.d.ts +212 -0
- package/target/tsc/surface/carousel.css.d.ts +3 -0
- package/target/tsc/surface/carousel.d.ts +231 -0
- package/target/tsc/surface/dialog.d.ts +580 -0
- package/target/tsc/surface/divider.d.ts +92 -0
- package/target/tsc/surface/drag.d.ts +92 -0
- package/target/tsc/surface/gestures.css.d.ts +3 -0
- package/target/tsc/surface/gestures.d.ts +292 -0
- package/target/tsc/surface/index.css.d.ts +3 -0
- package/target/tsc/surface/index.d.ts +29 -0
- package/target/tsc/surface/interactive.d.ts +22 -0
- package/target/tsc/surface/list-patterns.d.ts +384 -0
- package/target/tsc/surface/list.css.d.ts +3 -0
- package/target/tsc/surface/list.d.ts +340 -0
- package/target/tsc/surface/menu.css.d.ts +3 -0
- package/target/tsc/surface/menu.d.ts +590 -0
- package/target/tsc/surface/scaffold.d.ts +337 -0
- package/target/tsc/surface/sheet.d.ts +384 -0
- package/target/tsc/surface/side-sheet.d.ts +183 -0
- package/target/tsc/surface/slots.d.ts +21 -0
- package/target/tsc/surface/surface.css.d.ts +3 -0
- package/target/tsc/surface/surface.d.ts +192 -0
- package/target/tsc/text/index.css.d.ts +3 -0
- package/target/tsc/text/index.d.ts +18 -0
- package/target/tsc/text/text.css.d.ts +3 -0
- package/target/tsc/text/text.d.ts +94 -0
- package/target/tsc/text/typography.css.d.ts +3 -0
- package/target/tsc/text/typography.d.ts +82 -0
- package/target/tsc/util/box-side.d.ts +76 -0
- package/target/tsc/util/debug.d.ts +20 -0
- package/target/tsc/util/dom.d.ts +35 -0
- package/target/tsc/util/event.d.ts +93 -0
- package/target/tsc/util/index.d.ts +12 -0
- package/target/tsc/util/preconditions.d.ts +79 -0
- package/target/tsc/util/reactive.d.ts +36 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color in the HCT color space.
|
|
3
|
+
*
|
|
4
|
+
* HCT describes a color by the hue and chroma of the CAM16 color appearance model, under the
|
|
5
|
+
* viewing conditions of {@link hctOfArgb}, and by its tone, the CIE L* lightness. The hue, chroma,
|
|
6
|
+
* and tone are always derived from {@link Hct.argb | `argb`}: a color {@link solveHct | solved}
|
|
7
|
+
* from a requested hue, chroma, and tone has, in general, a different hue, chroma, and tone than
|
|
8
|
+
* requested.
|
|
9
|
+
*/
|
|
10
|
+
export interface Hct {
|
|
11
|
+
/**
|
|
12
|
+
* ARGB color, as an unsigned 32-bit integer.
|
|
13
|
+
*/
|
|
14
|
+
readonly argb: number;
|
|
15
|
+
/**
|
|
16
|
+
* Hue, in degrees, in `[0, 360)`.
|
|
17
|
+
*/
|
|
18
|
+
readonly hue: number;
|
|
19
|
+
/**
|
|
20
|
+
* Chroma, `0` or greater.
|
|
21
|
+
*/
|
|
22
|
+
readonly chroma: number;
|
|
23
|
+
/**
|
|
24
|
+
* Tone, in `[0, 100]`.
|
|
25
|
+
*/
|
|
26
|
+
readonly tone: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Clamp a number to a range.
|
|
30
|
+
*
|
|
31
|
+
* The lower bound is tested first: if `min` is greater than `max`, a number less than `min` is
|
|
32
|
+
* clamped to `min`, and any other number to `max`.
|
|
33
|
+
*
|
|
34
|
+
* @param min - lower bound
|
|
35
|
+
* @param max - upper bound
|
|
36
|
+
* @param val - number to clamp
|
|
37
|
+
* @returns `min` if `val` is less than `min`; otherwise, `max` if `val` is greater than `max`;
|
|
38
|
+
* otherwise, `val`
|
|
39
|
+
*/
|
|
40
|
+
export declare function clamp(min: number, max: number, val: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Normalize an angle, in degrees, to `[0, 360]`.
|
|
43
|
+
*
|
|
44
|
+
* Note that a tiny negative angle is normalized to `360`, and that `-0` is retained as-is.
|
|
45
|
+
*
|
|
46
|
+
* @param deg - angle, in degrees
|
|
47
|
+
* @returns equivalent angle, in `[0, 360]`
|
|
48
|
+
*/
|
|
49
|
+
export declare function sanitizeDegrees(deg: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Convert a tone to relative luminance.
|
|
52
|
+
*
|
|
53
|
+
* @param tone - CIE L* lightness
|
|
54
|
+
* @returns relative luminance, on a scale of `0` to `100`
|
|
55
|
+
*/
|
|
56
|
+
export declare function yOfLstar(tone: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Convert relative luminance to a tone.
|
|
59
|
+
*
|
|
60
|
+
* @param y - relative luminance, on a scale of `0` to `100`
|
|
61
|
+
* @returns CIE L* lightness
|
|
62
|
+
*/
|
|
63
|
+
export declare function lstarOfY(y: number): number;
|
|
64
|
+
/**
|
|
65
|
+
* Convert an ARGB color to CIE L*a*b*.
|
|
66
|
+
*
|
|
67
|
+
* Alpha of `argb` is ignored.
|
|
68
|
+
*
|
|
69
|
+
* @param argb - ARGB color
|
|
70
|
+
* @returns tuple of the L*, a*, and b* coordinates of `argb`, under a D65 white point
|
|
71
|
+
*/
|
|
72
|
+
export declare function labOfArgb(argb: number): [l: number, a: number, b: number];
|
|
73
|
+
/**
|
|
74
|
+
* Convert an ARGB color to HCT.
|
|
75
|
+
*
|
|
76
|
+
* Hue and chroma are those of CAM16 under fixed viewing conditions: a D65 white point, an
|
|
77
|
+
* adapting luminance of `200 / pi` times the relative luminance of tone `50`, a background of tone
|
|
78
|
+
* `50`, and an average surround, without discounting the illuminant. Tone is the CIE L* lightness
|
|
79
|
+
* of the color. Alpha of `argb` is ignored.
|
|
80
|
+
*
|
|
81
|
+
* @param argb - ARGB color
|
|
82
|
+
* @returns HCT color of `argb`
|
|
83
|
+
*/
|
|
84
|
+
export declare function hctOfArgb(argb: number): Hct;
|
|
85
|
+
/**
|
|
86
|
+
* Convert an HCT color to an ARGB color.
|
|
87
|
+
*
|
|
88
|
+
* This solves the color of tone `tone` whose hue is as close as possible to `hue`, and whose
|
|
89
|
+
* chroma is as close as possible to `chroma` without exceeding the chroma available in the sRGB
|
|
90
|
+
* gamut at that hue and tone. Colors of a chroma less than `0.0001`, and colors of a tone less
|
|
91
|
+
* than `0.0001` or greater than `99.9999`, are solved as grays.
|
|
92
|
+
*
|
|
93
|
+
* @param hue - hue, in degrees
|
|
94
|
+
* @param chroma - chroma
|
|
95
|
+
* @param tone - tone
|
|
96
|
+
* @returns opaque, unsigned ARGB color
|
|
97
|
+
*/
|
|
98
|
+
export declare function argbOfHct(hue: number, chroma: number, tone: number): number;
|
|
99
|
+
/**
|
|
100
|
+
* Solve an HCT color.
|
|
101
|
+
*
|
|
102
|
+
* @param hue - hue, in degrees
|
|
103
|
+
* @param chroma - chroma
|
|
104
|
+
* @param tone - tone
|
|
105
|
+
* @returns HCT color of {@link argbOfHct | solved} color
|
|
106
|
+
*/
|
|
107
|
+
export declare function solveHct(hue: number, chroma: number, tone: number): Hct;
|
|
108
|
+
/**
|
|
109
|
+
* Format an ARGB color as a CSS hexadecimal color.
|
|
110
|
+
*
|
|
111
|
+
* @param argb - ARGB color
|
|
112
|
+
* @returns `#rrggbb` color, in lowercase, without alpha
|
|
113
|
+
*/
|
|
114
|
+
export declare function hexOfArgb(argb: number): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Material 3 color roles and source-color dynamic schemes.
|
|
3
|
+
*
|
|
4
|
+
* Role names follow the AndroidX Material 3 [`ColorScheme`][color-scheme], while dynamic schemes
|
|
5
|
+
* follow the Material 3 [dynamic color][dynamic-color] specifications of 2021 and 2025.
|
|
6
|
+
*
|
|
7
|
+
* Static role names and their light/dark CSS behavior are defined by `index.css`: the root
|
|
8
|
+
* follows the preferred color scheme, and the `cw-theme-light` and `cw-theme-dark` classes apply
|
|
9
|
+
* either scheme to a subtree. The TypeScript API in this module generates immutable schemes of
|
|
10
|
+
* every dynamic color style from CSS hex or ARGB source colors, and applies them to elements.
|
|
11
|
+
*
|
|
12
|
+
* Schemes are generated in the HCT color space, whose hue and chroma are those of the CAM16 color
|
|
13
|
+
* appearance model and whose tone is the CIE L* lightness. The source color determines a tonal
|
|
14
|
+
* palette of each role group, and each role takes the color of its palette at a tone which
|
|
15
|
+
* reaches the contrast of the role against its background, at the requested contrast level.
|
|
16
|
+
*
|
|
17
|
+
* [color-scheme]: https://android.googlesource.com/platform/frameworks/support/+/HEAD/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/ColorScheme.kt
|
|
18
|
+
* [dynamic-color]: https://m3.material.io/styles/color/dynamic
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
export type { ColorScheme, ColorSchemeArgb, ColorSchemeCleanup, ColorSchemeCssRole, ColorSchemeMode, ColorSchemeOptions, ColorSchemeRole, ColorSchemeRoleMapping, ColorSchemeSpecVersion, ColorSchemeTarget, ColorSchemeValues, ColorSchemeVariant, ColorSchemeVariables, ColorSource, ColorValue } from "./scheme";
|
|
23
|
+
export { COLOR_SCHEME_CSS_ROLES, COLOR_SCHEME_ROLE_MAPPINGS, applyColorScheme, createColorScheme, removeColorScheme } from "./scheme";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Hct } from "./hct";
|
|
2
|
+
/**
|
|
3
|
+
* Test whether a hue is a yellow hue.
|
|
4
|
+
*
|
|
5
|
+
* @param hue - hue, in degrees
|
|
6
|
+
* @returns `true` if, and only if, `hue` is in `[105, 125)`
|
|
7
|
+
*/
|
|
8
|
+
export declare function isYellowHue(hue: number): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve color of a tonal palette at a tone.
|
|
11
|
+
*
|
|
12
|
+
* A tonal palette holds the colors of a hue and chroma at every tone. This {@link argbOfHct |
|
|
13
|
+
* solves} the color of hue `hue` and chroma `chroma` at tone `tone`, except for tone `99` of a
|
|
14
|
+
* {@link isYellowHue | yellow} hue, whose color is the average of the colors at tones `98` and
|
|
15
|
+
* `100`, channel by channel.
|
|
16
|
+
*
|
|
17
|
+
* @param hue - hue of palette, in degrees
|
|
18
|
+
* @param chroma - chroma of palette
|
|
19
|
+
* @param tone - tone of color
|
|
20
|
+
* @returns opaque, unsigned ARGB color
|
|
21
|
+
*/
|
|
22
|
+
export declare function argbOfPalette(hue: number, chroma: number, tone: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Lighten a color if it is disliked.
|
|
25
|
+
*
|
|
26
|
+
* @param color - color to fix
|
|
27
|
+
* @returns `color` lightened to tone `70` if it is {@link isDisliked | disliked}; otherwise,
|
|
28
|
+
* `color` as-is
|
|
29
|
+
*/
|
|
30
|
+
export declare function fixDislikedColor(color: Hct): Hct;
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CSS hexadecimal color or an ARGB 32-bit color integer.
|
|
3
|
+
*/
|
|
4
|
+
export type ColorSource = string | number;
|
|
5
|
+
/**
|
|
6
|
+
* Color-scheme appearance mode.
|
|
7
|
+
*/
|
|
8
|
+
export type ColorSchemeMode = "light" | "dark";
|
|
9
|
+
/**
|
|
10
|
+
* Material dynamic color specification revision.
|
|
11
|
+
*
|
|
12
|
+
* | Revision | Description |
|
|
13
|
+
* | -------- | ------------------------------------------------------------------------ |
|
|
14
|
+
* | `"2021"` | Dynamic color specification of 2021, available for every variant. |
|
|
15
|
+
* | `"2025"` | Dynamic color specification of 2025. |
|
|
16
|
+
*
|
|
17
|
+
* The `"2025"` revision is available for the `tonalSpot`, `neutral`, `vibrant`, and `expressive`
|
|
18
|
+
* {@link ColorSchemeVariant | variants}; other variants fall back to `"2021"`.
|
|
19
|
+
*/
|
|
20
|
+
export type ColorSchemeSpecVersion = "2021" | "2025";
|
|
21
|
+
/**
|
|
22
|
+
* Dynamic color style.
|
|
23
|
+
*
|
|
24
|
+
* | Variant | Scheme |
|
|
25
|
+
* | -------------- | ----------------------------------------------------------------------- |
|
|
26
|
+
* | `"tonalSpot"` | Low to medium colorfulness, with a tertiary hue related to the source. |
|
|
27
|
+
* | `"neutral"` | Near grayscale. |
|
|
28
|
+
* | `"vibrant"` | Maximum colorfulness of the primary palette at each tone. |
|
|
29
|
+
* | `"expressive"` | Intentionally detached from the source color. |
|
|
30
|
+
* | `"fidelity"` | Source color as primary container, adjusted for color relativity. |
|
|
31
|
+
* | `"content"` | Source color as primary container, adjusted for color relativity. |
|
|
32
|
+
* | `"monochrome"` | Grayscale. |
|
|
33
|
+
* | `"rainbow"` | Playful; the hue of the source color does not appear. |
|
|
34
|
+
* | `"fruitSalad"` | Playful; the hue of the source color does not appear. |
|
|
35
|
+
*/
|
|
36
|
+
export type ColorSchemeVariant = "tonalSpot" | "expressive" | "vibrant" | "fidelity" | "content" | "monochrome" | "neutral" | "rainbow" | "fruitSalad";
|
|
37
|
+
/**
|
|
38
|
+
* Options used to construct a dynamic Material 3 color scheme.
|
|
39
|
+
*/
|
|
40
|
+
export interface ColorSchemeOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Appearance mode.
|
|
43
|
+
*
|
|
44
|
+
* When {@link ColorSchemeOptions.isDark} is also supplied, both values must select the same
|
|
45
|
+
* mode; conflicting values cause {@link createColorScheme} to throw a `RangeError`.
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue `"light"` when neither appearance option is supplied
|
|
48
|
+
*/
|
|
49
|
+
readonly mode?: ColorSchemeMode;
|
|
50
|
+
/**
|
|
51
|
+
* Boolean appearance convenience. `true` selects dark mode.
|
|
52
|
+
*
|
|
53
|
+
* When {@link ColorSchemeOptions.mode} is also supplied, both values must agree.
|
|
54
|
+
*
|
|
55
|
+
* @defaultValue `false` when neither appearance option is supplied
|
|
56
|
+
*/
|
|
57
|
+
readonly isDark?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Contrast adjustment in the inclusive range `[-1, 1]`. Must be finite.
|
|
60
|
+
*
|
|
61
|
+
* `0` is the standard contrast of the design, `-1` the minimum, and `1` the maximum contrast.
|
|
62
|
+
* Medium and high contrast schemes, for example for users preferring more contrast
|
|
63
|
+
* (`prefers-contrast: more`), are generated with a higher level, such as `0.5` and `1`,
|
|
64
|
+
* respectively.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue `0`
|
|
67
|
+
*/
|
|
68
|
+
readonly contrastLevel?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Dynamic color style.
|
|
71
|
+
*
|
|
72
|
+
* @defaultValue `"tonalSpot"`
|
|
73
|
+
*/
|
|
74
|
+
readonly variant?: ColorSchemeVariant;
|
|
75
|
+
/**
|
|
76
|
+
* Requested specification revision.
|
|
77
|
+
*
|
|
78
|
+
* Variants which do not support the requested revision use the `"2021"` revision instead,
|
|
79
|
+
* exposed by {@link ColorScheme.specVersion}.
|
|
80
|
+
*
|
|
81
|
+
* @defaultValue `"2025"`
|
|
82
|
+
*/
|
|
83
|
+
readonly specVersion?: ColorSchemeSpecVersion;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A CSS color value emitted by a color scheme.
|
|
87
|
+
*/
|
|
88
|
+
export type ColorValue = string;
|
|
89
|
+
/**
|
|
90
|
+
* Canonical Material 3 color role names.
|
|
91
|
+
*/
|
|
92
|
+
export type ColorSchemeRole = "primary" | "onPrimary" | "primaryContainer" | "onPrimaryContainer" | "inversePrimary" | "secondary" | "onSecondary" | "secondaryContainer" | "onSecondaryContainer" | "tertiary" | "onTertiary" | "tertiaryContainer" | "onTertiaryContainer" | "background" | "onBackground" | "surface" | "onSurface" | "surfaceVariant" | "onSurfaceVariant" | "surfaceTint" | "inverseSurface" | "inverseOnSurface" | "error" | "onError" | "errorContainer" | "onErrorContainer" | "outline" | "outlineVariant" | "scrim" | "surfaceBright" | "surfaceDim" | "surfaceContainer" | "surfaceContainerHigh" | "surfaceContainerHighest" | "surfaceContainerLow" | "surfaceContainerLowest" | "primaryFixed" | "primaryFixedDim" | "onPrimaryFixed" | "onPrimaryFixedVariant" | "secondaryFixed" | "secondaryFixedDim" | "onSecondaryFixed" | "onSecondaryFixedVariant" | "tertiaryFixed" | "tertiaryFixedDim" | "onTertiaryFixed" | "onTertiaryFixedVariant" | "shadow";
|
|
93
|
+
/**
|
|
94
|
+
* ARGB values for all Material 3 roles and Cobweb's retained `shadow` role.
|
|
95
|
+
*/
|
|
96
|
+
export type ColorSchemeArgb = Readonly<Record<ColorSchemeRole, number>>;
|
|
97
|
+
/**
|
|
98
|
+
* Cobweb role suffixes used after `--cw-Color-`.
|
|
99
|
+
*
|
|
100
|
+
* Grouped names deliberately retain the existing Cobweb vocabulary (`fill`, `onFill`, and
|
|
101
|
+
* `inverseFill`) while the ungrouped `background`, `scrim`, and outline roles mirror Material 3.
|
|
102
|
+
*/
|
|
103
|
+
export type ColorSchemeCssRole = "primary-fill" | "primary-onFill" | "primary-container" | "primary-onContainer" | "primary-inverseFill" | "primary-fixedFill" | "primary-fixedFillDim" | "primary-onFixedFill" | "primary-onFixedFillVariant" | "secondary-fill" | "secondary-onFill" | "secondary-container" | "secondary-onContainer" | "secondary-fixedFill" | "secondary-fixedFillDim" | "secondary-onFixedFill" | "secondary-onFixedFillVariant" | "tertiary-fill" | "tertiary-onFill" | "tertiary-container" | "tertiary-onContainer" | "tertiary-fixedFill" | "tertiary-fixedFillDim" | "tertiary-onFixedFill" | "tertiary-onFixedFillVariant" | "error-fill" | "error-onFill" | "error-container" | "error-onContainer" | "background" | "onBackground" | "surface-fill" | "surface-onFill" | "surface-fillVariant" | "surface-onFillVariant" | "surface-tint" | "surface-inverseFill" | "surface-inverseOnFill" | "surface-fillBright" | "surface-fillDim" | "surface-container" | "surface-containerHigh" | "surface-containerHighest" | "surface-containerLow" | "surface-containerLowest" | "outline" | "outlineVariant" | "scrim" | "shadow";
|
|
104
|
+
/**
|
|
105
|
+
* CSS custom properties keyed by their complete Cobweb property name.
|
|
106
|
+
*/
|
|
107
|
+
export type ColorSchemeVariables = Readonly<Record<`--cw-Color-${ColorSchemeCssRole}`, ColorValue>>;
|
|
108
|
+
/**
|
|
109
|
+
* Values keyed by Cobweb role suffix, without the `--cw-Color-` prefix.
|
|
110
|
+
*/
|
|
111
|
+
export type ColorSchemeValues = Readonly<Record<ColorSchemeCssRole, ColorValue>>;
|
|
112
|
+
/**
|
|
113
|
+
* An immutable Material 3 color scheme.
|
|
114
|
+
*
|
|
115
|
+
* Role properties use the canonical Material 3 names and contain CSS hexadecimal colors. The
|
|
116
|
+
* `values` and `variables` views expose the same colors using Cobweb's design-role names. The
|
|
117
|
+
* object and its nested views are frozen before being returned.
|
|
118
|
+
*/
|
|
119
|
+
export interface ColorScheme {
|
|
120
|
+
/**
|
|
121
|
+
* Specification revision the scheme was generated with, after the fallback of its variant.
|
|
122
|
+
*/
|
|
123
|
+
readonly specVersion: ColorSchemeSpecVersion;
|
|
124
|
+
/**
|
|
125
|
+
* Source color as an opaque CSS hexadecimal color.
|
|
126
|
+
*
|
|
127
|
+
* The original alpha channel is available through {@link ColorScheme.sourceColorArgb}.
|
|
128
|
+
*/
|
|
129
|
+
readonly sourceColor: ColorValue;
|
|
130
|
+
/**
|
|
131
|
+
* Original source color as an unsigned 32-bit ARGB integer, including alpha.
|
|
132
|
+
*/
|
|
133
|
+
readonly sourceColorArgb: number;
|
|
134
|
+
/**
|
|
135
|
+
* Resolved light or dark appearance mode.
|
|
136
|
+
*/
|
|
137
|
+
readonly mode: ColorSchemeMode;
|
|
138
|
+
/**
|
|
139
|
+
* Whether {@link ColorScheme.mode} is `"dark"`.
|
|
140
|
+
*/
|
|
141
|
+
readonly isDark: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Resolved contrast adjustment in the inclusive range `[-1, 1]`.
|
|
144
|
+
*/
|
|
145
|
+
readonly contrastLevel: number;
|
|
146
|
+
/**
|
|
147
|
+
* Dynamic color style the scheme was generated with.
|
|
148
|
+
*/
|
|
149
|
+
readonly variant: ColorSchemeVariant;
|
|
150
|
+
/**
|
|
151
|
+
* Primary accent color for prominent controls and active elements.
|
|
152
|
+
*/
|
|
153
|
+
readonly primary: ColorValue;
|
|
154
|
+
/**
|
|
155
|
+
* Foreground color paired with {@link ColorScheme.primary}.
|
|
156
|
+
*/
|
|
157
|
+
readonly onPrimary: ColorValue;
|
|
158
|
+
/**
|
|
159
|
+
* Container color for primary-accent content.
|
|
160
|
+
*/
|
|
161
|
+
readonly primaryContainer: ColorValue;
|
|
162
|
+
/**
|
|
163
|
+
* Foreground color paired with {@link ColorScheme.primaryContainer}.
|
|
164
|
+
*/
|
|
165
|
+
readonly onPrimaryContainer: ColorValue;
|
|
166
|
+
/**
|
|
167
|
+
* Primary accent color for an inverse surface.
|
|
168
|
+
*/
|
|
169
|
+
readonly inversePrimary: ColorValue;
|
|
170
|
+
/**
|
|
171
|
+
* Secondary accent color for less prominent controls.
|
|
172
|
+
*/
|
|
173
|
+
readonly secondary: ColorValue;
|
|
174
|
+
/**
|
|
175
|
+
* Foreground color paired with {@link ColorScheme.secondary}.
|
|
176
|
+
*/
|
|
177
|
+
readonly onSecondary: ColorValue;
|
|
178
|
+
/**
|
|
179
|
+
* Container color for secondary-accent content.
|
|
180
|
+
*/
|
|
181
|
+
readonly secondaryContainer: ColorValue;
|
|
182
|
+
/**
|
|
183
|
+
* Foreground color paired with {@link ColorScheme.secondaryContainer}.
|
|
184
|
+
*/
|
|
185
|
+
readonly onSecondaryContainer: ColorValue;
|
|
186
|
+
/**
|
|
187
|
+
* Tertiary accent color for contrasting accents.
|
|
188
|
+
*/
|
|
189
|
+
readonly tertiary: ColorValue;
|
|
190
|
+
/**
|
|
191
|
+
* Foreground color paired with {@link ColorScheme.tertiary}.
|
|
192
|
+
*/
|
|
193
|
+
readonly onTertiary: ColorValue;
|
|
194
|
+
/**
|
|
195
|
+
* Container color for tertiary-accent content.
|
|
196
|
+
*/
|
|
197
|
+
readonly tertiaryContainer: ColorValue;
|
|
198
|
+
/**
|
|
199
|
+
* Foreground color paired with {@link ColorScheme.tertiaryContainer}.
|
|
200
|
+
*/
|
|
201
|
+
readonly onTertiaryContainer: ColorValue;
|
|
202
|
+
/**
|
|
203
|
+
* Background color for the application canvas.
|
|
204
|
+
*/
|
|
205
|
+
readonly background: ColorValue;
|
|
206
|
+
/**
|
|
207
|
+
* Foreground color paired with {@link ColorScheme.background}.
|
|
208
|
+
*/
|
|
209
|
+
readonly onBackground: ColorValue;
|
|
210
|
+
/**
|
|
211
|
+
* Default surface color for components and containers.
|
|
212
|
+
*/
|
|
213
|
+
readonly surface: ColorValue;
|
|
214
|
+
/**
|
|
215
|
+
* Foreground color paired with {@link ColorScheme.surface}.
|
|
216
|
+
*/
|
|
217
|
+
readonly onSurface: ColorValue;
|
|
218
|
+
/**
|
|
219
|
+
* Alternate surface color retained for compatible component designs.
|
|
220
|
+
*/
|
|
221
|
+
readonly surfaceVariant: ColorValue;
|
|
222
|
+
/**
|
|
223
|
+
* Lower-emphasis foreground color for surface content.
|
|
224
|
+
*/
|
|
225
|
+
readonly onSurfaceVariant: ColorValue;
|
|
226
|
+
/**
|
|
227
|
+
* Tint used to express elevated surface treatments.
|
|
228
|
+
*/
|
|
229
|
+
readonly surfaceTint: ColorValue;
|
|
230
|
+
/**
|
|
231
|
+
* Surface color contrasting with the current appearance mode.
|
|
232
|
+
*/
|
|
233
|
+
readonly inverseSurface: ColorValue;
|
|
234
|
+
/**
|
|
235
|
+
* Foreground color paired with {@link ColorScheme.inverseSurface}.
|
|
236
|
+
*/
|
|
237
|
+
readonly inverseOnSurface: ColorValue;
|
|
238
|
+
/**
|
|
239
|
+
* Color indicating an error or destructive state.
|
|
240
|
+
*/
|
|
241
|
+
readonly error: ColorValue;
|
|
242
|
+
/**
|
|
243
|
+
* Foreground color paired with {@link ColorScheme.error}.
|
|
244
|
+
*/
|
|
245
|
+
readonly onError: ColorValue;
|
|
246
|
+
/**
|
|
247
|
+
* Container color for error content.
|
|
248
|
+
*/
|
|
249
|
+
readonly errorContainer: ColorValue;
|
|
250
|
+
/**
|
|
251
|
+
* Foreground color paired with {@link ColorScheme.errorContainer}.
|
|
252
|
+
*/
|
|
253
|
+
readonly onErrorContainer: ColorValue;
|
|
254
|
+
/**
|
|
255
|
+
* Outline color for boundaries requiring emphasis.
|
|
256
|
+
*/
|
|
257
|
+
readonly outline: ColorValue;
|
|
258
|
+
/**
|
|
259
|
+
* Lower-emphasis outline color for decorative boundaries.
|
|
260
|
+
*/
|
|
261
|
+
readonly outlineVariant: ColorValue;
|
|
262
|
+
/**
|
|
263
|
+
* Color for a scrim obscuring content behind an overlay.
|
|
264
|
+
*/
|
|
265
|
+
readonly scrim: ColorValue;
|
|
266
|
+
/**
|
|
267
|
+
* Brightest general surface color in the current mode.
|
|
268
|
+
*/
|
|
269
|
+
readonly surfaceBright: ColorValue;
|
|
270
|
+
/**
|
|
271
|
+
* Dimmest general surface color in the current mode.
|
|
272
|
+
*/
|
|
273
|
+
readonly surfaceDim: ColorValue;
|
|
274
|
+
/**
|
|
275
|
+
* Default surface-container color.
|
|
276
|
+
*/
|
|
277
|
+
readonly surfaceContainer: ColorValue;
|
|
278
|
+
/**
|
|
279
|
+
* Higher-emphasis surface-container color.
|
|
280
|
+
*/
|
|
281
|
+
readonly surfaceContainerHigh: ColorValue;
|
|
282
|
+
/**
|
|
283
|
+
* Highest-emphasis surface-container color.
|
|
284
|
+
*/
|
|
285
|
+
readonly surfaceContainerHighest: ColorValue;
|
|
286
|
+
/**
|
|
287
|
+
* Lower-emphasis surface-container color.
|
|
288
|
+
*/
|
|
289
|
+
readonly surfaceContainerLow: ColorValue;
|
|
290
|
+
/**
|
|
291
|
+
* Lowest-emphasis surface-container color.
|
|
292
|
+
*/
|
|
293
|
+
readonly surfaceContainerLowest: ColorValue;
|
|
294
|
+
/**
|
|
295
|
+
* Primary fixed-accent color for content using a fixed color pairing.
|
|
296
|
+
*/
|
|
297
|
+
readonly primaryFixed: ColorValue;
|
|
298
|
+
/**
|
|
299
|
+
* Dimmer fixed-accent color paired with {@link ColorScheme.primaryFixed}.
|
|
300
|
+
*/
|
|
301
|
+
readonly primaryFixedDim: ColorValue;
|
|
302
|
+
/**
|
|
303
|
+
* Foreground color for the primary fixed-accent pair.
|
|
304
|
+
*/
|
|
305
|
+
readonly onPrimaryFixed: ColorValue;
|
|
306
|
+
/**
|
|
307
|
+
* Lower-emphasis foreground color for the primary fixed-accent pair.
|
|
308
|
+
*/
|
|
309
|
+
readonly onPrimaryFixedVariant: ColorValue;
|
|
310
|
+
/**
|
|
311
|
+
* Secondary fixed-accent color for content using a fixed color pairing.
|
|
312
|
+
*/
|
|
313
|
+
readonly secondaryFixed: ColorValue;
|
|
314
|
+
/**
|
|
315
|
+
* Dimmer fixed-accent color paired with {@link ColorScheme.secondaryFixed}.
|
|
316
|
+
*/
|
|
317
|
+
readonly secondaryFixedDim: ColorValue;
|
|
318
|
+
/**
|
|
319
|
+
* Foreground color for the secondary fixed-accent pair.
|
|
320
|
+
*/
|
|
321
|
+
readonly onSecondaryFixed: ColorValue;
|
|
322
|
+
/**
|
|
323
|
+
* Lower-emphasis foreground color for the secondary fixed-accent pair.
|
|
324
|
+
*/
|
|
325
|
+
readonly onSecondaryFixedVariant: ColorValue;
|
|
326
|
+
/**
|
|
327
|
+
* Tertiary fixed-accent color for content using a fixed color pairing.
|
|
328
|
+
*/
|
|
329
|
+
readonly tertiaryFixed: ColorValue;
|
|
330
|
+
/**
|
|
331
|
+
* Dimmer fixed-accent color paired with {@link ColorScheme.tertiaryFixed}.
|
|
332
|
+
*/
|
|
333
|
+
readonly tertiaryFixedDim: ColorValue;
|
|
334
|
+
/**
|
|
335
|
+
* Foreground color for the tertiary fixed-accent pair.
|
|
336
|
+
*/
|
|
337
|
+
readonly onTertiaryFixed: ColorValue;
|
|
338
|
+
/**
|
|
339
|
+
* Lower-emphasis foreground color for the tertiary fixed-accent pair.
|
|
340
|
+
*/
|
|
341
|
+
readonly onTertiaryFixedVariant: ColorValue;
|
|
342
|
+
/**
|
|
343
|
+
* Shadow color retained as a Cobweb design role.
|
|
344
|
+
*/
|
|
345
|
+
readonly shadow: ColorValue;
|
|
346
|
+
/**
|
|
347
|
+
* Frozen map of canonical role names to unsigned 32-bit ARGB colors.
|
|
348
|
+
*/
|
|
349
|
+
readonly argb: ColorSchemeArgb;
|
|
350
|
+
/**
|
|
351
|
+
* Frozen map of Cobweb role suffixes to CSS hexadecimal colors.
|
|
352
|
+
*
|
|
353
|
+
* Keys omit the `--cw-Color-` prefix; see {@link ColorSchemeCssRole}.
|
|
354
|
+
*/
|
|
355
|
+
readonly values: ColorSchemeValues;
|
|
356
|
+
/**
|
|
357
|
+
* Frozen map of complete `--cw-Color-*` property names to CSS hexadecimal colors.
|
|
358
|
+
*
|
|
359
|
+
* This view contains color properties; {@link ColorScheme.cssText} also sets `color-scheme`.
|
|
360
|
+
*/
|
|
361
|
+
readonly variables: ColorSchemeVariables;
|
|
362
|
+
/**
|
|
363
|
+
* Serialized declarations of {@link ColorScheme.variables} and `color-scheme`.
|
|
364
|
+
*
|
|
365
|
+
* This may be emitted in a style rule, for example to generate a fixed scheme at build time.
|
|
366
|
+
*/
|
|
367
|
+
readonly cssText: string;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* A target with an inline CSS declaration block.
|
|
371
|
+
*/
|
|
372
|
+
export type ColorSchemeTarget = Element & ElementCSSInlineStyle;
|
|
373
|
+
/**
|
|
374
|
+
* Reversible cleanup returned by {@link applyColorScheme}.
|
|
375
|
+
*/
|
|
376
|
+
export type ColorSchemeCleanup = () => void;
|
|
377
|
+
/**
|
|
378
|
+
* Canonical role to Cobweb CSS suffix mapping.
|
|
379
|
+
*/
|
|
380
|
+
export interface ColorSchemeRoleMapping {
|
|
381
|
+
/**
|
|
382
|
+
* Canonical Material color role used to read a generated scheme.
|
|
383
|
+
*/
|
|
384
|
+
readonly role: ColorSchemeRole;
|
|
385
|
+
/**
|
|
386
|
+
* Corresponding Cobweb suffix used after `--cw-Color-`.
|
|
387
|
+
*/
|
|
388
|
+
readonly cssRole: ColorSchemeCssRole;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Mapping from canonical Material 3 role names to Cobweb role suffixes, in serialization order.
|
|
392
|
+
*/
|
|
393
|
+
export declare const COLOR_SCHEME_ROLE_MAPPINGS: readonly ColorSchemeRoleMapping[];
|
|
394
|
+
/**
|
|
395
|
+
* All supported Cobweb color role suffixes in deterministic serialization order.
|
|
396
|
+
*/
|
|
397
|
+
export declare const COLOR_SCHEME_CSS_ROLES: readonly ColorSchemeCssRole[];
|
|
398
|
+
/**
|
|
399
|
+
* Construct a complete Material 3 color scheme from a source color.
|
|
400
|
+
*
|
|
401
|
+
* CSS strings use the CSS hexadecimal forms `#RGB`, `#RGBA`, `#RRGGBB`, and `#RRGGBBAA` (the
|
|
402
|
+
* latter follows CSS's `RRGGBBAA` order). Alpha is retained in `sourceColorArgb`, but HCT scheme
|
|
403
|
+
* generation uses the RGB channels and emits opaque role colors. Numeric sources are unsigned
|
|
404
|
+
* `0xAARRGGBB` values. No DOM or global browser state is accessed by this function.
|
|
405
|
+
*
|
|
406
|
+
* Generating a scheme solves the contrast of every role, which takes in the order of a tenth of a
|
|
407
|
+
* millisecond. Interfaces regenerating schemes from continuous input, such as a color picker,
|
|
408
|
+
* should memoize schemes per input and throttle regeneration, for example to one scheme per
|
|
409
|
+
* animation frame. Fixed schemes are best generated at build time, emitting {@link
|
|
410
|
+
* ColorScheme.cssText} in a style rule.
|
|
411
|
+
*
|
|
412
|
+
* @param sourceColor - CSS hex string or unsigned ARGB integer
|
|
413
|
+
* @param modeOrOptions - mode, boolean `isDark`, or options object
|
|
414
|
+
* @param contrastLevel - positional contrast level, overriding any value in the options object
|
|
415
|
+
* @param variant - positional variant, overriding any value in the options object
|
|
416
|
+
* @returns immutable scheme with canonical roles, Cobweb properties, and serialized CSS
|
|
417
|
+
* @throws {@link TypeError} `sourceColor` is malformed, or an option has an unsupported value
|
|
418
|
+
* @throws {@link RangeError} `sourceColor` is an out of range number, `mode` and `isDark` disagree,
|
|
419
|
+
* or the contrast level is out of range
|
|
420
|
+
*/
|
|
421
|
+
export declare function createColorScheme(sourceColor: ColorSource, modeOrOptions?: ColorSchemeMode | boolean | ColorSchemeOptions, contrastLevel?: number, variant?: ColorSchemeVariant): ColorScheme;
|
|
422
|
+
/**
|
|
423
|
+
* Apply a generated color scheme to an element's inline custom properties.
|
|
424
|
+
*
|
|
425
|
+
* Only color-scheme declarations are changed. Unrelated inline styles remain reactive while a
|
|
426
|
+
* scheme is applied. Cleanup restores pre-existing values and priorities for declarations still
|
|
427
|
+
* owned by this application, preserving subsequent authored overrides. Reapplying replaces the
|
|
428
|
+
* current scheme, while retaining the declarations which preceded the first application; cleanup
|
|
429
|
+
* for an older application does not disturb a newer application.
|
|
430
|
+
*
|
|
431
|
+
* @param target - element receiving `--cw-Color-*` declarations
|
|
432
|
+
* @param scheme - scheme to apply
|
|
433
|
+
* @returns idempotent cleanup function
|
|
434
|
+
* @throws {@link TypeError} `target` has no inline style declarations or `scheme` is not a color
|
|
435
|
+
* scheme
|
|
436
|
+
*/
|
|
437
|
+
export declare function applyColorScheme(target: ColorSchemeTarget, scheme: ColorScheme): ColorSchemeCleanup;
|
|
438
|
+
/**
|
|
439
|
+
* Remove the most recently applied generated color scheme from a target.
|
|
440
|
+
*
|
|
441
|
+
* Restores previous values and priorities only for declarations still owned by that application.
|
|
442
|
+
* Authored overrides remain intact. A target without an applied scheme is unchanged.
|
|
443
|
+
*
|
|
444
|
+
* @param target - element previously passed to {@link applyColorScheme}
|
|
445
|
+
*/
|
|
446
|
+
export declare function removeColorScheme(target: ColorSchemeTarget): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Hct } from "./hct";
|
|
2
|
+
/**
|
|
3
|
+
* Determine an analogous color of a color.
|
|
4
|
+
*
|
|
5
|
+
* Going around the hue wheel of `source`, starting at its hue, this sums the changes of
|
|
6
|
+
* relative temperature from color to color. The analogous color is the first color at which the
|
|
7
|
+
* sum reaches one sixth of the total change, excluding the change from the last color back to the
|
|
8
|
+
* first.
|
|
9
|
+
*
|
|
10
|
+
* @param source - color to determine analogous color of
|
|
11
|
+
* @returns analogous color, of the chroma and tone of `source`
|
|
12
|
+
*/
|
|
13
|
+
export declare function analogousColorOf(source: Hct): Hct;
|
|
14
|
+
/**
|
|
15
|
+
* Determine the complementary color of a color.
|
|
16
|
+
*
|
|
17
|
+
* The complementary color is the color of the hue wheel of `source`, among the hues between the
|
|
18
|
+
* coldest and the warmest color on the side of the wheel opposite to `source`, whose relative
|
|
19
|
+
* temperature is nearest to `1` less the relative temperature of `source`.
|
|
20
|
+
*
|
|
21
|
+
* @param source - color to determine complementary color of
|
|
22
|
+
* @returns complementary color, of the chroma and tone of `source`
|
|
23
|
+
*/
|
|
24
|
+
export declare function complementaryColorOf(source: Hct): Hct;
|