@podoba/react 0.0.44 → 0.0.45

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": "@podoba/react",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "type": "module",
5
5
  "description": "podoba React components — React Aria Components + Tailwind primitives + layout, built with uic.",
6
6
  "repository": {
@@ -28,8 +28,8 @@
28
28
  "typecheck": "tsc --build"
29
29
  },
30
30
  "dependencies": {
31
- "@podoba/tokens": "^0.0.44",
32
- "@podoba/tailwind": "^0.0.44",
31
+ "@podoba/tokens": "^0.0.45",
32
+ "@podoba/tailwind": "^0.0.45",
33
33
  "react-aria-components": "1.18.0",
34
34
  "class-variance-authority": "0.7.1",
35
35
  "clsx": "2.1.1",
@@ -5,39 +5,57 @@ import { Label, Slider as RACSlider, type SliderProps as RACSliderProps, SliderT
5
5
  * Slider — a draggable value selector (single value or a range when `value`/
6
6
  * `defaultValue` is a two-number array). Built on React Aria Components `Slider`
7
7
  * (keyboard support, RTL, ARIA). The filled portion is brand-green and each
8
- * thumb carries its current value above it (respects `formatOptions`).
8
+ * thumb carries its current value next to it (respects `formatOptions`).
9
+ * `orientation="vertical"` renders a 12rem tall track with the minimum at the
10
+ * bottom and the value label to the right of each thumb.
9
11
  */
10
12
  export type SliderProps<T extends number | number[]> = RACSliderProps<T> & {
11
13
  /** Visible label (required for accessibility). */
12
14
  label: ReactNode
13
- /** Hide the value label above each thumb. */
15
+ /** Hide the value label next to each thumb. */
14
16
  hideValue?: boolean
15
17
  }
16
18
 
17
19
  export const Slider = <T extends number | number[]>({ label, hideValue, ...props }: SliderProps<T>) => (
18
20
  <RACSlider {...props} className="flex flex-col gap-1.5 data-[disabled]:opacity-50">
19
21
  <Label className="text-heading5 font-medium text-fg">{label}</Label>
20
- {/* mt-6 leaves room for the value label that sits above each thumb. */}
21
- <SliderTrack className="relative mt-6 flex h-6 w-full items-center">
22
+ <SliderTrack
23
+ className={({ orientation }) =>
24
+ orientation === 'vertical'
25
+ ? 'relative flex h-48 w-6 justify-center'
26
+ : // mt-6 leaves room for the value label that sits above each thumb.
27
+ 'relative mt-6 flex h-6 w-full items-center'
28
+ }
29
+ >
22
30
  {({ state }) => {
31
+ const isVertical = state.orientation === 'vertical'
23
32
  const start = state.values.length > 1 ? state.getThumbPercent(0) : 0
24
33
  const end = state.getThumbPercent(state.values.length - 1)
25
34
  return (
26
35
  <>
27
- <div className="h-1.5 w-full rounded-full bg-surface-muted" />
36
+ <div className={`rounded-full bg-surface-muted ${isVertical ? 'h-full w-1.5' : 'h-1.5 w-full'}`} />
28
37
  <div
29
- className="absolute h-1.5 rounded-full bg-brand-green"
30
- style={{ left: `${start * 100}%`, width: `${(end - start) * 100}%` }}
38
+ className={`absolute rounded-full bg-brand-green ${isVertical ? 'w-1.5' : 'h-1.5'}`}
39
+ style={
40
+ isVertical
41
+ ? { bottom: `${start * 100}%`, height: `${(end - start) * 100}%` }
42
+ : { left: `${start * 100}%`, width: `${(end - start) * 100}%` }
43
+ }
31
44
  />
32
45
  {state.values.map((_, i) => (
33
46
  <SliderThumb
34
47
  // biome-ignore lint/suspicious/noArrayIndexKey: thumbs are positional and fixed-count
35
48
  key={i}
36
49
  index={i}
37
- className="h-4 w-4 rounded-full border-2 border-fg bg-surface outline-none transition-transform data-[dragging]:scale-110 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
50
+ // React Aria positions the thumb along the track (`left` or, when
51
+ // vertical, `top`) with `translate(-50%, -50%)` but leaves the
52
+ // cross axis unset, so center it there ourselves.
53
+ className={`${isVertical ? 'left-1/2' : 'top-1/2'} h-4 w-4 rounded-full border-2 border-fg bg-surface outline-none transition-transform data-[dragging]:scale-110 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring`}
38
54
  >
39
55
  {hideValue ? null : (
40
- <span className="pointer-events-none absolute -top-6 left-1/2 -translate-x-1/2 whitespace-nowrap text-label font-medium tabular-nums text-fg">
56
+ <span
57
+ className={`pointer-events-none absolute whitespace-nowrap text-label font-medium tabular-nums text-fg ${isVertical ? 'top-1/2 left-full ml-2 -translate-y-1/2' : '-top-6 left-1/2 -translate-x-1/2'}`}
58
+ >
41
59
  {state.getThumbValueLabel(i)}
42
60
  </span>
43
61
  )}