Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,40 @@ Tell Tailwind v4 to read the classes the components use, next to the tokens impo

## Components

| Component | Use it for |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `StatTile`, `MetricStrip` | Headline numbers in one bordered strip, separated by hairlines |
| `ChartCard` | A chart with title, legend and a Chart / Table switch (`table` + `viewLabels`) |
| `LineChart` | Trends over time; `area` for the series the chart is about, `context` for a grey comparison |
| `ColumnChart` | Magnitudes per period; one highlighted period over muted context, `stack`, `goal`, gaps |
| `BarList` | Ranked horizontal bars, one hue; `other` for the folded tail |
| `SegmentedBar` | One whole split in ≤ 6 parts; values print inside where they fit |
| `Sparkline` | Tiny decorative columns beside a number; `goal` line, gaps for future / missing periods |
| `ProgressBar` | A share of a whole as a thin bar; decorative unless it gets an `aria-label` |
| `ProgressRing` | A share in a list column (« 5/7 »): a thin arc over a track, success once complete |
| `PeriodStepper` | Previous / next period around the current label; `renderLink` for the app's router |
| `Status`, `StatusIcon` | A state as shape + label (`success`, `warning`, `danger`, `neutral`) |
| `Tag`, `Kbd` | Quiet attribute labels, keyboard hints |
| `Avatar` | A person's initials in a quiet disc, next to their name (`initials(name)` is exported too) |
| `SelectionBar` | Floating actions on a list selection; announces the count, Escape clears |
| `SegmentedControl` | 2–5 exclusive choices with a sliding indicator and arrow-key navigation; `null` = no choice |
| `FactList` | Facts as label / value pairs in a `<dl>`; empty values left out, or `emptyLabel` for them |
| `DateChip` | A day as a small tile, month over day, beside a row that says the full date |
| `FormSection` | One part of a long form: title, kicker and actions left, fields right (`col-span-full`) |
| `SaveBar` | A form's save actions at the bottom, with the unsaved-changes dot and an announced label |
| `Panel` | A bordered block of a page: title and actions, rows edge to edge or `padded` fields, footer |
| `SectionHeading` | The line above a block: title, quiet count, tag, actions; `collapsible` shows and hides it |
| `SidePanel` | Edits the selected item beside the main column; sticky, Escape closes, focus goes back; `walk` steps through the list (« 3 sur 12 ») |
| `Callout` | A notice in the page (refused save, offline, trial): soft tint + status shape, one action |
| `DateField` | A date written with its weekday, typed in the reader's order or picked in a month calendar; native picker on touch |
| `MapPin` | A place on a map, numbered like the list beside it; a button with hovered / selected states |
| `MapDot` | An entrance's state in a map editor: on, free, elsewhere, to add, to remove |
| `MapCluster` | Places too close to tell apart: a quiet disc with their count, a button that zooms in |
| `MapControls` | Zoom and « Recentrer » over the map; `MapControlGroup` / `MapControlButton` for more |
| `MapCaption`, `MapCard` | A line about the map (top left); a picked place's card (corner, or full width below 1280) |
| `MapAttribution` | The data credit, always visible bottom right (pass `MAP_ATTRIBUTION` from the tokens) |
| `MapStatus` | Loading or failed tiles, in the middle of the map's frame |
| `Mark`, `Lockup` | The Unitae mark, alone or with the wordmark |
| Component | Use it for |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `StatTile`, `MetricStrip` | Headline numbers in one bordered strip, separated by hairlines |
| `ChartCard` | A chart with title, legend and a Chart / Table switch (`table` + `viewLabels`) |
| `LineChart` | Trends over time; `area` for the series the chart is about, `context` for a grey comparison |
| `ColumnChart` | Magnitudes per period; one highlighted period over muted context, `stack`, `goal`, gaps |
| `BarList` | Ranked horizontal bars, one hue; `other` for the folded tail |
| `SegmentedBar` | One whole split in ≤ 6 parts; values print inside where they fit |
| `Sparkline` | Tiny decorative columns beside a number; `goal` line, gaps for future / missing periods |
| `ProgressBar` | A share of a whole as a thin bar; decorative unless it gets an `aria-label` |
| `ProgressRing` | A share in a list column (« 5/7 »): a thin arc over a track, success once complete |
| `PeriodStepper` | Previous / next period around the current label; `renderLink` for the app's router |
| `Status`, `StatusIcon` | A state as shape + label (`success`, `warning`, `danger`, `neutral`) |
| `Tag`, `Kbd` | Quiet attribute labels, keyboard hints |
| `Avatar` | A person's initials in a quiet disc, next to their name (`initials(name)` is exported too) |
| `SelectionBar` | Floating actions on a list selection; announces the count, Escape clears |
| `SegmentedControl` | 2–5 exclusive choices with a sliding indicator and arrow-key navigation; `null` = no choice |
| `FactList` | Facts as label / value pairs in a `<dl>`; empty values left out, or `emptyLabel` for them |
| `DateChip` | A day as a small tile, month over day, beside a row that says the full date |
| `FormSection` | One part of a long form: title, kicker and actions left, fields right (`col-span-full`) |
| `SaveBar` | A form's save actions at the bottom, with the unsaved-changes dot and an announced label |
| `Panel` | A bordered block of a page: title and actions, rows edge to edge or `padded` fields, footer |
| `SectionHeading` | The line above a block: title, quiet count, tag, actions; `collapsible` shows and hides it |
| `SidePanel` | Edits the selected item beside the main column; sticky, Escape closes, focus goes back; `walk` steps through the list (« 3 sur 12 »); `actions` puts the item's own buttons in the header |
| `Callout` | A notice in the page (refused save, offline, trial): soft tint + status shape, one action |
| `DateField` | A date written with its weekday, typed in the reader's order or picked in a month calendar; native picker on touch |
| `MapPin` | A place on a map, numbered like the list beside it; a button with hovered / selected states |
| `MapDot` | An entrance's state in a map editor: on, free, elsewhere, to add, to remove |
| `MapCluster` | Places too close to tell apart: a quiet disc with their count, a button that zooms in |
| `MapControls` | Zoom and « Recentrer » over the map; `MapControlGroup` / `MapControlButton` for more |
| `MapCaption`, `MapCard` | A line about the map (top left); a picked place's card (corner, or full width below 1280) |
| `MapAttribution` | The data credit, always visible bottom right (pass `MAP_ATTRIBUTION` from the tokens) |
| `MapStatus` | Loading or failed tiles, in the middle of the map's frame |
| `Mark`, `Lockup` | The Unitae mark, alone or with the wordmark |

Helpers: `seriesColor(i)` (categorical colours in order, folded past eight), `chartMuted`, `chartContext`,
`chartOther`, `cn`.
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unitae/ui",
"version": "0.9.0",
"version": "0.10.0",
"description": "Unitae UI components: stat tiles, chart kit (with table twins), status, avatars, selection bar, segmented control, form sections, save bar, panels, section headings, map pieces and the brand mark. Built on @unitae/tokens.",
"license": "MIT",
"type": "module",
Expand Down
7 changes: 7 additions & 0 deletions ui/src/side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export interface SidePanelProps {
footer?: ReactNode
/** Where focus goes back on close, e.g. the row's edit button. Defaults to what had focus when the panel opened. */
returnFocus?: HTMLElement | null
/**
* The item's own actions in the header, before the walk and the close button: « Modifier », a « … » menu. The
* footer stays for the form's cancel and save.
*/
actions?: ReactNode
/**
* Walks the list the panel was opened from: where this item sits (« 3 sur 12 ») and buttons to the previous and
* next ones, in the header beside the close button. Leave a handler out where there is nowhere to go.
Expand Down Expand Up @@ -48,6 +53,7 @@ export function SidePanel({
closeLabel,
footer,
returnFocus,
actions,
walk,
children,
className,
Expand Down Expand Up @@ -132,6 +138,7 @@ export function SidePanel({
</p>
)}
</div>
{actions != null && <div className="-mt-0.5 flex flex-none items-center gap-1">{actions}</div>}
{walk != null && (
<div className="-mt-0.5 flex flex-none items-center gap-0.5">
<span className="mr-1 text-faint text-xs tabular-nums">{walk.position}</span>
Expand Down
18 changes: 18 additions & 0 deletions ui/test/components.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,24 @@ describe('SidePanel walk', () => {
expect(calls).toEqual(['previous', 'next'])
})

it('puts its actions in the header, before the walk and the close button', () => {
render(
<SidePanel
title="Benoit CARINCI"
onClose={() => {}}
closeLabel="Fermer"
actions={<button type="button">Modifier</button>}
walk={{ position: '1 sur 2', previousLabel: 'Précédent', nextLabel: 'Suivant', onNext: () => {} }}
>
<p>Contenu</p>
</SidePanel>,
)
const buttons = within(screen.getByRole('complementary'))
.getAllByRole('button')
.map((button) => button.textContent || button.getAttribute('aria-label'))
expect(buttons).toEqual(['Modifier', 'Précédent', 'Suivant', 'Fermer'])
})

it('disables a step that has nowhere to go', () => {
render(
<SidePanel
Expand Down
Loading