@designa8/vibedesign-v6 2.2.1 → 2.2.3

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/dist/styles.css CHANGED
@@ -1827,6 +1827,9 @@
1827
1827
  .object-center {
1828
1828
  object-position: center;
1829
1829
  }
1830
+ .object-top {
1831
+ object-position: top;
1832
+ }
1830
1833
  .\!p-0 {
1831
1834
  padding: 0 !important;
1832
1835
  }
@@ -2139,6 +2142,9 @@
2139
2142
  .break-words {
2140
2143
  overflow-wrap: break-word;
2141
2144
  }
2145
+ .whitespace-normal {
2146
+ white-space: normal;
2147
+ }
2142
2148
  .whitespace-nowrap {
2143
2149
  white-space: nowrap;
2144
2150
  }
@@ -2693,24 +2699,24 @@
2693
2699
  }
2694
2700
  }
2695
2701
  }
2696
- .hover\:text-semantic-error {
2702
+ .hover\:no-underline {
2697
2703
  &:hover {
2698
2704
  @media (hover: hover) {
2699
- color: var(--color-semantic-error);
2705
+ text-decoration-line: none;
2700
2706
  }
2701
2707
  }
2702
2708
  }
2703
- .hover\:no-underline {
2709
+ .hover\:underline {
2704
2710
  &:hover {
2705
2711
  @media (hover: hover) {
2706
- text-decoration-line: none;
2712
+ text-decoration-line: underline;
2707
2713
  }
2708
2714
  }
2709
2715
  }
2710
- .hover\:underline {
2716
+ .hover\:opacity-80 {
2711
2717
  &:hover {
2712
2718
  @media (hover: hover) {
2713
- text-decoration-line: underline;
2719
+ opacity: 80%;
2714
2720
  }
2715
2721
  }
2716
2722
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designa8/vibedesign-v6",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "Complete design system \"Plasma Design System\" generated by Atoms Design.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -205,11 +205,14 @@ interface HistoryRowProps {
205
205
  }
206
206
 
207
207
  /**
208
- * One row = one rounded surface. The `<li>` owns the only fill (the selected
209
- * `bg-primary-disabled`). The label hit target is a transparent native button
210
- * with no border, no hover fill and no radius of its own, so nothing paints a
211
- * second rectangle over the chip. Title and chip are vertically centred with
212
- * the source chip inset from the title and from the rounded edge.
208
+ * One row = one square, full-bleed surface. The row owns the only fill (the
209
+ * selected `bg-primary-disabled` / hovered `bg-surface-soft`) and it runs from
210
+ * the sidebar's left edge to its right edge — no corner radius, no horizontal
211
+ * inset. The label hit target is a bare Button (no fill, no border, no radius
212
+ * of its own) so nothing paints a second rectangle over the chip. The row keeps
213
+ * its own inner padding (`pl-sm … pr-xs`) so the label and the origin chip
214
+ * never sit flush against the panel edge, and the thinking dot stays
215
+ * immediately left of the label.
213
216
  */
214
217
  const HistoryRow: React.FC<HistoryRowProps> = ({ item, active = false, onClick }) => {
215
218
  const [hovered, setHovered] = React.useState(false);
@@ -219,22 +222,22 @@ const HistoryRow: React.FC<HistoryRowProps> = ({ item, active = false, onClick }
219
222
  return (
220
223
  <li
221
224
  className={[
222
- "list-none flex items-center gap-xs rounded-md pr-xs",
225
+ "list-none flex items-center gap-xs rounded-none pr-xs",
223
226
  "transition-colors duration-150 ease-out",
224
227
  active ? "bg-primary-disabled" : hovered ? "bg-surface-soft" : "bg-transparent",
225
228
  ].join(" ")}
226
229
  onMouseEnter={() => setHovered(true)}
227
230
  onMouseLeave={() => setHovered(false)}
228
231
  >
229
- <button
232
+ <Button
230
233
  type="button"
234
+ variant="bare"
235
+ size="auto"
231
236
  aria-current={active ? "page" : undefined}
232
237
  onClick={onClick}
233
238
  className={[
234
- "flex flex-1 min-w-0 items-center gap-xs bg-transparent pl-sm py-xs pr-0 text-left",
235
- "border-0 shadow-none cursor-pointer rounded-md",
236
- "transition duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
237
- active ? "text-primary" : "text-body hover:text-ink",
239
+ "flex-1 min-w-0 !justify-start !gap-xs !rounded-none pl-sm py-xs pr-0 text-left whitespace-normal",
240
+ active ? "!text-primary" : "!text-body hover:!text-ink",
238
241
  ].join(" ")}
239
242
  >
240
243
  {thinking && (
@@ -246,7 +249,7 @@ const HistoryRow: React.FC<HistoryRowProps> = ({ item, active = false, onClick }
246
249
  <span dir="auto" className="block min-w-0 truncate text-body-sm">
247
250
  {item.label}
248
251
  </span>
249
- </button>
252
+ </Button>
250
253
  <Chip
251
254
  label={isAgent ? "Agent" : "Manual"}
252
255
  variant={isAgent ? "primary" : "default"}
@@ -254,23 +257,24 @@ const HistoryRow: React.FC<HistoryRowProps> = ({ item, active = false, onClick }
254
257
  className="flex-shrink-0"
255
258
  />
256
259
  {item.onDelete && (
257
- <button
260
+ <Button
258
261
  type="button"
262
+ variant="bare"
263
+ size="auto"
259
264
  aria-label={`Delete ${item.label}`}
260
265
  onClick={(e) => {
261
266
  e.stopPropagation();
262
267
  item.onDelete!(item.id);
263
268
  }}
264
269
  className={[
265
- "p-xxs rounded-xs bg-transparent border-0 flex-shrink-0 text-muted",
266
- "cursor-pointer transition duration-200 ease-out hover:text-semantic-error",
267
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
270
+ "!p-xxs !rounded-xs flex-shrink-0 !text-muted hover:!text-semantic-error",
271
+ "transition duration-200 ease-out",
268
272
  hovered ? "opacity-100" : "opacity-0",
269
273
  ].join(" ")}
270
274
  tabIndex={hovered ? 0 : -1}
271
275
  >
272
276
  <Icon name="trash-delete" style={{ width: "14px", height: "14px" }} />
273
- </button>
277
+ </Button>
274
278
  )}
275
279
  </li>
276
280
  );
@@ -419,9 +423,10 @@ export const ChatHistorySidebar = React.forwardRef<HTMLElement, ChatHistorySideb
419
423
  )}
420
424
  </div>
421
425
 
422
- {/* Flat chat history list — only meaningful when expanded, no section headings */}
426
+ {/* Flat chat history list — full-bleed rows (no horizontal list padding),
427
+ only inner row padding so labels and chips stay off the panel edge. */}
423
428
  {!collapsed && (
424
- <div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-sm pb-md">
429
+ <div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden pb-md">
425
430
  {flatList.length > 0 ? (
426
431
  <ul className="space-y-xxs" role="list">
427
432
  {flatList.map((item) => (
@@ -49,6 +49,7 @@ const chats: ChatHistoryItem[] = [
49
49
  export default function ChatHistorySidebarPreview() {
50
50
  const [collapsed, setCollapsed] = React.useState(false);
51
51
  const [activeId, setActiveId] = React.useState("c1");
52
+ const [place, setPlace] = React.useState("Acme");
52
53
 
53
54
  const items = React.useMemo(
54
55
  () =>
@@ -63,13 +64,12 @@ export default function ChatHistorySidebarPreview() {
63
64
  <div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
64
65
  <div>
65
66
  <p className="text-body-sm text-muted mb-sm">
66
- Select any row — the title hit target is transparent, the row owns the single selected fill,
67
- and the Manual / Agent chip sits inset inside that surface. The first and fourth rows are
68
- thinking, so their dot pulses.
67
+ Select any row — the fill is square and runs edge to edge, with the label and chip inset by
68
+ the row's own padding. The first and fourth rows are thinking, so their dot pulses.
69
69
  </p>
70
70
  <div className="flex gap-lg items-stretch" style={{ height: 460 }}>
71
71
  <ChatHistorySidebar
72
- brandName="Acme"
72
+ brandName={place}
73
73
  avatarInitials="JD"
74
74
  collapsed={collapsed}
75
75
  onCollapsedChange={setCollapsed}
@@ -78,9 +78,17 @@ export default function ChatHistorySidebarPreview() {
78
78
  onSelectHistoryItem={setActiveId}
79
79
  onNewChat={() => setActiveId("")}
80
80
  onProjectSettings={() => setActiveId("")}
81
+ onBackToProjects={() => {
82
+ setPlace("Projects");
83
+ setActiveId("d1");
84
+ }}
85
+ onHome={() => {
86
+ setPlace("Home");
87
+ setActiveId("r1");
88
+ }}
81
89
  />
82
90
  <div className="flex-1 flex items-center justify-center rounded-lg border border-hairline-soft text-body-sm text-muted-soft">
83
- Main content area
91
+ {place}
84
92
  </div>
85
93
  </div>
86
94
  </div>
@@ -90,7 +98,7 @@ export default function ChatHistorySidebarPreview() {
90
98
  <div className="flex gap-lg items-stretch" style={{ height: 260 }}>
91
99
  <ChatHistorySidebar brandName="Acme" avatarInitials="JD" defaultCollapsed={false} />
92
100
  <div className="flex-1 flex items-center justify-center rounded-lg border border-hairline-soft text-body-sm text-muted-soft">
93
- Collapsed rail on the left
101
+ Empty history
94
102
  </div>
95
103
  </div>
96
104
  </div>
@@ -81,7 +81,7 @@ export interface ChatMessage {
81
81
  postContent?: string;
82
82
  /** Optional attached images — renders as a row of small thumbnails with a click-to-open lightbox */
83
83
  images?: ChatMessageImage[];
84
- /** Optional design-suggestion widget — a larger thumbnail (or option strip) that opens a fullscreen lightbox */
84
+ /** Optional design-suggestion widget — a larger thumbnail (or option strip) rendered at the TOP of the AI message, before its text, that opens a fullscreen lightbox */
85
85
  suggestedImage?: ChatMessageSuggestedImage;
86
86
  }
87
87
 
@@ -359,13 +359,13 @@ const AgentConversationMark: React.FC<{
359
359
  mark: AgentConversationMarkData;
360
360
  align?: "start" | "end";
361
361
  }> = ({ mark, align = "start" }) => {
362
- const pillClasses =
363
- "inline-flex items-center gap-xs rounded-full bg-canvas px-sm py-xxs text-caption font-weight-heading-sm text-primary shadow-sm hover:bg-surface-soft transition-colors duration-150 whitespace-nowrap";
364
-
365
362
  return (
366
363
  <div className={["flex mt-sm", align === "end" ? "justify-end" : "justify-start"].join(" ")}>
367
364
  {mark.href ? (
368
- <a href={mark.href} className={pillClasses}>
365
+ <a
366
+ href={mark.href}
367
+ className="inline-flex items-center gap-xs rounded-full bg-canvas px-sm py-xxs text-caption font-weight-heading-sm text-primary shadow-sm whitespace-nowrap cursor-pointer transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue"
368
+ >
369
369
  <Icon name="two-people-users-group" size={12} />
370
370
  {mark.label}
371
371
  </a>
@@ -445,9 +445,11 @@ const MessageImageGallery: React.FC<{ images: ChatMessageImage[]; align?: "start
445
445
  // ─── Suggested-design widget (larger thumbnail → fullscreen lightbox) ─────────
446
446
 
447
447
  /**
448
- * Renders a design-suggestion widget in an AI bubble: a larger thumbnail
449
- * (single mockup or a compact option strip when 2+ options are supplied)
450
- * that opens a full-viewport Modal lightbox.
448
+ * Renders a design-suggestion widget at the TOP of an AI message, before the
449
+ * message text: a larger thumbnail (single mockup or a compact option strip
450
+ * when 2+ options are supplied) that opens a full-viewport Modal lightbox.
451
+ * The thumbnail is anchored to the top of the message column (self-start,
452
+ * object-top) so a generated design never sinks to the bottom of the row.
451
453
  *
452
454
  * Single-mockup case (0–1 options): full image + primary CTA under the
453
455
  * thumbnail and again in the modal footer (existing ctaLabel/onCta).
@@ -488,7 +490,7 @@ const SuggestedImageWidget: React.FC<{ suggestedImage: ChatMessageSuggestedImage
488
490
  };
489
491
 
490
492
  return (
491
- <div className="mt-md">
493
+ <div className="mb-md flex flex-col items-start self-start">
492
494
  {/* Trigger thumbnail — a small chat-bubble attachment, capped so it
493
495
  doesn't overtake the whole message column. This wrapper sits nested
494
496
  well inside the always-w-full ChatScreen root, so it is not the
@@ -498,14 +500,14 @@ const SuggestedImageWidget: React.FC<{ suggestedImage: ChatMessageSuggestedImage
498
500
  variant="ghost"
499
501
  pushEffect={false}
500
502
  onClick={handleOpen}
501
- className="group relative block !p-0 max-w-full overflow-hidden rounded-lg bg-surface-strong border border-hairline"
503
+ className="group relative block self-start !p-0 max-w-full overflow-hidden rounded-lg bg-surface-strong border border-hairline"
502
504
  style={{ maxHeight: "14rem", width: "20rem" }}
503
505
  aria-label={alt ?? "Open design suggestion"}
504
506
  >
505
507
  <img
506
508
  src={src}
507
509
  alt={alt ?? ""}
508
- className="w-full object-cover transition-transform duration-150 group-hover:scale-[1.02]"
510
+ className="block w-full object-cover object-top transition-transform duration-150 group-hover:scale-[1.02]"
509
511
  style={{ maxHeight: "14rem" }}
510
512
  />
511
513
  {hasOptions && (
@@ -515,7 +517,7 @@ const SuggestedImageWidget: React.FC<{ suggestedImage: ChatMessageSuggestedImage
515
517
  key={opt.id}
516
518
  src={opt.src}
517
519
  alt={opt.label}
518
- className="h-10 w-10 flex-shrink-0 rounded-sm object-cover border border-hairline"
520
+ className="h-10 w-10 flex-shrink-0 rounded-sm object-cover object-top border border-hairline"
519
521
  />
520
522
  ))}
521
523
  </div>
@@ -670,19 +672,22 @@ const CopyMessageButton: React.FC<{ text: string; onCopy?: (content: string) =>
670
672
 
671
673
  return (
672
674
  <div className="flex items-center justify-end mb-xs">
673
- <button
675
+ <Button
674
676
  type="button"
677
+ variant="bare"
678
+ size="auto"
679
+ pushEffect={false}
675
680
  onClick={handleCopy}
676
681
  aria-label={copied ? "Message copied" : "Copy message"}
677
682
  data-copied={copied ? "true" : "false"}
678
- className="inline-flex items-center justify-center rounded-xs p-xxs text-muted-soft opacity-0 cursor-pointer transition duration-150 ease-out hover:text-ink active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 data-[copied=true]:opacity-100"
683
+ className="inline-flex items-center justify-center rounded-xs p-xxs text-muted-soft opacity-0 hover:text-ink active:scale-[0.98] focus-visible:ring-focus-blue group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 data-[copied=true]:opacity-100"
679
684
  >
680
685
  <Icon
681
686
  name={copied ? "check-checkmark" : "copy-clipboard"}
682
687
  size={14}
683
688
  className={copied ? "text-semantic-success" : undefined}
684
689
  />
685
- </button>
690
+ </Button>
686
691
  <span role="status" aria-live="polite" className="sr-only">
687
692
  {copied ? "Message copied to clipboard" : ""}
688
693
  </span>
@@ -737,11 +742,18 @@ const ThinkingIndicator: React.FC = () => (
737
742
 
738
743
  // ─── AI message ───────────────────────────────────────────────────────────────
739
744
 
740
- /** AI message — plain prose column (no bubble) so long answers stay readable */
745
+ /**
746
+ * AI message — plain prose column (no bubble) so long answers stay readable.
747
+ * A suggested design renders FIRST, at the top of the column, before the
748
+ * message text.
749
+ */
741
750
  const AiMessage: React.FC<{ message: ChatMessage }> = ({ message }) => (
742
751
  <div className="flex items-start gap-md w-full">
743
752
  <AIAvatar />
744
- <div className="flex-1 min-w-0">
753
+ <div className="flex-1 min-w-0 flex flex-col items-stretch justify-start">
754
+ {message.suggestedImage && (
755
+ <SuggestedImageWidget suggestedImage={message.suggestedImage} />
756
+ )}
745
757
  <ExpandableMessage
746
758
  variant="flush"
747
759
  maxLines={6}
@@ -752,9 +764,6 @@ const AiMessage: React.FC<{ message: ChatMessage }> = ({ message }) => (
752
764
  {message.images && message.images.length > 0 && (
753
765
  <MessageImageGallery images={message.images} align="start" />
754
766
  )}
755
- {message.suggestedImage && (
756
- <SuggestedImageWidget suggestedImage={message.suggestedImage} />
757
- )}
758
767
  {message.timeline && message.timeline.length > 0 && (
759
768
  <TimelineBlock items={message.timeline} />
760
769
  )}
@@ -826,13 +835,16 @@ const UserMessage: React.FC<{ message: ChatMessage }> = ({ message }) => {
826
835
  {hasText && failed && (
827
836
  <div className="mt-xs flex items-center gap-sm justify-end">
828
837
  <span className="text-caption text-semantic-error">Not sent</span>
829
- <button
838
+ <Button
830
839
  type="button"
840
+ variant="bare"
841
+ size="auto"
842
+ pushEffect={false}
831
843
  onClick={() => message.onRetry?.(message)}
832
- className="rounded-xs text-caption text-primary-text underline underline-offset-2 cursor-pointer transition duration-150 ease-out hover:text-primary-active active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue"
844
+ className="rounded-xs text-caption text-primary-text underline underline-offset-2 hover:text-primary-active active:scale-[0.98] focus-visible:ring-focus-blue"
833
845
  >
834
846
  Retry
835
- </button>
847
+ </Button>
836
848
  </div>
837
849
  )}
838
850
 
@@ -22,7 +22,7 @@ Step two should support pasting a comma-separated list of emails and show inline
22
22
  Step three should show a grid of starter templates with a live preview thumbnail for each.
23
23
  On the last step, show a summary of every choice made so far with an edit link back to that step.`;
24
24
 
25
- const mainConversation: ChatMessage[] = [
25
+ const demoConversation: ChatMessage[] = [
26
26
  {
27
27
  id: "1",
28
28
  role: "ai",
@@ -39,6 +39,12 @@ const mainConversation: ChatMessage[] = [
39
39
  id: "3",
40
40
  role: "ai",
41
41
  content: "I can help you create a new atom. What type of atom would you like to create?",
42
+ suggestedImage: {
43
+ src: "https://picsum.photos/seed/designmock1/600/900",
44
+ alt: "Generated pricing page design",
45
+ ctaLabel: "Create this design",
46
+ onCta: () => console.log("create design"),
47
+ },
42
48
  },
43
49
  {
44
50
  id: "4",
@@ -71,23 +77,32 @@ const mainConversation: ChatMessage[] = [
71
77
  { src: "https://picsum.photos/seed/mosaic3/600/400", alt: "Screenshot 3" },
72
78
  ],
73
79
  },
74
- ];
75
-
76
- const statesConversation: ChatMessage[] = [
77
80
  {
78
- id: "1",
81
+ id: "7",
79
82
  role: "user",
80
83
  content: LONG_USER_MESSAGE,
81
84
  userInitials: "ME",
82
85
  sentAt: "12:12",
83
86
  },
84
87
  {
85
- id: "2",
88
+ id: "8",
86
89
  role: "ai",
87
90
  content: "Understood — I'll start with the wizard shell and come back with the step-by-step plan.",
91
+ suggestedImage: {
92
+ src: "https://picsum.photos/seed/designmock2/600/900",
93
+ alt: "Generated onboarding wizard design",
94
+ ctaLabel: "Create this design",
95
+ onCta: () => console.log("create wizard design"),
96
+ options: [
97
+ { id: "a", src: "https://picsum.photos/seed/designA/600/900", label: "Design A" },
98
+ { id: "b", src: "https://picsum.photos/seed/designB/600/900", label: "Design B" },
99
+ { id: "c", src: "https://picsum.photos/seed/designC/600/900", label: "Design C" },
100
+ ],
101
+ onSelectOption: (id) => console.log("select design", id),
102
+ },
88
103
  },
89
104
  {
90
- id: "3",
105
+ id: "9",
91
106
  role: "user",
92
107
  content: "Can you suggest a design for our new pricing page?",
93
108
  userInitials: "ME",
@@ -95,7 +110,7 @@ const statesConversation: ChatMessage[] = [
95
110
  onRetry: (message) => console.log("retry message", message.id),
96
111
  },
97
112
  {
98
- id: "4",
113
+ id: "10",
99
114
  role: "user",
100
115
  content: "",
101
116
  userInitials: "ME",
@@ -109,30 +124,20 @@ const statesConversation: ChatMessage[] = [
109
124
  ];
110
125
 
111
126
  export default function Preview() {
112
- const [suggestDesigns1, setSuggestDesigns1] = React.useState(false);
113
- const [suggestDesigns2, setSuggestDesigns2] = React.useState(true);
127
+ const [suggestDesigns, setSuggestDesigns] = React.useState(true);
128
+ const [selectedModelId, setSelectedModelId] = React.useState("fast");
114
129
 
115
130
  return (
116
- <div className="w-full max-w-3xl mx-auto space-y-xl">
117
- <div style={{ height: 720 }}>
118
- <ChatScreen
119
- messages={mainConversation}
120
- placeholder="Ask anything…"
121
- models={DEMO_MODELS}
122
- selectedModelId="fast"
123
- suggestDesigns={suggestDesigns1}
124
- onSuggestDesignsChange={setSuggestDesigns1}
125
- onSend={(value) => console.log("send", value)}
126
- />
127
- </div>
131
+ <div className="w-full max-w-3xl mx-auto">
128
132
  <div style={{ height: 720 }}>
129
133
  <ChatScreen
130
- messages={statesConversation}
134
+ messages={demoConversation}
131
135
  placeholder="Ask anything…"
132
136
  models={DEMO_MODELS}
133
- selectedModelId="pro"
134
- suggestDesigns={suggestDesigns2}
135
- onSuggestDesignsChange={setSuggestDesigns2}
137
+ selectedModelId={selectedModelId}
138
+ onModelChange={setSelectedModelId}
139
+ suggestDesigns={suggestDesigns}
140
+ onSuggestDesignsChange={setSuggestDesigns}
136
141
  onSend={(value) => console.log("send", value)}
137
142
  />
138
143
  </div>
@@ -20,6 +20,10 @@ export interface ChipProps extends React.HTMLAttributes<HTMLSpanElement> {
20
20
  imageSrc?: string;
21
21
  /** Alt text for the thumbnail. Falls back to `label`. */
22
22
  imageAlt?: string;
23
+ /** Upload progress as a number from 0 to 100. When set and below 100, overlays
24
+ * a visible progress bar band across the bottom of the thumbnail, filled to that percent
25
+ * with the primary color on a scrim. At 100 or when omitted, shows the thumbnail with no bar. */
26
+ uploadProgress?: number;
23
27
  /** If provided, renders a dismiss (×) button and calls this handler on click */
24
28
  onDismiss?: () => void;
25
29
  /** Disabled state — mutes colors and prevents interactions */
@@ -39,11 +43,11 @@ const variantClasses: Record<ChipVariant, string> = {
39
43
 
40
44
  const sizeClasses: Record<
41
45
  ChipSize,
42
- { chip: string; text: string; icon: string; thumb: string; dismissSize: "sm" }
46
+ { chip: string; text: string; icon: string; thumb: string; dismissSize: "sm"; progressHeight: string }
43
47
  > = {
44
- sm: { chip: "h-6 px-xs gap-xs rounded-xs", text: "text-caption", icon: "w-3 h-3", thumb: "w-4 h-4", dismissSize: "sm" },
45
- md: { chip: "h-8 px-sm gap-xs rounded-sm", text: "text-body-sm", icon: "w-4 h-4", thumb: "w-5 h-5", dismissSize: "sm" },
46
- lg: { chip: "h-10 px-md gap-sm rounded-md", text: "text-body-md", icon: "w-5 h-5", thumb: "w-6 h-6", dismissSize: "sm" },
48
+ sm: { chip: "h-6 px-xs gap-xs rounded-xs", text: "text-caption", icon: "w-3 h-3", thumb: "w-4 h-4", dismissSize: "sm", progressHeight: "h-1" },
49
+ md: { chip: "h-8 px-sm gap-xs rounded-sm", text: "text-body-sm", icon: "w-4 h-4", thumb: "w-5 h-5", dismissSize: "sm", progressHeight: "h-1.5" },
50
+ lg: { chip: "h-10 px-md gap-sm rounded-md", text: "text-body-md", icon: "w-5 h-5", thumb: "w-6 h-6", dismissSize: "sm", progressHeight: "h-2" },
47
51
  };
48
52
 
49
53
  export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
@@ -55,6 +59,7 @@ export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
55
59
  icon,
56
60
  imageSrc,
57
61
  imageAlt,
62
+ uploadProgress,
58
63
  onDismiss,
59
64
  disabled = false,
60
65
  className = "",
@@ -68,18 +73,35 @@ export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
68
73
 
69
74
  const disabledStyles = disabled ? "opacity-50 pointer-events-none select-none" : "";
70
75
  const isLightboxTrigger = Boolean(imageSrc) && !disabled;
76
+ const showProgressBar = imageSrc && typeof uploadProgress === "number" && uploadProgress < 100;
71
77
 
72
78
  const openLightbox = () => {
73
79
  if (isLightboxTrigger) setLightboxOpen(true);
74
80
  };
75
81
 
76
- const handleBodyKeyDown = (e: React.KeyboardEvent<HTMLSpanElement>) => {
77
- if (!isLightboxTrigger) return;
78
- if (e.key === "Enter" || e.key === " " || e.key === "Spacebar") {
79
- e.preventDefault();
80
- openLightbox();
81
- }
82
- };
82
+ const renderThumbnail = () => (
83
+ <span
84
+ className={`${sz.thumb} flex-shrink-0 rounded-xs overflow-hidden inline-block relative`}
85
+ aria-hidden="true"
86
+ >
87
+ <img
88
+ src={imageSrc}
89
+ alt={imageAlt || label}
90
+ className="w-full h-full object-cover"
91
+ />
92
+ {showProgressBar && (
93
+ <div
94
+ className={`absolute bottom-0 left-0 right-0 ${sz.progressHeight} bg-scrim`}
95
+ aria-label={`Upload progress: ${uploadProgress}%`}
96
+ >
97
+ <div
98
+ className={`h-full bg-primary transition-all duration-200`}
99
+ style={{ width: `${uploadProgress}%` }}
100
+ />
101
+ </div>
102
+ )}
103
+ </span>
104
+ );
83
105
 
84
106
  return (
85
107
  <span
@@ -97,39 +119,34 @@ export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
97
119
  .join(" ")}
98
120
  {...props}
99
121
  >
100
- <span
101
- className="inline-flex items-center gap-xs"
102
- onClick={isLightboxTrigger ? openLightbox : undefined}
103
- onKeyDown={isLightboxTrigger ? handleBodyKeyDown : undefined}
104
- role={isLightboxTrigger ? "button" : undefined}
105
- tabIndex={isLightboxTrigger ? 0 : undefined}
106
- aria-label={isLightboxTrigger ? `View image for ${label}` : undefined}
107
- style={isLightboxTrigger ? { cursor: "pointer" } : undefined}
108
- >
109
- {imageSrc ? (
110
- <span
111
- className={`${sz.thumb} flex-shrink-0 rounded-xs overflow-hidden inline-block`}
112
- aria-hidden="true"
113
- >
114
- <img
115
- src={imageSrc}
116
- alt={imageAlt || label}
117
- className="w-full h-full object-cover"
118
- />
119
- </span>
120
- ) : (
121
- icon && (
122
- <span
123
- className={`${sz.icon} flex-shrink-0 flex items-center justify-center`}
124
- aria-hidden="true"
125
- >
126
- {icon}
127
- </span>
128
- )
129
- )}
130
-
131
- <span className={sz.text}>{label}</span>
132
- </span>
122
+ {isLightboxTrigger ? (
123
+ <Button
124
+ variant="bare"
125
+ size="auto"
126
+ onClick={openLightbox}
127
+ aria-label={`View image for ${label}`}
128
+ className="inline-flex items-center gap-xs cursor-pointer p-0 m-0 hover:opacity-80 transition-opacity"
129
+ >
130
+ {renderThumbnail()}
131
+ <span className={sz.text}>{label}</span>
132
+ </Button>
133
+ ) : (
134
+ <span className="inline-flex items-center gap-xs">
135
+ {imageSrc ? (
136
+ renderThumbnail()
137
+ ) : (
138
+ icon && (
139
+ <span
140
+ className={`${sz.icon} flex-shrink-0 flex items-center justify-center`}
141
+ aria-hidden="true"
142
+ >
143
+ {icon}
144
+ </span>
145
+ )
146
+ )}
147
+ <span className={sz.text}>{label}</span>
148
+ </span>
149
+ )}
133
150
 
134
151
  {onDismiss && (
135
152
  <Button