@arbor-education/design-system.components 0.25.2 → 0.25.3
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/CHANGELOG.md +6 -0
- package/dist/components/row/Row.d.ts +1 -0
- package/dist/components/row/Row.d.ts.map +1 -1
- package/dist/components/row/Row.js +4 -2
- package/dist/components/row/Row.js.map +1 -1
- package/dist/components/row/Row.stories.d.ts +111 -4
- package/dist/components/row/Row.stories.d.ts.map +1 -1
- package/dist/components/row/Row.stories.js +362 -64
- package/dist/components/row/Row.stories.js.map +1 -1
- package/dist/components/row/Row.test.js +19 -0
- package/dist/components/row/Row.test.js.map +1 -1
- package/package.json +1 -1
- package/src/components/row/Row.stories.tsx +504 -81
- package/src/components/row/Row.test.tsx +25 -0
- package/src/components/row/Row.tsx +11 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Title,
|
|
10
10
|
} from '@storybook/addon-docs/blocks';
|
|
11
11
|
import { fn } from 'storybook/test';
|
|
12
|
+
import { Section } from 'Components/section/Section.js';
|
|
12
13
|
|
|
13
14
|
import { Row } from './Row.js';
|
|
14
15
|
import { Badge } from 'Components/badge/Badge';
|
|
@@ -16,24 +17,25 @@ import { Tag } from 'Components/tag/Tag';
|
|
|
16
17
|
import { Icon } from 'Components/icon/Icon';
|
|
17
18
|
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
19
|
-
//
|
|
20
|
+
// Docs page content
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
|
|
22
23
|
const DESCRIPTION_INTRO = [
|
|
23
|
-
'`Row` is a single-line display component
|
|
24
|
-
'
|
|
24
|
+
'`Row` is a single-line display component for presenting a labelled piece of data inside summary panels, detail cards, or section-style layouts.',
|
|
25
|
+
'Pass an `onClick` handler to make the row fully interactive — it enters the tab order, gains hover and focus styles, and renders a pair of animated directional icons.',
|
|
26
|
+
'Pass `href` to turn the value into a native anchor link, supporting any protocol including `mailto:` and `tel:`.',
|
|
25
27
|
].join(' ');
|
|
26
28
|
|
|
27
|
-
const PROPS_INTRO
|
|
28
|
-
= 'The preview below is wired to the **Controls** panel — tweak any prop to see the story update in real time.';
|
|
29
|
+
const PROPS_INTRO = 'The preview below is wired to the **Controls** panel — tweak any prop to see the story update in real time.';
|
|
29
30
|
|
|
30
31
|
const USAGE_GUIDANCE = [
|
|
31
32
|
'### When to use',
|
|
32
33
|
'',
|
|
33
|
-
'- Displaying a labelled
|
|
34
|
+
'- Displaying a labelled key-value pair in a detail panel or summary card (e.g. "Year group · Year 9").',
|
|
34
35
|
'- Rendering a list of named data points where a consistent label/value layout improves scannability.',
|
|
35
|
-
'- Providing a
|
|
36
|
-
'-
|
|
36
|
+
'- Providing a clickable drill-down link to a related record when `onClick` is supplied.',
|
|
37
|
+
'- Wrapping a value in a native link (URL, email address, phone number) via the `href` prop.',
|
|
38
|
+
'- Showing supplementary context alongside a value (e.g. a threshold note or timestamp in the `note` slot).',
|
|
37
39
|
'',
|
|
38
40
|
'---',
|
|
39
41
|
'',
|
|
@@ -41,45 +43,76 @@ const USAGE_GUIDANCE = [
|
|
|
41
43
|
'',
|
|
42
44
|
'| Situation | Use instead |',
|
|
43
45
|
'|---|---|',
|
|
44
|
-
'| Navigation links | Native `<a>` or router `<Link>` — a `div` with `onClick` is not a true anchor |',
|
|
45
46
|
'| Tabular data with sortable columns | [`Table`](?path=/docs/components-table--docs) |',
|
|
47
|
+
'| Form controls with labels | [`FormField`](?path=/docs/components-formfield--docs) |',
|
|
46
48
|
'| Toggling or selecting items | Checkbox or radio group |',
|
|
47
|
-
'|
|
|
49
|
+
'| Navigation links standing alone | Native `<a>` or router `<Link>` |',
|
|
48
50
|
].join('\n');
|
|
49
51
|
|
|
50
52
|
const DEVELOPER_NOTES = [
|
|
51
53
|
'### Clickable vs static rows',
|
|
52
54
|
'',
|
|
53
|
-
'The `onClick` prop is the **sole toggle** for all
|
|
55
|
+
'The `onClick` prop is the **sole toggle** for all interactive behaviour — there is no separate `isClickable` prop.',
|
|
54
56
|
'',
|
|
55
57
|
'| State | `tabIndex` | CSS modifier | Icons rendered |',
|
|
56
58
|
'|---|---|---|---|',
|
|
57
59
|
'| Static | `-1` (not in tab order) | — | None |',
|
|
58
60
|
'| Clickable | `0` (in tab order) | `ds-row--clickable` | `chevron-right` + `arrow-right` |',
|
|
59
61
|
'',
|
|
60
|
-
'**Dual-icon swap:** Both icons are always
|
|
62
|
+
'**Dual-icon swap:** Both icons are always in the DOM when `onClick` is provided. CSS controls visibility —',
|
|
63
|
+
'at rest `chevron-right` shows; on hover/focus `arrow-right` shows. No JavaScript state is involved.',
|
|
61
64
|
'',
|
|
62
|
-
'
|
|
63
|
-
'
|
|
65
|
+
'---',
|
|
66
|
+
'',
|
|
67
|
+
'### The `href` prop and value fallback',
|
|
68
|
+
'',
|
|
69
|
+
'When `href` is provided, the value is wrapped in a native `<a>` element:',
|
|
64
70
|
'',
|
|
65
|
-
'
|
|
71
|
+
'```tsx',
|
|
72
|
+
'// value becomes the link text',
|
|
73
|
+
'<Row label="Email" value="admin@school.com" href="mailto:admin@school.com" />',
|
|
74
|
+
'',
|
|
75
|
+
'// href becomes the link text when value is omitted — avoid with special protocols',
|
|
76
|
+
'<Row label="Profile" href="/students/123" />',
|
|
77
|
+
'```',
|
|
78
|
+
'',
|
|
79
|
+
'> **⚠️ Always provide `value` when using `mailto:` or `tel:` hrefs.** Without `value`, the raw protocol',
|
|
80
|
+
'> string (e.g. `"mailto:admin@school.com"`) is used as link text.',
|
|
66
81
|
'',
|
|
67
82
|
'---',
|
|
68
83
|
'',
|
|
69
84
|
'### Keyboard activation',
|
|
70
85
|
'',
|
|
71
|
-
'Clickable rows respond to **Enter** and **Space** keydown events
|
|
86
|
+
'Clickable rows respond to **Enter** and **Space** keydown events.',
|
|
87
|
+
'The focus ring uses `box-shadow: 0 0 0 3px var(--color-brand-300)` — applied on `:focus`.',
|
|
72
88
|
'',
|
|
73
89
|
'---',
|
|
74
90
|
'',
|
|
75
91
|
'### Accessibility gap',
|
|
76
92
|
'',
|
|
77
|
-
'> **Known limitation:**
|
|
78
|
-
'> Screen readers will not announce
|
|
93
|
+
'> **Known limitation:** The clickable row renders as a `<div>` with no `role="button"` attribute.',
|
|
94
|
+
'> Screen readers will not announce it as interactive. Keyboard users can still activate it, but',
|
|
95
|
+
'> VoiceOver/NVDA users have no indication the row is actionable.',
|
|
96
|
+
'',
|
|
97
|
+
'`href` rows render a real `<a>` tag — full native link semantics and announced correctly by screen readers.',
|
|
98
|
+
'',
|
|
99
|
+
'`Row` does **not** spread arbitrary HTML attributes. `className` and `style` are the only escape hatches.',
|
|
100
|
+
'',
|
|
101
|
+
'---',
|
|
102
|
+
'',
|
|
103
|
+
'### Component tokens',
|
|
79
104
|
'',
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
105
|
+
'Row is themed entirely through `--section-list-row-*` component tokens:',
|
|
106
|
+
'',
|
|
107
|
+
'| Token | Purpose |',
|
|
108
|
+
'|---|---|',
|
|
109
|
+
'| `--section-list-row-default-color-background` | Resting background colour |',
|
|
110
|
+
'| `--section-list-row-hover-hover-bg` | Hover background (clickable rows only) |',
|
|
111
|
+
'| `--section-list-row-spacing-vertical` | Top/bottom padding |',
|
|
112
|
+
'| `--section-list-row-spacing-horizontal` | Left/right padding |',
|
|
113
|
+
'| `--section-list-row-radius` | Border radius |',
|
|
114
|
+
'| `--section-list-row-default-color-icon-arrow` | Chevron/arrow icon stroke at rest |',
|
|
115
|
+
'| `--section-list-row-hover-color-icon-arrow` | Chevron/arrow icon stroke on hover |',
|
|
83
116
|
'',
|
|
84
117
|
'---',
|
|
85
118
|
'',
|
|
@@ -92,8 +125,10 @@ const DEVELOPER_NOTES = [
|
|
|
92
125
|
'',
|
|
93
126
|
'type RowProps = {',
|
|
94
127
|
' className?: string;',
|
|
128
|
+
' style?: CSSProperties;',
|
|
95
129
|
' label?: ReactNode;',
|
|
96
130
|
' value?: ReactNode;',
|
|
131
|
+
' href?: string;',
|
|
97
132
|
' note?: ReactNode;',
|
|
98
133
|
' onClick?: MouseEventHandler<HTMLDivElement>;',
|
|
99
134
|
'};',
|
|
@@ -103,7 +138,7 @@ const DEVELOPER_NOTES = [
|
|
|
103
138
|
const RELATED_COMPONENTS = [
|
|
104
139
|
'## Related components',
|
|
105
140
|
'',
|
|
106
|
-
'[Section](?path=/docs/components-section--docs) · [Card](?path=/docs/components-card--docs) · [Table](?path=/docs/components-table--docs)',
|
|
141
|
+
'[Section](?path=/docs/components-section--docs) · [Card](?path=/docs/components-card--docs) · [Table](?path=/docs/components-table--docs) · [FormField](?path=/docs/components-formfield--docs)',
|
|
107
142
|
].join('\n');
|
|
108
143
|
|
|
109
144
|
// ---------------------------------------------------------------------------
|
|
@@ -135,11 +170,12 @@ function RowDocsPage() {
|
|
|
135
170
|
// Meta
|
|
136
171
|
// ---------------------------------------------------------------------------
|
|
137
172
|
|
|
138
|
-
const meta
|
|
173
|
+
const meta = {
|
|
139
174
|
title: 'Components/Row',
|
|
140
175
|
component: Row,
|
|
141
176
|
tags: ['autodocs'],
|
|
142
177
|
parameters: {
|
|
178
|
+
layout: 'padded',
|
|
143
179
|
docs: {
|
|
144
180
|
page: RowDocsPage,
|
|
145
181
|
},
|
|
@@ -147,8 +183,8 @@ const meta: Meta<typeof Row> = {
|
|
|
147
183
|
argTypes: {
|
|
148
184
|
label: {
|
|
149
185
|
description: [
|
|
150
|
-
'
|
|
151
|
-
'
|
|
186
|
+
'Left-column text identifying the data point.',
|
|
187
|
+
'Rendered in a `<span>` with semi-bold weight and a maximum width of 190 px so labels align consistently across stacked rows.',
|
|
152
188
|
].join(' '),
|
|
153
189
|
control: 'text',
|
|
154
190
|
table: {
|
|
@@ -160,6 +196,8 @@ const meta: Meta<typeof Row> = {
|
|
|
160
196
|
description: [
|
|
161
197
|
'The right-hand value corresponding to the label.',
|
|
162
198
|
'Renders in the centre column with `flex-grow: 1`, filling available width.',
|
|
199
|
+
'When `href` is provided, this becomes the anchor text.',
|
|
200
|
+
'If `href` is set and `value` is omitted, the href string itself is used as the link text.',
|
|
163
201
|
].join(' '),
|
|
164
202
|
control: 'text',
|
|
165
203
|
table: {
|
|
@@ -167,22 +205,35 @@ const meta: Meta<typeof Row> = {
|
|
|
167
205
|
defaultValue: { summary: 'undefined' },
|
|
168
206
|
},
|
|
169
207
|
},
|
|
208
|
+
href: {
|
|
209
|
+
description: [
|
|
210
|
+
'When provided, wraps `value` in a native `<a>` element pointing to this URL.',
|
|
211
|
+
'Supports any protocol — `https://`, `mailto:`, `tel:`, etc.',
|
|
212
|
+
'Always provide `value` when using `mailto:` or `tel:` — without it the raw protocol string becomes the link text.',
|
|
213
|
+
].join(' '),
|
|
214
|
+
control: 'text',
|
|
215
|
+
table: {
|
|
216
|
+
type: { summary: 'string' },
|
|
217
|
+
defaultValue: { summary: 'undefined' },
|
|
218
|
+
},
|
|
219
|
+
},
|
|
170
220
|
note: {
|
|
171
221
|
description: [
|
|
172
|
-
'
|
|
173
|
-
'
|
|
222
|
+
'Supplementary italic text rendered right-aligned after the value.',
|
|
223
|
+
'When present, the CSS `:has()` selector reduces the value column\'s `flex-basis` from 70% to 50% to make room.',
|
|
224
|
+
'Useful for thresholds, last-updated timestamps, or secondary context.',
|
|
174
225
|
].join(' '),
|
|
175
226
|
control: 'text',
|
|
176
227
|
table: {
|
|
177
|
-
type: { summary: '
|
|
228
|
+
type: { summary: 'string' },
|
|
178
229
|
defaultValue: { summary: 'undefined' },
|
|
179
230
|
},
|
|
180
231
|
},
|
|
181
232
|
onClick: {
|
|
182
233
|
description: [
|
|
183
|
-
'When provided,
|
|
184
|
-
'gains the `ds-row--clickable` modifier, shows hover/focus styles, and renders dual directional
|
|
185
|
-
'
|
|
234
|
+
'When provided, activates all clickable behaviour: the row enters the tab order (`tabIndex={0}`),',
|
|
235
|
+
'gains the `ds-row--clickable` modifier, shows hover/focus styles, and renders the dual directional icon pair.',
|
|
236
|
+
'Responds to **Enter** and **Space** keyboard events.',
|
|
186
237
|
].join(' '),
|
|
187
238
|
action: 'onClick',
|
|
188
239
|
control: false,
|
|
@@ -192,21 +243,26 @@ const meta: Meta<typeof Row> = {
|
|
|
192
243
|
},
|
|
193
244
|
},
|
|
194
245
|
className: {
|
|
195
|
-
description:
|
|
196
|
-
'Additional CSS class names applied to the root `<div>`.',
|
|
197
|
-
'This is the only HTML-attribute escape hatch — arbitrary HTML attributes cannot be passed via props.',
|
|
198
|
-
].join(' '),
|
|
246
|
+
description: 'Additional CSS class names applied to the root `<div>`. The only HTML-attribute escape hatch — arbitrary attributes like `aria-label` or `data-testid` cannot be passed without modifying the component.',
|
|
199
247
|
control: 'text',
|
|
200
248
|
table: {
|
|
201
249
|
type: { summary: 'string' },
|
|
202
250
|
defaultValue: { summary: 'undefined' },
|
|
203
251
|
},
|
|
204
252
|
},
|
|
253
|
+
style: {
|
|
254
|
+
description: 'Inline styles applied to the root `<div>`.',
|
|
255
|
+
control: false,
|
|
256
|
+
table: {
|
|
257
|
+
type: { summary: 'CSSProperties' },
|
|
258
|
+
defaultValue: { summary: 'undefined' },
|
|
259
|
+
},
|
|
260
|
+
},
|
|
205
261
|
},
|
|
206
|
-
}
|
|
262
|
+
} satisfies Meta<typeof Row>;
|
|
207
263
|
|
|
208
264
|
export default meta;
|
|
209
|
-
type Story = StoryObj<typeof
|
|
265
|
+
type Story = StoryObj<typeof Row>;
|
|
210
266
|
|
|
211
267
|
// ---------------------------------------------------------------------------
|
|
212
268
|
// Helper
|
|
@@ -216,10 +272,97 @@ const withDescription = (story: Story, description: string): Story => ({
|
|
|
216
272
|
...story,
|
|
217
273
|
parameters: {
|
|
218
274
|
...story.parameters,
|
|
219
|
-
docs: {
|
|
275
|
+
docs: {
|
|
276
|
+
...story.parameters?.docs,
|
|
277
|
+
description: {
|
|
278
|
+
story: description,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
220
281
|
},
|
|
221
282
|
});
|
|
222
283
|
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
// Template components
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
|
|
288
|
+
const MixedClickableAndStaticTemplate = () => (
|
|
289
|
+
<Section title="Pupil details">
|
|
290
|
+
<Row label="Name" value="Amara Osei-Bonsu" />
|
|
291
|
+
<Row label="Year group" value="Year 10" />
|
|
292
|
+
<Row label="Form" value="10JH" />
|
|
293
|
+
<Row
|
|
294
|
+
label="SEN status"
|
|
295
|
+
value="SEN Support"
|
|
296
|
+
note="Review due May 2026"
|
|
297
|
+
onClick={() => {}}
|
|
298
|
+
/>
|
|
299
|
+
<Row
|
|
300
|
+
label="Attendance (YTD)"
|
|
301
|
+
value="88.3%"
|
|
302
|
+
note="Below 90% threshold"
|
|
303
|
+
onClick={() => {}}
|
|
304
|
+
/>
|
|
305
|
+
</Section>
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
const InSectionTemplate = () => (
|
|
309
|
+
<Section title="Personal details">
|
|
310
|
+
<Row label="Pupil" value="Amara Osei-Bonsu" />
|
|
311
|
+
<Row label="Date of birth" value="14 March 2010" />
|
|
312
|
+
<Row label="Admission number" value="001847" />
|
|
313
|
+
<Row label="UPN" value="A823456789012" />
|
|
314
|
+
<Row
|
|
315
|
+
label="Email address"
|
|
316
|
+
value="a.osei-bonsu@pupil.school.example"
|
|
317
|
+
href="mailto:a.osei-bonsu@pupil.school.example"
|
|
318
|
+
/>
|
|
319
|
+
</Section>
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const AccessibilityNotesTemplate = () => (
|
|
323
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-large)' }}>
|
|
324
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
325
|
+
<p style={{ margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }}>
|
|
326
|
+
Static row —
|
|
327
|
+
{' '}
|
|
328
|
+
<code>tabIndex="-1"</code>
|
|
329
|
+
, no ARIA role, not in tab order
|
|
330
|
+
</p>
|
|
331
|
+
<Row label="Year group" value="Year 9" />
|
|
332
|
+
</div>
|
|
333
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
334
|
+
<p style={{ margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }}>
|
|
335
|
+
Clickable row —
|
|
336
|
+
{' '}
|
|
337
|
+
<code>tabIndex="0"</code>
|
|
338
|
+
, keyboard-activatable, but
|
|
339
|
+
{' '}
|
|
340
|
+
<strong>
|
|
341
|
+
no
|
|
342
|
+
<code>role="button"</code>
|
|
343
|
+
</strong>
|
|
344
|
+
{' '}
|
|
345
|
+
— screen readers may not announce it as interactive
|
|
346
|
+
</p>
|
|
347
|
+
<Row label="SEN record" value="SEN Support" onClick={() => {}} />
|
|
348
|
+
</div>
|
|
349
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
350
|
+
<p style={{ margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }}>
|
|
351
|
+
href row — renders a real
|
|
352
|
+
{' '}
|
|
353
|
+
<code><a></code>
|
|
354
|
+
{' '}
|
|
355
|
+
tag with full native link semantics ✓
|
|
356
|
+
</p>
|
|
357
|
+
<Row
|
|
358
|
+
label="Email address"
|
|
359
|
+
value="admin@school.example"
|
|
360
|
+
href="mailto:admin@school.example"
|
|
361
|
+
/>
|
|
362
|
+
</div>
|
|
363
|
+
</div>
|
|
364
|
+
);
|
|
365
|
+
|
|
223
366
|
// ---------------------------------------------------------------------------
|
|
224
367
|
// Stories
|
|
225
368
|
// ---------------------------------------------------------------------------
|
|
@@ -234,7 +377,7 @@ export const Default: Story = withDescription(
|
|
|
234
377
|
},
|
|
235
378
|
render: args => <Row {...args} />,
|
|
236
379
|
},
|
|
237
|
-
'The
|
|
380
|
+
'The interactive canvas — every prop is wired to the Controls panel. By default the row is clickable — clear `onClick` from the controls to switch to static mode and observe how the icons and hover behaviour disappear.',
|
|
238
381
|
);
|
|
239
382
|
|
|
240
383
|
export const LabelOnly: Story = withDescription(
|
|
@@ -257,10 +400,10 @@ export default EnrolmentStatusRow;
|
|
|
257
400
|
},
|
|
258
401
|
render: () => <Row label="Enrolment status" />,
|
|
259
402
|
},
|
|
260
|
-
'Minimum meaningful render — a label with no value or note.
|
|
403
|
+
'Minimum meaningful render — a label with no value, href, or note. The value and note `<span>` elements still render in the DOM but remain empty. The row holds its correct minimum height.',
|
|
261
404
|
);
|
|
262
405
|
|
|
263
|
-
export const
|
|
406
|
+
export const ValueOnly: Story = withDescription(
|
|
264
407
|
{
|
|
265
408
|
parameters: {
|
|
266
409
|
controls: { disable: true },
|
|
@@ -270,17 +413,17 @@ export const LabelAndValue: Story = withDescription(
|
|
|
270
413
|
code: `
|
|
271
414
|
import { Row } from '@arbor-education/design-system.components';
|
|
272
415
|
|
|
273
|
-
function
|
|
274
|
-
return <Row
|
|
416
|
+
function ActiveStatusRow() {
|
|
417
|
+
return <Row value="Active" />;
|
|
275
418
|
}
|
|
276
|
-
export default
|
|
419
|
+
export default ActiveStatusRow;
|
|
277
420
|
`.trim(),
|
|
278
421
|
},
|
|
279
422
|
},
|
|
280
423
|
},
|
|
281
|
-
render: () => <Row
|
|
424
|
+
render: () => <Row value="Active" />,
|
|
282
425
|
},
|
|
283
|
-
'
|
|
426
|
+
'A value with no label — the label column renders empty. Valid but uncommon; most real-world rows pair a label with every value.',
|
|
284
427
|
);
|
|
285
428
|
|
|
286
429
|
export const WithNote: Story = withDescription(
|
|
@@ -315,7 +458,138 @@ export default AttendanceRow;
|
|
|
315
458
|
/>
|
|
316
459
|
),
|
|
317
460
|
},
|
|
318
|
-
'Adding
|
|
461
|
+
'Adding `note` renders supplementary italic text right-aligned after the value. The CSS `:has()` selector automatically shrinks the value column from 70% to 50% flex-basis to make room. Use notes for thresholds, last-updated timestamps, or secondary context that helps interpret the value.',
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
export const WithHref: Story = withDescription(
|
|
465
|
+
{
|
|
466
|
+
parameters: {
|
|
467
|
+
controls: { disable: true },
|
|
468
|
+
docs: {
|
|
469
|
+
source: {
|
|
470
|
+
language: 'tsx',
|
|
471
|
+
code: `
|
|
472
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
473
|
+
|
|
474
|
+
function ProfileLinkRow() {
|
|
475
|
+
return (
|
|
476
|
+
<Row
|
|
477
|
+
label="Student profile"
|
|
478
|
+
value="View full profile"
|
|
479
|
+
href="/students/amara-osei-bonsu"
|
|
480
|
+
/>
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
export default ProfileLinkRow;
|
|
484
|
+
`.trim(),
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
render: () => (
|
|
489
|
+
<Row
|
|
490
|
+
label="Student profile"
|
|
491
|
+
value="View full profile"
|
|
492
|
+
href="/students/amara-osei-bonsu"
|
|
493
|
+
/>
|
|
494
|
+
),
|
|
495
|
+
},
|
|
496
|
+
'When `href` is provided alongside `value`, the value text becomes the anchor text. The `<a>` element carries full native link semantics — right-click opens the browser context menu, the link can be opened in a new tab, and screen readers announce it correctly as a link.',
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
export const WithHrefFallback: Story = withDescription(
|
|
500
|
+
{
|
|
501
|
+
parameters: {
|
|
502
|
+
controls: { disable: true },
|
|
503
|
+
docs: {
|
|
504
|
+
source: {
|
|
505
|
+
language: 'tsx',
|
|
506
|
+
code: `
|
|
507
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
508
|
+
|
|
509
|
+
// ⚠️ href without value — the href string becomes the link text
|
|
510
|
+
function HrefFallbackRow() {
|
|
511
|
+
return <Row label="Profile" href="/students/123" />;
|
|
512
|
+
}
|
|
513
|
+
export default HrefFallbackRow;
|
|
514
|
+
`.trim(),
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
render: () => <Row label="Profile" href="/students/123" />,
|
|
519
|
+
},
|
|
520
|
+
'When `href` is set but `value` is omitted, the href string itself is used as the link text (`value || href`). For plain paths like `/students/123` this is acceptable. For `mailto:` or `tel:` hrefs, the raw URI string is exposed to the user — always pair those with an explicit `value`. See the **WithHrefMailto** story for the correct email pattern.',
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
export const WithHrefMailto: Story = withDescription(
|
|
524
|
+
{
|
|
525
|
+
parameters: {
|
|
526
|
+
controls: { disable: true },
|
|
527
|
+
docs: {
|
|
528
|
+
source: {
|
|
529
|
+
language: 'tsx',
|
|
530
|
+
code: `
|
|
531
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
532
|
+
|
|
533
|
+
function EmailRow() {
|
|
534
|
+
return (
|
|
535
|
+
<Row
|
|
536
|
+
label="Email address"
|
|
537
|
+
value="j.smith@school.example"
|
|
538
|
+
href="mailto:j.smith@school.example"
|
|
539
|
+
/>
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
export default EmailRow;
|
|
543
|
+
`.trim(),
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
render: () => (
|
|
548
|
+
<Row
|
|
549
|
+
label="Email address"
|
|
550
|
+
value="j.smith@school.example"
|
|
551
|
+
href="mailto:j.smith@school.example"
|
|
552
|
+
/>
|
|
553
|
+
),
|
|
554
|
+
},
|
|
555
|
+
'The canonical email-address pattern: `href="mailto:..."` opens the user\'s mail client and `value` is the human-readable address shown as link text. Always provide `value` with `mailto:` hrefs — omitting it exposes the raw protocol string (e.g. `"mailto:j.smith@school.example"`) as link text.',
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
export const WithHrefAndNote: Story = withDescription(
|
|
559
|
+
{
|
|
560
|
+
parameters: {
|
|
561
|
+
controls: { disable: true },
|
|
562
|
+
docs: {
|
|
563
|
+
source: {
|
|
564
|
+
language: 'tsx',
|
|
565
|
+
code: `
|
|
566
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
567
|
+
|
|
568
|
+
function GuardianEmailRow() {
|
|
569
|
+
return (
|
|
570
|
+
<Row
|
|
571
|
+
label="Guardian email"
|
|
572
|
+
value="s.okafor@guardian.example"
|
|
573
|
+
href="mailto:s.okafor@guardian.example"
|
|
574
|
+
note="Primary contact"
|
|
575
|
+
/>
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
export default GuardianEmailRow;
|
|
579
|
+
`.trim(),
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
render: () => (
|
|
584
|
+
<Row
|
|
585
|
+
label="Guardian email"
|
|
586
|
+
value="s.okafor@guardian.example"
|
|
587
|
+
href="mailto:s.okafor@guardian.example"
|
|
588
|
+
note="Primary contact"
|
|
589
|
+
/>
|
|
590
|
+
),
|
|
591
|
+
},
|
|
592
|
+
'`href` and `note` used together. The anchor sits in the value column while the note stays right-aligned. The CSS `:has()` reflow is active — the value column narrows to 50% flex-basis to accommodate the note.',
|
|
319
593
|
);
|
|
320
594
|
|
|
321
595
|
export const Clickable: Story = withDescription(
|
|
@@ -350,7 +624,7 @@ export default ClassRow;
|
|
|
350
624
|
/>
|
|
351
625
|
),
|
|
352
626
|
},
|
|
353
|
-
'Providing
|
|
627
|
+
'Providing `onClick` activates all clickable behaviour: `ds-row--clickable` modifier, pointer cursor, hover background, and the dual icon pair. **Hover the row** to see `chevron-right` swap to `arrow-right` — a pure CSS transition with no JavaScript state. Press **Tab** to focus, then **Enter** or **Space** to fire the handler.',
|
|
354
628
|
);
|
|
355
629
|
|
|
356
630
|
export const ClickableWithNote: Story = withDescription(
|
|
@@ -387,7 +661,83 @@ export default GuardianRow;
|
|
|
387
661
|
/>
|
|
388
662
|
),
|
|
389
663
|
},
|
|
390
|
-
'
|
|
664
|
+
'Clickable row with all three right-side elements active: value, note, and the chevron/arrow icon pair. The note takes 20% flex-basis; the value narrows to 50%; the icon is flex-shrunk. The secondary context ("Primary contact") persists alongside the navigation affordance.',
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
export const MixedClickableAndStatic: Story = withDescription(
|
|
668
|
+
{
|
|
669
|
+
parameters: {
|
|
670
|
+
controls: { disable: true },
|
|
671
|
+
docs: {
|
|
672
|
+
source: {
|
|
673
|
+
language: 'tsx',
|
|
674
|
+
code: `
|
|
675
|
+
import { Row, Section } from '@arbor-education/design-system.components';
|
|
676
|
+
|
|
677
|
+
function PupilDetailSection() {
|
|
678
|
+
return (
|
|
679
|
+
<Section title="Pupil details">
|
|
680
|
+
<Row label="Name" value="Amara Osei-Bonsu" />
|
|
681
|
+
<Row label="Year group" value="Year 10" />
|
|
682
|
+
<Row label="Form" value="10JH" />
|
|
683
|
+
<Row
|
|
684
|
+
label="SEN status"
|
|
685
|
+
value="SEN Support"
|
|
686
|
+
note="Review due May 2026"
|
|
687
|
+
onClick={() => navigateToSENRecord()}
|
|
688
|
+
/>
|
|
689
|
+
<Row
|
|
690
|
+
label="Attendance (YTD)"
|
|
691
|
+
value="88.3%"
|
|
692
|
+
note="Below 90% threshold"
|
|
693
|
+
onClick={() => navigateToAttendance()}
|
|
694
|
+
/>
|
|
695
|
+
</Section>
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
export default PupilDetailSection;
|
|
699
|
+
`.trim(),
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
render: MixedClickableAndStaticTemplate,
|
|
704
|
+
},
|
|
705
|
+
'Static and clickable rows freely mixed inside a `Section`. Static rows display data; clickable rows provide navigation affordance. The visual contrast — pointer cursor, hover background, directional icon — makes the interactive rows immediately distinguishable without extra labelling.',
|
|
706
|
+
);
|
|
707
|
+
|
|
708
|
+
export const InSection: Story = withDescription(
|
|
709
|
+
{
|
|
710
|
+
parameters: {
|
|
711
|
+
controls: { disable: true },
|
|
712
|
+
docs: {
|
|
713
|
+
source: {
|
|
714
|
+
language: 'tsx',
|
|
715
|
+
code: `
|
|
716
|
+
import { Row, Section } from '@arbor-education/design-system.components';
|
|
717
|
+
|
|
718
|
+
function PersonalDetailsSection() {
|
|
719
|
+
return (
|
|
720
|
+
<Section title="Personal details">
|
|
721
|
+
<Row label="Pupil" value="Amara Osei-Bonsu" />
|
|
722
|
+
<Row label="Date of birth" value="14 March 2010" />
|
|
723
|
+
<Row label="Admission number" value="001847" />
|
|
724
|
+
<Row label="UPN" value="A823456789012" />
|
|
725
|
+
<Row
|
|
726
|
+
label="Email address"
|
|
727
|
+
value="a.osei-bonsu@pupil.school.example"
|
|
728
|
+
href="mailto:a.osei-bonsu@pupil.school.example"
|
|
729
|
+
/>
|
|
730
|
+
</Section>
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
export default PersonalDetailsSection;
|
|
734
|
+
`.trim(),
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
render: InSectionTemplate,
|
|
739
|
+
},
|
|
740
|
+
'The canonical real-world usage: `Row` components as children of a `Section`. The `Section` provides the container heading and background; each `Row` handles the label/value layout. Most product uses of `Row` are inside a `Section`.',
|
|
391
741
|
);
|
|
392
742
|
|
|
393
743
|
export const LongContent: Story = withDescription(
|
|
@@ -402,7 +752,7 @@ import { Row } from '@arbor-education/design-system.components';
|
|
|
402
752
|
|
|
403
753
|
function LongContentExample() {
|
|
404
754
|
return (
|
|
405
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-
|
|
755
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
406
756
|
<Row
|
|
407
757
|
label="Special educational needs and disabilities coordinator"
|
|
408
758
|
value="Mrs Jacqueline Abernathy-Thornton"
|
|
@@ -423,7 +773,7 @@ export default LongContentExample;
|
|
|
423
773
|
},
|
|
424
774
|
},
|
|
425
775
|
render: () => (
|
|
426
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-
|
|
776
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
427
777
|
<Row
|
|
428
778
|
label="Special educational needs and disabilities coordinator"
|
|
429
779
|
value="Mrs Jacqueline Abernathy-Thornton"
|
|
@@ -438,7 +788,7 @@ export default LongContentExample;
|
|
|
438
788
|
</div>
|
|
439
789
|
),
|
|
440
790
|
},
|
|
441
|
-
'Long label and value strings exercise the flex layout. The label column
|
|
791
|
+
'Long label and value strings exercise the flex layout. The label column enforces a 190 px maximum width — long labels wrap rather than compress the value column. Test your specific container widths if you have long copy in narrow panels.',
|
|
442
792
|
);
|
|
443
793
|
|
|
444
794
|
export const MultipleRows: Story = withDescription(
|
|
@@ -451,57 +801,33 @@ export const MultipleRows: Story = withDescription(
|
|
|
451
801
|
code: `
|
|
452
802
|
import { Row } from '@arbor-education/design-system.components';
|
|
453
803
|
|
|
454
|
-
function
|
|
804
|
+
function PupilDataList() {
|
|
455
805
|
return (
|
|
456
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-
|
|
806
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
457
807
|
<Row label="Pupil" value="Amara Osei-Bonsu" />
|
|
458
808
|
<Row label="Year group" value="Year 10" />
|
|
459
809
|
<Row label="Form" value="10JH" />
|
|
460
810
|
<Row label="Admission number" value="001847" />
|
|
461
811
|
<Row label="UPN" value="A823456789012" />
|
|
462
|
-
<Row
|
|
463
|
-
label="SEN status"
|
|
464
|
-
value="SEN Support"
|
|
465
|
-
note="Review due May 2026"
|
|
466
|
-
onClick={() => navigateToSENRecord()}
|
|
467
|
-
/>
|
|
468
|
-
<Row
|
|
469
|
-
label="Attendance (YTD)"
|
|
470
|
-
value="88.3%"
|
|
471
|
-
note="Below 90% threshold"
|
|
472
|
-
onClick={() => navigateToAttendance()}
|
|
473
|
-
/>
|
|
474
812
|
</div>
|
|
475
813
|
);
|
|
476
814
|
}
|
|
477
|
-
export default
|
|
815
|
+
export default PupilDataList;
|
|
478
816
|
`.trim(),
|
|
479
817
|
},
|
|
480
818
|
},
|
|
481
819
|
},
|
|
482
820
|
render: () => (
|
|
483
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-
|
|
821
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
|
|
484
822
|
<Row label="Pupil" value="Amara Osei-Bonsu" />
|
|
485
823
|
<Row label="Year group" value="Year 10" />
|
|
486
824
|
<Row label="Form" value="10JH" />
|
|
487
825
|
<Row label="Admission number" value="001847" />
|
|
488
826
|
<Row label="UPN" value="A823456789012" />
|
|
489
|
-
<Row
|
|
490
|
-
label="SEN status"
|
|
491
|
-
value="SEN Support"
|
|
492
|
-
note="Review due May 2026"
|
|
493
|
-
onClick={fn()}
|
|
494
|
-
/>
|
|
495
|
-
<Row
|
|
496
|
-
label="Attendance (YTD)"
|
|
497
|
-
value="88.3%"
|
|
498
|
-
note="Below 90% threshold"
|
|
499
|
-
onClick={fn()}
|
|
500
|
-
/>
|
|
501
827
|
</div>
|
|
502
828
|
),
|
|
503
829
|
},
|
|
504
|
-
'
|
|
830
|
+
'Multiple static rows stacked with `gap: var(--spacing-xsmall)`. Each `Row` carries its own background and padding — the gap sits between rows. Use `Section` as the outer container in production to get the correct heading and container treatment.',
|
|
505
831
|
);
|
|
506
832
|
|
|
507
833
|
export const ReactNodeInValue: Story = withDescription(
|
|
@@ -634,3 +960,100 @@ export default AnnotatedLabelRows;
|
|
|
634
960
|
},
|
|
635
961
|
'The `label` slot accepts any `ReactNode` — inline icons can annotate labels that require clarification. An `Icon` placed inline with the label text signals to the user that more information is available, without cluttering the value column.',
|
|
636
962
|
);
|
|
963
|
+
|
|
964
|
+
export const AccessibilityNotes: Story = withDescription(
|
|
965
|
+
{
|
|
966
|
+
parameters: {
|
|
967
|
+
controls: { disable: true },
|
|
968
|
+
docs: {
|
|
969
|
+
source: {
|
|
970
|
+
language: 'tsx',
|
|
971
|
+
code: `
|
|
972
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
973
|
+
|
|
974
|
+
// Static: tabIndex="-1", no ARIA role, not keyboard-focusable
|
|
975
|
+
<Row label="Year group" value="Year 9" />
|
|
976
|
+
|
|
977
|
+
// Clickable: tabIndex="0", Enter/Space activate onClick
|
|
978
|
+
// ⚠️ No role="button" — screen readers may not announce as interactive
|
|
979
|
+
<Row label="SEN record" value="SEN Support" onClick={handleClick} />
|
|
980
|
+
|
|
981
|
+
// href: real <a> tag — full native link semantics, announced as a link ✓
|
|
982
|
+
<Row label="Email address" value="admin@school.example" href="mailto:admin@school.example" />
|
|
983
|
+
`.trim(),
|
|
984
|
+
},
|
|
985
|
+
},
|
|
986
|
+
},
|
|
987
|
+
render: AccessibilityNotesTemplate,
|
|
988
|
+
},
|
|
989
|
+
[
|
|
990
|
+
'**Known accessibility gap:** Clickable rows (`onClick` provided) render as a `<div>` with no `role="button"`.',
|
|
991
|
+
'Screen readers will not announce them as interactive.',
|
|
992
|
+
'Keyboard users can still activate via Tab + Enter/Space, but VoiceOver/NVDA users have no indication the row is actionable.',
|
|
993
|
+
'',
|
|
994
|
+
'`href` rows are the exception — they render a real `<a>` tag with full native link semantics.',
|
|
995
|
+
'',
|
|
996
|
+
'If your use case requires screen-reader announcements on clickable rows, pass `className` with a workaround or request a component update.',
|
|
997
|
+
].join(' '),
|
|
998
|
+
);
|
|
999
|
+
|
|
1000
|
+
export const CustomClassAndStyle: Story = withDescription(
|
|
1001
|
+
{
|
|
1002
|
+
parameters: {
|
|
1003
|
+
controls: { disable: true },
|
|
1004
|
+
docs: {
|
|
1005
|
+
source: {
|
|
1006
|
+
language: 'tsx',
|
|
1007
|
+
code: `
|
|
1008
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
1009
|
+
|
|
1010
|
+
function HighlightedRow() {
|
|
1011
|
+
return (
|
|
1012
|
+
<Row
|
|
1013
|
+
label="Safeguarding flag"
|
|
1014
|
+
value="CP Plan — Stage 3"
|
|
1015
|
+
className="my-highlighted-row"
|
|
1016
|
+
style={{ borderLeft: '4px solid var(--color-semantic-destructive-600)' }}
|
|
1017
|
+
/>
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
export default HighlightedRow;
|
|
1021
|
+
`.trim(),
|
|
1022
|
+
},
|
|
1023
|
+
},
|
|
1024
|
+
},
|
|
1025
|
+
render: () => (
|
|
1026
|
+
<Row
|
|
1027
|
+
label="Safeguarding flag"
|
|
1028
|
+
value="CP Plan — Stage 3"
|
|
1029
|
+
className="my-highlighted-row"
|
|
1030
|
+
style={{ borderLeft: '4px solid var(--color-semantic-destructive-600)' }}
|
|
1031
|
+
/>
|
|
1032
|
+
),
|
|
1033
|
+
},
|
|
1034
|
+
'`className` and `style` are the only HTML-attribute escape hatches — `Row` does not spread arbitrary HTML attributes. Use `className` to apply component-token overrides or modifier classes; use `style` for one-off inline tweaks.',
|
|
1035
|
+
);
|
|
1036
|
+
|
|
1037
|
+
export const EmptyRow: Story = withDescription(
|
|
1038
|
+
{
|
|
1039
|
+
parameters: {
|
|
1040
|
+
controls: { disable: true },
|
|
1041
|
+
docs: {
|
|
1042
|
+
source: {
|
|
1043
|
+
language: 'tsx',
|
|
1044
|
+
code: `
|
|
1045
|
+
import { Row } from '@arbor-education/design-system.components';
|
|
1046
|
+
|
|
1047
|
+
// All props omitted — renders three empty spans in a flex container
|
|
1048
|
+
function EmptyRowExample() {
|
|
1049
|
+
return <Row />;
|
|
1050
|
+
}
|
|
1051
|
+
export default EmptyRowExample;
|
|
1052
|
+
`.trim(),
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
render: () => <Row />,
|
|
1057
|
+
},
|
|
1058
|
+
'All props omitted. The component renders without crashing — three empty `<span>` elements in a flex container at the default row height. A `Row` with no props is visible as an empty strip, not invisible, so conditionally-rendered row content produces a layout placeholder rather than disappearing silently.',
|
|
1059
|
+
);
|