hudini 0.18.0 → 0.18.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/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +2 -1
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/flat-icon-button/flat-icon-button.js +3 -3
- package/dist/components/flat-section-header/flat-section-header.js +1 -1
- package/dist/components/flat-text-button/flat-text-button.d.ts.map +1 -1
- package/dist/components/flat-text-button/flat-text-button.js +3 -3
- package/dist/components/flat-text-button/flat-text-button.js.map +1 -1
- package/dist/components/icon-button/icon-button.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.js +3 -2
- package/dist/components/icon-button/icon-button.js.map +1 -1
- package/dist/components/text-button/text-button.d.ts.map +1 -1
- package/dist/components/text-button/text-button.js +3 -3
- package/dist/components/text-button/text-button.js.map +1 -1
- package/dist/components/text-button/text-button.spec.js +10 -1
- package/dist/components/text-button/text-button.spec.js.map +1 -1
- package/dist/hudini.js +87 -40
- package/dist/hudini.min.js +1 -1
- package/dist/utils/color-variants.d.ts +6 -1
- package/dist/utils/color-variants.d.ts.map +1 -1
- package/dist/utils/color-variants.js +18 -5
- package/dist/utils/color-variants.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { type ColorKey } from 'phaser-wind';
|
|
|
2
2
|
/**
|
|
3
3
|
* Calculates a color variant by adjusting brightness.
|
|
4
4
|
*
|
|
5
|
-
* @param color - The base color (can be a Phaser Wind token like "blue-500" or a CSS color like "#3B82F6")
|
|
5
|
+
* @param color - The base color (can be a Phaser Wind token like "blue-500", a color name like "red", or a CSS color like "#3B82F6")
|
|
6
6
|
* @param tokenDiff - Amount to adjust the shade for color tokens. Positive values make it darker, negative lighter.
|
|
7
7
|
* For example: -400 for lighter (blue-500 → blue-100), +400 for darker (blue-500 → blue-900)
|
|
8
8
|
* @param colorDiff - Amount to lighten/darken CSS colors. Positive values lighten, negative values darken.
|
|
@@ -10,6 +10,7 @@ import { type ColorKey } from 'phaser-wind';
|
|
|
10
10
|
* @returns The adjusted color as a number
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
|
+
* - If only a color name is provided without a shade (e.g., "red"), it automatically adds "-500" as the default shade
|
|
13
14
|
* - If a color token is provided (e.g., "blue-500"), it uses the token system to calculate variants
|
|
14
15
|
* by adjusting the shade value with tokenDiff (clamped between 100-900)
|
|
15
16
|
* - If a CSS color is provided (hex or rgb), it uses Phaser's lighten/darken methods
|
|
@@ -17,6 +18,10 @@ import { type ColorKey } from 'phaser-wind';
|
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* ```typescript
|
|
21
|
+
* // Using color name only - defaults to -500
|
|
22
|
+
* const defaultRed = getColorVariant('red', 0, 0);
|
|
23
|
+
* // Returns red-500 color value
|
|
24
|
+
*
|
|
20
25
|
* // Using color token - lighter variant
|
|
21
26
|
* const lightBlue = getColorVariant('blue-500', -400, 0);
|
|
22
27
|
* // Returns blue-100 color value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-variants.d.ts","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"color-variants.d.ts","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,QAAQ,EAAiB,MAAM,aAAa,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,QAAQ,GAAG,MAAM,EACxB,WAAW,MAAM,EACjB,WAAW,MAAM,KAChB,MAsCF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Phaser from 'phaser';
|
|
2
|
-
import { Color } from 'phaser-wind';
|
|
2
|
+
import { Color, palette } from 'phaser-wind';
|
|
3
3
|
/**
|
|
4
4
|
* Calculates a color variant by adjusting brightness.
|
|
5
5
|
*
|
|
6
|
-
* @param color - The base color (can be a Phaser Wind token like "blue-500" or a CSS color like "#3B82F6")
|
|
6
|
+
* @param color - The base color (can be a Phaser Wind token like "blue-500", a color name like "red", or a CSS color like "#3B82F6")
|
|
7
7
|
* @param tokenDiff - Amount to adjust the shade for color tokens. Positive values make it darker, negative lighter.
|
|
8
8
|
* For example: -400 for lighter (blue-500 → blue-100), +400 for darker (blue-500 → blue-900)
|
|
9
9
|
* @param colorDiff - Amount to lighten/darken CSS colors. Positive values lighten, negative values darken.
|
|
@@ -11,6 +11,7 @@ import { Color } from 'phaser-wind';
|
|
|
11
11
|
* @returns The adjusted color as a number
|
|
12
12
|
*
|
|
13
13
|
* @remarks
|
|
14
|
+
* - If only a color name is provided without a shade (e.g., "red"), it automatically adds "-500" as the default shade
|
|
14
15
|
* - If a color token is provided (e.g., "blue-500"), it uses the token system to calculate variants
|
|
15
16
|
* by adjusting the shade value with tokenDiff (clamped between 100-900)
|
|
16
17
|
* - If a CSS color is provided (hex or rgb), it uses Phaser's lighten/darken methods
|
|
@@ -18,6 +19,10 @@ import { Color } from 'phaser-wind';
|
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* ```typescript
|
|
22
|
+
* // Using color name only - defaults to -500
|
|
23
|
+
* const defaultRed = getColorVariant('red', 0, 0);
|
|
24
|
+
* // Returns red-500 color value
|
|
25
|
+
*
|
|
21
26
|
* // Using color token - lighter variant
|
|
22
27
|
* const lightBlue = getColorVariant('blue-500', -400, 0);
|
|
23
28
|
* // Returns blue-100 color value
|
|
@@ -36,10 +41,18 @@ import { Color } from 'phaser-wind';
|
|
|
36
41
|
* ```
|
|
37
42
|
*/
|
|
38
43
|
export const getColorVariant = (color, tokenDiff, colorDiff) => {
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
// If only the color name is provided (without shade), validate and add -500 as default
|
|
45
|
+
let normalizedColor = color;
|
|
46
|
+
if (typeof color === 'string' && !color.includes('-') && !Color.isValidColorToken(color)) {
|
|
47
|
+
// Check if the color exists in the palette
|
|
48
|
+
if (color in palette && color !== 'black' && color !== 'white') {
|
|
49
|
+
normalizedColor = `${color}-500`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const colorRgb = Color.rgb(normalizedColor);
|
|
53
|
+
if (Color.isValidColorToken(normalizedColor)) {
|
|
41
54
|
// Token-based calculation
|
|
42
|
-
const parts =
|
|
55
|
+
const parts = normalizedColor.split('-');
|
|
43
56
|
const colorShade = parseInt(parts[1].toString(), 10);
|
|
44
57
|
const shadeMin = 100;
|
|
45
58
|
const shadeMax = 900;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-variants.js","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAgC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"color-variants.js","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgC,MAAM,aAAa,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAwB,EACxB,SAAiB,EACjB,SAAiB,EACT,EAAE;IACV,uFAAuF;IACvF,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QACzF,2CAA2C;QAC3C,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;YAC/D,eAAe,GAAG,GAAG,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2
2
|
"name": "hudini",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "🎩 Magical Phaser UI components - Reusable HUD elements for game development. Is magic, like a wizard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^3.2.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"phaser-wind": "0.9.
|
|
65
|
+
"phaser-wind": "0.9.1",
|
|
66
66
|
"font-awesome-for-phaser": "0.10.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|