@rickosborne/css 2025.2.16
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 +736 -0
- package/angle.cjs +57 -0
- package/angle.cjs.map +6 -0
- package/angle.d.ts +16 -0
- package/angle.d.ts.map +1 -0
- package/angle.mjs +38 -0
- package/angle.mjs.map +6 -0
- package/color-parser.cjs +132 -0
- package/color-parser.cjs.map +6 -0
- package/color-parser.d.ts +28 -0
- package/color-parser.d.ts.map +1 -0
- package/color-parser.mjs +113 -0
- package/color-parser.mjs.map +6 -0
- package/colors.cjs +269 -0
- package/colors.cjs.map +6 -0
- package/colors.d.ts +193 -0
- package/colors.d.ts.map +1 -0
- package/colors.mjs +250 -0
- package/colors.mjs.map +6 -0
- package/css-error.cjs +39 -0
- package/css-error.cjs.map +6 -0
- package/css-error.d.ts +13 -0
- package/css-error.d.ts.map +1 -0
- package/css-error.mjs +20 -0
- package/css-error.mjs.map +6 -0
- package/distance.cjs +66 -0
- package/distance.cjs.map +6 -0
- package/distance.d.ts +37 -0
- package/distance.d.ts.map +1 -0
- package/distance.mjs +47 -0
- package/distance.mjs.map +6 -0
- package/format.cjs +78 -0
- package/format.cjs.map +6 -0
- package/format.d.ts +18 -0
- package/format.d.ts.map +1 -0
- package/format.mjs +59 -0
- package/format.mjs.map +6 -0
- package/href.cjs +37 -0
- package/href.cjs.map +6 -0
- package/href.d.ts +29 -0
- package/href.d.ts.map +1 -0
- package/href.mjs +17 -0
- package/href.mjs.map +6 -0
- package/index.cjs +27 -0
- package/index.cjs.map +6 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.mjs +10 -0
- package/index.mjs.map +6 -0
- package/package.json +114 -0
- package/tokenizer.cjs +87 -0
- package/tokenizer.cjs.map +6 -0
- package/tokenizer.d.ts +34 -0
- package/tokenizer.d.ts.map +1 -0
- package/tokenizer.mjs +68 -0
- package/tokenizer.mjs.map +6 -0
- package/units.cjs +68 -0
- package/units.cjs.map +6 -0
- package/units.d.ts +15 -0
- package/units.d.ts.map +1 -0
- package/units.mjs +49 -0
- package/units.mjs.map +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
# @rickosborne/css
|
|
2
|
+
|
|
3
|
+
Basic CSS utilities built on:
|
|
4
|
+
|
|
5
|
+
- [@rickosborne/typical](https://www.npmjs.com/package/@rickosborne/typical) for types
|
|
6
|
+
- [@rickosborne/guard](https://www.npmjs.com/package/@rickosborne/guard) for guards
|
|
7
|
+
- [@rickosborne/foundation](https://www.npmjs.com/package/@rickosborne/foundation) for basic utilities
|
|
8
|
+
|
|
9
|
+
This is not, in any way, a general-purpose CSS handling library.
|
|
10
|
+
It includes some very happy-path-oriented utilities, primarily intended for when you have control over the input.
|
|
11
|
+
|
|
12
|
+
> ⚠️⚠️⚠️ ***This library does not attempt to cover the various edge cases of the real world or the CSS spec.*** ⚠️⚠️⚠️
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Install via your favorite package manager.
|
|
16
|
+
|
|
17
|
+
Each package supports CommonJS `require`, ESM `import`, and TypeScript usage.
|
|
18
|
+
|
|
19
|
+
You also have a choice: barrel imports or direct imports.
|
|
20
|
+
|
|
21
|
+
Barrel imports mean you're going to require/import everything from the same package-level namespace:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// CommonJS
|
|
25
|
+
const { isPlainObject, isListOf } = require("@rickosborne/guard");
|
|
26
|
+
// ESM / TypeScript
|
|
27
|
+
import { isPlainObject, isListOf } from "@rickosborne/guard";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Implications:
|
|
31
|
+
|
|
32
|
+
- Nice and simple.
|
|
33
|
+
- Your build system needs to do tree-shaking well ... or you'll end up adding the entire package even if you only import two functions.
|
|
34
|
+
|
|
35
|
+
The other option is to use direct imports:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// CommonJS
|
|
39
|
+
const { isPlainObject } = require("@rickosborne/guard/is-object");
|
|
40
|
+
const { isListOf } = require("@rickosborne/guard/is-list-of");
|
|
41
|
+
// ESM / TypeScript
|
|
42
|
+
import { isPlainObject } from "@rickosborne/guard/is-object.js";
|
|
43
|
+
import { isListOf } from "@rickosborne/guard/is-list-of.js";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Implications:
|
|
47
|
+
|
|
48
|
+
- You (probably) don't have to worry about tree-shaking as your build (likely) ends up with only the functions you need.
|
|
49
|
+
|
|
50
|
+
If you're using a modern build system, there aren't any strong reasons to prefer one way over the other.
|
|
51
|
+
It's really just down to your personal preference.
|
|
52
|
+
|
|
53
|
+
### A quick note about file extensions
|
|
54
|
+
|
|
55
|
+
Do you need to use file extensions?
|
|
56
|
+
And if so, which extensions?
|
|
57
|
+
|
|
58
|
+
Honestly ... this is a dumpster fire question.
|
|
59
|
+
It really comes down to your own setup and configuration.
|
|
60
|
+
|
|
61
|
+
Within each package itself:
|
|
62
|
+
|
|
63
|
+
- The CommonJS files all have `.cjs` extensions.
|
|
64
|
+
- The ESM files all have `.mjs` extensions.
|
|
65
|
+
- Node subpath exports have been set up to send `.js` imports to the `.cjs` (via `require`) or `.mjs` (via `import`) files, depending on your setup.
|
|
66
|
+
|
|
67
|
+
So, in theory, the only extension which _won't_ work would be `.ts` because the source isn't included.
|
|
68
|
+
|
|
69
|
+
If you run into a problem with a particular configuration, file a GitHub issue with:
|
|
70
|
+
|
|
71
|
+
- Your `tsconfig.json`'s `module`, `moduleResolution`, and `target` settings.
|
|
72
|
+
- Your `package.json`'s `type` and `imports` settings.
|
|
73
|
+
- An example of another package which imports correctly for you.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
This package is licensed as [CC-BY-NC-SA-4.0] unless otherwise noted.
|
|
78
|
+
That is, Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
|
|
79
|
+
|
|
80
|
+
[CC-BY-NC-SA-4.0]: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
***
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
### Classes
|
|
88
|
+
|
|
89
|
+
#### CSSError
|
|
90
|
+
|
|
91
|
+
<a id="api-csserror"></a>
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
class CSSError extends Error
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Functions
|
|
98
|
+
|
|
99
|
+
#### angle01FromCSS
|
|
100
|
+
|
|
101
|
+
<a id="api-angle01fromcss"></a>
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
angle01FromCSS: (text: string | undefined, defaultUnit?: CSSAngleUnit) => number | undefined
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### colorTokensFromCSS
|
|
108
|
+
|
|
109
|
+
<a id="api-colortokensfromcss"></a>
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
colorTokensFromCSS: (text: string) => CSSColorTokens | undefined
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### convertBetweenUnits
|
|
116
|
+
|
|
117
|
+
<a id="api-convertbetweenunits"></a>
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
convertBetweenUnits: <Unit extends string, NumberFormat extends number>(original: number | undefined, fromUnit: Unit, toUnit: Unit, conversions: Readonly<Record<Unit, number>>, format?: (num: number) => NumberFormat) => NumberFormat | undefined
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Given a number and a lookup table of units, convert the number from the source units to the destination units.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
#### cssFormatAlpha01
|
|
127
|
+
|
|
128
|
+
<a id="api-cssformatalpha01"></a>
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
cssFormatAlpha01: (alpha: number | undefined, resolution?: number | undefined) => string
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Format a CSS alpha in the range [0,1] value to an optional resolution.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
#### cssFormatDimension
|
|
138
|
+
|
|
139
|
+
<a id="api-cssformatdimension"></a>
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
cssFormatDimension: (value: number, units?: string | undefined, resolution?: number | undefined) => string
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Format a number and its optional units as a CSS dimension.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
#### cssFormatHex
|
|
150
|
+
|
|
151
|
+
<a id="api-cssformathex"></a>
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
cssFormatHex: (hex: string, format?: "short" | "long") => string
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Format a CSS color hex, with optional short or long transformation.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
#### cssFormatPercent
|
|
161
|
+
|
|
162
|
+
<a id="api-cssformatpercent"></a>
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
cssFormatPercent: (value: number | undefined, resolution?: number | undefined) => string
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Format a number as a CSS percentage.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
#### cssNameFromHex
|
|
172
|
+
|
|
173
|
+
<a id="api-cssnamefromhex"></a>
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
cssNameFromHex: (hex: string | undefined) => CSSColorName | undefined
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Look up a CSS color name from its hex value.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
#### dimensionFromCSS
|
|
183
|
+
|
|
184
|
+
<a id="api-dimensionfromcss"></a>
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
dimensionFromCSS: (text: string | undefined) => OptionalDimensionPair
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### hexFromCSSName
|
|
191
|
+
|
|
192
|
+
<a id="api-hexfromcssname"></a>
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
hexFromCSSName: (name: string | undefined) => string | undefined
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Get the hex value for a CSS color name, if possible.
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
#### isAbsoluteLengthUnit
|
|
202
|
+
|
|
203
|
+
<a id="api-isabsolutelengthunit"></a>
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
isAbsoluteLengthUnit: (obj: unknown) => obj is CSSAbsoluteLengthUnit
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Type guard for [CSSAbsoluteLengthUnit](#api-cssabsolutelengthunit).
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
#### isAngleUnit
|
|
213
|
+
|
|
214
|
+
<a id="api-isangleunit"></a>
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
isAngleUnit: (obj: unknown) => obj is CSSAngleUnit
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Type guard for [CSSAngleUnit](#api-cssangleunit).
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
#### isColorName
|
|
224
|
+
|
|
225
|
+
<a id="api-iscolorname"></a>
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
isColorName: (obj: unknown) => obj is string
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Loose type guard for CSS colors. See [isCSSColorName](#api-iscsscolorname) for the more strict version.
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
#### isCSSColorName
|
|
235
|
+
|
|
236
|
+
<a id="api-iscsscolorname"></a>
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
isCSSColorName: (obj: unknown) => obj is CSSColorName
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Strict type guard for [CSSColorName](#api-csscolorname). See [isColorName](#api-iscolorname) for the more loose version.
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
#### isLengthUnit
|
|
246
|
+
|
|
247
|
+
<a id="api-islengthunit"></a>
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
isLengthUnit: (obj: unknown) => obj is CSSLengthUnit
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Type guard for [CSSLengthUnit](#api-csslengthunit).
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
#### isRelativeLengthUnit
|
|
257
|
+
|
|
258
|
+
<a id="api-isrelativelengthunit"></a>
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
isRelativeLengthUnit: (obj: unknown) => obj is CSSRelativeLengthUnit
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Type guard for [CSSRelativeLengthUnit](#api-cssrelativelengthunit).
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
#### isTransparentHex
|
|
268
|
+
|
|
269
|
+
<a id="api-istransparenthex"></a>
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
isTransparentHex: (hex: string) => boolean
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Whether the given hex would produce a fully transparent (alpha 0) color.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
#### readFromCSS
|
|
279
|
+
|
|
280
|
+
<a id="api-readfromcss"></a>
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
readFromCSS: (text: string) => CSSTokenReader
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Minimal CSS pull parser, which only supports the happy-path tokens expected in a CSS color expression. Does not support anywhere near the full CSS Colors spec, but it'll do in a pinch.
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
#### toCSSColorName
|
|
291
|
+
|
|
292
|
+
<a id="api-tocsscolorname"></a>
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
toCSSColorName: (name: unknown) => CSSColorName | undefined
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Interfaces
|
|
299
|
+
|
|
300
|
+
#### CSSColorToken
|
|
301
|
+
|
|
302
|
+
<a id="api-csscolortoken"></a>
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
export interface CSSColorToken<Type extends string = string>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### CSSErrorOptions
|
|
309
|
+
|
|
310
|
+
<a id="api-csserroroptions"></a>
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
export interface CSSErrorOptions extends ErrorOptions
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### CSSFunctionToken
|
|
317
|
+
|
|
318
|
+
<a id="api-cssfunctiontoken"></a>
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
export interface CSSFunctionToken extends CSSColorToken<"function">
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
#### CSSHexHashToken
|
|
325
|
+
|
|
326
|
+
<a id="api-csshexhashtoken"></a>
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
export interface CSSHexHashToken extends CSSColorToken<"hex">
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### CSSKeywordToken
|
|
333
|
+
|
|
334
|
+
<a id="api-csskeywordtoken"></a>
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
export interface CSSKeywordToken extends CSSColorToken<"keyword">
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
#### CSSLiteralToken
|
|
341
|
+
|
|
342
|
+
<a id="api-cssliteraltoken"></a>
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
export interface CSSLiteralToken extends CSSColorToken<"literal">
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### CSSNumberToken
|
|
349
|
+
|
|
350
|
+
<a id="api-cssnumbertoken"></a>
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
export interface CSSNumberToken extends CSSColorToken<"number">
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### CSSTokenReader
|
|
357
|
+
|
|
358
|
+
<a id="api-csstokenreader"></a>
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
export interface CSSTokenReader
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### CSSTokenReaderMatcher
|
|
365
|
+
|
|
366
|
+
<a id="api-csstokenreadermatcher"></a>
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
export interface CSSTokenReaderMatcher<Type extends CSSToken["type"] = CSSToken["type"]>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### FunctionColorToken
|
|
373
|
+
|
|
374
|
+
<a id="api-functioncolortoken"></a>
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
export interface FunctionColorToken
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### HexColorToken
|
|
381
|
+
|
|
382
|
+
<a id="api-hexcolortoken"></a>
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
export interface HexColorToken
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### NameColorToken
|
|
389
|
+
|
|
390
|
+
<a id="api-namecolortoken"></a>
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
export interface NameColorToken
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### TypeAliases
|
|
397
|
+
|
|
398
|
+
#### CSSAbsoluteLengthUnit
|
|
399
|
+
|
|
400
|
+
<a id="api-cssabsolutelengthunit"></a>
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
type CSSAbsoluteLengthUnit = "cm" | "mm" | "Q" | "in" | "pt" | "pc" | "px";
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### CSSAngleUnit
|
|
407
|
+
|
|
408
|
+
<a id="api-cssangleunit"></a>
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
type CSSAngleUnit = "%" | "deg" | "grad" | "rad" | "turn";
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Unit for a CSS angle.
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
#### CSSColorFunction
|
|
419
|
+
|
|
420
|
+
<a id="api-csscolorfunction"></a>
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
type CSSColorFunction = "color" | "rgb" | "rgba" | "hsl" | "hsla" | "hwb";
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
#### CSSColorName
|
|
427
|
+
|
|
428
|
+
<a id="api-csscolorname"></a>
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
type CSSColorName = keyof typeof HEX_FROM_NAME;
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
CSS Level 4 color name.
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
#### CSSColorTokens
|
|
438
|
+
|
|
439
|
+
<a id="api-csscolortokens"></a>
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
type CSSColorTokens = NameColorToken | HexColorToken | FunctionColorToken;
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### CSSLengthUnit
|
|
446
|
+
|
|
447
|
+
<a id="api-csslengthunit"></a>
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
type CSSLengthUnit = CSSRelativeLengthUnit | CSSAbsoluteLengthUnit;
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
#### CSSRelativeLengthUnit
|
|
454
|
+
|
|
455
|
+
<a id="api-cssrelativelengthunit"></a>
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
type CSSRelativeLengthUnit = "em" | "ex" | "cap" | "ch" | "ic" | "rem" | "lh" | "rlh" | "vw" | "vh" | "vi" | "vb" | "vmin" | "vmax" | "svw" | "lvw" | "dvw" | "svh" | "lvh" | "dvh" | "svi" | "lvi" | "dvi" | "svb" | "lvb" | "dvb" | "svmin" | "lvmin" | "dvmin" | "svmax" | "lvmax" | "dvmax";
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
#### CSSToken
|
|
462
|
+
|
|
463
|
+
<a id="api-csstoken"></a>
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
type CSSToken = CSSKeywordToken | CSSFunctionToken | CSSHexHashToken | CSSLiteralToken | CSSNumberToken;
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### DimensionPair
|
|
470
|
+
|
|
471
|
+
<a id="api-dimensionpair"></a>
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
type DimensionPair = [value: number, units: string | undefined];
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
A CSS dimension, a number and an optional unit, as a tuple.
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
#### OptionalDimensionPair
|
|
481
|
+
|
|
482
|
+
<a id="api-optionaldimensionpair"></a>
|
|
483
|
+
|
|
484
|
+
```typescript
|
|
485
|
+
type OptionalDimensionPair = [value: number | undefined, units: string | undefined];
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Variation of a [DimensionPair](#api-dimensionpair) where the value may not be present.
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
### Variables
|
|
492
|
+
|
|
493
|
+
#### ABSOLUTE_LENGTH_UNITS
|
|
494
|
+
|
|
495
|
+
<a id="api-absolute-length-units"></a>
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
ABSOLUTE_LENGTH_UNITS: Readonly<CSSAbsoluteLengthUnit[]>
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
List of [CSSAbsoluteLengthUnit](#api-cssabsolutelengthunit).
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
#### ANGLE_CONVERSIONS
|
|
505
|
+
|
|
506
|
+
<a id="api-angle-conversions"></a>
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
ANGLE_CONVERSIONS: Readonly<Record<CSSAngleUnit, number>>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
#### ANGLE_UNITS
|
|
513
|
+
|
|
514
|
+
<a id="api-angle-units"></a>
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
ANGLE_UNITS: Readonly<CSSAngleUnit[]>
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
List of [CSSAngleUnit](#api-cssangleunit).
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
#### COLOR_FUNCTIONS
|
|
524
|
+
|
|
525
|
+
<a id="api-color-functions"></a>
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
COLOR_FUNCTIONS: Readonly<CSSColorFunction[]>
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
#### HEX_FROM_NAME
|
|
532
|
+
|
|
533
|
+
<a id="api-hex-from-name"></a>
|
|
534
|
+
|
|
535
|
+
```typescript
|
|
536
|
+
HEX_FROM_NAME: Readonly<{
|
|
537
|
+
readonly AliceBlue: "#F0F8FF";
|
|
538
|
+
readonly AntiqueWhite: "#FAEBD7";
|
|
539
|
+
readonly Aqua: "#00FFFF";
|
|
540
|
+
readonly Aquamarine: "#7FFFD4";
|
|
541
|
+
readonly Azure: "#F0FFFF";
|
|
542
|
+
readonly Beige: "#F5F5DC";
|
|
543
|
+
readonly Bisque: "#FFE4C4";
|
|
544
|
+
readonly Black: "#000000";
|
|
545
|
+
readonly BlanchedAlmond: "#FFEBCD";
|
|
546
|
+
readonly Blue: "#0000FF";
|
|
547
|
+
readonly BlueViolet: "#8A2BE2";
|
|
548
|
+
readonly Brown: "#A52A2A";
|
|
549
|
+
readonly Burlywood: "#DEB887";
|
|
550
|
+
readonly CadetBlue: "#5F9EA0";
|
|
551
|
+
readonly Chartreuse: "#7FFF00";
|
|
552
|
+
readonly Chocolate: "#D2691E";
|
|
553
|
+
readonly Coral: "#FF7F50";
|
|
554
|
+
readonly CornflowerBlue: "#6495ED";
|
|
555
|
+
readonly Cornsilk: "#FFF8DC";
|
|
556
|
+
readonly Crimson: "#DC143C";
|
|
557
|
+
readonly Cyan: "#00FFFF";
|
|
558
|
+
readonly DarkBlue: "#00008B";
|
|
559
|
+
readonly DarkCyan: "#008B8B";
|
|
560
|
+
readonly DarkGoldenrod: "#B8860B";
|
|
561
|
+
readonly DarkGray: "#A9A9A9";
|
|
562
|
+
readonly DarkGreen: "#006400";
|
|
563
|
+
readonly DarkGrey: "#A9A9A9";
|
|
564
|
+
readonly DarkKhaki: "#BDB76B";
|
|
565
|
+
readonly DarkMagenta: "#8B008B";
|
|
566
|
+
readonly DarkOliveGreen: "#556B2F";
|
|
567
|
+
readonly DarkOrange: "#FF8C00";
|
|
568
|
+
readonly DarkOrchid: "#9932CC";
|
|
569
|
+
readonly DarkRed: "#8B0000";
|
|
570
|
+
readonly DarkSalmon: "#E9967A";
|
|
571
|
+
readonly DarkSeaGreen: "#8FBC8F";
|
|
572
|
+
readonly DarkSlateBlue: "#483D8B";
|
|
573
|
+
readonly DarkSlateGray: "#2F4F4F";
|
|
574
|
+
readonly DarkSlateGrey: "#2F4F4F";
|
|
575
|
+
readonly DarkTurquoise: "#00CED1";
|
|
576
|
+
readonly DarkViolet: "#9400D3";
|
|
577
|
+
readonly DeepPink: "#FF1493";
|
|
578
|
+
readonly DeepSkyBlue: "#00BFFF";
|
|
579
|
+
readonly DimGray: "#696969";
|
|
580
|
+
readonly DimGrey: "#696969";
|
|
581
|
+
readonly DodgerBlue: "#1E90FF";
|
|
582
|
+
readonly FireBrick: "#B22222";
|
|
583
|
+
readonly FloralWhite: "#FFFAF0";
|
|
584
|
+
readonly ForestGreen: "#228B22";
|
|
585
|
+
readonly Fuchsia: "#FF00FF";
|
|
586
|
+
readonly Gainsboro: "#DCDCDC";
|
|
587
|
+
readonly GhostWhite: "#F8F8FF";
|
|
588
|
+
readonly Gold: "#FFD700";
|
|
589
|
+
readonly Goldenrod: "#DAA520";
|
|
590
|
+
readonly Gray: "#808080";
|
|
591
|
+
readonly Green: "#008000";
|
|
592
|
+
readonly GreenYellow: "#ADFF2F";
|
|
593
|
+
readonly Grey: "#808080";
|
|
594
|
+
readonly Honeydew: "#F0FFF0";
|
|
595
|
+
readonly HotPink: "#FF69B4";
|
|
596
|
+
readonly IndianRed: "#CD5C5C";
|
|
597
|
+
readonly Indigo: "#4B0082";
|
|
598
|
+
readonly Ivory: "#FFFFF0";
|
|
599
|
+
readonly Khaki: "#F0E68C";
|
|
600
|
+
readonly Lavender: "#E6E6FA";
|
|
601
|
+
readonly LavenderBlush: "#FFF0F5";
|
|
602
|
+
readonly LawnGreen: "#7CFC00";
|
|
603
|
+
readonly LemonChiffon: "#FFFACD";
|
|
604
|
+
readonly Lightblue: "#ADD8E6";
|
|
605
|
+
readonly LightCoral: "#F08080";
|
|
606
|
+
readonly LightCyan: "#E0FFFF";
|
|
607
|
+
readonly LightGoldenrodYellow: "#FAFAD2";
|
|
608
|
+
readonly LightGray: "#D3D3D3";
|
|
609
|
+
readonly LightGreen: "#90EE90";
|
|
610
|
+
readonly LightGrey: "#D3D3D3";
|
|
611
|
+
readonly LightPink: "#FFB6C1";
|
|
612
|
+
readonly LightSalmon: "#FFA07A";
|
|
613
|
+
readonly LightSeaGreen: "#20B2AA";
|
|
614
|
+
readonly LightSkyBlue: "#87CEFA";
|
|
615
|
+
readonly LightSlateGray: "#778899";
|
|
616
|
+
readonly LightSlateGrey: "#778899";
|
|
617
|
+
readonly LightSteelblue: "#B0C4DE";
|
|
618
|
+
readonly LightYellow: "#FFFFE0";
|
|
619
|
+
readonly Lime: "#00FF00";
|
|
620
|
+
readonly LimeGreen: "#32CD32";
|
|
621
|
+
readonly Linen: "#FAF0E6";
|
|
622
|
+
readonly Magenta: "#FF00FF";
|
|
623
|
+
readonly Maroon: "#800000";
|
|
624
|
+
readonly MediumAquamarine: "#66CDAA";
|
|
625
|
+
readonly MediumBlue: "#0000CD";
|
|
626
|
+
readonly MediumOrchid: "#BA55D3";
|
|
627
|
+
readonly MediumPurple: "#9370DB";
|
|
628
|
+
readonly MediumSeaGreen: "#3CB371";
|
|
629
|
+
readonly MediumSlateBlue: "#7B68EE";
|
|
630
|
+
readonly MediumSpringGreen: "#00FA9A";
|
|
631
|
+
readonly MediumTurquoise: "#48D1CC";
|
|
632
|
+
readonly MediumVioletRed: "#C71585";
|
|
633
|
+
readonly MidnightBlue: "#191970";
|
|
634
|
+
readonly MintCream: "#F5FFFA";
|
|
635
|
+
readonly MistyRose: "#FFE4E1";
|
|
636
|
+
readonly Moccasin: "#FFE4B5";
|
|
637
|
+
readonly NavajoWhite: "#FFDEAD";
|
|
638
|
+
readonly Navy: "#000080";
|
|
639
|
+
readonly NavyBlue: "#9FAFDF";
|
|
640
|
+
readonly OldLace: "#FDF5E6";
|
|
641
|
+
readonly Olive: "#808000";
|
|
642
|
+
readonly OliveDrab: "#6B8E23";
|
|
643
|
+
readonly Orange: "#FFA500";
|
|
644
|
+
readonly OrangeRed: "#FF4500";
|
|
645
|
+
readonly Orchid: "#DA70D6";
|
|
646
|
+
readonly PaleGoldenrod: "#EEE8AA";
|
|
647
|
+
readonly PaleGreen: "#98FB98";
|
|
648
|
+
readonly PaleTurquoise: "#AFEEEE";
|
|
649
|
+
readonly PaleVioletRed: "#DB7093";
|
|
650
|
+
readonly PapayaWhip: "#FFEFD5";
|
|
651
|
+
readonly PeachPuff: "#FFDAB9";
|
|
652
|
+
readonly Peru: "#CD853F";
|
|
653
|
+
readonly Pink: "#FFC0CB";
|
|
654
|
+
readonly Plum: "#DDA0DD";
|
|
655
|
+
readonly PowderBlue: "#B0E0E6";
|
|
656
|
+
readonly Purple: "#800080";
|
|
657
|
+
readonly RebeccaPurple: "#663399";
|
|
658
|
+
readonly Red: "#FF0000";
|
|
659
|
+
readonly RosyBrown: "#BC8F8F";
|
|
660
|
+
readonly RoyalBlue: "#4169E1";
|
|
661
|
+
readonly SaddleBrown: "#8B4513";
|
|
662
|
+
readonly Salmon: "#FA8072";
|
|
663
|
+
readonly SandyBrown: "#F4A460";
|
|
664
|
+
readonly SeaGreen: "#2E8B57";
|
|
665
|
+
readonly Seashell: "#FFF5EE";
|
|
666
|
+
readonly Sienna: "#A0522D";
|
|
667
|
+
readonly Silver: "#C0C0C0";
|
|
668
|
+
readonly SkyBlue: "#87CEEB";
|
|
669
|
+
readonly SlateBlue: "#6A5ACD";
|
|
670
|
+
readonly SlateGray: "#708090";
|
|
671
|
+
readonly SlateGrey: "#708090";
|
|
672
|
+
readonly Snow: "#FFFAFA";
|
|
673
|
+
readonly SpringGreen: "#00FF7F";
|
|
674
|
+
readonly SteelBlue: "#4682B4";
|
|
675
|
+
readonly Tan: "#D2B48C";
|
|
676
|
+
readonly Teal: "#008080";
|
|
677
|
+
readonly Thistle: "#D8BFD8";
|
|
678
|
+
readonly Tomato: "#FF6347";
|
|
679
|
+
readonly transparent: "#00000000";
|
|
680
|
+
readonly Turquoise: "#40E0D0";
|
|
681
|
+
readonly Violet: "#EE82EE";
|
|
682
|
+
readonly Wheat: "#F5DEB3";
|
|
683
|
+
readonly White: "#FFFFFF";
|
|
684
|
+
readonly WhiteSmoke: "#F5F5F5";
|
|
685
|
+
readonly Yellow: "#FFFF00";
|
|
686
|
+
readonly YellowGreen: "#9ACD32";
|
|
687
|
+
}>
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
CSS Level 4 color names mapped to their hex values.
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
#### RELATIVE_LENGTH_UNITS
|
|
694
|
+
|
|
695
|
+
<a id="api-relative-length-units"></a>
|
|
696
|
+
|
|
697
|
+
```typescript
|
|
698
|
+
RELATIVE_LENGTH_UNITS: Readonly<CSSRelativeLengthUnit[]>
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
List of [CSSRelativeLengthUnit](#api-cssrelativelengthunit).
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
#### RENAMED_COLORS
|
|
705
|
+
|
|
706
|
+
<a id="api-renamed-colors"></a>
|
|
707
|
+
|
|
708
|
+
```typescript
|
|
709
|
+
RENAMED_COLORS: Partial<Record<CSSColorName, CSSColorName>>
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
Some color names share hex values. This maps to the value which would be returned by [cssNameFromHex](#api-cssnamefromhex).
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
#### RESOLUTION_BY_UNIT
|
|
716
|
+
|
|
717
|
+
<a id="api-resolution-by-unit"></a>
|
|
718
|
+
|
|
719
|
+
```typescript
|
|
720
|
+
RESOLUTION_BY_UNIT: Record<string, number | undefined>
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
Approximations of useful resolutions for various CSS units.
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
#### TRANSPARENT
|
|
727
|
+
|
|
728
|
+
<a id="api-transparent"></a>
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
TRANSPARENT = "transparent"
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
CSS color keyword for a color with full transparency (0 alpha).
|
|
735
|
+
|
|
736
|
+
|