@designa8/vibedesign-linear-internal-v1-b737 0.1.0 → 0.3.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 +1 -1
- package/dist/index.cjs +2422 -1957
- package/dist/index.js +2409 -1944
- package/dist/styles.css +75 -0
- package/package.json +11 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +498 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +109 -0
- package/src/atoms/AttachmentChip/AttachmentChip.tsx +126 -0
- package/src/atoms/AttachmentChip/index.ts +2 -0
- package/src/atoms/AttachmentChip/preview.tsx +144 -0
- package/src/atoms/Button/Button.tsx +19 -5
- package/src/index.ts +2 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Icon } from "../Icon";
|
|
3
|
+
import type { IconName } from "../Icon";
|
|
4
|
+
import { IconButton } from "../IconButton";
|
|
5
|
+
import { Spinner } from "../Spinner";
|
|
6
|
+
|
|
7
|
+
export type AttachmentChipSize = "sm" | "md";
|
|
8
|
+
|
|
9
|
+
export interface AttachmentChipProps extends React.ComponentPropsWithoutRef<"span"> {
|
|
10
|
+
/** File name shown (and truncated) in the chip. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Thumbnail image for the attachment. Falls back to `icon` when omitted. */
|
|
13
|
+
imageSrc?: string;
|
|
14
|
+
/** Alt text for the thumbnail. Defaults to `label`. */
|
|
15
|
+
imageAlt?: string;
|
|
16
|
+
/** Glyph shown in the thumbnail when there is no image. */
|
|
17
|
+
icon?: IconName;
|
|
18
|
+
/** 0–99 while the file is uploading. Omit once the upload finishes. */
|
|
19
|
+
uploadProgress?: number;
|
|
20
|
+
/** Renders a trailing ghost remove button and fires when it is clicked. */
|
|
21
|
+
onRemove?: () => void;
|
|
22
|
+
size?: AttachmentChipSize;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function cn(...parts: Array<string | false | null | undefined>) {
|
|
26
|
+
return parts.filter(Boolean).join(" ");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Heights line up with Button's `md` (h-8) and `sm` (h-7) so chips sit level in a composer row. */
|
|
30
|
+
const heights: Record<AttachmentChipSize, string> = {
|
|
31
|
+
md: "h-8 pl-xs pr-xxs text-body-sm",
|
|
32
|
+
sm: "h-7 pl-xxs pr-xxs text-caption",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const thumbs: Record<AttachmentChipSize, string> = {
|
|
36
|
+
md: "size-6",
|
|
37
|
+
sm: "size-5",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const glyphSize: Record<AttachmentChipSize, number> = { md: 14, sm: 12 };
|
|
41
|
+
|
|
42
|
+
const radius: Record<AttachmentChipSize, string> = { md: "rounded-md", sm: "rounded-md" };
|
|
43
|
+
|
|
44
|
+
export const AttachmentChip = React.forwardRef<HTMLSpanElement, AttachmentChipProps>(
|
|
45
|
+
(
|
|
46
|
+
{
|
|
47
|
+
label,
|
|
48
|
+
imageSrc,
|
|
49
|
+
imageAlt,
|
|
50
|
+
icon = "file",
|
|
51
|
+
uploadProgress,
|
|
52
|
+
onRemove,
|
|
53
|
+
size = "md",
|
|
54
|
+
className,
|
|
55
|
+
...rest
|
|
56
|
+
},
|
|
57
|
+
ref,
|
|
58
|
+
) => {
|
|
59
|
+
const uploading = typeof uploadProgress === "number";
|
|
60
|
+
const percent = uploading
|
|
61
|
+
? Math.max(0, Math.min(99, Math.round(uploadProgress as number)))
|
|
62
|
+
: undefined;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<span
|
|
66
|
+
ref={ref}
|
|
67
|
+
aria-busy={uploading || undefined}
|
|
68
|
+
className={cn(
|
|
69
|
+
"inline-flex max-w-full items-center gap-xs border border-hairline bg-canvas text-ink shadow-sm",
|
|
70
|
+
radius[size],
|
|
71
|
+
heights[size],
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
{...rest}
|
|
75
|
+
>
|
|
76
|
+
<span
|
|
77
|
+
className={cn(
|
|
78
|
+
"relative flex shrink-0 items-center justify-center overflow-hidden rounded-xs bg-surface-soft text-muted",
|
|
79
|
+
thumbs[size],
|
|
80
|
+
)}
|
|
81
|
+
>
|
|
82
|
+
{imageSrc ? (
|
|
83
|
+
<img
|
|
84
|
+
src={imageSrc}
|
|
85
|
+
alt={imageAlt ?? label}
|
|
86
|
+
loading="lazy"
|
|
87
|
+
className="size-full object-cover"
|
|
88
|
+
/>
|
|
89
|
+
) : (
|
|
90
|
+
<Icon name={icon} size={glyphSize[size]} />
|
|
91
|
+
)}
|
|
92
|
+
|
|
93
|
+
{/* Upload scrim stays mounted so finishing an upload fades out instead of popping.
|
|
94
|
+
`inverse-ink` keeps the ring light in both themes — the scrim is always dark. */}
|
|
95
|
+
<span
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
data-state={uploading ? "open" : "closed"}
|
|
98
|
+
className="pointer-events-none absolute inset-0 flex items-center justify-center bg-scrim/40 text-inverse-ink opacity-0 transition-opacity duration-200 ease-out data-[state=open]:opacity-100"
|
|
99
|
+
>
|
|
100
|
+
{uploading ? <Spinner variant="ring" size="sm" tone="current" /> : null}
|
|
101
|
+
</span>
|
|
102
|
+
</span>
|
|
103
|
+
|
|
104
|
+
<span className="min-w-0 max-w-40 truncate">{label}</span>
|
|
105
|
+
|
|
106
|
+
{uploading ? (
|
|
107
|
+
<span className="sr-only" aria-live="polite">
|
|
108
|
+
{`Uploading ${percent}%`}
|
|
109
|
+
</span>
|
|
110
|
+
) : null}
|
|
111
|
+
|
|
112
|
+
{onRemove ? (
|
|
113
|
+
<IconButton
|
|
114
|
+
icon="x"
|
|
115
|
+
variant="ghost"
|
|
116
|
+
size="sm"
|
|
117
|
+
aria-label={`Remove ${label}`}
|
|
118
|
+
onClick={onRemove}
|
|
119
|
+
/>
|
|
120
|
+
) : null}
|
|
121
|
+
</span>
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
AttachmentChip.displayName = "AttachmentChip";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AttachmentChip } from "./AttachmentChip";
|
|
3
|
+
import type { AttachmentChipSize } from "./AttachmentChip";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
|
|
6
|
+
interface DemoAttachment {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
imageSrc?: string;
|
|
10
|
+
icon?: "file";
|
|
11
|
+
size?: AttachmentChipSize;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const initial: DemoAttachment[] = [
|
|
15
|
+
{ id: "a1", label: "brand-guidelines-v2.pdf", imageSrc: "https://picsum.photos/seed/a8chip/64/64" },
|
|
16
|
+
{ id: "a2", label: "Q3-revenue-forecast.xlsx" },
|
|
17
|
+
{ id: "a3", label: "hero-mockup-final.png", imageSrc: "https://picsum.photos/seed/a8thumb/64/64", size: "sm" },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
function Section({
|
|
21
|
+
title,
|
|
22
|
+
hint,
|
|
23
|
+
children,
|
|
24
|
+
}: {
|
|
25
|
+
title: string;
|
|
26
|
+
hint?: string;
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<section className="w-full space-y-xs">
|
|
31
|
+
<h2 className="text-caption font-weight-label uppercase tracking-overline text-muted">{title}</h2>
|
|
32
|
+
{hint ? <p className="w-full max-w-prose text-body-sm text-muted">{hint}</p> : null}
|
|
33
|
+
<div className="w-full">{children}</div>
|
|
34
|
+
</section>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function Preview() {
|
|
39
|
+
const [attachments, setAttachments] = React.useState<DemoAttachment[]>(initial);
|
|
40
|
+
const [progress, setProgress] = React.useState<number | undefined>(14);
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (progress === undefined) return;
|
|
44
|
+
const id = window.setInterval(() => {
|
|
45
|
+
setProgress((current) => {
|
|
46
|
+
if (current === undefined) return current;
|
|
47
|
+
const next = current + 11;
|
|
48
|
+
return next >= 99 ? undefined : next;
|
|
49
|
+
});
|
|
50
|
+
}, 900);
|
|
51
|
+
return () => window.clearInterval(id);
|
|
52
|
+
}, [progress === undefined]);
|
|
53
|
+
|
|
54
|
+
const remove = (id: string) =>
|
|
55
|
+
setAttachments((current) => current.filter((item) => item.id !== id));
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="w-full max-w-3xl mx-auto space-y-xl p-lg">
|
|
59
|
+
<Section title="In a prompt composer" hint="Click the × to remove an attachment.">
|
|
60
|
+
<div className="w-full rounded-lg border border-hairline bg-surface p-md">
|
|
61
|
+
<div className="flex w-full flex-wrap items-center gap-xs">
|
|
62
|
+
{attachments.map((item) => (
|
|
63
|
+
<AttachmentChip
|
|
64
|
+
key={item.id}
|
|
65
|
+
label={item.label}
|
|
66
|
+
imageSrc={item.imageSrc}
|
|
67
|
+
icon={item.icon}
|
|
68
|
+
size={item.size}
|
|
69
|
+
onRemove={() => remove(item.id)}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
72
|
+
{attachments.length === 0 ? (
|
|
73
|
+
<span className="text-body-sm text-muted">
|
|
74
|
+
No attachments — send a new prompt above.
|
|
75
|
+
</span>
|
|
76
|
+
) : null}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<div className="pt-sm">
|
|
80
|
+
<Button
|
|
81
|
+
variant="ghost"
|
|
82
|
+
size="sm"
|
|
83
|
+
onClick={() => setAttachments(initial)}
|
|
84
|
+
disabled={attachments.length === initial.length}
|
|
85
|
+
>
|
|
86
|
+
Reset attachments
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</Section>
|
|
90
|
+
|
|
91
|
+
<Section
|
|
92
|
+
title="Uploading"
|
|
93
|
+
hint="The thumbnail dims, a progress ring spins, and the chip is aria-busy until the upload finishes."
|
|
94
|
+
>
|
|
95
|
+
<div className="flex w-full flex-wrap items-center gap-sm">
|
|
96
|
+
<AttachmentChip
|
|
97
|
+
label="meeting-transcript.docx"
|
|
98
|
+
uploadProgress={progress}
|
|
99
|
+
onRemove={() => setProgress(undefined)}
|
|
100
|
+
/>
|
|
101
|
+
<AttachmentChip
|
|
102
|
+
label="whiteboard.png"
|
|
103
|
+
imageSrc="https://picsum.photos/seed/a8upload/64/64"
|
|
104
|
+
size="sm"
|
|
105
|
+
uploadProgress={progress}
|
|
106
|
+
/>
|
|
107
|
+
<Button variant="secondary" size="sm" onClick={() => setProgress(8)}>
|
|
108
|
+
Restart upload
|
|
109
|
+
</Button>
|
|
110
|
+
</div>
|
|
111
|
+
</Section>
|
|
112
|
+
|
|
113
|
+
<Section
|
|
114
|
+
title="Sizes"
|
|
115
|
+
hint="sm sits at 28px and md at 32px, so chips line up with the Button sizes in a composer bar."
|
|
116
|
+
>
|
|
117
|
+
<div className="flex w-full flex-wrap items-center gap-sm">
|
|
118
|
+
<AttachmentChip label="readme.md" size="sm" />
|
|
119
|
+
<AttachmentChip label="readme.md" size="md" />
|
|
120
|
+
<AttachmentChip
|
|
121
|
+
label="brand-guidelines-v2.pdf"
|
|
122
|
+
imageSrc="https://picsum.photos/seed/a8size/64/64"
|
|
123
|
+
size="sm"
|
|
124
|
+
/>
|
|
125
|
+
<AttachmentChip
|
|
126
|
+
label="brand-guidelines-v2.pdf"
|
|
127
|
+
imageSrc="https://picsum.photos/seed/a8size2/64/64"
|
|
128
|
+
size="md"
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</Section>
|
|
132
|
+
|
|
133
|
+
<Section
|
|
134
|
+
title="Glyph thumb, no remove"
|
|
135
|
+
hint="Omit onRemove when the attachment is fixed, e.g. a read-only transcript view."
|
|
136
|
+
>
|
|
137
|
+
<div className="flex w-full flex-wrap items-center gap-sm">
|
|
138
|
+
<AttachmentChip label="prompt-context.json" />
|
|
139
|
+
<AttachmentChip label="long-file-name-that-truncates-in-the-chip.tar.gz" size="sm" />
|
|
140
|
+
</div>
|
|
141
|
+
</Section>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
@@ -4,11 +4,15 @@ import { Icon } from "../Icon";
|
|
|
4
4
|
/**
|
|
5
5
|
* `field` is a bordered, left-aligned select/combobox trigger and `item` is a
|
|
6
6
|
* borderless, left-aligned list or menu row. Both stretch to the full width
|
|
7
|
-
* and press with a background change only (no scale).
|
|
7
|
+
* and press with a background change only (no scale). `item` also paints a
|
|
8
|
+
* soft brand tint while `aria-checked`, so a radio / checkbox row can be the
|
|
9
|
+
* button itself.
|
|
8
10
|
* `bare` is a chrome-less segment for a control whose parent owns the stroke
|
|
9
11
|
* and paints the selection behind the label (segmented controls, toolbars):
|
|
10
12
|
* transparent at rest, no focus stroke of its own, muted label that darkens on
|
|
11
13
|
* hover and inverts to `on-primary` while `aria-selected`.
|
|
14
|
+
* `media` is a borderless, full-width block trigger that wraps a thumbnail or
|
|
15
|
+
* other media (no fixed height, no padding); clicking it opens a larger view.
|
|
12
16
|
*/
|
|
13
17
|
export type ButtonVariant =
|
|
14
18
|
| "primary"
|
|
@@ -17,7 +21,8 @@ export type ButtonVariant =
|
|
|
17
21
|
| "danger"
|
|
18
22
|
| "field"
|
|
19
23
|
| "item"
|
|
20
|
-
| "bare"
|
|
24
|
+
| "bare"
|
|
25
|
+
| "media";
|
|
21
26
|
export type ButtonSize = "sm" | "md" | "lg";
|
|
22
27
|
|
|
23
28
|
export interface ButtonProps extends React.ComponentPropsWithoutRef<"button"> {
|
|
@@ -45,7 +50,7 @@ const base =
|
|
|
45
50
|
const rowBase =
|
|
46
51
|
"relative flex w-full min-w-0 select-none items-center justify-start whitespace-nowrap border text-left font-weight-body-md cursor-pointer transition-colors duration-150 ease-out focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
47
52
|
|
|
48
|
-
const isRow = (v: ButtonVariant) => v === "field" || v === "item";
|
|
53
|
+
const isRow = (v: ButtonVariant) => v === "field" || v === "item" || v === "media";
|
|
49
54
|
|
|
50
55
|
const variants: Record<ButtonVariant, string> = {
|
|
51
56
|
primary:
|
|
@@ -59,9 +64,11 @@ const variants: Record<ButtonVariant, string> = {
|
|
|
59
64
|
field:
|
|
60
65
|
"border-hairline bg-canvas text-ink enabled:hover:border-hairline-strong focus-visible:border-primary aria-expanded:border-primary aria-invalid:border-semantic-error disabled:bg-surface-soft disabled:border-hairline-soft",
|
|
61
66
|
item:
|
|
62
|
-
"border-transparent bg-transparent text-ink enabled:hover:bg-surface-soft enabled:active:bg-surface-strong focus-visible:bg-surface-soft aria-selected:bg-primary-soft aria-selected:font-weight-label",
|
|
67
|
+
"border-transparent bg-transparent text-ink enabled:hover:bg-surface-soft enabled:active:bg-surface-strong focus-visible:bg-surface-soft aria-selected:bg-primary-soft aria-selected:font-weight-label aria-checked:bg-primary-soft disabled:bg-transparent",
|
|
63
68
|
bare:
|
|
64
69
|
"border-transparent bg-transparent text-body transition-colors aria-selected:text-on-primary not-aria-selected:enabled:hover:bg-surface-soft not-aria-selected:enabled:hover:text-ink focus-visible:ring-inset not-aria-selected:focus-visible:bg-surface-soft",
|
|
70
|
+
media:
|
|
71
|
+
"border-transparent bg-transparent p-0 focus-visible:ring-inset enabled:hover:bg-surface-soft enabled:active:bg-surface-strong",
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
const sizes: Record<ButtonSize, string> = {
|
|
@@ -98,6 +105,7 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
98
105
|
},
|
|
99
106
|
ref,
|
|
100
107
|
) => {
|
|
108
|
+
const media = variant === "media";
|
|
101
109
|
return (
|
|
102
110
|
<button
|
|
103
111
|
ref={ref}
|
|
@@ -109,7 +117,11 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
109
117
|
className={cn(
|
|
110
118
|
isRow(variant) ? rowBase : base,
|
|
111
119
|
variants[variant],
|
|
112
|
-
|
|
120
|
+
media
|
|
121
|
+
? "rounded-lg"
|
|
122
|
+
: iconOnly
|
|
123
|
+
? iconOnlySizes[size]
|
|
124
|
+
: sizes[size],
|
|
113
125
|
fullWidth && "w-full",
|
|
114
126
|
loading && "pointer-events-none",
|
|
115
127
|
className,
|
|
@@ -131,6 +143,8 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
131
143
|
)}
|
|
132
144
|
{iconOnly ? (
|
|
133
145
|
!loading && children
|
|
146
|
+
) : media ? (
|
|
147
|
+
children
|
|
134
148
|
) : (
|
|
135
149
|
<span className={isRow(variant) ? "min-w-0 flex-1 truncate" : undefined}>
|
|
136
150
|
{loading && loadingText ? loadingText : children}
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,9 @@ export * from "./atoms/Accordion";
|
|
|
4
4
|
export * from "./atoms/AccordionItem";
|
|
5
5
|
export * from "./atoms/AccordionItemDesktop";
|
|
6
6
|
export * from "./atoms/AccordionItemMobile";
|
|
7
|
+
export * from "./atoms/AgentQuestionCard";
|
|
7
8
|
export * from "./atoms/Alert";
|
|
9
|
+
export * from "./atoms/AttachmentChip";
|
|
8
10
|
export * from "./atoms/Avatar";
|
|
9
11
|
export * from "./atoms/AvatarGroup";
|
|
10
12
|
export * from "./atoms/Badge";
|