@jcsoftdev/ui 0.1.4 → 0.1.5

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.
@@ -22,7 +22,7 @@ export interface GaugeChartProps {
22
22
  variant?: "semi" | "three-quarter";
23
23
  /** Filled arc (`progress`) or a pointer over the bands (`needle`). */
24
24
  mode?: "progress" | "needle";
25
- /** Colored bands. With `progress` they sit behind the arc and the arc takes the color of the band it is in. */
25
+ /** Colored bands. With `progress` the track stays neutral, the arc takes the color of the band it is in, and a band shows only while hovered or focused. */
26
26
  ranges?: readonly GaugeRange[];
27
27
  height?: number | "fill";
28
28
  /** Width / height ratio; sizes the drawing from the container width when `height` is not "fill". */
@@ -282,7 +282,7 @@ function GaugePlot({
282
282
  )
283
283
  }
284
284
  ) }) : null,
285
- bands.length === 0 ? /* @__PURE__ */ jsx(
285
+ bands.length === 0 || !needle ? /* @__PURE__ */ jsx(
286
286
  "path",
287
287
  {
288
288
  d: arcLine(cx, cy, mid, a0 + capAngle, a1 - capAngle),
@@ -291,7 +291,8 @@ function GaugePlot({
291
291
  strokeLinecap: roundedCaps ? "round" : "butt",
292
292
  style: { stroke: "var(--chart-grid)" }
293
293
  }
294
- ) : /* @__PURE__ */ jsx("g", { mask: roundedCaps ? `url(#${uid}-track)` : void 0, children: bandPaths.map((path, index) => {
294
+ ) : null,
295
+ bands.length > 0 ? /* @__PURE__ */ jsx("g", { mask: roundedCaps ? `url(#${uid}-track)` : void 0, children: bandPaths.map((path, index) => {
295
296
  const item = bands[index];
296
297
  if (!item || !path) return null;
297
298
  return /* @__PURE__ */ jsx(
@@ -300,14 +301,14 @@ function GaugePlot({
300
301
  d: path,
301
302
  width: band,
302
303
  color: rangeColor(item),
303
- opacity: needle ? 0.92 : 0.26,
304
- dimmed: focused != null && focused !== index,
304
+ opacity: needle ? 0.92 : focused === index ? 0.32 : 0,
305
+ dimmed: needle && focused != null && focused !== index,
305
306
  onEnter: (event) => nav.hover(index, event),
306
307
  onLeave: nav.leave
307
308
  },
308
309
  index
309
310
  );
310
- }) }),
311
+ }) }) : null,
311
312
  !needle && fraction > 0 ? /* @__PURE__ */ jsx(
312
313
  "path",
313
314
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcsoftdev/ui",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Token-driven React component library: React 19, Radix, Tailwind v4.",
5
5
  "author": "jcsoftdev",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@ export interface GaugeChartProps {
41
41
  variant?: "semi" | "three-quarter";
42
42
  /** Filled arc (`progress`) or a pointer over the bands (`needle`). */
43
43
  mode?: "progress" | "needle";
44
- /** Colored bands. With `progress` they sit behind the arc and the arc takes the color of the band it is in. */
44
+ /** Colored bands. With `progress` the track stays neutral, the arc takes the color of the band it is in, and a band shows only while hovered or focused. */
45
45
  ranges?: readonly GaugeRange[];
46
46
  height?: number | "fill";
47
47
  /** Width / height ratio; sizes the drawing from the container width when `height` is not "fill". */
@@ -406,7 +406,7 @@ function GaugePlot({
406
406
  </defs>
407
407
  ) : null}
408
408
 
409
- {bands.length === 0 ? (
409
+ {bands.length === 0 || !needle ? (
410
410
  <path
411
411
  d={arcLine(cx, cy, mid, a0 + capAngle, a1 - capAngle)}
412
412
  fill="none"
@@ -414,7 +414,8 @@ function GaugePlot({
414
414
  strokeLinecap={roundedCaps ? "round" : "butt"}
415
415
  style={{ stroke: "var(--chart-grid)" }}
416
416
  />
417
- ) : (
417
+ ) : null}
418
+ {bands.length > 0 ? (
418
419
  <g mask={roundedCaps ? `url(#${uid}-track)` : undefined}>
419
420
  {bandPaths.map((path, index) => {
420
421
  const item = bands[index];
@@ -426,15 +427,18 @@ function GaugePlot({
426
427
  d={path}
427
428
  width={band}
428
429
  color={rangeColor(item)}
429
- opacity={needle ? 0.92 : 0.26}
430
- dimmed={focused != null && focused !== index}
430
+ // In progress mode the bands behind the arc would show as a
431
+ // patchwork of tints next to it, so they stay invisible hit areas
432
+ // and only appear while explored.
433
+ opacity={needle ? 0.92 : focused === index ? 0.32 : 0}
434
+ dimmed={needle && focused != null && focused !== index}
431
435
  onEnter={(event) => nav.hover(index, event)}
432
436
  onLeave={nav.leave}
433
437
  />
434
438
  );
435
439
  })}
436
440
  </g>
437
- )}
441
+ ) : null}
438
442
 
439
443
  {!needle && fraction > 0 ? (
440
444
  <path