@wistia/kaleidoscope 0.0.2 → 0.0.3-beta.744e55dd.c7dc7eb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/color-BD12TVX4.d.ts +393 -0
- package/dist/{index.d.ts.map → color-BD12TVX4.d.ts.map} +1 -1
- package/dist/color-K4N47FR5.js +1347 -0
- package/dist/color-K4N47FR5.js.map +1 -0
- package/dist/entries/color.d.ts +3 -0
- package/dist/entries/color.js +11 -0
- package/dist/entries/vocabulary.d.ts +3 -0
- package/dist/entries/vocabulary.js +11 -0
- package/dist/index.d.ts +3 -279
- package/dist/index.js +4 -896
- package/dist/vocabulary-CsAxpvD3.js +276 -0
- package/dist/vocabulary-CsAxpvD3.js.map +1 -0
- package/dist/vocabulary-DAD2PSCW.d.ts +353 -0
- package/dist/vocabulary-DAD2PSCW.d.ts.map +1 -0
- package/package.json +23 -15
- package/CHANGELOG.md +0 -13
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -84,6 +84,48 @@ most contrasting color available, which is always black or white and is picked b
|
|
|
84
84
|
both. Check the result with `contrast` when the ratio is load-bearing.
|
|
85
85
|
|
|
86
86
|
|
|
87
|
+
## Lightness
|
|
88
|
+
|
|
89
|
+
`getColorLightnessClassification` classifies a color by its lightness, returning 'veryDark', 'dark', midtone', or 'light'
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { getColorLightnessClassification } from '@wistia/kaleidoscope';
|
|
93
|
+
|
|
94
|
+
getColorLightnessClassification('#000000'); // 'veryDark'
|
|
95
|
+
getColorLightnessClassification('#2949e5'); // 'dark'
|
|
96
|
+
getColorLightnessClassification('#7f7f7f'); // 'midtone'
|
|
97
|
+
getColorLightnessClassification('#ffffff'); // 'light'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Accented backgrounds
|
|
101
|
+
|
|
102
|
+
Often we want a surface (a card or panel) to have a visually distinct background color derived from the main background the surface sits on.
|
|
103
|
+
|
|
104
|
+
Use these utilities only when the contrast ratio of the accented background color against the given background color is insignificant.
|
|
105
|
+
|
|
106
|
+
`getSlightAccentedBackgroundColor` is one step darker/lighter than the background
|
|
107
|
+
`getHeavyAccentedBackgroundColor` is two steps darker/lighter than the background
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import {
|
|
112
|
+
getHeavyAccentedBackgroundColor,
|
|
113
|
+
getSlightAccentedBackgroundColor,
|
|
114
|
+
} from '@wistia/kaleidoscope';
|
|
115
|
+
|
|
116
|
+
getSlightAccentedBackgroundColor('#f5f5f5').toHex(); // '#e0e0e0'
|
|
117
|
+
getHeavyAccentedBackgroundColor('#f5f5f5').toHex(); // '#cbcbcb'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Pass `primaryColor` when the background color is derived from a primary color so that the accented color
|
|
121
|
+
preserves the vibrancy of the primary color rather than getting muddy/gray.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
getSlightAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#cdd5f9'
|
|
125
|
+
getHeavyAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#adbbf5'
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
87
129
|
## Storybook
|
|
88
130
|
|
|
89
131
|
Color is easier to judge by eye than by assertion, so every feature has a story, including
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/colorContrastRatiosByShape.d.ts
|
|
3
|
+
declare const colorContrastRatiosByShape: {
|
|
4
|
+
readonly nonText: 3.0;
|
|
5
|
+
readonly largeText: 3.0;
|
|
6
|
+
readonly paragraphText: 4.5;
|
|
7
|
+
readonly smallText: 5.5;
|
|
8
|
+
};
|
|
9
|
+
/** The kind of content a color has to be legible as, which sets the ratio it has to clear. */
|
|
10
|
+
type ColorShape = keyof typeof colorContrastRatiosByShape;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/Color.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* An immutable sRGB color with transformation methods like lighten, darken, tint, shade.
|
|
15
|
+
* Also includes methods to calculate contrast ratio against another color, relative luminance, etc.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* new Color('#2949e5').lighten(0.5).toHex(); // '#89aaff'
|
|
20
|
+
* new Color('#2949e5').withAlpha(0.5).toRgba(); // 'rgba(41, 73, 229, 0.5)'
|
|
21
|
+
* new Color('#2949e5').contrast('#ffffff'); // 6.6
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare class Color {
|
|
25
|
+
#private;
|
|
26
|
+
/**
|
|
27
|
+
* Read `input` into a color, returning `null` when it cannot be parsed.
|
|
28
|
+
*/
|
|
29
|
+
static parse(input: ColorInput): Color | null;
|
|
30
|
+
static fromHsl(hsl: Hsl, alpha?: number): Color;
|
|
31
|
+
static fromLab(lab: Lab, alpha?: number): Color;
|
|
32
|
+
/** Red channel, 0–255. Kept unrounded so that chained operations don't accumulate error. */
|
|
33
|
+
readonly r: number;
|
|
34
|
+
/** Green channel, 0–255. Kept unrounded so that chained operations don't accumulate error. */
|
|
35
|
+
readonly g: number;
|
|
36
|
+
/** Blue channel, 0–255. Kept unrounded so that chained operations don't accumulate error. */
|
|
37
|
+
readonly b: number;
|
|
38
|
+
/** Alpha channel, 0–1. */
|
|
39
|
+
readonly a: number;
|
|
40
|
+
/**
|
|
41
|
+
* @param input - any supported color representation. Input that cannot be read as a
|
|
42
|
+
* color resolves to brand blue rather than failing, so a malformed value degrades to
|
|
43
|
+
* a usable color instead of interrupting a render.
|
|
44
|
+
*/
|
|
45
|
+
constructor(input: ColorInput);
|
|
46
|
+
/** `#rrggbb`. Alpha is dropped — use {@link Color.toHexWithAlpha} to keep it. */
|
|
47
|
+
toHex(): string;
|
|
48
|
+
/** `#rrggbbaa`. */
|
|
49
|
+
toHexWithAlpha(): string;
|
|
50
|
+
/** `rgb(41, 73, 229)`. */
|
|
51
|
+
toRgb(): string;
|
|
52
|
+
/** `rgba(41, 73, 229, 0.5)`. */
|
|
53
|
+
toRgba(): string;
|
|
54
|
+
/** Rounded channels, ready to hand to another color library. */
|
|
55
|
+
toRgbaTuple(): RgbaTuple;
|
|
56
|
+
toHsl(): Hsl;
|
|
57
|
+
toLab(): Lab;
|
|
58
|
+
/** Hex when fully opaque, `rgba()` otherwise, so the alpha is never silently lost. */
|
|
59
|
+
toString(): string;
|
|
60
|
+
/**
|
|
61
|
+
* WCAG relative luminance, from 0 (black) to 1 (white). Alpha is ignored — luminance
|
|
62
|
+
* is only meaningful once a color has been composited onto a background.
|
|
63
|
+
*/
|
|
64
|
+
luminance(): number;
|
|
65
|
+
/**
|
|
66
|
+
* WCAG contrast ratio against `other`, from 1 (identical) to 21 (black on white),
|
|
67
|
+
* reported to one decimal place.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link colorContrastRatiosByShape} for the ratio each kind of content needs
|
|
70
|
+
*/
|
|
71
|
+
contrast(other: ColorInput): number;
|
|
72
|
+
/**
|
|
73
|
+
* Raise perceptual lightness `ratio` (0–1) of the way to white, holding the hue steady.
|
|
74
|
+
*
|
|
75
|
+
* The hue is held in OKLCh, so a lightened color stays recognizably itself: a blue
|
|
76
|
+
* lightens to a paler blue instead of drifting purple, and a red that runs out of sRGB
|
|
77
|
+
* gives up colorfulness rather than sliding towards orange. That is the difference from
|
|
78
|
+
* {@link Color.tint}, which stirs white into the channels and lets the hue land where it
|
|
79
|
+
* may.
|
|
80
|
+
*/
|
|
81
|
+
lighten(ratio: number): Color;
|
|
82
|
+
/** Lower perceptual lightness `ratio` (0–1) of the way to black, holding the hue steady. */
|
|
83
|
+
darken(ratio: number): Color;
|
|
84
|
+
/** Mix `ratio` (0–1) of white in. */
|
|
85
|
+
tint(ratio: number, mode?: InterpolationMode): Color;
|
|
86
|
+
/** Mix `ratio` (0–1) of black in. */
|
|
87
|
+
shade(ratio: number, mode?: InterpolationMode): Color;
|
|
88
|
+
/**
|
|
89
|
+
* Mix towards `other`, where `ratio` 0 keeps this color and 1 returns `other`. Alpha is
|
|
90
|
+
* always interpolated linearly, whichever `mode` the channels travel through.
|
|
91
|
+
*/
|
|
92
|
+
blend(other: ColorInput, ratio?: number, mode?: InterpolationMode): Color;
|
|
93
|
+
/** Replace the alpha channel with `alpha` (0–1). */
|
|
94
|
+
withAlpha(alpha: number): Color;
|
|
95
|
+
/**
|
|
96
|
+
* Replace HSL lightness with `lightness` (0–100), leaving hue and saturation alone.
|
|
97
|
+
* Use this to hit an absolute lightness; use {@link Color.lighten} to step relative to
|
|
98
|
+
* where the color already is.
|
|
99
|
+
*/
|
|
100
|
+
withLightness(lightness: number): Color;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/types.d.ts
|
|
104
|
+
/** Red, green and blue channels, each in the 0–255 range. */
|
|
105
|
+
type RgbTuple = [red: number, green: number, blue: number];
|
|
106
|
+
/** Red, green and blue channels (0–255) plus an alpha channel (0–1). */
|
|
107
|
+
type RgbaTuple = [red: number, green: number, blue: number, alpha: number];
|
|
108
|
+
/** RGB channels (0–255) with an optional alpha channel (0–1). */
|
|
109
|
+
type ColorTuple = [red: number, green: number, blue: number, alpha?: number];
|
|
110
|
+
/** Any object carrying RGB channels (0–255) and an optional alpha channel (0–1). */
|
|
111
|
+
type RgbaObject = {
|
|
112
|
+
readonly a?: number;
|
|
113
|
+
readonly b: number;
|
|
114
|
+
readonly g: number;
|
|
115
|
+
readonly r: number;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Anything that can be read as a color:
|
|
119
|
+
*
|
|
120
|
+
* - a hex string — `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` (the `#` is optional)
|
|
121
|
+
* - an `rgb()`/`rgba()` string in either legacy comma syntax (`rgb(41, 73, 229)`) or
|
|
122
|
+
* modern space syntax (`rgb(41 73 229 / 50%)`), with numbers or percentages
|
|
123
|
+
* - an `[r, g, b]` or `[r, g, b, a]` tuple
|
|
124
|
+
* - an object with `r`, `g`, `b` and optionally `a` — including another `Color`
|
|
125
|
+
*
|
|
126
|
+
* CSS named colors (`red`, `transparent`, …) are not supported.
|
|
127
|
+
*/
|
|
128
|
+
type ColorInput = Color | ColorTuple | RgbaObject | string;
|
|
129
|
+
/** Hue (0–360), saturation (0–100) and lightness (0–100). */
|
|
130
|
+
type Hsl = {
|
|
131
|
+
readonly hue: number;
|
|
132
|
+
readonly lightness: number;
|
|
133
|
+
readonly saturation: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* CIELAB: perceptual lightness (0–100), plus the green–red (`a`) and blue–yellow (`b`)
|
|
137
|
+
* axes, which are unbounded but in practice fall within ±128.
|
|
138
|
+
*/
|
|
139
|
+
type Lab = {
|
|
140
|
+
readonly a: number;
|
|
141
|
+
readonly b: number;
|
|
142
|
+
readonly lightness: number;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The color space a blend interpolates through.
|
|
146
|
+
*
|
|
147
|
+
* - `oklch` — perceptually uniform, and the only mode that carries hue as a hue, so a
|
|
148
|
+
* blend takes the short way round the wheel instead of through the grays in between
|
|
149
|
+
* - `lab` — perceptually uniform, interpolated on the rectangular axes
|
|
150
|
+
* - `lrgb` — linear RGB; avoids the muddy midpoints of naive RGB blending
|
|
151
|
+
* - `rgb` — naive channel-wise RGB; fastest, and what CSS `color-mix()` does in sRGB
|
|
152
|
+
*/
|
|
153
|
+
type InterpolationMode = "lab" | "lrgb" | "oklch" | "rgb";
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/adjustColorForProperContrast.d.ts
|
|
156
|
+
type AdjustColorForProperContrastOptions = {
|
|
157
|
+
/** What the foreground sits on. Never adjusted. */
|
|
158
|
+
readonly backgroundColor: ColorInput;
|
|
159
|
+
/** The color to nudge until it is legible. Returned untouched if it already is. */
|
|
160
|
+
readonly foregroundColor: ColorInput;
|
|
161
|
+
/** What the foreground is. Defaults to `paragraphText` (4.5:1). */
|
|
162
|
+
readonly shape?: ColorShape;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Walk `foregroundColor` towards white or black until it clears the contrast ratio
|
|
166
|
+
* `shape` requires against `backgroundColor`.
|
|
167
|
+
*
|
|
168
|
+
* Hue is pinned for the whole walk, so the result still reads as the color you passed in
|
|
169
|
+
* — a washed-out brand blue stays blue rather than drifting towards its neighbors. The
|
|
170
|
+
* direction is whichever gains contrast faster, reversing if it hits an extreme with the
|
|
171
|
+
* ratio still unmet. Text-grade ratios that can't be met either way settle on plain white
|
|
172
|
+
* or black, since at that point nothing else beats them.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* // Already legible, so nothing moves.
|
|
177
|
+
* adjustColorForProperContrast({
|
|
178
|
+
* foregroundColor: '#2949e5',
|
|
179
|
+
* backgroundColor: '#ffffff',
|
|
180
|
+
* }).toHex(); // '#2949e5'
|
|
181
|
+
*
|
|
182
|
+
* // A brand blue on itself, darkened until it separates.
|
|
183
|
+
* adjustColorForProperContrast({
|
|
184
|
+
* foregroundColor: '#2949e5',
|
|
185
|
+
* backgroundColor: '#2949e5',
|
|
186
|
+
* shape: 'nonText',
|
|
187
|
+
* }).toHex();
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
declare const adjustColorForProperContrast: ({ backgroundColor, foregroundColor, shape }: AdjustColorForProperContrastOptions) => Color;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/ColorScale.d.ts
|
|
193
|
+
type ColorScaleOptions = {
|
|
194
|
+
/**
|
|
195
|
+
* Quantize the scale into bands instead of leaving it continuous: a count of equally sized
|
|
196
|
+
* classes across the domain, or explicit class breaks.
|
|
197
|
+
*/
|
|
198
|
+
readonly classes?: number | number[];
|
|
199
|
+
/**
|
|
200
|
+
* Redistribute stops so that perceived lightness moves evenly from end to end. Worth
|
|
201
|
+
* turning on for any scale a reader is meant to rank by eye.
|
|
202
|
+
*/
|
|
203
|
+
readonly correctLightness?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* The input range, `[0, 1]` by default. Two values set the ends; supply one value per
|
|
206
|
+
* color to pin each color to a position, or more than two to warp the scale.
|
|
207
|
+
*/
|
|
208
|
+
readonly domain?: number[];
|
|
209
|
+
/** Bias the scale towards one end. Above 1 favors the start, below 1 the end. */
|
|
210
|
+
readonly gamma?: number;
|
|
211
|
+
/** The color space blends travel through. */
|
|
212
|
+
readonly mode?: InterpolationMode;
|
|
213
|
+
/** Trim `[start, end]` fractions off the scale, dropping its most extreme colors. */
|
|
214
|
+
readonly padding?: [number, number] | number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* A continuous scale between two or more colors — the chroma.js `scale` model, as an
|
|
218
|
+
* immutable class. Every configuration method returns a new scale, so a configured scale
|
|
219
|
+
* is safe to hold onto and share.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const scale = new ColorScale(['#2949e5', '#ffffff']);
|
|
224
|
+
* scale.at(0.5).toHex(); // the midpoint color
|
|
225
|
+
* scale.colors(5).map((color) => color.toHex()); // five evenly spaced colors
|
|
226
|
+
* scale.correctLightness().domain([0, 100]).at(72); // perceptually even, read in %
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare class ColorScale {
|
|
230
|
+
#private;
|
|
231
|
+
/**
|
|
232
|
+
* @param colors - the colors the scale runs through; a single color makes a flat scale
|
|
233
|
+
* @throws {TypeError} when `colors` is empty or `domain` has fewer than two values
|
|
234
|
+
*/
|
|
235
|
+
constructor(colors: readonly ColorInput[], options?: ColorScaleOptions);
|
|
236
|
+
/** The color at `value`, read through the scale's domain, classes, gamma and padding. */
|
|
237
|
+
at(value: number): Color;
|
|
238
|
+
/** `count` colors spread evenly across the domain. */
|
|
239
|
+
colors(count: number): Color[];
|
|
240
|
+
mode(mode: InterpolationMode): ColorScale;
|
|
241
|
+
domain(domain: number[]): ColorScale;
|
|
242
|
+
gamma(gamma: number): ColorScale;
|
|
243
|
+
padding(padding: [number, number] | number): ColorScale;
|
|
244
|
+
correctLightness(correctLightness?: boolean): ColorScale;
|
|
245
|
+
classes(classes: number | number[]): ColorScale;
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/getBestColorForText.d.ts
|
|
249
|
+
type BestColorForTextOptions = {
|
|
250
|
+
/** Always excluded from the result.*/
|
|
251
|
+
readonly backgroundColor: ColorInput;
|
|
252
|
+
/**
|
|
253
|
+
* Colors that are part of the palette but should not be considered as candidates.
|
|
254
|
+
* Useful in scenarios like the webinar pages color derivation logic, where we might include derived colors
|
|
255
|
+
* in the palette used by some fields, like `lowEmphasisTextColor`, but we want to exclude the derived colors
|
|
256
|
+
* from other fields, like `mainTextColor`.
|
|
257
|
+
*/
|
|
258
|
+
readonly exclude?: readonly ColorInput[];
|
|
259
|
+
/**
|
|
260
|
+
* The colors to choose from. Black and white are included automatically, so an empty/absent palette
|
|
261
|
+
* still yields whichever of the two has best contrast against `backgroundColor`.
|
|
262
|
+
*/
|
|
263
|
+
readonly palette?: readonly ColorInput[];
|
|
264
|
+
/** The type of text/shape that will use the resulting color. Defaults to `paragraphText` (4.5:1). */
|
|
265
|
+
readonly shape?: ColorShape;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Picks a color most suitable for a given text (or non-text) shape against the given background color.
|
|
269
|
+
* Accepts an optional color palette, but white and black are always included as options in addition to the palette.
|
|
270
|
+
* Also accepts a set of colors from the palette that should be excluded from consideration.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* getBestColorForText({ backgroundColor: '#2949e5' }).toHex(); // '#ffffff'
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
declare const getBestColorForText: ({ backgroundColor, exclude, palette, shape }: BestColorForTextOptions) => Color;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/getBrandDarkBackgroundColor.d.ts
|
|
280
|
+
/**
|
|
281
|
+
* Generates a dark background color from a given primary color, preserving the hue of the primary color.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* getBrandDarkBackgroundColor('#2949e5').toHex(); // '#242942'
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @see {@link getBrandLightBackgroundColor} for the light counterpart
|
|
289
|
+
*/
|
|
290
|
+
declare const getBrandDarkBackgroundColor: (_primaryColor: ColorInput) => Color;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/getBrandLightBackgroundColor.d.ts
|
|
293
|
+
/**
|
|
294
|
+
*
|
|
295
|
+
* Generates a light background color from a given primary color, preserving the hue of the primary color.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* getBrandLightBackgroundColor('#2949e5').toHex(); // '#ebeefd'
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @see {@link getBrandDarkBackgroundColor} for the dark counterpart
|
|
303
|
+
*/
|
|
304
|
+
declare const getBrandLightBackgroundColor: (_primaryColor: ColorInput) => Color;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/getBrandedColorScale.d.ts
|
|
307
|
+
type BrandColorScaleOptions = {
|
|
308
|
+
/** How many steps the scale is divided into. */
|
|
309
|
+
readonly steps?: number;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Builds a color scale using the derived light/dark background colors based on the given primary color,
|
|
313
|
+
* with the primary color slotted into the scale wherever it fits based on lightness.
|
|
314
|
+
*
|
|
315
|
+
* It's important to include the primary color in the scale because the light/dark derived background colors
|
|
316
|
+
* do not have the same saturation as the primary color, and we want the scale to reflect the vibrancy
|
|
317
|
+
* of the primary color.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* getBrandedColorScale('#2949e5').map((color) => color.toHex());
|
|
322
|
+
* // ['#ebeefd', '#d4dbfa', '#bdc8f7', '#a5b5f4', '#8da2f1', '#748eef',
|
|
323
|
+
* // '#5b7aec', '#4263e8', '#2949e5', '#2539ba', '#213080', '#171f45']
|
|
324
|
+
* // ^ the primary, at its own lightness
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
declare const getBrandedColorScale: (primaryColor: ColorInput, { steps }?: BrandColorScaleOptions) => Color[];
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/getColorLightnessClassification.d.ts
|
|
330
|
+
type ColorLightnessClassification = "dark" | "light" | "midtone" | "veryDark";
|
|
331
|
+
/**
|
|
332
|
+
* Classify a color's lightness based on relative luminance.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```ts
|
|
336
|
+
* getColorLightnessClassification('#000000'); // 'veryDark'
|
|
337
|
+
* getColorLightnessClassification('#2949e5'); // 'dark'
|
|
338
|
+
* getColorLightnessClassification('#7f7f7f'); // 'midtone'
|
|
339
|
+
* getColorLightnessClassification('#ffffff'); // 'light'
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
declare const getColorLightnessClassification: (color: ColorInput) => ColorLightnessClassification;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/getHeavyAccentedBackgroundColor.d.ts
|
|
345
|
+
type HeavyAccentedBackgroundColorOptions = {
|
|
346
|
+
readonly primaryColor?: ColorInput;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Get an accented version of a background color that is a two steps lighter/darker.
|
|
350
|
+
* Use this when the color contrast of the accented background color is not significant,
|
|
351
|
+
* such as for card/panel background colors.
|
|
352
|
+
*
|
|
353
|
+
* Accepts an optional primary color, used when the background color has been derived from the primary color,
|
|
354
|
+
* and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
|
|
355
|
+
* See {@link getSlightAccentedBackgroundColor} for a single step away from the background color instead of two.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* getHeavyAccentedBackgroundColor('#f5f5f5').toHex(); // '#cbcbcb'
|
|
360
|
+
* getHeavyAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#adbbf5'
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare const getHeavyAccentedBackgroundColor: (_backgroundColor: ColorInput, { primaryColor }?: HeavyAccentedBackgroundColorOptions) => Color;
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/getSlightAccentedBackgroundColor.d.ts
|
|
366
|
+
type SlightAccentedBackgroundColorOptions = {
|
|
367
|
+
readonly shouldReturnWhiteForWhiteBackground?: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Optional primary color, which is used when the background color is derived from the primary color,
|
|
370
|
+
* so we'll calculate the accented background color using a color scale.
|
|
371
|
+
*/
|
|
372
|
+
readonly primaryColor?: ColorInput;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Get an accented version of a background color that is a single step lighter/darker.
|
|
376
|
+
* Use this when the color contrast of the accented background color is not significant,
|
|
377
|
+
* such as for card/panel background colors.
|
|
378
|
+
*
|
|
379
|
+
* Accepts an optional primary color, used when the background color has been derived from the primary color,
|
|
380
|
+
* and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
|
|
381
|
+
* See {@link getHeavyAccentedBackgroundColor} for two steps away from the background color instead of one.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* getSlightAccentedBackgroundColor('#f5f5f5').toHex(); // '#e0e0e0'
|
|
386
|
+
* getSlightAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#cdd5f9'
|
|
387
|
+
* getSlightAccentedBackgroundColor('#ffffff', { shouldReturnWhiteForWhiteBackground: true }).toHex(); // '#ffffff'
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
declare const getSlightAccentedBackgroundColor: (_backgroundColor: ColorInput, { shouldReturnWhiteForWhiteBackground, primaryColor }?: SlightAccentedBackgroundColorOptions) => Color;
|
|
391
|
+
//#endregion
|
|
392
|
+
export { RgbaObject as C, colorContrastRatiosByShape as D, ColorShape as E, RgbTuple as S, Color as T, ColorInput as _, ColorLightnessClassification as a, InterpolationMode as b, getBrandedColorScale as c, BestColorForTextOptions as d, getBestColorForText as f, adjustColorForProperContrast as g, AdjustColorForProperContrastOptions as h, getHeavyAccentedBackgroundColor as i, getBrandLightBackgroundColor as l, ColorScaleOptions as m, getSlightAccentedBackgroundColor as n, getColorLightnessClassification as o, ColorScale as p, HeavyAccentedBackgroundColorOptions as r, BrandColorScaleOptions as s, SlightAccentedBackgroundColorOptions as t, getBrandDarkBackgroundColor as u, ColorTuple as v, RgbaTuple as w, Lab as x, Hsl as y };
|
|
393
|
+
//# sourceMappingURL=color-BD12TVX4.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"color-BD12TVX4.d.ts","names":[],"sources":["../src/colorContrastRatiosByShape.ts","../src/Color.ts","../src/types.ts","../src/adjustColorForProperContrast.ts","../src/ColorScale.ts","../src/getBestColorForText.ts","../src/getBrandDarkBackgroundColor.ts","../src/getBrandLightBackgroundColor.ts","../src/getBrandedColorScale.ts","../src/getColorLightnessClassification.ts","../src/getHeavyAccentedBackgroundColor.ts","../src/getSlightAccentedBackgroundColor.ts"],"mappings":";;cAAa;WACX;WACA;WACA;WACA;;;KAIU,0BAA0B;;;;;;;;;;;;;;cCyEzB;;;;;SAIJ,MAAM,OAAO,aAAa;SAK1B,QAAQ,KAAK,KAAK,iBAAY;SAK9B,QAAQ,KAAK,KAAK,iBAAY;;WAM5B;;WAGA;;WAGA;;WAGA;;;;;;EAOT,YAAY,OAAO;;EASnB;;EAKA;;EAKA;;EAKA;;EAKA,eAAe;EAIf,SAAS;EAIT,SAAS;;EAKT;;;;;EAQA;;;;;;;EAUA,SAAS,OAAO;;;;;;;;;;EAiBhB,QAAQ,gBAAgB;;EAKxB,OAAO,gBAAgB;;EAKvB,KAAK,eAAe,OAAM,oBAAiD;;EAK3E,MAAM,eAAe,OAAM,oBAAiD;;;;;EAQ5E,MACE,OAAO,YACP,gBACA,OAAM,oBACL;;EAwCH,UAAU,gBAAgB;;;;;;EAS1B,cAAc,oBAAoB;;;;;KC1QxB,YAAY,aAAa,eAAe;;KAGxC,aAAa,aAAa,eAAe,cAAc;;KAGvD,cAAc,aAAa,eAAe,cAAc;;KAGxD;WACD;WACA;WACA;WACA;;;;;;;;;;;;;KAcC,aAAa,QAAQ,aAAa;;KAGlC;WACD;WACA;WACA;;;;;;KAOC;WACD;WACA;WACA;;;;;;;;;;;KAYC;;;KC1BA;;WAED,iBAAiB;;WAGjB,iBAAiB;;WAGjB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6BN,iCACX,iBACA,iBACA,SACC,wCAAsC;;;KCzD7B;;;;;WAKD;;;;;WAMA;;;;;WAMA;;WAGA;;WAGA,OAAO;;WAGP;;;;;;;;;;;;;;;cAgDE;;;;;;EAmBX,YAAY,iBAAiB,cAAc,UAAS;;EAkEpD,GAAG,gBAAgB;;EAQnB,OAAO,gBAAgB;EAmBvB,KAAK,MAAM,oBAAoB;EAI/B,OAAO,mBAAmB;EAI1B,MAAM,gBAAgB;EAItB,QAAQ,qCAAqC;EAI7C,iBAAiB,6BAA0B;EAI3C,QAAQ,6BAA6B;;;;KCtN3B;;WAED,iBAAiB;;;;;;;WAQjB,mBAAmB;;;;;WAMnB,mBAAmB;;WAGnB,QAAQ;;;;;;;;;;;;cAaN,wBACX,iBACA,SACA,SACA,SACC,4BAA0B;;;;;;;;;;;;;cCnBhB,8BAA+B,eAAe,eAAa;;;;;;;;;;;;;;cCN3D,+BAAgC,eAAe,eAAa;;;KCd7D;;WAED;;;;;;;;;;;;;;;;;;cAmBE,uBACX,cAAc,cACZ,UAAqC,2BACtC;;;KC5BS;;;;;;;;;;;;cAqCC,kCACX,OAAO,eACN;;;KCpCS;WACD,eAAe;;;;;;;;;;;;;;;;;cAoBb,kCACX,kBAAkB,cAChB,iBAAgB,wCACjB;;;KCtBS;WACD;;;;;WAKA,eAAe;;;;;;;;;;;;;;;;;;cAoBb,mCACX,kBAAkB,cAEhB,qCACA,iBACC,yCACF"}
|