@asanchez-sa/abby 0.3.0 → 0.4.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/dist/components/badge/badge.d.ts +3 -2
- package/dist/components/badge/badge.js +27 -11
- package/dist/components/calendar/calendar.d.ts +26 -5
- package/dist/components/calendar/calendar.js +387 -72
- package/dist/components/chart/chart.d.ts +76 -0
- package/dist/components/chart/chart.js +565 -0
- package/dist/components/chart/parts/axes.js +126 -0
- package/dist/components/chart/parts/frame.d.ts +31 -0
- package/dist/components/chart/parts/frame.js +278 -0
- package/dist/components/chart/parts/legend.d.ts +16 -0
- package/dist/components/chart/parts/legend.js +82 -0
- package/dist/components/chart/parts/points.d.ts +1 -0
- package/dist/components/chart/parts/points.js +139 -0
- package/dist/components/chart/parts/scale.js +139 -0
- package/dist/components/chart/parts/table.js +105 -0
- package/dist/components/chart/parts/types.d.ts +44 -0
- package/dist/components/chart/parts/types.js +8 -0
- package/dist/components/filter-chip/filter-chip.d.ts +36 -0
- package/dist/components/filter-chip/filter-chip.js +97 -0
- package/dist/components/graph/graph.d.ts +151 -0
- package/dist/components/graph/graph.js +959 -0
- package/dist/components/model-selector/model-selector.d.ts +38 -3
- package/dist/components/model-selector/model-selector.js +331 -73
- package/dist/components/number-input/number-input.d.ts +14 -3
- package/dist/components/number-input/number-input.js +193 -34
- package/dist/components/spinner/spinner.d.ts +7 -1
- package/dist/components/spinner/spinner.js +86 -26
- package/dist/components/toast/toast.d.ts +19 -2
- package/dist/components/toast/toast.js +211 -49
- package/dist/components/toggle/toggle.d.ts +18 -4
- package/dist/components/toggle/toggle.js +167 -32
- package/dist/components/week-strip/week-strip.d.ts +27 -5
- package/dist/components/week-strip/week-strip.js +288 -134
- package/package.json +4 -1
- package/skills/agent-ready-ui/SKILL.md +1 -1
- package/skills/blocks/SKILL.md +1 -1
- package/skills/compose-screens/SKILL.md +47 -5
- package/skills/compose-screens/references/calendar-week.md +77 -0
- package/skills/compose-screens/references/charts-and-maps.md +183 -0
- package/skills/compose-screens/references/filter-chips.md +61 -0
- package/skills/compose-screens/references/number-units.md +52 -0
- package/skills/note-editor/SKILL.md +1 -1
- package/skills/note-status/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
package/skills/blocks/SKILL.md
CHANGED
|
@@ -3,15 +3,18 @@ name: compose-screens
|
|
|
3
3
|
description: "Use when building screens, forms, dialogs, menus or lists from
|
|
4
4
|
abby components: parts and their composition, button looks on trigger parts,
|
|
5
5
|
Icon and Link, sizes, Field for labels and errors, items for lists, controlled
|
|
6
|
-
state, popups without portals
|
|
7
|
-
|
|
6
|
+
state, popups without portals, bar charts of counts by day or week (stacked
|
|
7
|
+
into parts, with their legend and notes), line charts of a trend by week, maps
|
|
8
|
+
of nodes joined by lines, rows of filter chips, a chip that opens a menu to
|
|
9
|
+
narrow a list, a unit inside a number field. Takes precedence over generic
|
|
10
|
+
ui-sdk or shadcn examples."
|
|
8
11
|
metadata:
|
|
9
12
|
purpose: Shows how abby's styled components compose into screens, where they
|
|
10
13
|
differ from shadcn and from raw ui-sdk, and which choices keep them
|
|
11
14
|
accessible and usable by agents.
|
|
12
15
|
type: core
|
|
13
16
|
library: abby
|
|
14
|
-
library_version: 0.
|
|
17
|
+
library_version: 0.4.0
|
|
15
18
|
requires:
|
|
16
19
|
- setup
|
|
17
20
|
sources:
|
|
@@ -294,6 +297,20 @@ export function Toasts() {
|
|
|
294
297
|
}
|
|
295
298
|
```
|
|
296
299
|
|
|
300
|
+
`ToastProgress` is a thin bar on a toast's bottom edge that empties over its `duration`, so an Undo shows how long it has left. Compose it inside `Toast`, in the function child that `ToastRegion` renders for each toast; it reads the toast's duration and type, takes no props and is `aria-hidden`. It draws nothing for `duration: Infinity` or a `loading` toast, and it pauses while the pointer or focus is in the region, while the page is hidden and while the window is inactive.
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
<ToastRegion toaster={toast}>
|
|
304
|
+
{() => (
|
|
305
|
+
<Toast>
|
|
306
|
+
<ToastTitle />
|
|
307
|
+
<ToastAction variant="outline" />
|
|
308
|
+
<ToastProgress />
|
|
309
|
+
</Toast>
|
|
310
|
+
)}
|
|
311
|
+
</ToastRegion>
|
|
312
|
+
```
|
|
313
|
+
|
|
297
314
|
### Show a budget or seats with `Meter`'s parts
|
|
298
315
|
|
|
299
316
|
Inside `MeterTrack`, `MeterThreshold` marks a value (an alert at 80%), `MeterForecast` fills where the value is heading behind `MeterIndicator`, and `MeterSegment`s replace the indicator with stacked parts (`variant` `default`, `muted`, `empty`). `MeterTrack variant="segmented"` draws one cell per unit, like one per seat. A meter's content is presentational, so name the segments in a `MeterLegend` inside the `Meter` and give the threshold or the forecast a `label`: the meter reads them after its value. Give the meter the sum of the segments as its `value`.
|
|
@@ -329,6 +346,32 @@ export function Seats() {
|
|
|
329
346
|
}
|
|
330
347
|
```
|
|
331
348
|
|
|
349
|
+
### Put a unit at the end of a number field: `NumberInputUnit`
|
|
350
|
+
|
|
351
|
+
`NumberInputUnit` from `abby/number-input` draws a unit such as "USD" inside the field's edge, in gray, after `NumberInputControl` inside `NumberInputGroup`; `format` only formats the number. Read [the number unit reference](references/number-units.md) when you build one.
|
|
352
|
+
|
|
353
|
+
### Filter with a row of chips: `Toggle` `variant="chip"`
|
|
354
|
+
|
|
355
|
+
For one choice in a row of filters, wrap `Toggle variant="chip" size="sm"` in a `ToggleGroup` with `deselectable={false}`, so one chip is always chosen. The chosen chip is white with a hairline edge and a heavier label; the others are gray with no fill. `ToggleCount` from `abby/toggle` puts a count after the name, in `subtle`. It is `aria-hidden` and becomes the chip's description, so the chip's name stays its own. The default `Toggle` fills its pressed state with ink: use it for on/off options, not for a filter row.
|
|
356
|
+
|
|
357
|
+
Read [the filter chip reference](references/filter-chips.md) for an example row.
|
|
358
|
+
|
|
359
|
+
### Narrow a list with a `FilterChip` menu, not a `Select`
|
|
360
|
+
|
|
361
|
+
`FilterChip` from `abby/filter-chip` is a capsule that opens a menu of one choice to narrow a list on the same screen; a `Select` is for a form field whose value is saved. Its `items` are read as `Select`'s are, and `allValue` is the value that means no filter: the chip is active while the value is any other. Read [the filter chip reference](references/filter-chips.md) when you build one: its example, its active mark, `onClear` and refusing a choice.
|
|
362
|
+
|
|
363
|
+
### Pick a whole week on a calendar: `Calendar` `mode="week"`
|
|
364
|
+
|
|
365
|
+
`Calendar` from `abby/calendar` with `mode="week"` picks a week in one press, and its value is always `[start, end]`: seven days from the calendar's first day of the week. `marks(date)` draws a dot or a check under each day, as `WeekStrip` does. Read [the calendar reference](references/calendar-week.md) when you build one: its value rules, its marks, and a week picker in a `Popover`.
|
|
366
|
+
|
|
367
|
+
### Draw memories as a map with `Graph`
|
|
368
|
+
|
|
369
|
+
`Graph` from `abby/graph` places memories as nodes joined by labeled lines. The app gives each node its position, and the map never lays out, drags or pans. Read [the charts and maps reference](references/charts-and-maps.md) when you build one: its `nodes`, `edges`, selection, zoom and keyboard, with an example.
|
|
370
|
+
|
|
371
|
+
### Show counts or trends by day or week with `BarChart` and `LineChart`
|
|
372
|
+
|
|
373
|
+
`BarChart` from `abby/chart` draws one column of bars per category, with a tooltip for each value and a table for screen readers. `LineChart` from the same entry draws one trend line over the categories, with reference lines and small charts that share a scale. Read [the charts and maps reference](references/charts-and-maps.md) when you build one: its `data`, `series`, `highlight`, forecast and colors, and its `LineChart` section for `mark`, `domain` and `size="sm"`. For bars made of parts that add up to a total (`stacked`, with `totals`, a `note` and `ChartLegend`), read its stacked section.
|
|
374
|
+
|
|
332
375
|
### Build a window with a rail and a column
|
|
333
376
|
|
|
334
377
|
An app's shell with two levels, Alma's, is shadcn's nested sidebars: one `Sidebar variant="inset" collapsible="icon"` holds a `SidebarTitlebar` and, in a row under it, a rail and a column as panels with `collapsible="none"`. The provider's width is both. Collapsed, the rail stays; with `peek`, the column floats out over the page while the pointer rests on the sidebar, and Escape sends it away. The column keeps its width (no `flex-1`): opening, the sidebar's edge uncovers it instead of squeezing its rows.
|
|
@@ -391,8 +434,7 @@ export function Shell() {
|
|
|
391
434
|
- A team's tile (its initials on its color, 36px with 10px corners) is `TeamMark` from `abby/team-mark`: `<TeamMark name="Casa Norte" color="#8b6a3e" />`. Without `color` it's Alma's neutral tile with ink letters, for a team whose color the app doesn't know, such as an invitation. It repeats the name beside it, so it's hidden from screen readers and agents. On the sidebar's paper set `--team-mark-surface` to `var(--sidebar)`, and inside a rail's button add `className="size-full"`.
|
|
392
435
|
- A rail's button is `size="icon"`: a 36px circle whose name shows only in its tooltip. Its badge is `variant="dot"`: a dot while the column is open, the count once collapsed. Put what the badge says in the button's `aria-describedby`.
|
|
393
436
|
- A two-line row (a name and a line under it) is `size="lg"`, 48px. A row that's a link takes `render={<a href="…" />}`: the button turns it into a link an agent follows, so don't pass `LinkPart` there.
|
|
394
|
-
- `SidebarInsetHeader` is the page's top bar, lined up with the window's controls
|
|
395
|
-
- Collapsed to the rail, the trigger moves to the page's top bar: render a `SidebarTrigger` in `SidebarTitlebar` and another as the first child of `SidebarInsetHeader` while collapsed. The two glide as one button on their own.
|
|
437
|
+
- `SidebarInsetHeader` is the page's top bar, lined up with the window's controls. Collapsed to the rail, the trigger moves there: render a `SidebarTrigger` in `SidebarTitlebar` and another as the first child of `SidebarInsetHeader`. The two glide as one button on their own.
|
|
396
438
|
- Collapsed to the rail, `SidebarTitlebar` folds to 8px: no empty band over the rail. In a desktop app, hide the window's controls while it's collapsed (the provider's `onOpenChange`).
|
|
397
439
|
- The Shell block (see the blocks skill) is a whole window built this way.
|
|
398
440
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Picking a week on a calendar
|
|
2
|
+
|
|
3
|
+
Read this when you build a week picker with `Calendar` from `abby/calendar`, or a calendar with a mark under each day. The main skill points here from its "Pick a week on a calendar" section.
|
|
4
|
+
|
|
5
|
+
## `mode="week"`
|
|
6
|
+
|
|
7
|
+
`mode="week"` makes one press pick the whole week: a click on any day, or Enter or Space on a focused day. Up and Down move the focus from week to week. The row under the pointer or the keyboard lights up before anything is chosen, and the chosen week is drawn as a soft band.
|
|
8
|
+
|
|
9
|
+
- `value` and `onValueChange` always carry `[start, end]`: seven days that start on the calendar's first day of the week. The value is the same whether it came from a press, a key, a controller or an agent.
|
|
10
|
+
- A range that isn't a week is fitted to the week of its first date when it is set from outside, such as `setValue` or `value`. A value with no valid date is refused.
|
|
11
|
+
- ui-sdk has no week mode, so Abby gives ui-sdk `mode="range"` and fixes the range itself. A calendar that doesn't pass `mode` keeps ui-sdk's `single`, `range` or `multiple`.
|
|
12
|
+
- `CalendarMode` from `abby/calendar` includes `"week"`.
|
|
13
|
+
|
|
14
|
+
## `marks(date)`
|
|
15
|
+
|
|
16
|
+
`marks` takes the ISO date of a day and returns what it shows, the same type as `WeekStrip`'s marks. Under the day number it draws the first tone of `dots`, or the `check`. `label`, `corner` and `bar` are ignored here. The `description` is read by a screen reader after the date. Days without a mark return `undefined`.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { Calendar } from "abby/calendar";
|
|
20
|
+
|
|
21
|
+
const closed = new Set(["2026-11-18"]);
|
|
22
|
+
|
|
23
|
+
export function ClosedDays() {
|
|
24
|
+
return (
|
|
25
|
+
<Calendar
|
|
26
|
+
mode="week"
|
|
27
|
+
aria-label="Week"
|
|
28
|
+
marks={(date) => (closed.has(date) ? { check: true, description: "Closed" } : undefined)}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The legend that says what each tone means is the app's own. Compose it under the calendar, as the `WeekPopover` story does.
|
|
35
|
+
|
|
36
|
+
## A week picker in a `Popover`
|
|
37
|
+
|
|
38
|
+
Put the calendar in `PopoverContent`, with the `PopoverTrigger` showing the chosen week. Shortcuts such as "This week" are plain `Button`s that drive the calendar through `createCalendarController()`, so they don't need a second source of truth. A button in the content is not a `Button` rendered into a part: it is a child of the popup.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useState } from "react";
|
|
42
|
+
import { Button } from "abby/button";
|
|
43
|
+
import { Calendar, createCalendarController } from "abby/calendar";
|
|
44
|
+
import { Popover, PopoverContent, PopoverTrigger } from "abby/popover";
|
|
45
|
+
|
|
46
|
+
export function WeekPicker() {
|
|
47
|
+
const [calendar] = useState(() => createCalendarController());
|
|
48
|
+
const [week, setWeek] = useState<[string, string]>(["2026-11-16", "2026-11-22"]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Popover>
|
|
52
|
+
<PopoverTrigger variant="outline">16 – 22 Nov</PopoverTrigger>
|
|
53
|
+
<PopoverContent className="w-auto gap-2 p-2">
|
|
54
|
+
<Button
|
|
55
|
+
variant="ghost"
|
|
56
|
+
size="xs"
|
|
57
|
+
onClick={() => calendar.setValue(["2026-11-23", "2026-11-23"])}
|
|
58
|
+
>
|
|
59
|
+
This week
|
|
60
|
+
</Button>
|
|
61
|
+
<Calendar
|
|
62
|
+
mode="week"
|
|
63
|
+
aria-label="Week"
|
|
64
|
+
controller={calendar}
|
|
65
|
+
value={week}
|
|
66
|
+
onValueChange={(next) => setWeek(next as [string, string])}
|
|
67
|
+
marks={(date) =>
|
|
68
|
+
date === "2026-11-18" ? { dots: ["success"], description: "Closed" } : undefined
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
</PopoverContent>
|
|
72
|
+
</Popover>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The stories that show it are the exports `Week` and `WeekPopover` in `src/components/calendar/calendar.stories.tsx`; `WeekKeyboard`, `WeekMarks`, `WeekBand`, `WeekFromOutside` and `AgentRefusedWeek` there test it.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Charts and maps
|
|
2
|
+
|
|
3
|
+
Read this when you build a bar chart with `BarChart`, a line chart with `LineChart` or a map of nodes with `Graph`. The main skill points here from its "Show counts or trends by day or week" and "Draw memories as a map" sections.
|
|
4
|
+
|
|
5
|
+
## Counts by day or week with `BarChart`
|
|
6
|
+
|
|
7
|
+
`BarChart` from `abby/chart` draws bars in SVG, with no chart library: one column per category, one bar per series in that column, a Y axis with its ticks and grid, and x labels that thin out when there are many. Each bar shows its value in one tooltip on hover and focus; the chart is one tab stop, and the arrows, Home and End move between bars. A table for a screen reader holds every value.
|
|
8
|
+
|
|
9
|
+
- `data`: one row per category, `{ label, id?, values }`. `label` is the x label; `values` holds one number per series key, and `null` or a missing key draws no bar.
|
|
10
|
+
- `series`: `{ key, name, color?, variant? }` in the order the bars are drawn. `key` reads `values`, `name` reads in the tooltip and the table.
|
|
11
|
+
- `highlight`: the `id` (or `label`) of the current category, today or this week. Its bars take the full color and the rest take their 20% tint.
|
|
12
|
+
- Colors: without `color`, series take `chart-1` to `chart-5` in order. `color` takes a token (`chart-1`…`chart-5`, `primary`, `muted`, `warning`, `success`, `destructive`) or any CSS color, such as `var(--area)`.
|
|
13
|
+
- `variant: "forecast"` draws what hasn't happened yet as a dashed outline in the first series' column. It is not a column of its own.
|
|
14
|
+
- `format` takes `Intl.NumberFormat` options for the axis, the tooltip and the table. `empty`, `categoryHeader` and `missing` replace the texts.
|
|
15
|
+
- The chart needs a name, `aria-label` or `aria-labelledby`. Without one it throws in development, so the name is never optional.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { BarChart } from "abby/chart";
|
|
19
|
+
|
|
20
|
+
const days = [
|
|
21
|
+
{ label: "Mon", values: { uses: 12, forecast: null } },
|
|
22
|
+
{ label: "Tue", values: { uses: 18, forecast: null } },
|
|
23
|
+
{ label: "Wed", values: { uses: 9, forecast: null } },
|
|
24
|
+
{ label: "Thu", values: { uses: 21, forecast: null } },
|
|
25
|
+
{ label: "Fri", values: { uses: null, forecast: 14 } },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export function MemoryUsage() {
|
|
29
|
+
return (
|
|
30
|
+
<BarChart
|
|
31
|
+
aria-label="Memory uses by day"
|
|
32
|
+
data={days}
|
|
33
|
+
series={[
|
|
34
|
+
{ key: "uses", name: "Uses", color: "success" },
|
|
35
|
+
{
|
|
36
|
+
key: "forecast",
|
|
37
|
+
name: "Forecast",
|
|
38
|
+
variant: "forecast",
|
|
39
|
+
color: "var(--muted-foreground)",
|
|
40
|
+
},
|
|
41
|
+
]}
|
|
42
|
+
highlight="Thu"
|
|
43
|
+
format={{ maximumFractionDigits: 0 }}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Stacked bars: parts of a total
|
|
50
|
+
|
|
51
|
+
Read this part when each bar is made of parts that add up to its total, like the questions an area answered and missed each week, or what happened to what a memory learned.
|
|
52
|
+
|
|
53
|
+
- `stacked`: the series of each category pile into one bar, in the order of `series`, the first at the bottom, with 2px of air between segments. The scale fits the largest sum. A value of `null` or 0 draws no segment, and a value below 0 draws none and adds nothing to the sum. With one series, `stacked` draws the same as without it.
|
|
54
|
+
- `totals`: writes each category's sum over its bar. With `stacked` the table gets a Total column, and `totalHeader` (a text of the chart's texts, like `categoryHeader`) renames it. Each stack is one point for the tooltip and the arrow keys, and its tooltip names every segment and the sum.
|
|
55
|
+
- `note`: `{ category, text, color? }` writes a short text beside one bar, like "7 open". `category` is the `id` or `label` of that row; `color` defaults to `muted-foreground`.
|
|
56
|
+
- `highlight` with `stacked`: the current category's label and total go bold, and its segments keep their full color.
|
|
57
|
+
- `ChartLegend` from `abby/chart` lists each series with its swatch and name, in the order of `series`. Pass the same `series` array the chart gets. With `data` it also shows what each series adds up to over all the rows. `format`, `locale` and `className` work as on the chart. Put it where the screen wants it; it's plain text for a screen reader, and a forecast series draws a dashed swatch.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { BarChart, ChartLegend } from "abby/chart";
|
|
61
|
+
|
|
62
|
+
const states = [
|
|
63
|
+
{ key: "confirmed", name: "Confirmed", color: "success" },
|
|
64
|
+
{
|
|
65
|
+
key: "corrected",
|
|
66
|
+
name: "Corrected",
|
|
67
|
+
color: "color-mix(in srgb, var(--success) 45%, transparent)",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "dropped",
|
|
71
|
+
name: "Dropped",
|
|
72
|
+
color: "color-mix(in srgb, var(--foreground) 18%, transparent)",
|
|
73
|
+
},
|
|
74
|
+
{ key: "open", name: "Open", color: "warning" },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const weeks = [
|
|
78
|
+
{ id: "w1", label: "3 Sep", values: { confirmed: 14, corrected: 3, dropped: 1, open: 2 } },
|
|
79
|
+
{ id: "w2", label: "10 Sep", values: { confirmed: 11, corrected: 4, dropped: 0, open: 7 } },
|
|
80
|
+
{ id: "w3", label: "17 Sep", values: { confirmed: 18, corrected: 2, dropped: 2, open: 0 } },
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
export function MemoryStates() {
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<ChartLegend series={states} data={weeks} />
|
|
87
|
+
<BarChart
|
|
88
|
+
aria-label="Memory states by week"
|
|
89
|
+
data={weeks}
|
|
90
|
+
series={states}
|
|
91
|
+
stacked
|
|
92
|
+
totals
|
|
93
|
+
highlight="w3"
|
|
94
|
+
note={{ category: "w2", text: "7 open", color: "warning" }}
|
|
95
|
+
/>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Trends by week with `LineChart`
|
|
102
|
+
|
|
103
|
+
`LineChart` from `abby/chart` draws one line over one series, one point per category, in the same frame as `BarChart`: a name, a tooltip on each point and a table for screen readers. Use it when the question is whether something rises or falls over time; use `BarChart` to compare counts with each other. Its `data` rows and `series` are `BarChart`'s, and the first series is the line.
|
|
104
|
+
|
|
105
|
+
- `mark`: which points get a dot and their value. `"ends"` (the default) marks the first and the last, `"last"` only the last. A small chart always marks only the last.
|
|
106
|
+
- `references`: `{ value, label?, color? }` horizontal lines to compare against, each labeled at the start. `color` defaults to a hairline.
|
|
107
|
+
- `labels="ends"`: labels only the first and last category under the plot, instead of every one.
|
|
108
|
+
- `size="sm"`: a chart to put side by side with others. It drops the axes and the grid and keeps the line, its last point and its value to the right.
|
|
109
|
+
- `domain`: `[min, max]`, the scale used exactly. Charts with the same `domain` and `height` draw the same value at the same height, so they share one scale. Without it the scale runs from 0 to a round number above the largest value.
|
|
110
|
+
- A `null` value breaks the line, and no dot leaves the plot.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { LineChart } from "abby/chart";
|
|
114
|
+
|
|
115
|
+
const weeks = [
|
|
116
|
+
{ label: "3 nov", values: { answers: 48 } },
|
|
117
|
+
{ label: "10 nov", values: { answers: 71 } },
|
|
118
|
+
{ label: "17 nov", values: { answers: 64 } },
|
|
119
|
+
{ label: "24 nov", values: { answers: 92 } },
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
export function AnswersPerWeek() {
|
|
123
|
+
return (
|
|
124
|
+
<LineChart
|
|
125
|
+
aria-label="Answers per week"
|
|
126
|
+
data={weeks}
|
|
127
|
+
series={[{ key: "answers", name: "Answers", color: "chart-1" }]}
|
|
128
|
+
mark="ends"
|
|
129
|
+
labels="ends"
|
|
130
|
+
references={[{ value: 80, label: "Goal" }]}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Draw memories as a map with `Graph`
|
|
137
|
+
|
|
138
|
+
`Graph` from `abby/graph` draws nodes as buttons and the lines between them in SVG, with no layout of its own. The app places every node: `x` and `y` are its center in map units at zoom 1. The map never lays out, drags or pans. A node's `name` is its button's name; `meta` is the line under it, `current` widens it for the memory being read, `replaced` strikes it through, and `color` takes `chart-1` to `chart-5`.
|
|
139
|
+
|
|
140
|
+
- `edges` are `{ from, to, label?, weight?, variant? }`: `weight` sets the line's width, and `variant` is `solid`, `dashed` or `warning`. An edge to a missing node, a loop or a repeated node id is ignored.
|
|
141
|
+
- `selected`, `defaultSelected` and `onSelectedChange(id, details)` choose a node; `details.cancel()` refuses a change, an agent's included. The map is one tab stop: arrows move to the nearest node, Enter chooses it, and `+` and `−` zoom by 1.25 between 0.5 and 2.
|
|
142
|
+
- `label` names the map (`"Graph"` by default). `GraphLegend` names each line style and `GraphList` gives the same map as text for screen readers.
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { Graph, type GraphEdgeData, type GraphNodeData } from "abby/graph";
|
|
146
|
+
|
|
147
|
+
const nodes: GraphNodeData[] = [
|
|
148
|
+
{
|
|
149
|
+
id: "this",
|
|
150
|
+
name: "Suppliers are paid 45 days after the invoice",
|
|
151
|
+
x: 383,
|
|
152
|
+
y: 410,
|
|
153
|
+
color: "chart-4",
|
|
154
|
+
meta: "This memory",
|
|
155
|
+
current: true,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "old",
|
|
159
|
+
name: "Suppliers are paid at 30 days",
|
|
160
|
+
x: 137,
|
|
161
|
+
y: 230,
|
|
162
|
+
color: "chart-4",
|
|
163
|
+
replaced: true,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "contract",
|
|
167
|
+
name: "Kova framework contract 2026",
|
|
168
|
+
x: 645,
|
|
169
|
+
y: 288,
|
|
170
|
+
color: "chart-4",
|
|
171
|
+
meta: "Carmen Vidal · Oct 2",
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
const edges: GraphEdgeData[] = [
|
|
176
|
+
{ from: "this", to: "old", label: "Replaces", variant: "warning" },
|
|
177
|
+
{ from: "this", to: "contract", label: "Based on", weight: 2 },
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
export function MemoryMap() {
|
|
181
|
+
return <Graph label="Memory map" nodes={nodes} edges={edges} defaultSelected="this" />;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Filter chips
|
|
2
|
+
|
|
3
|
+
Read this when you build a `FilterChip` from `abby/filter-chip`. The main skill points here from its "Narrow a list with a `FilterChip` menu" and "Filter with a row of chips" sections.
|
|
4
|
+
|
|
5
|
+
`FilterChip` is a 28px capsule with a hairline edge that opens a menu of one choice. It is `Menu` over one radio group, so its options are data an agent can read once the menu is open. Its look is Alma's chip, and a row of them is the results row of a search, with an area, a person and a date each narrowing the list.
|
|
6
|
+
|
|
7
|
+
- `items`: the options, strings or `{ value, label, disabled? }`. A string is an option whose label and value match. Pass the list as `items`, as `Select` does, instead of writing the options as children.
|
|
8
|
+
- `value` and `defaultValue`, with `onValueChange(value, details)`. The chip keeps its own choice when uncontrolled. `details.cancel()` keeps the current value, and an agent's choice can be refused this way.
|
|
9
|
+
- `allValue`: the value that means "no filter", such as `"all"`. The chip is active while the value is any other.
|
|
10
|
+
- Active: the edge turns `ring` and the value takes a medium weight. That mark reads on its own at 3:1; a tint would not, so do not replace it with a background.
|
|
11
|
+
- `prefix`: what the filter is, in grey before the value ("Persona:"). Write its colon yourself. `chevron` draws a chevron after the value, to show that it opens.
|
|
12
|
+
- `color`: a CSS color, such as the area's, drawn as a small square before the value while the chip is active.
|
|
13
|
+
- `onClear` with `clearLabel`: an active chip shows a × beside the trigger. The × goes back to `allValue` whether the chip is controlled or not: it calls `onValueChange(allValue, details)` with `details.reason` `"clear-press"`, then `onClear` unless `details.cancel()` refused it. The × is its own button, so give each chip its own `clearLabel` when a page holds several.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { FilterChip } from "abby/filter-chip";
|
|
17
|
+
|
|
18
|
+
export function AreaFilter() {
|
|
19
|
+
return (
|
|
20
|
+
<FilterChip
|
|
21
|
+
prefix="Area:"
|
|
22
|
+
chevron
|
|
23
|
+
allValue="all"
|
|
24
|
+
defaultValue="all"
|
|
25
|
+
items={[
|
|
26
|
+
{ value: "all", label: "All areas" },
|
|
27
|
+
{ value: "product", label: "Product" },
|
|
28
|
+
]}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use `Select` instead when the value is a field of a form that is saved with it. Use `Toggle variant="chip"` (below) when the choice is one of a few options that are always shown.
|
|
35
|
+
|
|
36
|
+
## A row of chips with `Toggle`
|
|
37
|
+
|
|
38
|
+
When the few options are always shown, wrap `Toggle variant="chip" size="sm"` in a `ToggleGroup` with `deselectable={false}`, so one chip is always chosen. `ToggleCount` puts a count after the name; it is `aria-hidden` and becomes the chip's description.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { Toggle, ToggleCount, ToggleGroup } from "abby/toggle";
|
|
42
|
+
|
|
43
|
+
export function PaymentFilters() {
|
|
44
|
+
return (
|
|
45
|
+
<ToggleGroup aria-label="Sections" defaultValue={["payments"]} deselectable={false}>
|
|
46
|
+
<Toggle value="all" variant="chip" size="sm">
|
|
47
|
+
All
|
|
48
|
+
<ToggleCount>356</ToggleCount>
|
|
49
|
+
</Toggle>
|
|
50
|
+
<Toggle value="payments" variant="chip" size="sm">
|
|
51
|
+
Supplier payments
|
|
52
|
+
<ToggleCount>142</ToggleCount>
|
|
53
|
+
</Toggle>
|
|
54
|
+
<Toggle value="budgets" variant="chip" size="sm">
|
|
55
|
+
Budgets
|
|
56
|
+
<ToggleCount>96</ToggleCount>
|
|
57
|
+
</Toggle>
|
|
58
|
+
</ToggleGroup>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# A unit inside a number field
|
|
2
|
+
|
|
3
|
+
Read this when you build a number field whose unit sits inside it, such as a spending cap in "USD" or a count in "seats". The main skill points here from its "Put a unit at the end of a number field" section.
|
|
4
|
+
|
|
5
|
+
`NumberInputUnit` from `abby/number-input` draws the unit at the end of the field, inside its edge and in `subtle`, so the number keeps the field's foreground and the unit reads as a label. It is a child of `NumberInputGroup`, placed after `NumberInputControl` and before `NumberInputIncrement`.
|
|
6
|
+
|
|
7
|
+
- The unit is text, as children: `<NumberInputUnit>USD</NumberInputUnit>`. The part draws only one at the end of the number; a unit in front of it is out of scope.
|
|
8
|
+
- `format` formats the number only. Pass `minimumFractionDigits` or another `Intl.NumberFormat` option there and write the unit in `NumberInputUnit`, not as a currency symbol inside `format`.
|
|
9
|
+
- The control reserves room for the unit, so the number never runs under it, and the control's font weight becomes medium while a unit is present. Nothing else about the control changes.
|
|
10
|
+
- The unit can't be selected, and a click on it focuses the field. It is `aria-hidden`: the control's `aria-describedby` gets its text next to the description `Field` gives, so a screen reader reads the unit once, as the control's description.
|
|
11
|
+
- It works with and without `NumberInputDecrement` and `NumberInputIncrement`. With the buttons, put the unit between the control and the increment button, as below.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import {
|
|
15
|
+
NumberInput,
|
|
16
|
+
NumberInputControl,
|
|
17
|
+
NumberInputDecrement,
|
|
18
|
+
NumberInputGroup,
|
|
19
|
+
NumberInputIncrement,
|
|
20
|
+
NumberInputUnit,
|
|
21
|
+
} from "abby/number-input";
|
|
22
|
+
|
|
23
|
+
export function SpendingCap() {
|
|
24
|
+
return (
|
|
25
|
+
<NumberInput
|
|
26
|
+
defaultValue={0.02}
|
|
27
|
+
min={0}
|
|
28
|
+
step={0.01}
|
|
29
|
+
locale="es"
|
|
30
|
+
format={{ minimumFractionDigits: 2 }}
|
|
31
|
+
>
|
|
32
|
+
<NumberInputGroup>
|
|
33
|
+
<NumberInputDecrement aria-label="Decrease" />
|
|
34
|
+
<NumberInputControl aria-label="Spending cap" />
|
|
35
|
+
<NumberInputUnit>USD</NumberInputUnit>
|
|
36
|
+
<NumberInputIncrement aria-label="Increase" />
|
|
37
|
+
</NumberInputGroup>
|
|
38
|
+
</NumberInput>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Without the buttons, the group holds only the control and the unit:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
<NumberInputGroup>
|
|
47
|
+
<NumberInputControl aria-label="Spending cap" />
|
|
48
|
+
<NumberInputUnit>USD</NumberInputUnit>
|
|
49
|
+
</NumberInputGroup>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The stories `Unit`, `UnitWholeAmount` and `UnitWithButtons` in `src/components/number-input/number-input.stories.tsx` show these; `UnitDescription` measures the description, the placement, the padding and the click.
|
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
and keep both usable by an agent without loading the editor.
|
|
13
13
|
type: core
|
|
14
14
|
library: abby
|
|
15
|
-
library_version: 0.
|
|
15
|
+
library_version: 0.4.0
|
|
16
16
|
sources:
|
|
17
17
|
- src/components/note-status/note-status.tsx
|
|
18
18
|
- src/components/note-place/note-place.tsx
|
package/skills/setup/SKILL.md
CHANGED