@you-agent-factory/components 0.0.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 +223 -0
- package/docs/README.md +83 -0
- package/docs/button.md +119 -0
- package/docs/charts.md +325 -0
- package/docs/data-display-code-panel.md +120 -0
- package/docs/feedback-alert-panel.md +117 -0
- package/docs/feedback-skeleton.md +54 -0
- package/docs/forms-form-field.md +490 -0
- package/docs/forms-input-primitives.md +311 -0
- package/docs/forms-select-primitives.md +362 -0
- package/docs/graphs.md +250 -0
- package/docs/layout-display-primitives.md +211 -0
- package/docs/overlays.md +414 -0
- package/docs/table-data-table.md +331 -0
- package/docs/typography-roles.md +182 -0
- package/docs/widget-frame-recipes.md +273 -0
- package/package.json +161 -0
- package/src/category-paths.ts +20 -0
- package/src/charts/chart-state-panel.tsx +103 -0
- package/src/charts/chart.tsx +287 -0
- package/src/charts/index.ts +21 -0
- package/src/data-display/code-panel.tsx +67 -0
- package/src/data-display/data-table.tsx +180 -0
- package/src/data-display/description-list.tsx +24 -0
- package/src/data-display/index.ts +34 -0
- package/src/data-display/table-layout.ts +12 -0
- package/src/data-display/table.tsx +131 -0
- package/src/feedback/alert-panel-semantics.ts +75 -0
- package/src/feedback/alert-panel.tsx +187 -0
- package/src/feedback/index.ts +21 -0
- package/src/feedback/skeleton.tsx +16 -0
- package/src/forms/index.ts +73 -0
- package/src/forms/package-checkbox.tsx +50 -0
- package/src/forms/package-enum-select.tsx +185 -0
- package/src/forms/package-file-input.tsx +25 -0
- package/src/forms/package-form-field.tsx +202 -0
- package/src/forms/package-input.tsx +25 -0
- package/src/forms/package-native-select.tsx +25 -0
- package/src/forms/package-select.tsx +209 -0
- package/src/forms/package-textarea.tsx +35 -0
- package/src/forms/select-icons.tsx +35 -0
- package/src/graphs/graph-edge-path.ts +241 -0
- package/src/graphs/graph-edge.tsx +130 -0
- package/src/graphs/graph-interactive-example.tsx +187 -0
- package/src/graphs/graph-node-button.tsx +51 -0
- package/src/graphs/graph-node-handle-badge.tsx +108 -0
- package/src/graphs/graph-node-handle.ts +28 -0
- package/src/graphs/graph-node-shell.tsx +111 -0
- package/src/graphs/graph-node-state-indicator.tsx +47 -0
- package/src/graphs/graph-node-state.ts +111 -0
- package/src/graphs/graph-viewport-surface.tsx +27 -0
- package/src/graphs/index.ts +41 -0
- package/src/icons/index.ts +4 -0
- package/src/index.ts +209 -0
- package/src/layout/action-row.tsx +53 -0
- package/src/layout/index.ts +9 -0
- package/src/layout/surface-panel.tsx +91 -0
- package/src/navigation/index.ts +4 -0
- package/src/overlays/collapsible.tsx +22 -0
- package/src/overlays/dialog.tsx +148 -0
- package/src/overlays/index.ts +31 -0
- package/src/overlays/overlay-layout.ts +9 -0
- package/src/overlays/popover.tsx +29 -0
- package/src/overlays/scroll-area.tsx +78 -0
- package/src/primitives/button-link.tsx +22 -0
- package/src/primitives/button.tsx +258 -0
- package/src/primitives/icon-button-shell.tsx +49 -0
- package/src/primitives/index.ts +31 -0
- package/src/primitives/package-text.tsx +29 -0
- package/src/primitives/typography-roles.ts +12 -0
- package/src/primitives/typography.tsx +165 -0
- package/src/recipes/index.ts +61 -0
- package/src/recipes/widget-frame-content.tsx +114 -0
- package/src/recipes/widget-frame-disclosure.tsx +161 -0
- package/src/recipes/widget-frame-layout.ts +40 -0
- package/src/recipes/widget-frame-skeleton.tsx +16 -0
- package/src/recipes/widget-frame-states.tsx +99 -0
- package/src/recipes/widget-frame-typography.ts +19 -0
- package/src/recipes/widget-frame.tsx +84 -0
- package/src/styles/color-palette-presets.css +167 -0
- package/src/styles/color-role-tokens.css +163 -0
- package/src/styles/layout-role-tokens.css +27 -0
- package/src/styles/text-color-role-tokens.css +29 -0
- package/src/styles/typography-role-tokens.css +72 -0
- package/src/styles/typography-role-utilities.css +73 -0
- package/src/styles/typography-roles.css +53 -0
- package/src/styles.css +32 -0
- package/src/testing/index.ts +13 -0
- package/src/testing/render.tsx +16 -0
- package/src/tokens/index.ts +4 -0
- package/src/utilities/cn.ts +5 -0
- package/src/utilities/index.ts +6 -0
package/docs/charts.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Charts
|
|
2
|
+
|
|
3
|
+
Domain-neutral chart presentation primitives built on [Recharts](https://recharts.org/).
|
|
4
|
+
Import chart components from `@you-agent-factory/components/charts`. The package
|
|
5
|
+
owns markup, tokens, accessible chart chrome, tooltip and legend content, and
|
|
6
|
+
generic state panels. Host applications own data fetching, domain series
|
|
7
|
+
generation, localized copy, and semantic color mapping.
|
|
8
|
+
|
|
9
|
+
## Install and imports
|
|
10
|
+
|
|
11
|
+
Recharts is a regular dependency of `@you-agent-factory/components`. Host apps
|
|
12
|
+
that render charts should also depend on `recharts` so TypeScript can resolve
|
|
13
|
+
Recharts child components (`LineChart`, `Line`, `XAxis`, and so on).
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
ChartContainer,
|
|
18
|
+
ChartLegend,
|
|
19
|
+
ChartLegendContent,
|
|
20
|
+
ChartStatePanel,
|
|
21
|
+
ChartTooltip,
|
|
22
|
+
ChartTooltipContent,
|
|
23
|
+
type ChartConfig,
|
|
24
|
+
type ChartPresentation,
|
|
25
|
+
type ChartStatePanelProps,
|
|
26
|
+
type ChartStateStatus,
|
|
27
|
+
} from "@you-agent-factory/components/charts";
|
|
28
|
+
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Import package styles once in your host CSS before rendering charts:
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@import "@you-agent-factory/components/styles.css";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Minimal Recharts composition
|
|
38
|
+
|
|
39
|
+
`ChartContainer` wraps a Recharts chart, exposes an accessible chart region,
|
|
40
|
+
and injects CSS color variables from your config. Series strokes and fills
|
|
41
|
+
reference those variables.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
const chartConfig: ChartConfig = {
|
|
45
|
+
alpha: { color: "#3366cc", label: "Alpha series" },
|
|
46
|
+
beta: { color: "#cc6633", label: "Beta series" },
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const chartData = [
|
|
50
|
+
{ alpha: 4, beta: 2, tick: 1 },
|
|
51
|
+
{ alpha: 6, beta: 3, tick: 2 },
|
|
52
|
+
{ alpha: 5, beta: 4, tick: 3 },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
function ThroughputChart() {
|
|
56
|
+
return (
|
|
57
|
+
<ChartContainer config={chartConfig} title="Sample throughput chart">
|
|
58
|
+
<LineChart data={chartData}>
|
|
59
|
+
<CartesianGrid vertical={false} />
|
|
60
|
+
<XAxis dataKey="tick" />
|
|
61
|
+
<YAxis />
|
|
62
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
63
|
+
<Line dataKey="alpha" stroke="var(--color-alpha)" type="monotone" />
|
|
64
|
+
<Line dataKey="beta" stroke="var(--color-beta)" type="monotone" />
|
|
65
|
+
</LineChart>
|
|
66
|
+
</ChartContainer>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The container renders `role="img"` with `aria-label` set from the required
|
|
72
|
+
`title` prop. Recharts children read `--color-<seriesKey>` variables that
|
|
73
|
+
`ChartContainer` derives from `config` entries.
|
|
74
|
+
|
|
75
|
+
## Chart config
|
|
76
|
+
|
|
77
|
+
`ChartConfig` is a record of series keys to `ChartConfigEntry` objects:
|
|
78
|
+
|
|
79
|
+
| Field | Purpose |
|
|
80
|
+
| ------- | ------- |
|
|
81
|
+
| `color` | Hex or CSS color used for the `--color-<key>` variable and legend swatches |
|
|
82
|
+
| `label` | Human-readable series name shown in tooltips and legends |
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const chartConfig: ChartConfig = {
|
|
86
|
+
queued: { color: "#5c6bc0", label: "Queued work" },
|
|
87
|
+
completed: { color: "#43a047", label: "Completed work" },
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Map domain data into `ChartConfig` in the host app. The chart package does not
|
|
92
|
+
import work, session, provider, outcome, dashboard, or generated API types.
|
|
93
|
+
Dashboard work-outcome charts, for example, keep semantic role definitions and
|
|
94
|
+
series generation in dashboard feature code and pass a prepared config into
|
|
95
|
+
`ChartContainer`.
|
|
96
|
+
|
|
97
|
+
## Presentation: standalone versus embedded
|
|
98
|
+
|
|
99
|
+
`ChartPresentation` is `"standalone"` (default) or `"embedded"`.
|
|
100
|
+
|
|
101
|
+
- **Standalone** — Fixed-height bordered card (`h-[18rem]`) suited to docs,
|
|
102
|
+
Storybook, and full-width dashboard panels.
|
|
103
|
+
- **Embedded** — Flex child that fills available height and width inside a
|
|
104
|
+
parent layout (for example an information card or split pane).
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<ChartContainer
|
|
108
|
+
config={chartConfig}
|
|
109
|
+
presentation="embedded"
|
|
110
|
+
title="Embedded throughput chart"
|
|
111
|
+
>
|
|
112
|
+
{/* Recharts children */}
|
|
113
|
+
</ChartContainer>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Both presentations set `data-chart-presentation` on the root element for
|
|
117
|
+
testing and layout hooks.
|
|
118
|
+
|
|
119
|
+
## Tooltip and legend content
|
|
120
|
+
|
|
121
|
+
`ChartTooltip` is the Recharts `Tooltip` export. Pass `ChartTooltipContent` as
|
|
122
|
+
the `content` render prop so labels and swatches resolve from `ChartConfig`:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`ChartLegend` is the Recharts `Legend` export. For a compact footer legend
|
|
129
|
+
outside the Recharts tree, render `ChartLegendContent` in `ChartContainer`'s
|
|
130
|
+
`footer` prop and supply `payload` yourself:
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<ChartContainer
|
|
134
|
+
config={chartConfig}
|
|
135
|
+
footer={
|
|
136
|
+
<ChartLegendContent
|
|
137
|
+
payload={[
|
|
138
|
+
{
|
|
139
|
+
color: chartConfig.alpha.color,
|
|
140
|
+
dataKey: "alpha",
|
|
141
|
+
type: "line",
|
|
142
|
+
value: chartConfig.alpha.label,
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
/>
|
|
146
|
+
}
|
|
147
|
+
title="Chart with footer legend"
|
|
148
|
+
>
|
|
149
|
+
{/* Recharts children */}
|
|
150
|
+
</ChartContainer>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Optional `ChartContainer` props:
|
|
154
|
+
|
|
155
|
+
| Prop | Purpose |
|
|
156
|
+
| ---- | ------- |
|
|
157
|
+
| `footer` | Content below the chart surface (typical home for `ChartLegendContent`) |
|
|
158
|
+
| `overlay` | Non-interactive overlay inside the chart region |
|
|
159
|
+
| `interactionAttributes` | Extra attributes on the chart root (for example drag-to-zoom handlers owned by the host) |
|
|
160
|
+
| `rootAttributes` | Additional `data-*` or `aria-*` attributes on the chart root |
|
|
161
|
+
| `className` / `style` | Host styling overrides |
|
|
162
|
+
|
|
163
|
+
## Caller-owned legend state
|
|
164
|
+
|
|
165
|
+
Legend toggles are optional. When `onToggleSeries` is provided,
|
|
166
|
+
`ChartLegendContent` renders keyboard-focusable buttons with `aria-pressed`
|
|
167
|
+
reflecting visibility. The package does not store hidden-series state; the host
|
|
168
|
+
owns a `Set<string>` (or equivalent) and updates it in the toggle callback.
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import { useState } from "react";
|
|
172
|
+
|
|
173
|
+
function InteractiveLegendChart() {
|
|
174
|
+
const [hiddenSeries, setHiddenSeries] = useState<ReadonlySet<string>>(
|
|
175
|
+
() => new Set(),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const handleToggleSeries = (key: string) => {
|
|
179
|
+
setHiddenSeries((current) => {
|
|
180
|
+
const next = new Set(current);
|
|
181
|
+
if (next.has(key)) {
|
|
182
|
+
next.delete(key);
|
|
183
|
+
} else {
|
|
184
|
+
next.add(key);
|
|
185
|
+
}
|
|
186
|
+
return next;
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<ChartContainer
|
|
192
|
+
config={chartConfig}
|
|
193
|
+
footer={
|
|
194
|
+
<ChartLegendContent
|
|
195
|
+
getToggleLabel={(label, hidden) =>
|
|
196
|
+
hidden ? `Show ${label}` : `Hide ${label}`
|
|
197
|
+
}
|
|
198
|
+
hiddenSeries={hiddenSeries}
|
|
199
|
+
onToggleSeries={handleToggleSeries}
|
|
200
|
+
payload={legendPayload}
|
|
201
|
+
/>
|
|
202
|
+
}
|
|
203
|
+
title="Interactive legend chart"
|
|
204
|
+
>
|
|
205
|
+
<LineChart data={chartData}>
|
|
206
|
+
{!hiddenSeries.has("alpha") ? (
|
|
207
|
+
<Line dataKey="alpha" stroke="var(--color-alpha)" type="monotone" />
|
|
208
|
+
) : null}
|
|
209
|
+
{!hiddenSeries.has("beta") ? (
|
|
210
|
+
<Line dataKey="beta" stroke="var(--color-beta)" type="monotone" />
|
|
211
|
+
) : null}
|
|
212
|
+
</LineChart>
|
|
213
|
+
</ChartContainer>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Filter Recharts series in the host based on `hiddenSeries`. Use
|
|
219
|
+
`getToggleLabel` for accessible toggle names when the default label is not
|
|
220
|
+
sufficient.
|
|
221
|
+
|
|
222
|
+
## Chart state panels
|
|
223
|
+
|
|
224
|
+
Use `ChartStatePanel` when data is not ready for a chart. The `status` prop is
|
|
225
|
+
one of `"loading"`, `"empty"`, `"error"`, or `"success"`. Titles,
|
|
226
|
+
descriptions, and optional actions are caller-supplied; the package does not
|
|
227
|
+
ship product copy.
|
|
228
|
+
|
|
229
|
+
| Prop | Purpose |
|
|
230
|
+
| ---- | ------- |
|
|
231
|
+
| `status` | Panel state (`loading`, `empty`, `error`, `success`) |
|
|
232
|
+
| `title` | Heading text (`<h3>`) |
|
|
233
|
+
| `description` | Supporting copy |
|
|
234
|
+
| `action` | Optional retry or navigation control |
|
|
235
|
+
| `presentation` | `"standalone"` (dashed bordered shell) or `"embedded"` (fits inside a parent card) |
|
|
236
|
+
|
|
237
|
+
Accessibility:
|
|
238
|
+
|
|
239
|
+
- `error` uses `role="alert"` and `aria-live="assertive"`.
|
|
240
|
+
- Other states use `role="status"` and `aria-live="polite"`.
|
|
241
|
+
- `loading` sets `aria-busy` and shows a skeleton without relying on color
|
|
242
|
+
alone.
|
|
243
|
+
|
|
244
|
+
### Loading
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
<ChartStatePanel
|
|
248
|
+
description="Waiting for chart data to load."
|
|
249
|
+
status="loading"
|
|
250
|
+
title="Loading chart data"
|
|
251
|
+
/>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Empty
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
<ChartStatePanel
|
|
258
|
+
description="No data points are available for this range."
|
|
259
|
+
status="empty"
|
|
260
|
+
title="No chart data"
|
|
261
|
+
/>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Error
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
<ChartStatePanel
|
|
268
|
+
action={<button type="button">Retry chart load</button>}
|
|
269
|
+
description="The chart request failed. Try again later."
|
|
270
|
+
status="error"
|
|
271
|
+
title="Unable to load chart"
|
|
272
|
+
/>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Success
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
<ChartStatePanel
|
|
279
|
+
description="The chart finished loading successfully."
|
|
280
|
+
status="success"
|
|
281
|
+
title="Chart ready"
|
|
282
|
+
/>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Embedded state in a narrow layout
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
<div className="w-64 rounded-2xl border border-outline p-4">
|
|
289
|
+
<ChartStatePanel
|
|
290
|
+
description="No data points are available for this range."
|
|
291
|
+
presentation="embedded"
|
|
292
|
+
status="empty"
|
|
293
|
+
title="No chart data"
|
|
294
|
+
/>
|
|
295
|
+
</div>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Render a state panel instead of `ChartContainer` when the host determines data
|
|
299
|
+
is loading, empty, invalid, or failed. Do not embed domain fetching logic inside
|
|
300
|
+
the chart package.
|
|
301
|
+
|
|
302
|
+
## Host application responsibilities
|
|
303
|
+
|
|
304
|
+
The chart package is presentation-only. Host applications own:
|
|
305
|
+
|
|
306
|
+
| Responsibility | Examples |
|
|
307
|
+
| -------------- | -------- |
|
|
308
|
+
| Data fetching | API calls, caching, refresh, and error handling |
|
|
309
|
+
| Domain series generation | Aggregating work outcomes, time ranges, and metric keys into `chartData` rows |
|
|
310
|
+
| Localized copy | Titles, descriptions, axis labels, and toggle labels passed as props |
|
|
311
|
+
| Semantic styling | Mapping domain roles (queued, completed, failed, and so on) to colors and Recharts class names before building `ChartConfig` |
|
|
312
|
+
|
|
313
|
+
The dashboard work-outcome feature keeps `chart-contract.ts` and
|
|
314
|
+
`buildWorkChartData` for semantic colors and deterministic series mapping, then
|
|
315
|
+
imports generic primitives from `@you-agent-factory/components/charts` for
|
|
316
|
+
rendering. Follow the same boundary in other apps: prepare config and data in
|
|
317
|
+
feature code, render with package chart components.
|
|
318
|
+
|
|
319
|
+
## Storybook and tests
|
|
320
|
+
|
|
321
|
+
Domain-neutral Storybook examples live under `src/charts/*.stories.tsx`.
|
|
322
|
+
Package tests in `src/charts/chart.test.tsx` and
|
|
323
|
+
`chart-state-panel.test.tsx` render charts and state panels without dashboard
|
|
324
|
+
providers or fixtures. See those files for copy-paste-friendly neutral data
|
|
325
|
+
(`chart-story-fixtures.ts`).
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# CodePanel
|
|
2
|
+
|
|
3
|
+
Contained `<pre>` surface for generated scripts, logs, and diagnostic output.
|
|
4
|
+
`CodePanel` keeps long single-line and multi-line content inside the panel
|
|
5
|
+
without causing page-level horizontal overflow or overlapping header controls.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { CodePanel } from "@you-agent-factory/components";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Category entrypoint:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { CodePanel } from "@you-agent-factory/components/data-display";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Long-content containment
|
|
20
|
+
|
|
21
|
+
`CodePanel` applies layout classes that bound width and overflow at the panel
|
|
22
|
+
boundary:
|
|
23
|
+
|
|
24
|
+
- `min-w-0 w-full max-w-full` — shrink inside flex/grid parents instead of
|
|
25
|
+
forcing page overflow
|
|
26
|
+
- `overflow-x-auto` — horizontal scroll for unbreakable tokens when wrapping is
|
|
27
|
+
insufficient
|
|
28
|
+
- `whitespace-pre-wrap` and `[overflow-wrap:anywhere]` — wrap long single lines
|
|
29
|
+
inside the panel
|
|
30
|
+
- `font-mono text-code-medium text-code` — package code typography tokens
|
|
31
|
+
|
|
32
|
+
Place labels and action buttons in a sibling header row with `flex min-w-0` and
|
|
33
|
+
`shrink-0` on controls so long code does not overlap panel chrome.
|
|
34
|
+
|
|
35
|
+
## Vertical scrolling
|
|
36
|
+
|
|
37
|
+
Set `maxHeight` when multi-line blocks should scroll inside the panel instead
|
|
38
|
+
of expanding the page:
|
|
39
|
+
|
|
40
|
+
| `maxHeight` | Behavior |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `none` (default) | Grows with content; no vertical scroll region |
|
|
43
|
+
| `sm` | `max-h-48 overflow-y-auto` |
|
|
44
|
+
| `md` | `max-h-72 overflow-y-auto` |
|
|
45
|
+
| `lg` | `max-h-96 overflow-y-auto` |
|
|
46
|
+
|
|
47
|
+
Scrollable panels receive `tabIndex={0}` by default so keyboard users can
|
|
48
|
+
focus the code region and scroll with arrow keys. Focus rings use
|
|
49
|
+
`focus-visible:outline-primary`.
|
|
50
|
+
|
|
51
|
+
## Surface and padding
|
|
52
|
+
|
|
53
|
+
| Prop | Values | Purpose |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `surface` | `high` (default), `low` | `bg-surface-container-high` vs `bg-surface-container-low` |
|
|
56
|
+
| `padding` | `compact` (default), `default` | `p-2` vs `p-3` |
|
|
57
|
+
|
|
58
|
+
## Responsive expectations
|
|
59
|
+
|
|
60
|
+
- At narrow widths, long single-line JSON or shell output wraps inside the
|
|
61
|
+
panel; horizontal scroll remains available for unbreakable segments.
|
|
62
|
+
- At desktop widths, combine `maxHeight="lg"` with a `max-w-*` parent when code
|
|
63
|
+
blocks should stay readable beside side panels.
|
|
64
|
+
- Header labels should use `min-w-0 shrink` so truncated titles do not push
|
|
65
|
+
action buttons off-screen.
|
|
66
|
+
|
|
67
|
+
## Usage examples
|
|
68
|
+
|
|
69
|
+
Short snippet:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<CodePanel>const value = 1;</CodePanel>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Long single line inside a bounded column:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<div className="w-full max-w-md">
|
|
79
|
+
<CodePanel>{longSingleLineString}</CodePanel>
|
|
80
|
+
</div>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Long multi-line log with vertical scroll:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<CodePanel maxHeight="md" padding="default" surface="low">
|
|
87
|
+
{longMultiLineOutput}
|
|
88
|
+
</CodePanel>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Header row with copy action (controls stay visible):
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<div className="grid w-full max-w-md gap-2">
|
|
95
|
+
<div className="flex min-w-0 items-center justify-between gap-2">
|
|
96
|
+
<span className="min-w-0 shrink text-body-medium text-on-surface">
|
|
97
|
+
Generated script
|
|
98
|
+
</span>
|
|
99
|
+
<button className="shrink-0" type="button">
|
|
100
|
+
Copy
|
|
101
|
+
</button>
|
|
102
|
+
</div>
|
|
103
|
+
<CodePanel maxHeight="md" padding="default" surface="low">
|
|
104
|
+
{code}
|
|
105
|
+
</CodePanel>
|
|
106
|
+
</div>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Storybook
|
|
110
|
+
|
|
111
|
+
Package Storybook stories under **Data Display/CodePanel**:
|
|
112
|
+
|
|
113
|
+
- `data-display-codepanel--short-code`
|
|
114
|
+
- `data-display-codepanel--long-single-line`
|
|
115
|
+
- `data-display-codepanel--long-multi-line`
|
|
116
|
+
- `data-display-codepanel--long-code` — narrow viewport with header controls
|
|
117
|
+
- `data-display-codepanel--desktop-long-code` — desktop viewport with taller
|
|
118
|
+
scroll region
|
|
119
|
+
|
|
120
|
+
Stories use package imports and token fixture styles only.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# AlertPanel
|
|
2
|
+
|
|
3
|
+
Semantic feedback panels for neutral, informational, success, warning, danger,
|
|
4
|
+
error, loading, and empty states. Use `AlertPanel` when a surface needs a
|
|
5
|
+
contained message with token-backed tone, accessible roles, and optional status
|
|
6
|
+
labels — without dashboard routes, providers, or feature state.
|
|
7
|
+
|
|
8
|
+
## Import
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import {
|
|
12
|
+
AlertPanel,
|
|
13
|
+
AlertPanelText,
|
|
14
|
+
AlertPanelTitle,
|
|
15
|
+
type AlertPanelSemanticVariant,
|
|
16
|
+
} from "@you-agent-factory/components";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Category entrypoint:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
AlertPanel,
|
|
24
|
+
AlertPanelText,
|
|
25
|
+
AlertPanelTitle,
|
|
26
|
+
} from "@you-agent-factory/components/feedback";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Import `@you-agent-factory/components/styles.css` once in the host application so
|
|
30
|
+
semantic container and border tokens resolve correctly.
|
|
31
|
+
|
|
32
|
+
## Semantic variants
|
|
33
|
+
|
|
34
|
+
Prefer the `semantic` prop for reviewer-visible, all-in-one feedback states.
|
|
35
|
+
Each variant resolves tone, layout, default `role`, optional status labels, and
|
|
36
|
+
loading placeholders through package-owned semantics.
|
|
37
|
+
|
|
38
|
+
| `semantic` | When to use | Default `role` | Status label | Visual treatment |
|
|
39
|
+
| --- | --- | --- | --- | --- |
|
|
40
|
+
| `neutral` | General copy without urgency | `status` | — | `border-outline`, `bg-surface-container-low`, `text-on-surface-variant` |
|
|
41
|
+
| `info` | Helpful context or guidance | `status` | — | `border-af-info-border`, `bg-info-container`, `text-on-info-container` |
|
|
42
|
+
| `success` | Completed or healthy outcomes | `status` | — | `border-af-success-border`, `bg-success-container`, `text-on-success-container` |
|
|
43
|
+
| `warning` | Caution before continuing | `alert` | — | `border-af-warning-border`, `bg-warning-container`, `text-on-warning-container` |
|
|
44
|
+
| `danger` | Destructive or high-risk actions | `alert` | — | `border-af-danger-border`, `bg-error-container`, `text-on-error-container` |
|
|
45
|
+
| `error` | Failed requests or blocking faults | `alert` | `Error` | Same tokens as `danger` with explicit error label |
|
|
46
|
+
| `loading` | In-flight work without final copy | `status` | `Loading` | Neutral tone, built-in skeleton placeholders, `aria-busy` |
|
|
47
|
+
| `empty` | No data yet, dashed empty surface | `status` | `Empty` | Neutral tone, dashed border layout |
|
|
48
|
+
|
|
49
|
+
Legacy `tone` and `variant` props remain for migration compatibility. New
|
|
50
|
+
consumers should use `semantic` so roles, labels, and loading placeholders stay
|
|
51
|
+
consistent.
|
|
52
|
+
|
|
53
|
+
## Design token mapping
|
|
54
|
+
|
|
55
|
+
Alert tones map to semantic role tokens defined in
|
|
56
|
+
`src/styles/color-role-tokens.css`:
|
|
57
|
+
|
|
58
|
+
- **Neutral** — `--color-outline`, `--color-surface-container-low`,
|
|
59
|
+
`--color-on-surface-variant`
|
|
60
|
+
- **Info** — `--color-info-container`, `--color-on-info-container`,
|
|
61
|
+
`--color-af-info-border`
|
|
62
|
+
- **Success** — `--color-success-container`, `--color-on-success-container`,
|
|
63
|
+
`--color-af-success-border`
|
|
64
|
+
- **Warning** — `--color-warning-container`, `--color-on-warning-container`,
|
|
65
|
+
`--color-af-warning-border`
|
|
66
|
+
- **Danger / error** — `--color-error-container`, `--color-on-error-container`,
|
|
67
|
+
`--color-af-danger-border`
|
|
68
|
+
|
|
69
|
+
Typography uses package role utilities (`text-body-medium`,
|
|
70
|
+
`text-body-small`) rather than dashboard-only aliases.
|
|
71
|
+
|
|
72
|
+
## Accessibility
|
|
73
|
+
|
|
74
|
+
- Warning, danger, and error variants default to `role="alert"`; neutral, info,
|
|
75
|
+
success, loading, and empty default to `role="status"`.
|
|
76
|
+
- `error`, `loading`, and `empty` render an uppercase status label so state is
|
|
77
|
+
not communicated by color alone.
|
|
78
|
+
- `loading` sets `aria-busy="true"` and renders skeleton placeholders when no
|
|
79
|
+
children are provided.
|
|
80
|
+
- Compose titles with `AlertPanelTitle` and body copy with `AlertPanelText`.
|
|
81
|
+
|
|
82
|
+
## Usage examples
|
|
83
|
+
|
|
84
|
+
Neutral guidance:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<AlertPanel semantic="neutral">
|
|
88
|
+
<AlertPanelTitle>Factory session idle</AlertPanelTitle>
|
|
89
|
+
<AlertPanelText>Submit work to start orchestration.</AlertPanelText>
|
|
90
|
+
</AlertPanel>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Loading without custom markup:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<AlertPanel semantic="loading" />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Empty state with dashed layout:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<AlertPanel semantic="empty">
|
|
103
|
+
<AlertPanelTitle>No dispatches yet</AlertPanelTitle>
|
|
104
|
+
<AlertPanelText>Run a workflow to populate this list.</AlertPanelText>
|
|
105
|
+
</AlertPanel>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Storybook
|
|
109
|
+
|
|
110
|
+
Package Storybook exposes each semantic variant under **Feedback/AlertPanel**:
|
|
111
|
+
|
|
112
|
+
- `feedback-alertpanel--semantic-variants` — all eight states in one grid
|
|
113
|
+
- `feedback-alertpanel--neutral`, `--info`, `--success`, `--warning`,
|
|
114
|
+
`--danger`, `--error-state`, `--loading`, `--empty`
|
|
115
|
+
|
|
116
|
+
Stories use package imports and the package token fixture decorator only; they
|
|
117
|
+
do not mount dashboard providers.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
Non-interactive loading placeholders for feedback and layout surfaces. Use
|
|
4
|
+
`Skeleton` for pulse affordances inside busy regions; pair it with
|
|
5
|
+
`aria-busy="true"` on a parent when the surrounding surface is still loading.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { Skeleton } from "@you-agent-factory/components";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Category entrypoint:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Skeleton } from "@you-agent-factory/components/feedback";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Behavior
|
|
20
|
+
|
|
21
|
+
- Renders a `div` with `aria-hidden="true"` so assistive technology does not
|
|
22
|
+
treat placeholder bars as content.
|
|
23
|
+
- Uses package overlay token `bg-af-overlay` with `animate-pulse` and
|
|
24
|
+
`rounded-xl` for consistent loading chrome.
|
|
25
|
+
- Accepts standard `className` sizing (`h-*`, `w-*`, `max-w-*`) so consumers
|
|
26
|
+
can mirror dashboard panel layouts.
|
|
27
|
+
|
|
28
|
+
## Loading and empty feedback
|
|
29
|
+
|
|
30
|
+
- **Panel loading** — wrap multiple skeleton bars in a parent with
|
|
31
|
+
`aria-busy="true"`. Hide decorative skeleton groups with `aria-hidden="true"`
|
|
32
|
+
on the wrapper when the parent already exposes busy state.
|
|
33
|
+
- **Alert loading** — prefer `<AlertPanel semantic="loading" />` when the whole
|
|
34
|
+
feedback surface should show a standardized loading state with status label
|
|
35
|
+
and skeleton placeholders.
|
|
36
|
+
- **Empty states** — use `<AlertPanel semantic="empty" />` for intentional empty
|
|
37
|
+
feedback; do not use `Skeleton` alone to imply emptiness.
|
|
38
|
+
|
|
39
|
+
## Usage example
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
<div aria-busy="true" className="grid gap-3">
|
|
43
|
+
<Skeleton className="h-4 w-32" />
|
|
44
|
+
<Skeleton className="h-28 w-full" />
|
|
45
|
+
</div>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Storybook
|
|
49
|
+
|
|
50
|
+
Package Storybook stories under **Feedback/Skeleton**:
|
|
51
|
+
|
|
52
|
+
- `feedback-skeleton--compact` — short placeholder bars
|
|
53
|
+
- `feedback-skeleton--full-width` — wide block placeholder
|
|
54
|
+
- `feedback-skeleton--panel-loading-layout` — dashboard-style panel loading
|