@estiva-app/ui 0.117.0 → 0.118.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.
Files changed (54) hide show
  1. package/dist/ActivityLine.d.ts +37 -0
  2. package/dist/ActivityLine.d.ts.map +1 -0
  3. package/dist/CollapsibleSection.d.ts +6 -1
  4. package/dist/CollapsibleSection.d.ts.map +1 -1
  5. package/dist/ContainerHeader.d.ts +10 -1
  6. package/dist/ContainerHeader.d.ts.map +1 -1
  7. package/dist/DialogShell.d.ts +11 -3
  8. package/dist/DialogShell.d.ts.map +1 -1
  9. package/dist/ListTable.d.ts +71 -0
  10. package/dist/ListTable.d.ts.map +1 -0
  11. package/dist/MembersDialog.d.ts.map +1 -1
  12. package/dist/NavTree.d.ts +12 -1
  13. package/dist/NavTree.d.ts.map +1 -1
  14. package/dist/PageHeader.d.ts +11 -2
  15. package/dist/PageHeader.d.ts.map +1 -1
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +424 -320
  19. package/dist/index.js.map +4 -4
  20. package/package.json +1 -1
  21. package/registry.json +253 -5
  22. package/src/ActivityLine.mdx +67 -0
  23. package/src/ActivityLine.stories.tsx +49 -0
  24. package/src/ActivityLine.test.tsx +47 -0
  25. package/src/ActivityLine.tsx +74 -0
  26. package/src/Button.mdx +5 -0
  27. package/src/CollapsibleSection.mdx +6 -0
  28. package/src/CollapsibleSection.stories.tsx +4 -1
  29. package/src/CollapsibleSection.test.tsx +11 -0
  30. package/src/CollapsibleSection.tsx +7 -2
  31. package/src/ContainerHeader.mdx +7 -0
  32. package/src/ContainerHeader.stories.tsx +3 -0
  33. package/src/ContainerHeader.test.tsx +12 -1
  34. package/src/ContainerHeader.tsx +38 -18
  35. package/src/DialogShell.mdx +8 -2
  36. package/src/DialogShell.stories.tsx +20 -7
  37. package/src/DialogShell.tsx +10 -4
  38. package/src/ListTable.mdx +112 -0
  39. package/src/ListTable.stories.tsx +133 -0
  40. package/src/ListTable.test.tsx +81 -0
  41. package/src/ListTable.tsx +178 -0
  42. package/src/MembersDialog.test.tsx +8 -0
  43. package/src/MembersDialog.tsx +2 -10
  44. package/src/NavTree.mdx +6 -0
  45. package/src/NavTree.stories.tsx +14 -0
  46. package/src/NavTree.test.tsx +18 -0
  47. package/src/NavTree.tsx +16 -1
  48. package/src/PageHeader.mdx +13 -2
  49. package/src/PageHeader.stories.tsx +35 -1
  50. package/src/PageHeader.test.tsx +21 -0
  51. package/src/PageHeader.tsx +17 -5
  52. package/src/index.ts +2 -0
  53. package/src/registry/registry.test.ts +5 -5
  54. package/stories/Choosing.mdx +2 -0
@@ -0,0 +1,178 @@
1
+ import { createContext, useCallback, useContext, useLayoutEffect, useRef, useState, type MouseEvent, type ReactNode } from 'react'
2
+ import { cn } from './cn'
3
+ import { Link } from './Link'
4
+
5
+ /** How wide a column is: `small` 80px (a number, a few faces), `medium` 96px (a date), `large` 112px (a name). */
6
+ export type ListTableColumnWidth = 'small' | 'medium' | 'large'
7
+
8
+ /** Which columns give way first when the list runs short of room: `low` ones, then `high` ones. */
9
+ export type ListTableColumnKeep = 'high' | 'low'
10
+
11
+ /**
12
+ * One column after the name: its heading, how wide it is, and how long it stays when room runs short. A column's
13
+ * fields are not the list's props, so their words are named types, not read by the registry as props' values.
14
+ */
15
+ export interface ListTableColumn {
16
+ /** Its heading: "Team", "Members", "Active". */
17
+ label: string
18
+ /** `small` 80px (a number, a few faces), `medium` 96px (a date), `large` 112px (a name). Default `medium`. */
19
+ width?: ListTableColumnWidth
20
+ /**
21
+ * When the list runs short of room, which columns give way: `low` ones first, then `high` ones; the name and the
22
+ * end never do. Default `high`.
23
+ */
24
+ keep?: ListTableColumnKeep
25
+ }
26
+
27
+ export interface ListTableProps {
28
+ /** What the list is, to assistive technology: "Initiatives". */
29
+ 'aria-label': string
30
+ /** The first column's heading. Default "Name". */
31
+ nameLabel?: string
32
+ /** The columns after the name, in their order. None: no headings, only the rows — a list with no facts to show. */
33
+ columns: ListTableColumn[]
34
+ /** The rows hold something at their end — a small `Button`, a dot and a ⋮ — and the list keeps 64px for it. */
35
+ end?: boolean
36
+ /**
37
+ * The column headings on screen. Default true. `false` where the heading over the part already names the list and
38
+ * its facts read without a label — a team's page, under "Topics": faces and a number, "Yesterday" (Katerina,
39
+ * 16 November). Assistive technology still reads them, so each cell keeps its heading.
40
+ */
41
+ headings?: boolean
42
+ /** The rows: `ListTableRow`s. */
43
+ children: ReactNode
44
+ /** Placement only. */
45
+ className?: string
46
+ }
47
+
48
+ export interface ListTableRowProps {
49
+ /** Where the row leads. The whole row is the link. */
50
+ href: string
51
+ /** Its name, one line, cut short with an ellipsis. */
52
+ label: string
53
+ /** Under the name, one line, cut short: what it is about. */
54
+ description?: string
55
+ /** 16px, before the name: its kind. */
56
+ icon?: ReactNode
57
+ /** One per column, in the columns' order: words, or a part (`AvatarGroup`, `MetaText`). Absent, a dash: not read yet. */
58
+ cells: ReactNode[]
59
+ /** At the row's end, its own control: a small `Button` (Join), or the row's dot and ⋮. Never covered by the row's link. */
60
+ end?: ReactNode
61
+ onClick?: (event: MouseEvent<HTMLAnchorElement>) => void
62
+ /** Marks for the app's own tests and photo runs. */
63
+ [data: `data-${string}`]: string | boolean | undefined
64
+ }
65
+
66
+ const WIDTH_PX = { small: 80, medium: 96, large: 112 } as const
67
+ const WIDTH_CLASSES = { small: 'w-20', medium: 'w-24', large: 'w-28' } as const
68
+ /** The least room the name keeps before a column gives way. */
69
+ const NAME_LEAST_PX = 200
70
+ const DEFAULT_WIDTH = 'medium'
71
+ const sizeOf = (column: ListTableColumn) => column.width ?? DEFAULT_WIDTH
72
+ /** The row's 12px either side, the icon and its 12px gap. */
73
+ const ROW_FRAME_PX = 24 + 16 + 12
74
+ /** Each column's 12px gap before it. */
75
+ const GAP_PX = 12
76
+ const END_PX = 64
77
+
78
+ type Shown = 'all' | 'high' | 'none'
79
+ const ListTableContext = createContext<{ columns: ListTableColumn[]; shown: Shown; end: boolean } | null>(null)
80
+
81
+ const showsColumn = (column: ListTableColumn, shown: Shown) => shown === 'all' || (shown === 'high' && (column.keep ?? 'high') === 'high')
82
+
83
+ const widthOf = (columns: ListTableColumn[], end: boolean) =>
84
+ ROW_FRAME_PX + NAME_LEAST_PX + columns.reduce((sum, column) => sum + GAP_PX + WIDTH_PX[sizeOf(column)], 0) + (end ? GAP_PX + END_PX : 0)
85
+
86
+ /**
87
+ * A list of things on a page, under column headings: each row leads to its thing, with its name and what it is about,
88
+ * then a few short facts in columns, then an action at its end. The columns give way to the name by the list's own
89
+ * width, not the window's — `low` ones first, then `high` ones — so a list beside a sidebar keeps its names. The name
90
+ * is at most 384px and the facts sit beside it; the room left goes before the end, which keeps the list's right edge.
91
+ * The list takes the whole width it is given, as every page's body does (Katerina, 16 November).
92
+ *
93
+ * Peek's Explore topics, Ship's Topics and Leaf's Explore topics each drew this by hand, class for class, and their
94
+ * columns hid only at the phone's width: in a narrow window the names were cut to two letters (Katerina, 16 November).
95
+ */
96
+ export function ListTable({ 'aria-label': label, nameLabel = 'Name', columns, end = false, headings = true, children, className }: ListTableProps) {
97
+ const box = useRef<HTMLDivElement>(null)
98
+ const [shown, setShown] = useState<Shown>('all')
99
+ const measure = useCallback(() => {
100
+ const width = box.current?.getBoundingClientRect().width ?? 0
101
+ // jsdom has no layout: a list it draws shows every column.
102
+ if (width === 0) return
103
+ const high = columns.filter((column) => (column.keep ?? 'high') === 'high')
104
+ setShown(width >= widthOf(columns, end) ? 'all' : width >= widthOf(high, end) ? 'high' : 'none')
105
+ }, [columns, end])
106
+ useLayoutEffect(() => {
107
+ measure()
108
+ const list = box.current
109
+ if (!list || typeof ResizeObserver === 'undefined') return
110
+ const observer = new ResizeObserver(measure)
111
+ observer.observe(list)
112
+ return () => observer.disconnect()
113
+ }, [measure])
114
+ return (
115
+ <ListTableContext.Provider value={{ columns, shown, end }}>
116
+ <div ref={box} role="table" aria-label={label} className={cn('flex w-full flex-col gap-2', className)}>
117
+ {/* With no columns there is nothing to head: the part's own heading names the list, and a lone "Name" said nothing (Katerina, 16 November). */}
118
+ {columns.length > 0 && (
119
+ // Hidden, it is out of the flow too: the rows start where the list does, with no gap for it.
120
+ <div role="row" className={cn('flex items-center gap-3 px-3 text-caption text-text-muted', !headings && 'sr-only')}>
121
+ {/* Over the name, past the icon; as wide as the names' cells. */}
122
+ <span role="columnheader" className="min-w-0 max-w-sm flex-1 pl-7">
123
+ {nameLabel}
124
+ </span>
125
+ {columns.map((column) =>
126
+ showsColumn(column, shown) ? (
127
+ <span key={column.label} role="columnheader" className={cn('shrink-0 truncate', WIDTH_CLASSES[sizeOf(column)])}>
128
+ {column.label}
129
+ </span>
130
+ ) : null,
131
+ )}
132
+ {end && <span role="columnheader" aria-label="Actions" className="ml-auto w-16 shrink-0" />}
133
+ </div>
134
+ )}
135
+ {/* 2px between rows, as a list column's and a menu's. */}
136
+ <div role="rowgroup" className="flex flex-col gap-0.5">
137
+ {children}
138
+ </div>
139
+ </div>
140
+ </ListTableContext.Provider>
141
+ )
142
+ }
143
+
144
+ /** One row of a `ListTable`: the whole row leads to its thing; its end stays its own control. */
145
+ export function ListTableRow({ href, label, description, icon, cells, end, onClick, ...rest }: ListTableRowProps) {
146
+ const table = useContext(ListTableContext)
147
+ if (!table) throw new Error('ListTableRow is a row of a ListTable: put it inside one.')
148
+ return (
149
+ // A row's look in every list: 8px corners, the fill under the pointer and no edge.
150
+ <div role="row" className="relative flex min-w-0 items-center gap-3 rounded-lg px-3 py-2 hover:bg-bg-hover" {...rest}>
151
+ {/* At most 384px: a short name keeps its facts beside it, not across the page (Katerina, 16 November). */}
152
+ <span role="cell" className="flex min-w-0 max-w-sm flex-1 items-center gap-3">
153
+ {icon != null && <span className="flex shrink-0 items-center text-text-secondary">{icon}</span>}
154
+ {/* 2px between the name and its line, as every two-line row in the kit (LinkCard, LinkRow, PartCard, a tall MenuItem); they touched (Katerina, 16 November). */}
155
+ <Link href={href} variant="plain" cover className="flex min-w-0 flex-1 flex-col gap-0.5" {...(onClick ? { onClick } : {})}>
156
+ <span className="truncate text-body-2 font-medium text-text-primary">{label}</span>
157
+ {description && <span className="truncate text-caption text-text-secondary">{description}</span>}
158
+ </Link>
159
+ </span>
160
+ {table.columns.map((column, i) =>
161
+ showsColumn(column, table.shown) ? (
162
+ // A cell's parts sit 6px apart: faces and their number.
163
+ <span key={column.label} role="cell" className={cn('flex shrink-0 items-center gap-1.5 truncate text-caption text-text-secondary', WIDTH_CLASSES[sizeOf(column)])}>
164
+ {cells[i] ?? '–'}
165
+ </span>
166
+ ) : null,
167
+ )}
168
+ {table.end && (
169
+ // After the covering link and `relative`, so what is here stays its own control.
170
+ // The room the name leaves goes before it: the end keeps the list's right edge. A button's height (24px) in every
171
+ // row, so a row with nothing at its end is as tall as one with its ⋮ (40px; it was 36, Katerina, 16 November).
172
+ <span role="cell" className="relative ml-auto flex h-6 w-16 shrink-0 items-center justify-end gap-1">
173
+ {end}
174
+ </span>
175
+ )}
176
+ </div>
177
+ )
178
+ }
@@ -22,6 +22,14 @@ describe('MembersDialog', () => {
22
22
  expect(dialog.textContent).toContain('2')
23
23
  })
24
24
 
25
+ it('draws Add members’ way back whole: the bar’s own arrow, not a button pulled out of the title’s clipping box', async () => {
26
+ render(<MembersDialog members={members} candidates={[{ id: 'ravi', label: 'Ravi Mehta' }]} onAdd={() => {}} initialView="add" onClose={() => {}} />)
27
+ const back = await screen.findByRole('button', { name: 'Back to members' })
28
+ // Its fill and ring were cut off: it sat inside the title's box, which clips, pulled 8px out by -ml-2 (Katerina, 16 November).
29
+ expect(back.closest('.overflow-hidden')?.className).toContain('h-12')
30
+ expect(back.className).not.toMatch(/-m[lx]-/)
31
+ })
32
+
25
33
  it('offers no Join, Leave or Add when none is given', async () => {
26
34
  render(<MembersDialog members={members} onClose={() => {}} />)
27
35
  await screen.findByRole('dialog')
@@ -1,5 +1,5 @@
1
1
  import { useId, useState, type ReactNode } from 'react'
2
- import { IconArrowLeft, IconUserMinus, IconUserPlus } from '@tabler/icons-react'
2
+ import { IconUserMinus, IconUserPlus } from '@tabler/icons-react'
3
3
  import { Avatar } from './Avatar'
4
4
  import { Button } from './Button'
5
5
  import { Chip } from './Chip'
@@ -7,7 +7,6 @@ import { ChipInput, type ChipInputOption } from './ChipInput'
7
7
  import { DialogShell } from './DialogShell'
8
8
  import { Field } from './Field'
9
9
  import { Form } from './Form'
10
- import { IconButton } from './IconButton'
11
10
  import { MenuItem } from './Menu'
12
11
 
13
12
  /** One row of the roster: a face, a name, and an optional second line. */
@@ -129,14 +128,7 @@ export function AddPeopleLayer({
129
128
  <DialogShell
130
129
  title={title}
131
130
  onClose={onClose}
132
- headerContent={
133
- <div className="flex min-w-0 items-center gap-2">
134
- <IconButton tooltip={backLabel} aria-label={backLabel} className="-ml-2" onClick={onBack}>
135
- <IconArrowLeft size={16} stroke={1.5} />
136
- </IconButton>
137
- <span className="truncate text-h4 text-text-primary">{title}</span>
138
- </div>
139
- }
131
+ back={{ label: backLabel, onClick: onBack }}
140
132
  bodyClassName="flex flex-col gap-6"
141
133
  footer={
142
134
  <>
package/src/NavTree.mdx CHANGED
@@ -66,6 +66,12 @@ rows to any depth.
66
66
 
67
67
  <Canvas of={NavTreeStories.WithActionsAndUnread} />
68
68
 
69
+ - A group's `count` is how many rows it holds, 8px after its title, shown
70
+ open or shut — never written into the title ("Group · 2"), where it takes
71
+ the heading's type.
72
+
73
+ <Canvas of={NavTreeStories.GroupCount} />
74
+
69
75
  - A group's `menu` is its "More options" ⋮, after its actions and its
70
76
  `trailing`: what acts on the whole group — a folder's Rename, Archive. A
71
77
  row's `menu` acts on that row.
@@ -149,6 +149,20 @@ export const GroupIcons: Story = {
149
149
  },
150
150
  }
151
151
 
152
+ /** A group that says how many rows it holds, 8px after its title, open or shut. */
153
+ export const GroupCount: Story = {
154
+ args: {
155
+ groups: [
156
+ { id: 'n1', title: 'Group one', count: 2, defaultOpen: true, nodes: [
157
+ { id: 'n1a', label: 'Item one', href: '#', icon: placeholder },
158
+ { id: 'n1b', label: 'Item two', href: '#', icon: placeholder },
159
+ ] },
160
+ { id: 'n2', title: 'Group two', count: 1, defaultOpen: false, nodes: [{ id: 'n2a', label: 'Item three', href: '#', icon: placeholder }] },
161
+ ],
162
+ selected: undefined,
163
+ },
164
+ }
165
+
152
166
  /** Read as it opens: a group still being read, a group with nothing in it, a row whose rows are read when it opens, and one that could not be read. */
153
167
  export const ReadAsItOpens: Story = {
154
168
  args: {
@@ -38,6 +38,24 @@ describe('NavTree', () => {
38
38
  expect(onSelect.mock.calls[0][0].id).toBe('c')
39
39
  })
40
40
 
41
+ it('a group says its count beside its title, and the title stays its own words; an app-drawn group the same', () => {
42
+ render(
43
+ <NavTree groups={[{ id: 'g', title: 'Group one', count: 2, defaultOpen: false, nodes: [{ id: 'a', label: 'Item one', href: '#' }] }]} />,
44
+ )
45
+ expect(screen.getByText('2')).toBeTruthy()
46
+ expect(screen.getByText('Group one').textContent).toBe('Group one')
47
+ cleanup()
48
+ render(
49
+ <NavTree>
50
+ <NavTreeSection title="Group two" count={3} menu={<MenuItem label="Rename" />} menuLabel="More for Group two">
51
+ <a href="#">Item two</a>
52
+ </NavTreeSection>
53
+ </NavTree>,
54
+ )
55
+ expect(screen.getByText('3')).toBeTruthy()
56
+ expect(screen.getByRole('button', { name: 'More for Group two' })).toBeTruthy()
57
+ })
58
+
41
59
  it('draws the quiet label when given one', () => {
42
60
  render(<NavTree title="Groups" groups={GROUPS} emptyMessage="Nothing here yet." />)
43
61
  expect(screen.getByText('Groups')).not.toBeNull()
package/src/NavTree.tsx CHANGED
@@ -50,10 +50,14 @@ export interface NavTreeGroup {
50
50
  message?: string
51
51
  /** Beside the title, always shown: an `UnreadDot`, typically. */
52
52
  trailing?: ReactNode
53
+ /** How many rows it holds, 8px after the title, shown open or shut — `SectionHeader`'s. */
54
+ count?: number
53
55
  /** Beside the title, shown while the row is hovered or keyboard-focused: "Open", typically. */
54
56
  actions?: SectionAction[]
55
57
  /** The group's "More options" menu, after its actions: `MenuItem`s — a folder's Rename, Archive. */
56
58
  menu?: ReactNode
59
+ /** The ⋮'s accessible name. Default "More options". */
60
+ menuLabel?: string
57
61
  /** 16px, before the title — a folder's; the arrow takes its place on hover. */
58
62
  icon?: ReactNode
59
63
  defaultOpen?: boolean
@@ -231,8 +235,10 @@ function Group({ group, selected, onSelect, opening, storageKey }: { group: NavT
231
235
  message={group.message}
232
236
  loading={group.nodes === null}
233
237
  trailing={group.trailing}
238
+ {...(group.count != null ? { count: group.count } : {})}
234
239
  actions={group.actions}
235
240
  menu={group.menu}
241
+ {...(group.menuLabel != null ? { menuLabel: group.menuLabel } : {})}
236
242
  icon={group.icon}
237
243
  defaultOpen={group.defaultOpen ?? holds(group.nodes, selected)}
238
244
  open={group.open}
@@ -254,10 +260,17 @@ export interface NavTreeSectionProps {
254
260
  message?: string
255
261
  /** Beside the title, always shown: an `UnreadDot`, typically. */
256
262
  trailing?: ReactNode
263
+ /**
264
+ * How many rows it holds, 8px after the title, shown open or shut — `SectionHeader`'s. Written into the title by
265
+ * hand ("Other teams · 2"), the number took the heading's own type (Katerina, 16 November).
266
+ */
267
+ count?: number
257
268
  /** Beside the title, shown while the row is hovered or keyboard-focused: "Open", typically. */
258
269
  actions?: SectionAction[]
259
270
  /** The group's "More options" menu, after its actions: `MenuItem`s. */
260
271
  menu?: ReactNode
272
+ /** The ⋮'s accessible name, "More for Group one". Default "More options". */
273
+ menuLabel?: string
261
274
  /** 16px, before the title; the arrow takes its place on hover. */
262
275
  icon?: ReactNode
263
276
  /** Open unless told otherwise. */
@@ -291,7 +304,7 @@ export interface NavTreeSectionProps {
291
304
  * `groups`; an app whose groups each read their own data draws them itself,
292
305
  * as `NavTree`'s children.
293
306
  */
294
- export function NavTreeSection({ id, title, message, loading = false, pending = false, trailing, actions, menu, icon, defaultOpen = true, open, onOpenChange, storageKey, openFor, onIntent, children }: NavTreeSectionProps) {
307
+ export function NavTreeSection({ id, title, message, loading = false, pending = false, trailing, count, actions, menu, menuLabel, icon, defaultOpen = true, open, onOpenChange, storageKey, openFor, onIntent, children }: NavTreeSectionProps) {
295
308
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
296
309
  useEffect(() => () => clearTimeout(timer.current), [])
297
310
  // Pending for too long: a slow read, drawn as `loading` is (OPT-11). Each new wait starts the time again.
@@ -333,8 +346,10 @@ export function NavTreeSection({ id, title, message, loading = false, pending =
333
346
  storageKey={storageKey}
334
347
  openFor={openFor}
335
348
  trailing={trailing}
349
+ {...(count != null ? { count } : {})}
336
350
  actions={actions}
337
351
  menu={menu}
352
+ {...(menuLabel != null ? { menuLabel } : {})}
338
353
  icon={icon}
339
354
  className="shrink-0"
340
355
  // 2px between rows, as a list column's and a menu's (Katerina, 5 October).
@@ -26,10 +26,14 @@ page's buttons, 4px apart.
26
26
 
27
27
  - `private`: a lock before the title, when only its members can open it.
28
28
  - `after`: something that belongs to the title, right after it — a small
29
- `Button` that opens it elsewhere, a `Chip`.
29
+ `Button` that opens it elsewhere, a `Chip`, the places it is listed in as
30
+ **InlineChip**s. Several, given together, sit 8px apart: the bar spaces
31
+ them, so write no box around them.
30
32
 
31
33
  <Canvas of={PageHeaderStories.AfterTheTitle} />
32
34
 
35
+ <Canvas of={PageHeaderStories.SeveralAfterTheTitle} />
36
+
33
37
  - `meta`: quiet counts at the right, a dot between them; `done: true`
34
38
  for words about what is finished.
35
39
 
@@ -47,6 +51,12 @@ page's buttons, 4px apart.
47
51
 
48
52
  <Canvas of={PageHeaderStories.ColumnToggle} />
49
53
 
54
+ - `button`: a button with words, before the page's buttons and 8px clear
55
+ of them — Join, Add to Open work. Two, given together (Follow and Join),
56
+ sit 8px apart. Never a second toolbar beside the first.
57
+
58
+ <Canvas of={PageHeaderStories.AButtonBeforeTheButtons} />
59
+
50
60
  - A **Breadcrumb** in the title's place, for a page reached down a trail.
51
61
 
52
62
  <Canvas of={PageHeaderStories.Breadcrumb} />
@@ -107,6 +117,7 @@ It does these by itself. Write none of them around it.
107
117
  |---|---|---|
108
118
  | Draws ContainerHeader's bar: 48px, the hairline under it, 16px in at each end | a header row of your own | ContainerHeader used on its own in an app |
109
119
  | Keeps the counts, the time and the members 12px apart, and 12px clear of the buttons | `gap-3`, `pr-2` of your own around them | |
120
+ | Sets several things after the title 8px apart, and a button with words 8px before the page's buttons | a `flex gap-2` box of your own around them | |
110
121
  | Cuts a long string title short and keeps everything else whole | `truncate`, `min-w-0`, `shrink-0` | |
111
122
  | Draws the counts in `MetaText`, a dot between them | a dot or a count style of your own | |
112
123
  | Draws the time 12px italic, with the exact time in a tooltip | `text-caption italic` and a `WithTooltip` of your own | |
@@ -116,7 +127,7 @@ It does these by itself. Write none of them around it.
116
127
 
117
128
  | Key | What it does |
118
129
  |---|---|
119
- | Tab | Moves through the bar in reading order: what is after the title, the members, then the buttons |
130
+ | Tab | Moves through the bar in reading order: what is after the title, the members, the button with words, then the buttons |
120
131
  | Arrow keys | Move along the `Toolbar` of buttons, which is one Tab stop — the Toolbar's own keys |
121
132
 
122
133
  ## Props
@@ -1,9 +1,10 @@
1
1
  import { useState } from 'react'
2
2
  import type { Decorator, Meta, StoryObj } from '@storybook/react-vite'
3
- import { IconBox, IconDotsVertical, IconLayoutSidebarRight, IconLayoutSidebarRightFilled, IconSquareRounded } from '@tabler/icons-react'
3
+ import { IconBox, IconDotsVertical, IconLayoutSidebarRight, IconLayoutSidebarRightFilled, IconSquareRounded, IconTarget } from '@tabler/icons-react'
4
4
  import { Avatar } from './Avatar'
5
5
  import { Breadcrumb as Trail } from './Breadcrumb'
6
6
  import { Button } from './Button'
7
+ import { InlineChip } from './InlineChip'
7
8
  import { MembersPill } from './MembersPill'
8
9
  import { Menu, MenuItem } from './Menu'
9
10
  import { PageHeader } from './PageHeader'
@@ -37,6 +38,7 @@ const meta = {
37
38
  argTypes: {
38
39
  leading: { control: false },
39
40
  after: { control: false },
41
+ button: { control: false },
40
42
  members: { control: false },
41
43
  actions: { control: false },
42
44
  },
@@ -93,6 +95,38 @@ export const AfterTheTitle: Story = {
93
95
  },
94
96
  }
95
97
 
98
+ /** Several things after the title, 8px apart, spaced by the bar: the places it is listed in, then a small button. */
99
+ export const SeveralAfterTheTitle: Story = {
100
+ args: {
101
+ after: (
102
+ <>
103
+ <InlineChip href="#" icon={<IconTarget size={14} stroke={1.5} />}>
104
+ Group one
105
+ </InlineChip>
106
+ <InlineChip href="#" icon={<IconTarget size={14} stroke={1.5} />}>
107
+ Group two
108
+ </InlineChip>
109
+ <Button size="small" href="https://example.com" external leadingIcon={<IconSquareRounded size={14} stroke={1.5} />}>
110
+ Open
111
+ </Button>
112
+ </>
113
+ ),
114
+ },
115
+ }
116
+
117
+ /** A button with words before the page's buttons, 8px clear of them. */
118
+ export const AButtonBeforeTheButtons: Story = {
119
+ args: {
120
+ members,
121
+ button: (
122
+ <Button size="small" variant="primary">
123
+ Join
124
+ </Button>
125
+ ),
126
+ actions,
127
+ },
128
+ }
129
+
96
130
  /** Quiet counts at the right, a dot between them; words about what is finished in the success colour. */
97
131
  export const Counts: Story = { args: { leading: icon, meta: ['6 open', { label: '2 done', done: true }] } }
98
132
 
@@ -31,6 +31,27 @@ describe('PageHeader', () => {
31
31
  expect(screen.queryByRole('img', { name: 'Private' })).toBeNull()
32
32
  })
33
33
 
34
+ it('sets several things after the title 8px apart, and a button with words 8px before the page’s buttons', () => {
35
+ render(
36
+ <PageHeader
37
+ title="Item one"
38
+ after={
39
+ <>
40
+ <a href="#">Group one</a>
41
+ <a href="#">Group two</a>
42
+ </>
43
+ }
44
+ button={<button>Join</button>}
45
+ actions={<button>More</button>}
46
+ />,
47
+ )
48
+ expect(screen.getByText('Group one').parentElement?.className).toContain('gap-2')
49
+ const join = screen.getByRole('button', { name: 'Join' }).parentElement as HTMLElement
50
+ expect(join.className).toContain('pr-1')
51
+ // The button comes before the page's buttons, in reading order.
52
+ expect(join.compareDocumentPosition(screen.getByRole('button', { name: 'More' })) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
53
+ })
54
+
34
55
  it('a private page has a lock named "Private" before its title', () => {
35
56
  const { container } = render(<PageHeader title="Item one" private />)
36
57
  const lock = screen.getByRole('img', { name: 'Private' })
@@ -37,7 +37,10 @@ export interface PageHeaderProps {
37
37
  leading?: ReactNode
38
38
  /** A lock before the title: only its members can open this page. Named "Private" to assistive technology and in a tooltip. */
39
39
  private?: boolean
40
- /** Right after the title, 8px from it, and never cut short: a small `Button`, a `Chip`. */
40
+ /**
41
+ * Right after the title, 8px from it, and never cut short: a small `Button`, a `Chip`, a `Link`. Several, given
42
+ * together (a fragment), sit 8px apart: the bar spaces them, not a box of your own (Katerina, 16 November).
43
+ */
41
44
  after?: ReactNode
42
45
  /** Quiet words at the right, before the members: counts. A dot between each, each in `MetaText` (in Signal, the mono micro-type). */
43
46
  meta?: (string | PageHeaderMeta)[]
@@ -45,13 +48,19 @@ export interface PageHeaderProps {
45
48
  time?: { label: string; exact: string }
46
49
  /** Who is in it: a `MembersPill`. */
47
50
  members?: ReactNode
51
+ /**
52
+ * A button with words, before the page's buttons and 8px clear of them: Join, Add to Open work. Two, given together
53
+ * (Follow and Join), sit 8px apart. Peek drew them in a box of its own beside the toolbar, for want of this place
54
+ * (Katerina, 16 November).
55
+ */
56
+ button?: ReactNode
48
57
  /** The page's own buttons, at the right edge: a `Toolbar` with `surface={false}` of `ToolbarButton`s, or one `IconButton`. */
49
58
  actions?: ReactNode
50
59
  /** Placement only. */
51
60
  className?: string
52
61
  }
53
62
 
54
- export function PageHeader({ title, leading, private: locked = false, after, meta, time, members, actions, className }: PageHeaderProps) {
63
+ export function PageHeader({ title, leading, private: locked = false, after, meta, time, members, button, actions, className }: PageHeaderProps) {
55
64
  const words = (meta ?? []).map((one) => (typeof one === 'string' ? { label: one } : one))
56
65
  const quiet = words.length > 0 || time != null || members != null
57
66
 
@@ -64,17 +73,18 @@ export function PageHeader({ title, leading, private: locked = false, after, met
64
73
  </WithTooltip>
65
74
  )}
66
75
  {typeof title === 'string' ? <span className="truncate text-body-2-strong text-text-primary">{title}</span> : <div className="flex min-w-0 items-center">{title}</div>}
67
- {after != null && <span className="flex shrink-0 items-center">{after}</span>}
76
+ {after != null && <span className="flex shrink-0 items-center gap-2">{after}</span>}
68
77
  </div>
69
78
  )
70
79
 
80
+ const buttons = actions != null || button != null
71
81
  const right =
72
- quiet || actions != null ? (
82
+ quiet || buttons ? (
73
83
  <>
74
84
  {quiet && (
75
85
  // The quiet group: 12px between its parts, and 12px clear of the buttons — the bar sets
76
86
  // its actions 4px apart, so the group adds the other 8px, as Peek's and Leaf's bars do.
77
- <div className={cn('flex items-center gap-3', actions != null && 'pr-2')}>
87
+ <div className={cn('flex items-center gap-3', buttons && 'pr-2')}>
78
88
  {words.length > 0 && (
79
89
  <div className="flex items-center gap-2">
80
90
  {words.map((one, i) => (
@@ -97,6 +107,8 @@ export function PageHeader({ title, leading, private: locked = false, after, met
97
107
  {members}
98
108
  </div>
99
109
  )}
110
+ {/* The bar sets its parts 4px apart; the other 4px keep the words 8px clear of the icons. */}
111
+ {button != null && <span className={cn('flex shrink-0 items-center gap-2', actions != null && 'pr-1')}>{button}</span>}
100
112
  {actions}
101
113
  </>
102
114
  ) : undefined
package/src/index.ts CHANGED
@@ -139,6 +139,7 @@ export { TopBar, type TopBarProps } from './TopBar'
139
139
  export { PersonTrigger, type PersonTriggerProps } from './PersonTrigger'
140
140
  export { Property, type PropertyProps } from './Property'
141
141
  export { Reaction, type ReactionProps } from './Reaction'
142
+ export { ActivityLine, type ActivityLineProps } from './ActivityLine'
142
143
  export { ConversationActions, type ConversationActionsProps } from './ConversationActions'
143
144
  export { ConversationCard, ReplyCard, type ConversationCardProps, type ConversationEntryProps, type ConversationPerson, type ReplyCardProps } from './ConversationCard'
144
145
  export { ConversationLayout, type ConversationItem, type ConversationLayoutProps } from './ConversationLayout'
@@ -171,6 +172,7 @@ export { ContainerHeader, type ContainerHeaderProps } from './ContainerHeader'
171
172
  export { Panel, type PanelProps } from './Panel'
172
173
  export { PageHeader, type PageHeaderMeta, type PageHeaderProps } from './PageHeader'
173
174
  export { ListColumn, type ListColumnProps } from './ListColumn'
175
+ export { ListTable, ListTableRow, type ListTableColumn, type ListTableColumnKeep, type ListTableColumnWidth, type ListTableProps, type ListTableRowProps } from './ListTable'
174
176
  export { CollapsibleSection, useRememberedOpen, type CollapsibleSectionProps } from './CollapsibleSection'
175
177
  export { SectionLabel } from './SectionLabel'
176
178
  export { Tabs, type TabDef, type TabsProps } from './Tabs'
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
48
48
  expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
49
49
  })
50
50
 
51
- it('counts 253 names over 129 files: 167 components, 78 helpers and 8 hooks (useShortcut, a key that works from anywhere on the page, for Peek’s Ctrl/Cmd+O to Add to Open work (TOPI-7), on 10 November; CornerMenu, the "…" over a row’s or a card’s corner with Show as and Remove (TOPI-5), on 10 November; ConversationHeading, which place a comment is on in a list mixing several places (TOPI-2), on 9 November; FollowSwitch, LevelIcon and WhoFollowsDialog, how you follow a place and who follows it (TEA-6), on 6 November; goneWords and GONE_CLOSED, what stands in a gone comment’s place and under its thread in every app (ONE-9), on 6 November; DeletedNotice and NoAccessNotice, the cards on a deleted file and on one you cannot open (ALO-4), on 3 November; useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
51
+ it('counts 256 names over 131 files: 170 components, 78 helpers and 8 hooks (ListTable and ListTableRow, a list of things on a page under column headings, and ActivityLine, one thing that happened in a list of what is new, from the navigation prototype, on 16 November; useShortcut, a key that works from anywhere on the page, for Peek’s Ctrl/Cmd+O to Add to Open work (TOPI-7), on 10 November; CornerMenu, the "…" over a row’s or a card’s corner with Show as and Remove (TOPI-5), on 10 November; ConversationHeading, which place a comment is on in a list mixing several places (TOPI-2), on 9 November; FollowSwitch, LevelIcon and WhoFollowsDialog, how you follow a place and who follows it (TEA-6), on 6 November; goneWords and GONE_CLOSED, what stands in a gone comment’s place and under its thread in every app (ONE-9), on 6 November; DeletedNotice and NoAccessNotice, the cards on a deleted file and on one you cannot open (ALO-4), on 3 November; useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
52
52
  // The reconciliation GATES.md §24 explains. If this changes, that changes.
53
53
  // The `EDITOR_EXTENSIONS` count as components by their names; they are
54
54
  // editor extensions, documented on SelectionToolbar's, BlockNodes' and
55
55
  // ComposerTriggers' pages.
56
56
  const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
57
- expect(kinds).toEqual({ component: 167, helper: 78, hook: 8 })
58
- expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(129)
57
+ expect(kinds).toEqual({ component: 170, helper: 78, hook: 8 })
58
+ expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(131)
59
59
  })
60
60
 
61
61
  it('gives every entry a purpose, from its own page or from the comment above it', () => {
62
62
  expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
63
- expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(116)
64
- expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(137)
63
+ expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(118)
64
+ expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(138)
65
65
  })
66
66
 
67
67
  it('takes a name with a page of its own from the page, and a name without one from the code', () => {
@@ -109,6 +109,7 @@ The same conversation in every app; only its colours are each app's.
109
109
  | The strip on a pointed-at comment, and its ⋯ menu | **ConversationActions** and **ConversationMenu** — the cards draw both |
110
110
  | A time beside a name, "(edited)", urgent and new | **MetaText**, **EditedMarker**, **UrgentMark** |
111
111
  | How far back reactions were read | **ReactionHorizon** — draws nothing when every one was |
112
+ | One thing that happened, in a list of what is new: who, what they did, when, where | **ActivityLine** — a menu row’s look, a link or a button; the mark beside the first line |
112
113
 
113
114
  ## Structure and wayfinding
114
115
 
@@ -123,6 +124,7 @@ The same conversation in every app; only its colours are each app's.
123
124
  | Something new on a row or a card, no count | **UnreadDot** — the 6px dot in a 24px slot; in a sidebar row, **NavItem** `unread` draws it; `quiet` for a dot that is always there with nothing new; `tone="reaction"` for a reaction to you (NavItem `unreadTone`) |
124
125
  | One thing — a conversation, a project, an object — as a box you can pick | **Card** — the fill by what it sits on; `href` for a link, `hover="fill"` in a feed, `onPress` when a press opens it |
125
126
  | A section heading, chevron, hover actions, a count beside the title | **SectionHeader** |
127
+ | A list of things on a page, under column headings, each row a link | **ListTable** with **ListTableRow** — the columns give way by the list’s own width; `headings={false}` where the part’s heading names it |
126
128
  | A group of rows that opens and closes, and stays how you left it | **CollapsibleSection** — `storageKey` remembers |
127
129
  | The uppercase micro-label | **SectionLabel** |
128
130
  | A hairline, or a line with words in the middle | **Divider** — `label`; `look="section"` between stretches of a list, `sticky` while it scrolls |