@boyernick/standard-ui-react 0.1.1-canary.9 → 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 (82) hide show
  1. package/package.json +5 -3
  2. package/src/accordion.tsx +5 -2
  3. package/src/alert-dialog.tsx +1 -1
  4. package/src/attachment.tsx +5 -2
  5. package/src/autocomplete.tsx +4 -3
  6. package/src/block-editor.tsx +1747 -0
  7. package/src/brand.tsx +2 -2
  8. package/src/breadcrumb.tsx +14 -7
  9. package/src/button.tsx +22 -11
  10. package/src/calendar.tsx +6 -3
  11. package/src/carousel.tsx +220 -53
  12. package/src/checkbox.tsx +3 -2
  13. package/src/code-block.tsx +66 -5
  14. package/src/collapsible.tsx +4 -2
  15. package/src/combobox.tsx +4 -3
  16. package/src/command.tsx +27 -12
  17. package/src/dialog.tsx +33 -10
  18. package/src/empty.tsx +4 -4
  19. package/src/field.tsx +4 -3
  20. package/src/filter-group.tsx +143 -0
  21. package/src/icons.tsx +28 -1
  22. package/src/illustrations.tsx +219 -141
  23. package/src/index.ts +238 -18
  24. package/src/input.tsx +8 -5
  25. package/src/kbd.tsx +10 -4
  26. package/src/lib/focus.ts +41 -0
  27. package/src/lib/popup.ts +1 -1
  28. package/src/lifeline/company-icon.tsx +71 -0
  29. package/src/lifeline/index.ts +42 -0
  30. package/src/lifeline/lifeline-data.ts +97 -0
  31. package/src/lifeline/lifeline-desktop.tsx +204 -0
  32. package/src/lifeline/lifeline-event.tsx +108 -0
  33. package/src/lifeline/lifeline-fireworks.tsx +302 -0
  34. package/src/lifeline/lifeline-hover-image.tsx +269 -0
  35. package/src/lifeline/lifeline-icons.tsx +39 -0
  36. package/src/lifeline/lifeline-intro-timing.ts +105 -0
  37. package/src/lifeline/lifeline-labels.tsx +24 -0
  38. package/src/lifeline/lifeline-layout.ts +1 -0
  39. package/src/lifeline/lifeline-legend.tsx +31 -0
  40. package/src/lifeline/lifeline-lightbox.tsx +309 -0
  41. package/src/lifeline/lifeline-marker.tsx +183 -0
  42. package/src/lifeline/lifeline-people.tsx +99 -0
  43. package/src/lifeline/lifeline-photos.tsx +366 -0
  44. package/src/lifeline/lifeline-shell.tsx +135 -0
  45. package/src/lifeline/lifeline-utils.ts +83 -0
  46. package/src/lifeline/lifeline-vertical.tsx +482 -0
  47. package/src/lifeline/lifeline.tsx +69 -0
  48. package/src/lifeline/types.ts +112 -0
  49. package/src/lifeline/use-lifeline-intro.ts +130 -0
  50. package/src/lifeline/use-lifeline-scroll.ts +1011 -0
  51. package/src/lifeline/use-lifeline-vertical-scroll.ts +271 -0
  52. package/src/menubar.tsx +9 -2
  53. package/src/minimap.tsx +296 -0
  54. package/src/modal.tsx +608 -0
  55. package/src/navigation-menu.tsx +338 -67
  56. package/src/number-field.tsx +336 -61
  57. package/src/otp-field.tsx +4 -3
  58. package/src/pagination.tsx +262 -42
  59. package/src/password-protection.tsx +345 -0
  60. package/src/popover.tsx +1 -1
  61. package/src/progress.tsx +5 -0
  62. package/src/questionnaire.tsx +284 -0
  63. package/src/radio.tsx +4 -2
  64. package/src/scroll-area.tsx +4 -1
  65. package/src/select.tsx +5 -2
  66. package/src/sidebar.tsx +113 -28
  67. package/src/slider.tsx +66 -6
  68. package/src/sounds.tsx +6 -10
  69. package/src/spinner.tsx +105 -32
  70. package/src/switch.tsx +4 -1
  71. package/src/table.tsx +82 -15
  72. package/src/tabs.tsx +189 -38
  73. package/src/text-animate.tsx +71 -28
  74. package/src/textarea.tsx +6 -1
  75. package/src/timeline.tsx +378 -0
  76. package/src/toast.tsx +214 -35
  77. package/src/toggle.tsx +4 -2
  78. package/src/toolbar.tsx +12 -7
  79. package/src/tooltip.tsx +43 -3
  80. package/src/video-player.tsx +396 -127
  81. package/src/image-modal.tsx +0 -110
  82. package/src/markdown-editor.tsx +0 -302
@@ -1,167 +1,245 @@
1
- import type { SVGProps } from "react"
1
+ import type { ComponentProps, ReactNode } from "react"
2
2
  import { cn } from "./lib/cn"
3
3
 
4
- export type IllustrationProps = SVGProps<SVGSVGElement>
4
+ /**
5
+ * Small, composition-based illustrations for empty states.
6
+ *
7
+ * Built from divs and theme tokens rather than SVG paths, so they follow the
8
+ * palette into dark mode instead of carrying baked-in colours. They are
9
+ * deliberately abstract and monochrome — a miniature of the thing that is
10
+ * missing, not a picture about it. Nothing here uses a brand colour: an empty
11
+ * state is a quiet moment, and an accent turns it into an announcement.
12
+ */
5
13
 
6
- const illustrationProps = {
7
- viewBox: "0 0 240 160",
8
- fill: "none",
9
- xmlns: "http://www.w3.org/2000/svg",
10
- } as const
14
+ export type IllustrationProps = ComponentProps<"div">
11
15
 
12
- export const IllustrationEmpty = ({
13
- className,
14
- ...props
15
- }: IllustrationProps) => (
16
- <svg
17
- {...illustrationProps}
18
- className={cn("text-fg-tertiary", className)}
16
+ /** Fixed 64×48 stage, so a row of these lines up without ad-hoc sizing. */
17
+ const Frame = ({ className, children, ...props }: IllustrationProps) => (
18
+ <div
19
+ className={cn(
20
+ "inline-flex h-12 w-16 shrink-0 items-center justify-center",
21
+ className,
22
+ )}
19
23
  aria-hidden
20
24
  {...props}
21
25
  >
22
- <path
23
- d="M52 65 79 40h82l27 25v55H52V65Z"
24
- className="fill-background-secondary"
25
- stroke="currentColor"
26
- strokeWidth="2"
27
- />
28
- <path
29
- d="M52 65h45l8 13h30l8-13h45"
30
- stroke="currentColor"
31
- strokeWidth="2"
32
- strokeLinejoin="round"
33
- />
34
- <path
35
- d="M97 31h46"
36
- className="text-brand-primary"
37
- stroke="currentColor"
38
- strokeWidth="4"
39
- strokeLinecap="round"
40
- />
41
- <circle cx="120" cy="104" r="4" className="fill-brand-primary" />
42
- </svg>
26
+ {children}
27
+ </div>
43
28
  )
44
29
 
45
- export const IllustrationError = ({
30
+ /** A sheet. The hairline and radius are sub-pixel on purpose — at this size a
31
+ * 1px border reads as a heavy outline rather than an edge. */
32
+ const Card = ({
33
+ className,
34
+ children,
35
+ }: {
36
+ className?: string
37
+ children?: ReactNode
38
+ }) => (
39
+ <div
40
+ className={cn(
41
+ "relative flex shrink-0 flex-col overflow-hidden rounded-[3px] border-[0.5px] border-border-primary bg-surface p-1 shadow-hairline",
42
+ className,
43
+ )}
44
+ >
45
+ {children}
46
+ </div>
47
+ )
48
+
49
+ /** A line of content. */
50
+ const Bar = ({ width }: { width: string }) => (
51
+ <div
52
+ className="h-[3px] shrink-0 rounded-[1px] bg-background-tertiary"
53
+ style={{ width }}
54
+ />
55
+ )
56
+
57
+ /** Nothing here yet — a sheet with no content on it. */
58
+ export const IllustrationEmpty = ({ className, ...props }: IllustrationProps) => (
59
+ <Frame className={className} {...props}>
60
+ <Card className="h-10 w-8" />
61
+ </Frame>
62
+ )
63
+
64
+ /** Something to look through — a sheet behind a lens. */
65
+ export const IllustrationSearch = ({
46
66
  className,
47
67
  ...props
48
68
  }: IllustrationProps) => (
49
- <svg
50
- {...illustrationProps}
51
- className={cn("text-fg-tertiary", className)}
52
- aria-hidden
53
- {...props}
54
- >
55
- <rect
56
- x="47"
57
- y="28"
58
- width="146"
59
- height="104"
60
- rx="16"
61
- className="fill-background-secondary"
62
- stroke="currentColor"
63
- strokeWidth="2"
64
- />
65
- <path
66
- d="M47 54h146"
67
- stroke="currentColor"
68
- strokeWidth="2"
69
- />
70
- <circle cx="63" cy="41" r="3" className="fill-brand-primary" />
71
- <circle cx="74" cy="41" r="3" fill="currentColor" opacity=".45" />
72
- <circle cx="85" cy="41" r="3" fill="currentColor" opacity=".25" />
73
- <path
74
- d="m103 78 34 34m0-34-34 34"
75
- className="text-brand-primary"
76
- stroke="currentColor"
77
- strokeWidth="5"
78
- strokeLinecap="round"
79
- />
80
- </svg>
69
+ <Frame className={className} {...props}>
70
+ <Card className="h-10 w-8 gap-[3px]">
71
+ <Bar width="80%" />
72
+ <Bar width="55%" />
73
+ <Bar width="35%" />
74
+ </Card>
75
+ <div className="-ml-2.5 mt-4 size-4 rounded-full border-[1.5px] border-border-secondary bg-surface" />
76
+ </Frame>
81
77
  )
82
78
 
83
- export const IllustrationSuccess = ({
79
+ /** Something went wrong — the stack knocked out of true. */
80
+ export const IllustrationError = ({ className, ...props }: IllustrationProps) => (
81
+ <Frame className={className} {...props}>
82
+ <Card className="h-9 w-7 -rotate-6" />
83
+ <Card className="-ml-3 h-10 w-8 rotate-[7deg] gap-[3px]">
84
+ <Bar width="70%" />
85
+ <Bar width="45%" />
86
+ </Card>
87
+ </Frame>
88
+ )
89
+
90
+ /** Somewhere to put a file — a sheet going into a folder.
91
+ *
92
+ * Two earlier attempts failed for the same reason: an arrow stamped on a
93
+ * sheet, then a sheet on a plain grey slab, both read as a document with
94
+ * something next to it. A folder is its own silhouette — tab, body, a sheet
95
+ * tucked behind the front — so the arrangement carries the meaning and no
96
+ * symbol has to. It is also the one shape here that is not another sheet,
97
+ * which keeps it from reading as the error stack. */
98
+ export const IllustrationUpload = ({
84
99
  className,
85
100
  ...props
86
101
  }: IllustrationProps) => (
87
- <svg
88
- {...illustrationProps}
89
- className={cn("text-fg-tertiary", className)}
90
- aria-hidden
91
- {...props}
92
- >
93
- <circle
94
- cx="120"
95
- cy="80"
96
- r="53"
97
- className="fill-background-secondary"
98
- stroke="currentColor"
99
- strokeWidth="2"
100
- />
101
- <circle
102
- cx="120"
103
- cy="80"
104
- r="37"
105
- className="fill-brand-primary text-brand-primary"
106
- stroke="currentColor"
107
- strokeWidth="2"
108
- />
109
- <path
110
- d="m99 80 14 14 29-31"
111
- className="text-brand-foreground"
112
- stroke="currentColor"
113
- strokeWidth="6"
114
- strokeLinecap="round"
115
- strokeLinejoin="round"
116
- />
117
- <path
118
- d="M63 42h13M69.5 35.5v13M168 118h13m-6.5-6.5v13"
119
- className="text-brand-primary"
120
- stroke="currentColor"
121
- strokeWidth="3"
122
- strokeLinecap="round"
123
- />
124
- </svg>
102
+ <Frame className={className} {...props}>
103
+ <div className="relative h-11 w-12">
104
+ {/* Tucked deep enough that the folder front cuts across it. */}
105
+ <Card className="absolute inset-x-[13px] top-0 h-8 -rotate-6 gap-[3px]">
106
+ <Bar width="70%" />
107
+ <Bar width="45%" />
108
+ </Card>
109
+ {/* Laps 1px into the body so their borders read as one outline. */}
110
+ <div className="absolute bottom-[21px] left-1 h-1.5 w-4 rounded-t-[2px] border-x-[0.5px] border-t-[0.5px] border-border-secondary bg-background-tertiary" />
111
+ <div className="absolute inset-x-1 bottom-0 h-[22px] rounded-[3px] border-[0.5px] border-border-secondary bg-background-tertiary" />
112
+ </div>
113
+ </Frame>
125
114
  )
126
115
 
127
- export const IllustrationSearch = ({
116
+ /** Done a sheet carrying a mark. */
117
+ export const IllustrationSuccess = ({
128
118
  className,
129
119
  ...props
130
120
  }: IllustrationProps) => (
131
- <svg
132
- {...illustrationProps}
133
- className={cn("text-fg-tertiary", className)}
121
+ <Frame className={className} {...props}>
122
+ <Card className="h-10 w-8 items-center justify-center">
123
+ {/* A check is cheaper as two borders on a rotated box than as a path. */}
124
+ <span className="mb-0.5 h-3 w-1.5 rotate-45 border-r-[1.5px] border-b-[1.5px] border-fg-tertiary" />
125
+ </Card>
126
+ </Frame>
127
+ )
128
+
129
+ /* -------------------------------------------------------------------------
130
+ * File types
131
+ *
132
+ * A second, smaller family. These sit inline — in an attachment row, a list,
133
+ * a preview slot — so they are a bare sheet at 24×30 rather than a hero on a
134
+ * 64×48 stage. Same grammar: a sheet, and marks on it standing in for whatever
135
+ * the file holds.
136
+ *
137
+ * Presentational, like Kbd: they render the type you name. Mapping an
138
+ * extension to a type is the consumer's job, since only the consumer knows
139
+ * what it wants to do with the ones it does not recognise.
140
+ * ---------------------------------------------------------------------- */
141
+
142
+ export type FileIllustrationType =
143
+ | "document"
144
+ | "image"
145
+ | "spreadsheet"
146
+ | "presentation"
147
+ | "video"
148
+ | "audio"
149
+ | "code"
150
+ | "archive"
151
+ | "generic"
152
+
153
+ export type IllustrationFileProps = IllustrationProps & {
154
+ type?: FileIllustrationType
155
+ }
156
+
157
+ /** A block of colour standing in for content rather than a line of it. */
158
+ const Block = ({ className }: { className?: string }) => (
159
+ <div className={cn("rounded-[1px] bg-background-tertiary", className)} />
160
+ )
161
+
162
+ const marks: Record<FileIllustrationType, ReactNode> = {
163
+ document: (
164
+ <>
165
+ <Bar width="100%" />
166
+ <Bar width="100%" />
167
+ <Bar width="60%" />
168
+ </>
169
+ ),
170
+ // A horizon and a sun — the smallest arrangement that reads as a picture.
171
+ image: (
172
+ <div className="relative mt-auto h-3.5 w-full">
173
+ <Block className="absolute top-0 right-1 size-1.5 rounded-full" />
174
+ <Block className="absolute inset-x-0 bottom-0 h-2 [clip-path:polygon(0_100%,38%_28%,62%_100%)]" />
175
+ <Block className="absolute right-0 bottom-0 h-1.5 w-1/2 [clip-path:polygon(0_100%,50%_20%,100%_100%)]" />
176
+ </div>
177
+ ),
178
+ spreadsheet: (
179
+ <div className="grid h-full w-full grid-cols-3 grid-rows-3 gap-[1.5px]">
180
+ {Array.from({ length: 9 }, (_, i) => (
181
+ <Block key={i} />
182
+ ))}
183
+ </div>
184
+ ),
185
+ presentation: (
186
+ <>
187
+ <Block className="h-2.5 w-full" />
188
+ <Bar width="70%" />
189
+ </>
190
+ ),
191
+ // A play triangle, cut from a block so it keeps the same fill as everything else.
192
+ video: (
193
+ <div className="m-auto size-3">
194
+ <Block className="size-full [clip-path:polygon(22%_10%,90%_50%,22%_90%)]" />
195
+ </div>
196
+ ),
197
+ audio: (
198
+ <div className="m-auto flex h-3.5 items-center gap-[2px]">
199
+ <Block className="h-1.5 w-[2px]" />
200
+ <Block className="h-3.5 w-[2px]" />
201
+ <Block className="h-2.5 w-[2px]" />
202
+ <Block className="h-3.5 w-[2px]" />
203
+ <Block className="h-1.5 w-[2px]" />
204
+ </div>
205
+ ),
206
+ code: (
207
+ <>
208
+ <Bar width="55%" />
209
+ <div className="flex w-full pl-1.5">
210
+ <Bar width="70%" />
211
+ </div>
212
+ <div className="flex w-full pl-1.5">
213
+ <Bar width="50%" />
214
+ </div>
215
+ <Bar width="40%" />
216
+ </>
217
+ ),
218
+ // A stack, since an archive is other files in a coat.
219
+ archive: (
220
+ <div className="m-auto flex flex-col gap-[2px]">
221
+ <Block className="h-1.5 w-2.5" />
222
+ <Block className="h-1.5 w-2.5" />
223
+ <Block className="h-1.5 w-2.5" />
224
+ </div>
225
+ ),
226
+ generic: null,
227
+ }
228
+
229
+ /** One file, drawn as the kind of thing it holds. */
230
+ export const IllustrationFile = ({
231
+ type = "generic",
232
+ className,
233
+ ...props
234
+ }: IllustrationFileProps) => (
235
+ <div
236
+ className={cn(
237
+ "relative flex h-[30px] w-6 shrink-0 flex-col gap-[3px] overflow-hidden rounded-[3px] border-[0.5px] border-border-primary bg-surface p-1 shadow-hairline",
238
+ className,
239
+ )}
134
240
  aria-hidden
135
241
  {...props}
136
242
  >
137
- <path
138
- d="M42 38h113a12 12 0 0 1 12 12v69H42V38Z"
139
- className="fill-background-secondary"
140
- stroke="currentColor"
141
- strokeWidth="2"
142
- />
143
- <path d="M42 58h125" stroke="currentColor" strokeWidth="2" />
144
- <path
145
- d="M59 76h48M59 89h34M59 102h53"
146
- stroke="currentColor"
147
- strokeWidth="4"
148
- strokeLinecap="round"
149
- opacity=".5"
150
- />
151
- <circle
152
- cx="155"
153
- cy="91"
154
- r="27"
155
- className="fill-surface text-brand-primary"
156
- stroke="currentColor"
157
- strokeWidth="5"
158
- />
159
- <path
160
- d="m174 111 22 22"
161
- className="text-brand-primary"
162
- stroke="currentColor"
163
- strokeWidth="7"
164
- strokeLinecap="round"
165
- />
166
- </svg>
243
+ {marks[type]}
244
+ </div>
167
245
  )