@vvedantb/ui 0.16.0 → 0.16.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/README.md CHANGED
@@ -1002,7 +1002,7 @@ import { DatePicker, DateTimePicker, MonthPicker } from "@vvedantb/ui";
1002
1002
  - `MonthPicker`: `value` "YYYY-MM" or "", with year navigation and a month grid. `min` and `max` are "YYYY-MM".
1003
1003
  - `Calendar`: the styled `DayPicker` for custom layouts (every `DayPicker` prop). `parseDateValue` and `formatDateValue` convert between "YYYY-MM-DD" and a local `Date`.
1004
1004
 
1005
- ## Slider (0.16.0)
1005
+ ## Slider (0.16.0, dark contrast and className props 0.16.1)
1006
1006
 
1007
1007
  shadcn's slider on `@radix-ui/react-slider` (a peer dependency), with package tokens.
1008
1008
 
@@ -1014,7 +1014,7 @@ import { LabeledSliderRow, Slider } from "@vvedantb/ui";
1014
1014
  <LabeledSliderRow id="temperature" label="Temperature" value={temp} onValueChange={setTemp} max={2} step={0.1} formatValue={(v) => v.map((n) => n.toFixed(1)).join("–")} minLabel="Precise" maxLabel="Creative" />
1015
1015
  ```
1016
1016
 
1017
- - `Slider`: every Radix `Root` prop (`value`, `defaultValue`, `min`, `max`, `step`, `orientation`, `disabled`, `onValueChange`, `onValueCommit`, and so on). It renders one thumb per value, so `[n]` gives one thumb and `[a, b]` a range. The track is `bg-default`, the range `bg-primary`, and the thumb a `size-4` circle on `bg-background` with the `Switch` focus ring. Disabled dims to 50%. A vertical slider needs a height from its parent or `className` (default `min-h-40`). The ref goes to `Root`.
1017
+ - `Slider`: every Radix `Root` prop (`value`, `defaultValue`, `min`, `max`, `step`, `orientation`, `disabled`, `onValueChange`, `onValueCommit`, and so on). It renders one thumb per value, so `[n]` gives one thumb and `[a, b]` a range. The track is `bg-default` (`dark:bg-muted/40`), the range `bg-primary`, and the thumb a `size-4` circle on `bg-background` with `border-border` (`dark:bg-foreground dark:border-muted`, a light thumb in dark mode) and the `Switch` focus ring. `trackClassName`, `rangeClassName` and `thumbClassName` merge after the defaults, so caller classes win; override a `dark:` default with a `dark:` class. Disabled dims to 50%. A vertical slider needs a height from its parent or `className` (default `min-h-40`). The ref goes to `Root`.
1018
1018
  - Names: `id`, `aria-label`, `aria-labelledby` and `aria-valuetext` go to the first thumb, the focusable `role="slider"` element, not `Root`. `thumbLabels` sets `aria-label` per thumb and wins over `aria-label` on the first. Without a name, Radix labels a two-thumb range "Minimum" and "Maximum". The thumb is a `<span>`, so `<Label htmlFor>` does not name it; pass `aria-labelledby` with the label's `id`.
1019
1019
  - `LabeledSliderRow`: the `LabeledSwitchRow` layout with the slider below. `id`, `label`, `description`, `icon`, `value`, `onValueChange`, `onValueCommit`, `min`, `max`, `step`, `disabled`, `thumbLabels`, `className`. `formatValue` sets the right-aligned value (default: values joined by an en dash). `minLabel` and `maxLabel` add captions under the ends. The label names the first thumb through `aria-labelledby`, unless `thumbLabels` is set.
1020
1020
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "license": "MIT",
5
5
  "description": "Shared React 19 UI for web apps: one JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), design-token CSS, shared Tailwind v4 CSS and a Tailwind preset.",
6
6
  "type": "module",
package/src/ui/slider.tsx CHANGED
@@ -5,6 +5,12 @@ import { cn } from "../utils/cn";
5
5
  type SliderProps = React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & {
6
6
  /** Accessible name per thumb, by index. Wins over `aria-label` on the first thumb. */
7
7
  thumbLabels?: string[];
8
+ /** Classes for the track, merged after the defaults so they win (`bg-default dark:bg-muted/40`). */
9
+ trackClassName?: string;
10
+ /** Classes for the filled range, merged after the defaults so they win (`bg-primary`). */
11
+ rangeClassName?: string;
12
+ /** Classes for every thumb, merged after the defaults so they win (`bg-background dark:bg-foreground dark:border-muted`). */
13
+ thumbClassName?: string;
8
14
  };
9
15
 
10
16
  // `id`, `aria-label`, `aria-labelledby` and `aria-valuetext` go to the first
@@ -19,6 +25,9 @@ const Slider = React.forwardRef<React.ComponentRef<typeof SliderPrimitive.Root>,
19
25
  "aria-labelledby": ariaLabelledBy,
20
26
  "aria-valuetext": ariaValueText,
21
27
  thumbLabels,
28
+ trackClassName,
29
+ rangeClassName,
30
+ thumbClassName,
22
31
  ...props
23
32
  },
24
33
  ref,
@@ -33,8 +42,18 @@ const Slider = React.forwardRef<React.ComponentRef<typeof SliderPrimitive.Root>,
33
42
  {...props}
34
43
  ref={ref}
35
44
  >
36
- <SliderPrimitive.Track className="relative grow overflow-hidden rounded-full bg-default data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5">
37
- <SliderPrimitive.Range className="absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full" />
45
+ <SliderPrimitive.Track
46
+ className={cn(
47
+ "relative grow overflow-hidden rounded-full bg-default dark:bg-muted/40 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",
48
+ trackClassName,
49
+ )}
50
+ >
51
+ <SliderPrimitive.Range
52
+ className={cn(
53
+ "absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full",
54
+ rangeClassName,
55
+ )}
56
+ />
38
57
  </SliderPrimitive.Track>
39
58
  {Array.from({ length: count }, (_, i) => (
40
59
  <SliderPrimitive.Thumb
@@ -43,7 +62,10 @@ const Slider = React.forwardRef<React.ComponentRef<typeof SliderPrimitive.Root>,
43
62
  aria-label={thumbLabels?.[i] ?? (i === 0 ? ariaLabel : undefined)}
44
63
  aria-labelledby={i === 0 ? ariaLabelledBy : undefined}
45
64
  aria-valuetext={i === 0 ? ariaValueText : undefined}
46
- className="block size-4 shrink-0 rounded-full border border-border bg-background shadow-sm transition-[box-shadow] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring data-[disabled]:cursor-not-allowed"
65
+ className={cn(
66
+ "block size-4 shrink-0 rounded-full border border-border bg-background shadow-sm transition-[box-shadow] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring data-[disabled]:cursor-not-allowed dark:border-muted dark:bg-foreground",
67
+ thumbClassName,
68
+ )}
47
69
  />
48
70
  ))}
49
71
  </SliderPrimitive.Root>