@kahitsan/ksui 0.36.0 → 0.36.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahitsan/ksui",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "ksui is a standalone set of SolidJS UI components for KahitSan/Hilinga and any SolidJS app. Published to the public npm registry and consumed as a normal dependency. Ships source under a `solid` export condition so the consumer's vite-plugin-solid compiles it with only solid-js externalized; it depends on nothing but solid-js + lucide-solid and injects its own CSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -32,6 +32,10 @@ const styles: Record<string, string> = {
|
|
|
32
32
|
"animate-shimmer": "ks-progress-shimmer",
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
// ProgressColor is derived from COLOR_MAP so adding a hue later flows here
|
|
36
|
+
// without re-syncing a hardcoded list.
|
|
37
|
+
export type ProgressColor = keyof typeof COLOR_MAP;
|
|
38
|
+
|
|
35
39
|
export interface ProgressBarProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
36
40
|
progress: number;
|
|
37
41
|
icon?: Component<{ size: number; class?: string }>;
|
|
@@ -45,6 +49,9 @@ export interface ProgressBarProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
|
45
49
|
// LiveTimer push the live countdown into the right slot while the
|
|
46
50
|
// total label sits on the left.
|
|
47
51
|
rightLabel?: string;
|
|
52
|
+
// Explicit color signal — class-substring sniffing broke when COLOR_AMBER
|
|
53
|
+
// was tokenized (4f6ed40 dropped the literal "amber" from the class).
|
|
54
|
+
color?: ProgressColor;
|
|
48
55
|
class?: string;
|
|
49
56
|
}
|
|
50
57
|
|
|
@@ -163,6 +170,7 @@ const ProgressBar: Component<ProgressBarProps> = (props) => {
|
|
|
163
170
|
"position",
|
|
164
171
|
"hidePercentage",
|
|
165
172
|
"rightLabel",
|
|
173
|
+
"color",
|
|
166
174
|
"class",
|
|
167
175
|
]);
|
|
168
176
|
|
|
@@ -184,7 +192,12 @@ const ProgressBar: Component<ProgressBarProps> = (props) => {
|
|
|
184
192
|
return { progress: Math.max(0, Math.min(100, raw)), overflow: Math.max(0, raw - 100) };
|
|
185
193
|
});
|
|
186
194
|
|
|
187
|
-
const colorInfo = createMemo(() =>
|
|
195
|
+
const colorInfo = createMemo(() => {
|
|
196
|
+
// Explicit color wins; fall back to class-substring sniffing for back-compat
|
|
197
|
+
// with every caller that still drives color via a "text-red-400"-style class.
|
|
198
|
+
if (local.color) return COLOR_MAP[local.color];
|
|
199
|
+
return extractColorInfo(classProp() ?? "");
|
|
200
|
+
});
|
|
188
201
|
const iconSize = createMemo(() => extractTextSize(classProp() ?? ""));
|
|
189
202
|
|
|
190
203
|
const containerClasses = createMemo(() =>
|
|
@@ -11,7 +11,7 @@ import Play from "lucide-solid/icons/play";
|
|
|
11
11
|
import AlertTriangle from "lucide-solid/icons/triangle-alert";
|
|
12
12
|
import Check from "lucide-solid/icons/check";
|
|
13
13
|
import Calendar from "lucide-solid/icons/calendar";
|
|
14
|
-
import ProgressBar from "../base/ProgressBar";
|
|
14
|
+
import ProgressBar, { type ProgressColor } from "../base/ProgressBar";
|
|
15
15
|
|
|
16
16
|
export interface LiveTimerProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class"> {
|
|
17
17
|
// Core timing
|
|
@@ -354,6 +354,29 @@ const LiveTimer: Component<LiveTimerProps> = (props) => {
|
|
|
354
354
|
return staticConfig().colorClass;
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
+
// Mirrors colorClass's scenario logic but returns a COLOR_MAP key for
|
|
358
|
+
// ProgressBar's `color` prop — the class strings above were tokenized
|
|
359
|
+
// (4f6ed40) so the fill's class-substring sniff can no longer recover
|
|
360
|
+
// the hue. COMPLETED had no color substring even pre-tokenization, so it
|
|
361
|
+
// relies on the explicit prop rather than ever reaching the back-compat path.
|
|
362
|
+
const colorName = createMemo<ProgressColor>(() => {
|
|
363
|
+
switch (scenario()) {
|
|
364
|
+
case SCENARIO_COUNTDOWN_TIMER: {
|
|
365
|
+
const p = progress();
|
|
366
|
+
return p <= 25 ? "green" : p <= 75 ? "amber" : "red";
|
|
367
|
+
}
|
|
368
|
+
case SCENARIO_COUNTDOWN_TO_START:
|
|
369
|
+
return "blue";
|
|
370
|
+
case SCENARIO_OPEN_TIMER:
|
|
371
|
+
return "green";
|
|
372
|
+
case SCENARIO_OVERDUE:
|
|
373
|
+
return "purple";
|
|
374
|
+
case SCENARIO_COMPLETED:
|
|
375
|
+
default:
|
|
376
|
+
return "slate";
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
|
|
357
380
|
const finalClass = createMemo(() => {
|
|
358
381
|
const user = local.class ?? "";
|
|
359
382
|
if (user.includes("border-") && user.includes("text-")) return user;
|
|
@@ -410,6 +433,7 @@ const LiveTimer: Component<LiveTimerProps> = (props) => {
|
|
|
410
433
|
position={staticConfig().position}
|
|
411
434
|
hidePercentage={resolvedHidePercentage()}
|
|
412
435
|
shimmer={staticConfig().shimmer}
|
|
436
|
+
color={colorName()}
|
|
413
437
|
class={finalClass()}
|
|
414
438
|
{...others}
|
|
415
439
|
/>
|
|
@@ -424,6 +448,7 @@ const LiveTimer: Component<LiveTimerProps> = (props) => {
|
|
|
424
448
|
hidePercentage
|
|
425
449
|
rightLabel={statusLabel()}
|
|
426
450
|
shimmer={staticConfig().shimmer}
|
|
451
|
+
color={colorName()}
|
|
427
452
|
class={finalClass()}
|
|
428
453
|
{...others}
|
|
429
454
|
/>
|