dozy 1.0.53 → 1.0.55
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 +117 -1
- package/dist/assets/fonts/xaifont.ttf +0 -0
- package/dist/assets/fonts/xaifont.woff2 +0 -0
- package/dist/assets/fonts/{forthecode.ttf → xaiforcode.ttf} +0 -0
- package/dist/assets/fonts/xaiforcode.woff2 +0 -0
- package/dist/assets/fonts/{forthefont.ttf → xaiforfont.ttf} +0 -0
- package/dist/assets/fonts/xaiforfont.woff2 +0 -0
- package/dist/assets/reset.css +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/README-COLOR.md +0 -117
- package/dist/assets/fonts/forthecode.woff2 +0 -0
- package/dist/assets/fonts/forthefont.woff2 +0 -0
package/package.json
CHANGED
package/README-COLOR.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# Color Module
|
|
2
|
-
|
|
3
|
-
A powerful color manipulation module built on top of [culori](https://github.com/Evercoder/culori). It supports all CSS color spaces (RGB, HSL, OKLCH, etc.), smart parsing, and custom aliases.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Universal Support**: Works with Hex, RGB, HSL, OKLCH, P3, and named colors.
|
|
8
|
-
- **Smart Parsing**:
|
|
9
|
-
- Auto-detects Hex codes without `#` (e.g., `ff0000` -> `#ff0000`).
|
|
10
|
-
- Supports 3, 4, 6, and 8-digit Hex codes.
|
|
11
|
-
- Accepts `Color` objects directly (passthrough).
|
|
12
|
-
- **Custom Aliases**: Pre-defined short codes for common colors.
|
|
13
|
-
- **Flexible Inputs**: All functions accept `string | Color | any`.
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import {
|
|
19
|
-
smartParse,
|
|
20
|
-
smartString,
|
|
21
|
-
toHexString,
|
|
22
|
-
toRgbaArray,
|
|
23
|
-
getBrightness,
|
|
24
|
-
registerCustomColor,
|
|
25
|
-
} from 'dozy'
|
|
26
|
-
|
|
27
|
-
// Smart Parsing
|
|
28
|
-
smartParse('ff0000') // -> Color object for red
|
|
29
|
-
smartParse('abc') // -> Color object for #aabbcc (via auto-hex or custom alias)
|
|
30
|
-
smartParse('oklch(60% 0.15 50)') // -> Color object
|
|
31
|
-
|
|
32
|
-
// Smart String (returns CSS string)
|
|
33
|
-
smartString('ff0000') // -> "#ff0000"
|
|
34
|
-
smartString('red') // -> "red"
|
|
35
|
-
|
|
36
|
-
// Conversions
|
|
37
|
-
toHexString('rgb(255, 0, 0)') // -> "#ff0000"
|
|
38
|
-
toRgbString('#f00') // -> "rgb(255, 0, 0)"
|
|
39
|
-
toHslString('blue') // -> "hsl(240, 100%, 50%)"
|
|
40
|
-
|
|
41
|
-
// Brightness (0-1)
|
|
42
|
-
getBrightness('#000') // -> 0
|
|
43
|
-
getBrightness('#fff') // -> 1
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Pre-defined Aliases
|
|
47
|
-
|
|
48
|
-
| Alias | Color | Hex |
|
|
49
|
-
| ----- | ------------ | --------- |
|
|
50
|
-
| `v` | Black | `#000000` |
|
|
51
|
-
| `w` | White | `#FFFFFF` |
|
|
52
|
-
| `V` | Dark Grey | `#555555` |
|
|
53
|
-
| `W` | Light Grey | `#AAAAAA` |
|
|
54
|
-
| `R` | Dark Red | `#AA0000` |
|
|
55
|
-
| `r` | Light Red | `#FF5555` |
|
|
56
|
-
| `G` | Dark Green | `#00AA00` |
|
|
57
|
-
| `g` | Light Green | `#55FF55` |
|
|
58
|
-
| `B` | Dark Blue | `#0000AA` |
|
|
59
|
-
| `b` | Light Blue | `#5555FF` |
|
|
60
|
-
| `Y` | Dark Yellow | `#FFAA00` |
|
|
61
|
-
| `y` | Light Yellow | `#FFFF55` |
|
|
62
|
-
| `A` | Dark Cyan | `#00AAAA` |
|
|
63
|
-
| `a` | Light Cyan | `#55FFFF` |
|
|
64
|
-
| `P` | Dark Purple | `#AA00AA` |
|
|
65
|
-
| `p` | Light Purple | `#FF55FF` |
|
|
66
|
-
| `i` | Pink | `#FfC0CB` |
|
|
67
|
-
|
|
68
|
-
## API Reference
|
|
69
|
-
|
|
70
|
-
### `smartParse(input: string | Color | any, fallback?: string): Color | undefined`
|
|
71
|
-
|
|
72
|
-
Smartly parses a color string or object.
|
|
73
|
-
|
|
74
|
-
- **input**: The color string (e.g., `'#fff'`, `'ff0000'`, `'red'`) or a `Color` object.
|
|
75
|
-
- **fallback**: Optional color to return if parsing fails.
|
|
76
|
-
|
|
77
|
-
### `smartString(input: string | Color | any, fallback?: string): string | undefined`
|
|
78
|
-
|
|
79
|
-
Parses a color and returns a valid CSS string (Hex for sRGB, functional notation for others).
|
|
80
|
-
|
|
81
|
-
### `isValidColor(input: string | Color | any): boolean`
|
|
82
|
-
|
|
83
|
-
Checks if the input is a valid color.
|
|
84
|
-
|
|
85
|
-
### `getBrightness(input: string | Color | any): number`
|
|
86
|
-
|
|
87
|
-
Calculates brightness using Rec. 601 luma formula: `(R*299 + G*587 + B*114) / 1000`.
|
|
88
|
-
|
|
89
|
-
- Returns: `0` (black) to `1` (white).
|
|
90
|
-
|
|
91
|
-
### `toHexString(input: string | Color | any): string | undefined`
|
|
92
|
-
|
|
93
|
-
Converts input to a Hex string (e.g., `#ff0000`).
|
|
94
|
-
|
|
95
|
-
### `toRgbString(input: string | Color | any): string | undefined`
|
|
96
|
-
|
|
97
|
-
Converts input to `rgb()` or `rgba()` string.
|
|
98
|
-
|
|
99
|
-
### `toHslString(input: string | Color | any): string | undefined`
|
|
100
|
-
|
|
101
|
-
Converts input to `hsl()` or `hsla()` string.
|
|
102
|
-
|
|
103
|
-
### `toRgbaArray(input: string | Color | any): [number, number, number, number] | undefined`
|
|
104
|
-
|
|
105
|
-
Returns an array `[r, g, b, a]`.
|
|
106
|
-
|
|
107
|
-
- `r, g, b`: 0-255
|
|
108
|
-
- `a`: 0-1
|
|
109
|
-
|
|
110
|
-
### `registerCustomColor(name: string, color: string): void`
|
|
111
|
-
|
|
112
|
-
Registers a new global alias.
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
registerCustomColor('myBrand', '#123456')
|
|
116
|
-
smartParse('myBrand') // -> Color object for #123456
|
|
117
|
-
```
|
|
Binary file
|
|
Binary file
|