@rokkit/core 1.1.4 → 1.1.6
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/dist/color-space.d.ts +8 -6
- package/package.json +2 -2
- package/src/color-space.js +20 -18
package/dist/color-space.d.ts
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
* Abstract base class for color space adapters.
|
|
3
3
|
*/
|
|
4
4
|
export class ColorSpace {
|
|
5
|
-
/**
|
|
6
|
-
* Factory method to create a ColorSpace adapter by name.
|
|
7
|
-
* @param {string} space - 'rgb', 'hsl', or 'oklch'
|
|
8
|
-
* @returns {ColorSpace}
|
|
9
|
-
*/
|
|
10
|
-
static create(space: string): ColorSpace;
|
|
11
5
|
/** @returns {string} */
|
|
12
6
|
get name(): string;
|
|
13
7
|
/** @returns {string} CSS color-mix interpolation space */
|
|
@@ -38,6 +32,14 @@ export class ColorSpace {
|
|
|
38
32
|
*/
|
|
39
33
|
themeColor(varName: string): string;
|
|
40
34
|
}
|
|
35
|
+
export namespace ColorSpace {
|
|
36
|
+
/**
|
|
37
|
+
* Factory method to create a ColorSpace adapter by name.
|
|
38
|
+
* @param {string} space - 'rgb', 'hsl', or 'oklch'
|
|
39
|
+
* @returns {ColorSpace}
|
|
40
|
+
*/
|
|
41
|
+
function create(space: string): ColorSpace;
|
|
42
|
+
}
|
|
41
43
|
export class RgbColorSpace extends ColorSpace {
|
|
42
44
|
fromHex(hex: any): string;
|
|
43
45
|
wrap(value: any): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"ramda": "^0.32.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@rokkit/icons": "1.1.
|
|
49
|
+
"@rokkit/icons": "1.1.6"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/color-space.js
CHANGED
|
@@ -165,24 +165,6 @@ export class ColorSpace {
|
|
|
165
165
|
themeColor(varName) {
|
|
166
166
|
return `color-mix(in ${this.mixSpace}, var(${varName}) calc(<alpha-value> * 100%), transparent)`
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Factory method to create a ColorSpace adapter by name.
|
|
171
|
-
* @param {string} space - 'rgb', 'hsl', or 'oklch'
|
|
172
|
-
* @returns {ColorSpace}
|
|
173
|
-
*/
|
|
174
|
-
static create(space) {
|
|
175
|
-
switch (space) {
|
|
176
|
-
case 'rgb':
|
|
177
|
-
return new RgbColorSpace()
|
|
178
|
-
case 'hsl':
|
|
179
|
-
return new HslColorSpace()
|
|
180
|
-
case 'oklch':
|
|
181
|
-
return new OklchColorSpace()
|
|
182
|
-
default:
|
|
183
|
-
throw new Error(`Unknown color space: ${space}`)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
168
|
}
|
|
187
169
|
|
|
188
170
|
// ── RGB adapter ─────────────────────────────────────────────────────────
|
|
@@ -306,3 +288,23 @@ export class OklchColorSpace extends ColorSpace {
|
|
|
306
288
|
return value
|
|
307
289
|
}
|
|
308
290
|
}
|
|
291
|
+
|
|
292
|
+
// ── Factory ─────────────────────────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Factory method to create a ColorSpace adapter by name.
|
|
296
|
+
* @param {string} space - 'rgb', 'hsl', or 'oklch'
|
|
297
|
+
* @returns {ColorSpace}
|
|
298
|
+
*/
|
|
299
|
+
ColorSpace.create = function create(space) {
|
|
300
|
+
switch (space) {
|
|
301
|
+
case 'rgb':
|
|
302
|
+
return new RgbColorSpace()
|
|
303
|
+
case 'hsl':
|
|
304
|
+
return new HslColorSpace()
|
|
305
|
+
case 'oklch':
|
|
306
|
+
return new OklchColorSpace()
|
|
307
|
+
default:
|
|
308
|
+
throw new Error(`Unknown color space: ${space}`)
|
|
309
|
+
}
|
|
310
|
+
}
|