@designa8/vibedesign-linear-internal-v1-b737 0.1.0 → 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.
- package/README.md +1 -1
- package/dist/index.cjs +2249 -1878
- package/dist/index.js +2297 -1926
- package/dist/styles.css +49 -0
- package/package.json +6 -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/Button/Button.tsx +19 -5
- package/src/index.ts +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AgentQuestionCard } from "./AgentQuestionCard";
|
|
3
|
+
import type { AgentQuestionAnswer, AgentQuestionOption } from "./AgentQuestionCard";
|
|
4
|
+
|
|
5
|
+
const OPTIONS: AgentQuestionOption[] = [
|
|
6
|
+
{ id: "keep", label: "Keep the current layout and tighten spacing" },
|
|
7
|
+
{ id: "rebuild", label: "Rebuild the canvas grid from scratch" },
|
|
8
|
+
{ id: "defer", label: "Leave it as is for now" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const REFERENCE_IMAGE =
|
|
12
|
+
"https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?auto=format&fit=crop&w=720&q=70";
|
|
13
|
+
|
|
14
|
+
const Section = ({ title, children }: { title: string; children: React.ReactNode }) => (
|
|
15
|
+
<section className="space-y-sm">
|
|
16
|
+
<h2 className="text-caption text-muted">{title}</h2>
|
|
17
|
+
{children}
|
|
18
|
+
</section>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default function Preview() {
|
|
22
|
+
const [selected, setSelected] = React.useState<string | null>("keep");
|
|
23
|
+
const [text, setText] = React.useState("");
|
|
24
|
+
const [collapsed, setCollapsed] = React.useState(false);
|
|
25
|
+
const [submitted, setSubmitted] = React.useState<AgentQuestionAnswer | null>(null);
|
|
26
|
+
|
|
27
|
+
const [errorSelected, setErrorSelected] = React.useState<string | null>("rebuild");
|
|
28
|
+
const [errorText, setErrorText] = React.useState("");
|
|
29
|
+
const [showError, setShowError] = React.useState(true);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
33
|
+
<Section title="Live card — pick an option, choose Other…, or close it">
|
|
34
|
+
<AgentQuestionCard
|
|
35
|
+
questionId="q-layout"
|
|
36
|
+
questionNumber={1}
|
|
37
|
+
question="How should I handle the canvas layout for the new editor?"
|
|
38
|
+
options={OPTIONS}
|
|
39
|
+
imageSrc={REFERENCE_IMAGE}
|
|
40
|
+
imageAlt="Reference layout sketch"
|
|
41
|
+
selectedOptionId={selected}
|
|
42
|
+
freeTextValue={text}
|
|
43
|
+
hint={submitted ? "Answer sent" : "Pick an option or write your own"}
|
|
44
|
+
collapsed={collapsed}
|
|
45
|
+
onAnswerChange={(answer) => {
|
|
46
|
+
setSelected(answer.optionId);
|
|
47
|
+
setText(answer.text);
|
|
48
|
+
setSubmitted(null);
|
|
49
|
+
}}
|
|
50
|
+
onCollapsedChange={setCollapsed}
|
|
51
|
+
onSubmit={(answer) => setSubmitted(answer)}
|
|
52
|
+
/>
|
|
53
|
+
<p className="text-caption text-muted">
|
|
54
|
+
{submitted
|
|
55
|
+
? `Submitted ${submitted.optionId}${submitted.text ? ` — “${submitted.text}”` : ""}`
|
|
56
|
+
: "Nothing submitted yet."}
|
|
57
|
+
</p>
|
|
58
|
+
</Section>
|
|
59
|
+
|
|
60
|
+
<Section title="Error state — clear the free-text row to submit">
|
|
61
|
+
<AgentQuestionCard
|
|
62
|
+
questionId="q-tokens"
|
|
63
|
+
questionNumber={2}
|
|
64
|
+
question="Which token should the selected row use?"
|
|
65
|
+
options={[
|
|
66
|
+
{ id: "primary-soft", label: "primary-soft tint with a trailing check" },
|
|
67
|
+
{ id: "surface-soft", label: "surface-soft tint with no marker" },
|
|
68
|
+
]}
|
|
69
|
+
selectedOptionId={errorSelected}
|
|
70
|
+
freeTextValue={errorText}
|
|
71
|
+
onAnswerChange={(answer) => {
|
|
72
|
+
setErrorSelected(answer.optionId);
|
|
73
|
+
setErrorText(answer.text);
|
|
74
|
+
setShowError(false);
|
|
75
|
+
}}
|
|
76
|
+
errorMessage={showError ? "A written answer can’t be empty — keep typing." : undefined}
|
|
77
|
+
onSubmit={() => setShowError(true)}
|
|
78
|
+
/>
|
|
79
|
+
</Section>
|
|
80
|
+
|
|
81
|
+
<Section title="Submitting — spinner, Sending…, controls disabled">
|
|
82
|
+
<AgentQuestionCard
|
|
83
|
+
questionId="q-done"
|
|
84
|
+
questionNumber={3}
|
|
85
|
+
question="Should I apply the change to every breakpoint?"
|
|
86
|
+
options={[
|
|
87
|
+
{ id: "all", label: "Yes, every breakpoint" },
|
|
88
|
+
{ id: "desktop", label: "Desktop only for now" },
|
|
89
|
+
]}
|
|
90
|
+
defaultSelectedOptionId="all"
|
|
91
|
+
submitting
|
|
92
|
+
waitingCount={3}
|
|
93
|
+
onSubmit={() => undefined}
|
|
94
|
+
/>
|
|
95
|
+
</Section>
|
|
96
|
+
|
|
97
|
+
<Section title="Collapsed — restore bar with the waiting count">
|
|
98
|
+
<AgentQuestionCard
|
|
99
|
+
questionId="q-collapsed"
|
|
100
|
+
question="Ready for the next question?"
|
|
101
|
+
options={[{ id: "yes", label: "Yes, keep going" }]}
|
|
102
|
+
collapsed
|
|
103
|
+
waitingCount={2}
|
|
104
|
+
onSubmit={() => undefined}
|
|
105
|
+
/>
|
|
106
|
+
</Section>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -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,6 +4,7 @@ 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";
|
|
8
9
|
export * from "./atoms/Avatar";
|
|
9
10
|
export * from "./atoms/AvatarGroup";
|