@sniptide/ui 0.2.2 → 0.4.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sniptide/ui
2
2
 
3
- Sniptide's shared React components (shadcn on Base UI), brand pieces (`Logo`, `Stripes`) and the
3
+ Sniptide's shared React components (shadcn on Base UI), the brand `Logo` and the
4
4
  Tailwind v4 theme. The Sniptide app uses it from this monorepo; the website installs it from npm.
5
5
 
6
6
  The package ships TypeScript source, so the consuming Next.js app compiles it.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sniptide/ui",
3
- "version": "0.2.2",
4
- "gitHead": "596ab8b740ac423be868ffd6e1108f858cc8f17b",
3
+ "version": "0.4.0",
4
+ "gitHead": "d74bebf044b1eb57318d9ed9f25b85e6e510a185",
5
5
  "description": "Sniptide's shared React components and Tailwind theme, used by the app and the website.",
6
6
  "license": "AGPL-3.0-only",
7
7
  "homepage": "https://sniptide.com",
@@ -5,7 +5,7 @@ import { cn } from "cn"
5
5
  import { AlertCircleIcon, XIcon } from "lucide-react"
6
6
  import * as React from "react"
7
7
 
8
- type ToastKind = "success" | "error" | "info"
8
+ type ToastKind = "success" | "error"
9
9
  type ToastAction = { label: string; run: () => void | Promise<void> }
10
10
  type ToastItem = {
11
11
  id: number
@@ -21,7 +21,7 @@ type ToastOptions = {
21
21
  duration?: number
22
22
  }
23
23
 
24
- const DURATION: Record<ToastKind, number> = { success: 3000, error: 6000, info: 3000 }
24
+ const DURATION: Record<ToastKind, number> = { success: 3000, error: 6000 }
25
25
  const ACTION_DURATION = 8000
26
26
  const MAX_VISIBLE = 3
27
27
  const EMPTY: ToastItem[] = []
@@ -59,12 +59,12 @@ function show(kind: ToastKind, message: string, options: ToastOptions = {}) {
59
59
  }
60
60
 
61
61
  // Feedback for actions that have no button or form of their own to report on, like a menu item.
62
- // `info` is neutral; pass `action` for something the reader can take back, like Undo.
62
+ // `success` confirms something that happened with a pink check, and `error` says what failed.
63
+ // Pass `action` for something the reader can take back, like Undo; it renders as a blue chip.
63
64
  // Mount <Toaster /> once near the root.
64
65
  const toast = {
65
66
  success: (message: string, options?: ToastOptions) => show("success", message, options),
66
67
  error: (message: string, options?: ToastOptions) => show("error", message, options),
67
- info: (message: string, options?: ToastOptions) => show("info", message, options),
68
68
  dismiss,
69
69
  }
70
70
 
@@ -88,28 +88,33 @@ function Toaster({
88
88
  () => EMPTY,
89
89
  )
90
90
 
91
+ // Phones stack toasts centered under the top bar; from 1024px they sit in the bottom-right
92
+ // corner at one width, so a stack lines up on its right edge. On touch screens the 24px buttons
93
+ // reach 40px through an invisible hit area.
91
94
  return (
92
95
  <div
93
96
  data-slot="toaster"
94
97
  className={cn(
95
- "pointer-events-none fixed inset-x-0 bottom-[calc(env(safe-area-inset-bottom)+5rem)] z-100 flex flex-col items-center gap-2 px-4 lg:bottom-6",
98
+ "pointer-events-none fixed inset-x-0 top-[calc(env(safe-area-inset-top)+3.75rem)] z-100 flex flex-col items-center gap-2 px-4 lg:top-auto lg:right-[calc(env(safe-area-inset-right)+1.5rem)] lg:bottom-6 lg:left-auto lg:w-80 lg:px-0",
96
99
  className,
97
100
  )}
98
101
  >
99
102
  {current.map((item) => (
100
103
  <div
101
104
  key={item.id}
105
+ data-slot="toast"
106
+ data-kind={item.kind}
102
107
  role={item.kind === "error" ? "alert" : "status"}
103
108
  className={cn(
104
- "pointer-events-auto flex max-w-sm items-center gap-2 rounded-lg border bg-popover py-2 pr-1.5 pl-3 text-[13px] text-popover-foreground shadow-md animate-in fade-in slide-in-from-bottom-2 duration-200 motion-reduce:animate-none",
109
+ "pointer-events-auto flex w-full max-w-sm min-h-12 items-center gap-3 rounded-lg border bg-popover py-2.5 pr-2.5 pl-4 text-[13px] leading-[18px] text-popover-foreground shadow-(--float-shadow) animate-in fade-in slide-in-from-top-2 duration-200 lg:slide-in-from-bottom-2 motion-reduce:animate-none",
105
110
  item.kind === "error" ? "border-destructive/40" : "border-border",
106
111
  )}
107
112
  >
108
113
  {item.kind === "error" ? (
109
114
  <AlertCircleIcon className="size-4 shrink-0 text-destructive" aria-hidden="true" />
110
- ) : item.kind === "success" ? (
111
- <SuccessCheck className="text-primary" />
112
- ) : null}
115
+ ) : (
116
+ <SuccessCheck className="text-highlight" />
117
+ )}
113
118
  <span className="min-w-0 flex-1">{item.message}</span>
114
119
  {item.action ? (
115
120
  <button
@@ -118,7 +123,7 @@ function Toaster({
118
123
  dismiss(item.id)
119
124
  void item.action?.run()
120
125
  }}
121
- className="rounded-md shrink-0 px-2 py-1 text-[13px] font-semibold text-link outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40"
126
+ className="relative h-6 shrink-0 rounded-md bg-primary px-2 text-[13px] font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/85 focus-visible:ring-2 focus-visible:ring-ring/40 active:translate-y-px pointer-coarse:after:absolute pointer-coarse:after:-inset-2"
122
127
  >
123
128
  {item.action.label}
124
129
  </button>
@@ -127,7 +132,7 @@ function Toaster({
127
132
  type="button"
128
133
  aria-label={dismissLabel}
129
134
  onClick={() => dismiss(item.id)}
130
- className="rounded-md flex size-6 shrink-0 items-center justify-center text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
135
+ className="relative flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 pointer-coarse:after:absolute pointer-coarse:after:-inset-2"
131
136
  >
132
137
  <XIcon className="size-3.5" />
133
138
  </button>
@@ -45,8 +45,6 @@
45
45
  --float-shadow: 0 1px 2px rgb(27 25 25 / 0.06), 0 8px 24px -6px rgb(27 25 25 / 0.14);
46
46
  --dialog-shadow: 0 2px 4px rgb(27 25 25 / 0.06), 0 24px 48px -12px rgb(27 25 25 / 0.22);
47
47
  --logo-primary: #2a26ec;
48
- --logo-ink: #1b1919;
49
- --logo-hatch: #000000;
50
48
  --link: #2a26ec;
51
49
  /* Pink is the second brand colour. It marks what stands out without being an action: search
52
50
  matches, stars, the peak of a chart. --pink is the surface with --pink-foreground on it;
@@ -107,8 +105,6 @@
107
105
  /* The inverse logo from the Paper brand page: its own deep blue, light grey blocks and dim
108
106
  hatching. */
109
107
  --logo-primary: #1b17c6;
110
- --logo-ink: #dfdfdf;
111
- --logo-hatch: #535151;
112
108
  /* One blue, two weights. Tide Blue fills buttons and chart bars in both themes (white on it is
113
109
  8.1:1) but is too dark to read as text on these surfaces (2.3:1), so links, focus rings,
114
110
  code keywords and blue collection icons use its light tint, the same one the landing uses
@@ -170,8 +166,6 @@
170
166
  --color-sidebar-border: var(--sidebar-border);
171
167
  --color-sidebar-ring: var(--sidebar-ring);
172
168
  --color-logo-primary: var(--logo-primary);
173
- --color-logo-ink: var(--logo-ink);
174
- --color-logo-hatch: var(--logo-hatch);
175
169
  --color-link: var(--link);
176
170
  --color-pink: var(--pink);
177
171
  --color-pink-foreground: var(--pink-foreground);
@@ -1,75 +0,0 @@
1
- import { cn } from "@sniptide/ui/lib/utils"
2
-
3
- type Bar = [number, number, number?, number?]
4
-
5
- // Barcode stripes from the Paper auth screens' brand panel (720×900 artboard units).
6
- const ink: Bar[] = [
7
- [0, 1],
8
- [5, 2],
9
- [11, 3],
10
- [18, 4],
11
- [32, 36],
12
- [140, 1],
13
- [145, 2],
14
- [151, 3],
15
- [158, 4],
16
- [172, 72],
17
- [244, 1],
18
- [249, 2],
19
- [255, 3],
20
- [262, 4],
21
- [276, 1],
22
- [281, 2],
23
- [287, 3],
24
- [294, 4],
25
- [308, 1],
26
- [313, 2],
27
- [319, 3],
28
- [326, 4],
29
- [340, 48],
30
- [388, 16, 280, 620],
31
- [420, 36],
32
- [456, 1],
33
- [461, 2],
34
- [467, 3],
35
- [474, 4],
36
- ]
37
-
38
- const accent: Bar[] = [
39
- [68, 72, 420, 480],
40
- [404, 16],
41
- [488, 24],
42
- [584, 48],
43
- [668, 48],
44
- ]
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
-
61
- export function Stripes({ className }: { className?: string }) {
62
- return (
63
- <svg
64
- viewBox="0 0 720 900"
65
- xmlns="http://www.w3.org/2000/svg"
66
- aria-hidden="true"
67
- preserveAspectRatio="xMinYMid slice"
68
- className={cn("absolute", className)}
69
- >
70
- <Bars bars={hairlines} className="fill-logo-hatch" />
71
- <Bars bars={blocks} className="fill-logo-ink" />
72
- <Bars bars={accent} className="fill-primary" />
73
- </svg>
74
- )
75
- }