@sniptide/ui 0.1.1 → 0.2.0

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.
Files changed (38) hide show
  1. package/README.md +26 -7
  2. package/package.json +13 -31
  3. package/src/components/alert-dialog.tsx +3 -3
  4. package/src/components/avatar.tsx +1 -1
  5. package/src/components/badge.tsx +1 -1
  6. package/src/components/button.tsx +72 -13
  7. package/src/components/checkbox.tsx +24 -0
  8. package/src/components/combobox.tsx +127 -0
  9. package/src/components/dialog.tsx +3 -3
  10. package/src/components/dropdown-menu.tsx +35 -8
  11. package/src/components/form-error.tsx +33 -0
  12. package/src/components/input.tsx +1 -1
  13. package/src/components/kbd.tsx +1 -1
  14. package/src/components/logo.tsx +173 -31
  15. package/src/components/popover.tsx +40 -0
  16. package/src/components/progress.tsx +1 -1
  17. package/src/components/reveal.tsx +51 -0
  18. package/src/components/segmented-control.tsx +2 -2
  19. package/src/components/select.tsx +3 -3
  20. package/src/components/sheet.tsx +60 -4
  21. package/src/components/skeleton.tsx +15 -0
  22. package/src/components/spinner.tsx +33 -0
  23. package/src/components/step-slider.tsx +83 -0
  24. package/src/components/stripes.tsx +22 -12
  25. package/src/components/success-check.tsx +27 -0
  26. package/src/components/switch.tsx +2 -2
  27. package/src/components/table.tsx +124 -7
  28. package/src/components/tabs.tsx +1 -1
  29. package/src/components/textarea.tsx +1 -1
  30. package/src/components/toast.tsx +140 -0
  31. package/src/components/tooltip.tsx +1 -1
  32. package/src/fonts/OFL.txt +93 -0
  33. package/src/fonts/PaperMono-Regular.ttf +0 -0
  34. package/src/fonts/PaperMono[wght].ttf +0 -0
  35. package/src/lib/confetti.ts +112 -0
  36. package/src/lib/logo-paths.ts +17 -0
  37. package/src/styles/globals.css +121 -20
  38. package/src/styles/shadcn.css +677 -0
@@ -1,47 +1,189 @@
1
+ "use client"
2
+
3
+ import { launchConfetti } from "@sniptide/ui/lib/confetti"
4
+ import { markStripes, wordmarkPath } from "@sniptide/ui/lib/logo-paths"
1
5
  import { cn } from "@sniptide/ui/lib/utils"
6
+ import { useEffect, useId, useRef, useState } from "react"
7
+
8
+ const confettiClicks = 5
9
+ const confettiClickWindow = 1500
10
+
11
+ /**
12
+ * The tide that flows through the logo on click: a band that starts below the
13
+ * logo and travels past its top edge, clipped to the logo shapes. The
14
+ * `logo-flow` keyframes translate by percentages of the SVG view box, so the
15
+ * same band works for the mark and the wordmark.
16
+ */
17
+ function LogoFlow({
18
+ clipId,
19
+ gradientId,
20
+ x,
21
+ y,
22
+ width,
23
+ height,
24
+ onDone,
25
+ }: {
26
+ clipId: string
27
+ gradientId: string
28
+ x: number
29
+ y: number
30
+ width: number
31
+ height: number
32
+ onDone: () => void
33
+ }) {
34
+ return (
35
+ <g clipPath={`url(#${clipId})`}>
36
+ <defs>
37
+ <linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
38
+ <stop
39
+ offset="0"
40
+ className="[stop-color:var(--link)] dark:[stop-color:var(--primary)]"
41
+ stopOpacity="0"
42
+ />
43
+ <stop
44
+ offset="0.45"
45
+ className="[stop-color:var(--link)] dark:[stop-color:var(--primary)]"
46
+ />
47
+ <stop
48
+ offset="0.75"
49
+ className="[stop-color:color-mix(in_oklch,var(--link),white_55%)] dark:[stop-color:var(--link)]"
50
+ />
51
+ <stop
52
+ offset="1"
53
+ className="[stop-color:color-mix(in_oklch,var(--link),white_55%)] dark:[stop-color:var(--link)]"
54
+ stopOpacity="0"
55
+ />
56
+ </linearGradient>
57
+ </defs>
58
+ <rect
59
+ x={x}
60
+ y={y}
61
+ width={width}
62
+ height={height * 2}
63
+ fill={`url(#${gradientId})`}
64
+ className="animate-logo-flow motion-reduce:hidden"
65
+ onAnimationEnd={onDone}
66
+ />
67
+ </g>
68
+ )
69
+ }
70
+
71
+ const hoverGrow =
72
+ "origin-left transition-transform duration-150 motion-reduce:transition-none [a:hover_&]:scale-[1.04] [a:focus-visible_&]:scale-[1.04]"
73
+
74
+ export function LogoMark({
75
+ className,
76
+ flowing = false,
77
+ onFlowEnd = () => {},
78
+ }: {
79
+ className?: string
80
+ flowing?: boolean
81
+ onFlowEnd?: () => void
82
+ }) {
83
+ const id = useId().replace(/:/g, "")
84
+ const clipId = `${id}-mark-clip`
2
85
 
3
- // Sniptide mark from the Paper brand page. Fills follow the theme so it works in dark mode.
4
- export function LogoMark({ className }: { className?: string }) {
5
86
  return (
6
87
  <svg
7
- viewBox="0 0 160 160"
88
+ viewBox="2 2 20 19.27"
8
89
  xmlns="http://www.w3.org/2000/svg"
9
90
  aria-hidden="true"
10
- className={cn("size-7 shrink-0", className)}
91
+ className={cn("h-7 w-[29.05px] shrink-0 fill-[#2A26EC] dark:fill-white", className)}
11
92
  >
12
- <g className="fill-foreground">
13
- <rect x="0" y="0" width="80" height="32" />
14
- <rect x="43.6" y="96" width="80" height="32" />
15
- <rect x="123.6" y="128" width="36.4" height="32" />
16
- <rect x="0" y="64" width="4" height="64" />
17
- <rect x="6" y="64" width="3" height="64" />
18
- <rect x="10" y="64" width="2" height="64" />
19
- <rect x="43.6" y="32" width="4" height="64" />
20
- <rect x="49" y="32" width="3" height="64" />
21
- <rect x="53" y="32" width="2" height="64" />
22
- <rect x="156" y="32" width="4" height="32" />
23
- <rect x="151" y="32" width="3" height="32" />
24
- <rect x="156" y="96" width="4" height="32" />
25
- <rect x="151" y="96" width="3" height="32" />
26
- <rect x="80" y="156" width="43.6" height="4" />
27
- <rect x="80" y="151" width="43.6" height="3" />
28
- </g>
29
- <g className="fill-primary">
30
- <rect x="80" y="0" width="80" height="32" />
31
- <rect x="0" y="32" width="36.4" height="32" />
32
- <rect x="80" y="64" width="80" height="32" />
33
- <rect x="0" y="128" width="80" height="32" />
34
- </g>
93
+ {markStripes.map((points) => (
94
+ <polygon key={points} points={points} />
95
+ ))}
96
+ {flowing ? (
97
+ <>
98
+ <clipPath id={clipId}>
99
+ {markStripes.map((points) => (
100
+ <polygon key={points} points={points} />
101
+ ))}
102
+ </clipPath>
103
+ <LogoFlow
104
+ clipId={clipId}
105
+ gradientId={`${id}-mark-gradient`}
106
+ x={2}
107
+ y={2}
108
+ width={20}
109
+ height={19.27}
110
+ onDone={onFlowEnd}
111
+ />
112
+ </>
113
+ ) : null}
35
114
  </svg>
36
115
  )
37
116
  }
38
117
 
39
118
  export function Logo({ className }: { className?: string }) {
119
+ const id = useId().replace(/:/g, "")
120
+ const [flowing, setFlowing] = useState(false)
121
+ const wordmarkId = `${id}-wordmark`
122
+ const clipId = `${id}-wordmark-clip`
123
+
124
+ const ref = useRef<HTMLSpanElement>(null)
125
+
126
+ // The effect belongs to a logo that links somewhere, so a logo shown as plain
127
+ // branding stays still. The listener sits on the link so that keyboard
128
+ // activation triggers it too. Reduced motion skips it entirely. Five clicks
129
+ // in quick succession, each within a second and a half of the last, set off
130
+ // confetti.
131
+ useEffect(() => {
132
+ const link = ref.current?.closest("a")
133
+ if (!link) return
134
+ let clicks = 0
135
+ let lastClick = 0
136
+ const startFlow = () => {
137
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return
138
+ setFlowing(true)
139
+
140
+ const now = performance.now()
141
+ clicks = now - lastClick < confettiClickWindow ? clicks + 1 : 1
142
+ lastClick = now
143
+ if (clicks >= confettiClicks) {
144
+ clicks = 0
145
+ launchConfetti()
146
+ }
147
+ }
148
+ link.addEventListener("click", startFlow)
149
+ return () => link.removeEventListener("click", startFlow)
150
+ }, [])
151
+
40
152
  return (
41
- <span className={cn("flex items-center gap-2.5", className)}>
42
- <LogoMark />
43
- <span className="font-heading text-[25px] leading-7 font-bold tracking-[-0.01em]">
44
- SNIPTIDE
153
+ <span
154
+ ref={ref}
155
+ role="img"
156
+ aria-label="SNIPTIDE"
157
+ className={cn("flex shrink-0 items-center gap-2", hoverGrow, className)}
158
+ >
159
+ <LogoMark flowing={flowing} onFlowEnd={() => setFlowing(false)} />
160
+ <span className="shrink-0 pt-px">
161
+ <svg
162
+ viewBox="1341 238 4340 683"
163
+ xmlns="http://www.w3.org/2000/svg"
164
+ aria-hidden="true"
165
+ className="h-auto w-[130px] fill-[#0A0A0A] dark:fill-white"
166
+ >
167
+ <g transform="translate(0,1080) scale(0.1,-0.1)">
168
+ <path id={wordmarkId} d={wordmarkPath} />
169
+ </g>
170
+ {flowing ? (
171
+ <>
172
+ <clipPath id={clipId}>
173
+ <use href={`#${wordmarkId}`} transform="translate(0,1080) scale(0.1,-0.1)" />
174
+ </clipPath>
175
+ <LogoFlow
176
+ clipId={clipId}
177
+ gradientId={`${id}-wordmark-gradient`}
178
+ x={1341}
179
+ y={238}
180
+ width={4340}
181
+ height={683}
182
+ onDone={() => {}}
183
+ />
184
+ </>
185
+ ) : null}
186
+ </svg>
45
187
  </span>
46
188
  </span>
47
189
  )
@@ -0,0 +1,40 @@
1
+ "use client"
2
+
3
+ import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
4
+ import { cn } from "cn"
5
+
6
+ const Popover = PopoverPrimitive.Root
7
+ const PopoverTrigger = PopoverPrimitive.Trigger
8
+ const PopoverClose = PopoverPrimitive.Close
9
+ const PopoverTitle = PopoverPrimitive.Title
10
+
11
+ function PopoverContent({
12
+ className,
13
+ align = "start",
14
+ side,
15
+ sideOffset = 6,
16
+ ...props
17
+ }: PopoverPrimitive.Popup.Props &
18
+ Pick<PopoverPrimitive.Positioner.Props, "align" | "side" | "sideOffset">) {
19
+ return (
20
+ <PopoverPrimitive.Portal>
21
+ <PopoverPrimitive.Positioner
22
+ className="z-50"
23
+ align={align}
24
+ side={side}
25
+ sideOffset={sideOffset}
26
+ >
27
+ <PopoverPrimitive.Popup
28
+ data-slot="popover-content"
29
+ className={cn(
30
+ "rounded-lg border border-border bg-popover text-popover-foreground shadow-(--float-shadow) outline-none origin-[var(--transform-origin)] transition-[scale,opacity] duration-100 data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0",
31
+ className,
32
+ )}
33
+ {...props}
34
+ />
35
+ </PopoverPrimitive.Positioner>
36
+ </PopoverPrimitive.Portal>
37
+ )
38
+ }
39
+
40
+ export { Popover, PopoverClose, PopoverContent, PopoverTitle, PopoverTrigger }
@@ -4,7 +4,7 @@ import { cn } from "cn"
4
4
  function Progress({ className, ...props }: ProgressPrimitive.Root.Props) {
5
5
  return (
6
6
  <ProgressPrimitive.Root data-slot="progress" className={cn("w-full", className)} {...props}>
7
- <ProgressPrimitive.Track className="block h-1 w-full overflow-hidden bg-border">
7
+ <ProgressPrimitive.Track className="rounded-sm block h-1 w-full overflow-hidden bg-border">
8
8
  <ProgressPrimitive.Indicator className="block h-full bg-primary transition-[width]" />
9
9
  </ProgressPrimitive.Track>
10
10
  </ProgressPrimitive.Root>
@@ -0,0 +1,51 @@
1
+ "use client"
2
+
3
+ import { cn } from "cn"
4
+ import * as React from "react"
5
+
6
+ // Opens and closes a block by animating its height (a grid row from 0fr to 1fr) and fading it.
7
+ // The content mounts the first time it opens and then stays, so closing can animate and nothing
8
+ // loads before it is wanted. While closed it is inert, so it takes no focus. Under reduced motion
9
+ // it opens and closes at once.
10
+ function Reveal({
11
+ open,
12
+ id,
13
+ className,
14
+ children,
15
+ }: {
16
+ open: boolean
17
+ id?: string
18
+ className?: string
19
+ children: React.ReactNode
20
+ }) {
21
+ const [mounted, setMounted] = React.useState(open)
22
+ // Trails `open` by a frame on first mount, so the opening animates instead of jumping.
23
+ const [expanded, setExpanded] = React.useState(open)
24
+
25
+ React.useEffect(() => {
26
+ if (!open) {
27
+ setExpanded(false)
28
+ return
29
+ }
30
+ setMounted(true)
31
+ const frame = requestAnimationFrame(() => setExpanded(true))
32
+ return () => cancelAnimationFrame(frame)
33
+ }, [open])
34
+
35
+ return (
36
+ <div
37
+ id={id}
38
+ inert={!open}
39
+ className={cn(
40
+ "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
41
+ expanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
42
+ )}
43
+ >
44
+ <div className="min-h-0 overflow-hidden">
45
+ {mounted ? <div className={className}>{children}</div> : null}
46
+ </div>
47
+ </div>
48
+ )
49
+ }
50
+
51
+ export { Reveal }
@@ -27,7 +27,7 @@ function SegmentedControl<Value extends string>({
27
27
  <RadioGroup
28
28
  value={value}
29
29
  onValueChange={(next) => onValueChange(next as Value)}
30
- className={cn("flex gap-0.5 bg-muted p-[3px]", className)}
30
+ className={cn("flex gap-0.5 rounded-lg bg-muted p-[3px]", className)}
31
31
  {...props}
32
32
  >
33
33
  {options.map((option) => (
@@ -35,7 +35,7 @@ function SegmentedControl<Value extends string>({
35
35
  key={option.value}
36
36
  value={option.value}
37
37
  className={cn(
38
- "flex-1 py-[5px] text-center text-[13px] leading-[18px] text-muted-foreground outline-none select-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 data-checked:bg-background data-checked:font-medium data-checked:text-foreground data-checked:shadow-[0_1px_2px_rgb(0_0_0/0.08)] data-disabled:opacity-50",
38
+ "flex-1 rounded-md py-[5px] text-center text-[13px] leading-[18px] text-muted-foreground outline-none select-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 data-checked:bg-background data-checked:font-medium data-checked:text-foreground data-checked:shadow-[0_1px_2px_rgb(0_0_0/0.08)] data-disabled:opacity-50",
39
39
  itemClassName,
40
40
  )}
41
41
  >
@@ -11,7 +11,7 @@ function SelectTrigger({ className, children, ...props }: SelectPrimitive.Trigge
11
11
  <SelectPrimitive.Trigger
12
12
  data-slot="select-trigger"
13
13
  className={cn(
14
- "inline-flex h-9 items-center gap-2 border border-input bg-background px-3 text-sm text-foreground outline-none select-none focus-visible:border-primary data-popup-open:border-foreground disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
14
+ "inline-flex h-9 items-center gap-2 rounded-lg border border-input bg-background px-3 text-sm text-foreground outline-none select-none focus-visible:border-primary data-popup-open:border-foreground/40 disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
15
15
  className,
16
16
  )}
17
17
  {...props}
@@ -33,7 +33,7 @@ function SelectContent({ className, children, ...props }: SelectPrimitive.Popup.
33
33
  <SelectPrimitive.Popup
34
34
  data-slot="select-content"
35
35
  className={cn(
36
- "max-h-[var(--available-height)] min-w-[var(--anchor-width)] overflow-y-auto py-1 border border-foreground bg-popover text-popover-foreground shadow-[4px_4px_0_0_var(--foreground)] outline-none origin-[var(--transform-origin)] transition-[scale,opacity] duration-100 data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0",
36
+ "max-h-[var(--available-height)] min-w-[var(--anchor-width)] overflow-y-auto rounded-lg p-1 border border-border bg-popover text-popover-foreground shadow-(--float-shadow) outline-none origin-[var(--transform-origin)] transition-[scale,opacity] duration-100 data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0",
37
37
  className,
38
38
  )}
39
39
  {...props}
@@ -50,7 +50,7 @@ function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Prop
50
50
  <SelectPrimitive.Item
51
51
  data-slot="select-item"
52
52
  className={cn(
53
- "grid h-8 cursor-default grid-cols-[1fr_1rem] items-center gap-2 px-3 text-sm outline-none select-none data-highlighted:bg-muted",
53
+ "grid h-8 cursor-default grid-cols-[1fr_1rem] items-center gap-2 rounded-md px-3 text-sm outline-none select-none data-highlighted:bg-muted",
54
54
  className,
55
55
  )}
56
56
  {...props}
@@ -2,25 +2,29 @@
2
2
 
3
3
  import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
4
4
  import { cn } from "cn"
5
+ import { XIcon } from "lucide-react"
6
+ import type * as React from "react"
5
7
 
6
8
  const Sheet = SheetPrimitive.Root
7
9
  const SheetTrigger = SheetPrimitive.Trigger
8
10
  const SheetClose = SheetPrimitive.Close
9
11
  const SheetTitle = SheetPrimitive.Title
12
+ const SheetDescription = SheetPrimitive.Description
10
13
 
11
14
  function SheetContent({
12
15
  className,
13
16
  side = "left",
14
17
  ...props
15
- }: SheetPrimitive.Popup.Props & { side?: "left" | "right" }) {
18
+ }: SheetPrimitive.Popup.Props & { side?: "left" | "right" | "bottom" }) {
16
19
  return (
17
20
  <SheetPrimitive.Portal>
18
- <SheetPrimitive.Backdrop className="fixed inset-0 z-40 bg-foreground/30 transition-opacity data-ending-style:opacity-0 data-starting-style:opacity-0" />
21
+ <SheetPrimitive.Backdrop className="fixed inset-0 z-40 bg-foreground/30 transition-opacity dark:bg-black/60 data-ending-style:opacity-0 data-starting-style:opacity-0" />
19
22
  <SheetPrimitive.Popup
20
23
  data-slot="sheet-content"
21
24
  data-side={side}
25
+ // The side width stays unprefixed so a caller's width class can replace it.
22
26
  className={cn(
23
- "fixed inset-y-0 z-50 flex w-72 max-w-[85vw] flex-col bg-background outline-none transition-transform duration-200 data-[side=left]:left-0 data-[side=left]:border-r data-[side=right]:right-0 data-[side=right]:border-l data-[side=left]:data-starting-style:-translate-x-full data-[side=left]:data-ending-style:-translate-x-full data-[side=right]:data-starting-style:translate-x-full data-[side=right]:data-ending-style:translate-x-full",
27
+ "fixed z-50 flex w-72 max-w-[85vw] flex-col bg-background outline-none transition-transform duration-200 data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:border-l data-[side=bottom]:inset-x-0 data-[side=bottom]:w-auto data-[side=bottom]:max-w-none data-[side=bottom]:bottom-0 data-[side=bottom]:max-h-[85dvh] data-[side=bottom]:rounded-t-lg data-[side=bottom]:border-t data-[side=bottom]:pb-[env(safe-area-inset-bottom)] data-[side=left]:data-starting-style:-translate-x-full data-[side=left]:data-ending-style:-translate-x-full data-[side=right]:data-starting-style:translate-x-full data-[side=right]:data-ending-style:translate-x-full data-[side=bottom]:data-starting-style:translate-y-full data-[side=bottom]:data-ending-style:translate-y-full",
24
28
  className,
25
29
  )}
26
30
  {...props}
@@ -29,4 +33,56 @@ function SheetContent({
29
33
  )
30
34
  }
31
35
 
32
- export { Sheet, SheetClose, SheetContent, SheetTitle, SheetTrigger }
36
+ // A bottom sheet's title row: the title in the title-sm role and a close button at the end.
37
+ function SheetHeader({
38
+ title,
39
+ closeLabel,
40
+ className,
41
+ children,
42
+ }: {
43
+ title: React.ReactNode
44
+ closeLabel: string
45
+ className?: string
46
+ children?: React.ReactNode
47
+ }) {
48
+ return (
49
+ <div className={cn("flex shrink-0 items-center gap-2 px-4 pt-4 pb-2", className)}>
50
+ <SheetPrimitive.Title className="min-w-0 flex-1 truncate font-heading text-xl leading-7 font-bold tracking-[-0.02em]">
51
+ {title}
52
+ </SheetPrimitive.Title>
53
+ {children}
54
+ <SheetPrimitive.Close
55
+ aria-label={closeLabel}
56
+ className="-mr-1 inline-flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40"
57
+ >
58
+ <XIcon className="size-4" />
59
+ </SheetPrimitive.Close>
60
+ </div>
61
+ )
62
+ }
63
+
64
+ // The scrolling part of a sheet, padded to the 16px mobile gutter.
65
+ function SheetBody({ className, ...props }: React.ComponentProps<"div">) {
66
+ return (
67
+ <div
68
+ className={cn("min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-4", className)}
69
+ {...props}
70
+ />
71
+ )
72
+ }
73
+
74
+ // A 48px row in a sheet list: a 16px icon, a 14px label and an optional trailing value.
75
+ const sheetRowClass =
76
+ "flex min-h-12 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none hover:bg-muted focus-visible:bg-muted active:bg-muted aria-[current=page]:bg-muted [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground"
77
+
78
+ export {
79
+ Sheet,
80
+ SheetBody,
81
+ SheetClose,
82
+ SheetContent,
83
+ SheetDescription,
84
+ SheetHeader,
85
+ SheetTitle,
86
+ SheetTrigger,
87
+ sheetRowClass,
88
+ }
@@ -0,0 +1,15 @@
1
+ import { cn } from "cn"
2
+
3
+ // A placeholder block for content that is still loading. Reduced motion keeps it still.
4
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
5
+ return (
6
+ <div
7
+ data-slot="skeleton"
8
+ aria-hidden="true"
9
+ className={cn("animate-pulse rounded-md bg-muted motion-reduce:animate-none", className)}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ export { Skeleton }
@@ -0,0 +1,33 @@
1
+ import { cn } from "cn"
2
+
3
+ // The one loading indicator. Decorative by default (the control it sits in carries aria-busy or a
4
+ // status message); pass `label` where it stands alone. Reduced motion swaps the spin for a slow pulse.
5
+ function Spinner({
6
+ className,
7
+ label,
8
+ ...props
9
+ }: Omit<React.ComponentProps<"svg">, "children"> & { label?: string }) {
10
+ return (
11
+ <svg
12
+ data-slot="spinner"
13
+ viewBox="0 0 24 24"
14
+ fill="none"
15
+ stroke="currentColor"
16
+ strokeWidth={2.5}
17
+ strokeLinecap="round"
18
+ role={label ? "status" : undefined}
19
+ aria-label={label}
20
+ aria-hidden={label ? undefined : true}
21
+ className={cn(
22
+ "size-4 shrink-0 animate-spin motion-reduce:animate-[pulse_1.6s_ease-in-out_infinite]",
23
+ className,
24
+ )}
25
+ {...props}
26
+ >
27
+ <circle cx="12" cy="12" r="9" className="opacity-25" />
28
+ <path d="M21 12a9 9 0 0 0-9-9" />
29
+ </svg>
30
+ )
31
+ }
32
+
33
+ export { Spinner }
@@ -0,0 +1,83 @@
1
+ "use client"
2
+
3
+ import { Slider } from "@base-ui/react/slider"
4
+ import { cn } from "cn"
5
+ import type * as React from "react"
6
+
7
+ // A slider that snaps between a few named stops, such as Expires after: 1h, 1d, 1w, 1mo, 1y, Never.
8
+ // The chosen stop's name sits above the track, the track fills blue up to the thumb, and a dot
9
+ // marks every stop. Arrow keys move one stop at a time. The thumb and fill spring to the next
10
+ // stop with a slight overshoot, the thumb grows while it is held, and the label pops when the
11
+ // stop changes. Under reduced motion everything snaps.
12
+ function StepSlider<Value extends string>({
13
+ value,
14
+ onValueChange,
15
+ options,
16
+ className,
17
+ ...props
18
+ }: {
19
+ value: Value
20
+ onValueChange: (value: Value) => void
21
+ options: { value: Value; label: string; valueLabel?: React.ReactNode }[]
22
+ className?: string
23
+ "aria-label"?: string
24
+ "aria-labelledby"?: string
25
+ disabled?: boolean
26
+ }) {
27
+ const index = Math.max(
28
+ 0,
29
+ options.findIndex((option) => option.value === value),
30
+ )
31
+ const last = options.length - 1
32
+ const current = options[index]
33
+
34
+ return (
35
+ <Slider.Root
36
+ value={index}
37
+ min={0}
38
+ max={last}
39
+ step={1}
40
+ thumbAlignment="edge"
41
+ onValueChange={(next) => {
42
+ const option = options[next as number]
43
+ if (option && option.value !== value) onValueChange(option.value)
44
+ }}
45
+ className={cn("flex flex-col gap-2", className)}
46
+ disabled={props.disabled}
47
+ >
48
+ <span
49
+ key={current?.value}
50
+ aria-hidden="true"
51
+ className="animate-pop text-center text-sm font-medium text-link motion-reduce:animate-none"
52
+ >
53
+ {current?.valueLabel ?? current?.label}
54
+ </span>
55
+ <Slider.Control className="flex touch-none items-center select-none data-disabled:opacity-50">
56
+ <Slider.Track className="relative h-6 w-full rounded-md bg-muted">
57
+ <Slider.Indicator className="rounded-l-md bg-primary transition-[width] duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] in-data-dragging:transition-none motion-reduce:transition-none" />
58
+ {options.map((option, stop) => (
59
+ <span
60
+ key={option.value}
61
+ aria-hidden="true"
62
+ // The thumb is 32px wide and stays inside the track, so stops run from 16px in on
63
+ // each side.
64
+ style={{ left: `calc(16px + (100% - 32px) * ${last === 0 ? 0 : stop / last})` }}
65
+ className={cn(
66
+ "pointer-events-none absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full",
67
+ stop < index ? "bg-primary-foreground/70" : "bg-muted-foreground/50",
68
+ )}
69
+ />
70
+ ))}
71
+ <Slider.Thumb
72
+ aria-label={props["aria-label"]}
73
+ aria-labelledby={props["aria-labelledby"]}
74
+ getAriaValueText={(_, stop) => options[stop]?.label ?? ""}
75
+ className="h-6 w-8 rounded-md border border-border bg-background shadow-[0_1px_3px_rgb(0_0_0/0.18)] outline-none transition-[left,scale] duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] focus-visible:ring-3 focus-visible:ring-ring/30 active:scale-110 data-dragging:scale-110 data-dragging:transition-[scale] motion-reduce:transition-none dark:bg-foreground"
76
+ />
77
+ </Slider.Track>
78
+ </Slider.Control>
79
+ </Slider.Root>
80
+ )
81
+ }
82
+
83
+ export { StepSlider }
@@ -1,7 +1,9 @@
1
1
  import { cn } from "@sniptide/ui/lib/utils"
2
2
 
3
+ type Bar = [number, number, number?, number?]
4
+
3
5
  // Barcode stripes from the Paper auth screens' brand panel (720×900 artboard units).
4
- const ink: [number, number, number?, number?][] = [
6
+ const ink: Bar[] = [
5
7
  [0, 1],
6
8
  [5, 2],
7
9
  [11, 3],
@@ -33,7 +35,7 @@ const ink: [number, number, number?, number?][] = [
33
35
  [474, 4],
34
36
  ]
35
37
 
36
- const accent: [number, number, number?, number?][] = [
38
+ const accent: Bar[] = [
37
39
  [68, 72, 420, 480],
38
40
  [404, 16],
39
41
  [488, 24],
@@ -41,6 +43,21 @@ const accent: [number, number, number?, number?][] = [
41
43
  [668, 48],
42
44
  ]
43
45
 
46
+ // Hairlines are the thin 1-4 unit bars, blocks the wide ones. Dark mode dims the hairlines and
47
+ // lightens the blocks the way the brand's inverse logo does.
48
+ const hairlines = ink.filter(([, width]) => width <= 4)
49
+ const blocks = ink.filter(([, width]) => width > 4)
50
+
51
+ function Bars({ bars, className }: { bars: Bar[]; className: string }) {
52
+ return (
53
+ <g className={className}>
54
+ {bars.map(([x, width, y = 0, height = 900]) => (
55
+ <rect key={x} x={x} y={y} width={width} height={height} />
56
+ ))}
57
+ </g>
58
+ )
59
+ }
60
+
44
61
  export function Stripes({ className }: { className?: string }) {
45
62
  return (
46
63
  <svg
@@ -50,16 +67,9 @@ export function Stripes({ className }: { className?: string }) {
50
67
  preserveAspectRatio="xMinYMid slice"
51
68
  className={cn("absolute", className)}
52
69
  >
53
- <g className="fill-foreground">
54
- {ink.map(([x, width, y = 0, height = 900]) => (
55
- <rect key={x} x={x} y={y} width={width} height={height} />
56
- ))}
57
- </g>
58
- <g className="fill-primary">
59
- {accent.map(([x, width, y = 0, height = 900]) => (
60
- <rect key={x} x={x} y={y} width={width} height={height} />
61
- ))}
62
- </g>
70
+ <Bars bars={hairlines} className="fill-logo-hatch" />
71
+ <Bars bars={blocks} className="fill-logo-ink" />
72
+ <Bars bars={accent} className="fill-primary" />
63
73
  </svg>
64
74
  )
65
75
  }