@estiva-app/ui 0.116.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 (74) 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 +1 -0
  12. package/dist/MembersDialog.d.ts.map +1 -1
  13. package/dist/Menu.d.ts +9 -2
  14. package/dist/Menu.d.ts.map +1 -1
  15. package/dist/NavItem.d.ts.map +1 -1
  16. package/dist/NavTree.d.ts +12 -1
  17. package/dist/NavTree.d.ts.map +1 -1
  18. package/dist/PageHeader.d.ts +11 -2
  19. package/dist/PageHeader.d.ts.map +1 -1
  20. package/dist/SectionHeader.d.ts.map +1 -1
  21. package/dist/WhoFollowsDialog.d.ts +12 -2
  22. package/dist/WhoFollowsDialog.d.ts.map +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +816 -671
  26. package/dist/index.js.map +4 -4
  27. package/package.json +1 -1
  28. package/registry.json +272 -5
  29. package/src/ActivityLine.mdx +67 -0
  30. package/src/ActivityLine.stories.tsx +49 -0
  31. package/src/ActivityLine.test.tsx +47 -0
  32. package/src/ActivityLine.tsx +74 -0
  33. package/src/Button.mdx +5 -0
  34. package/src/CollapsibleSection.mdx +6 -0
  35. package/src/CollapsibleSection.stories.tsx +4 -1
  36. package/src/CollapsibleSection.test.tsx +11 -0
  37. package/src/CollapsibleSection.tsx +7 -2
  38. package/src/ContainerHeader.mdx +7 -0
  39. package/src/ContainerHeader.stories.tsx +3 -0
  40. package/src/ContainerHeader.test.tsx +12 -1
  41. package/src/ContainerHeader.tsx +38 -18
  42. package/src/DialogShell.mdx +8 -2
  43. package/src/DialogShell.stories.tsx +20 -7
  44. package/src/DialogShell.tsx +10 -4
  45. package/src/FollowSwitch.test.tsx +6 -4
  46. package/src/ListTable.mdx +112 -0
  47. package/src/ListTable.stories.tsx +133 -0
  48. package/src/ListTable.test.tsx +81 -0
  49. package/src/ListTable.tsx +178 -0
  50. package/src/MembersDialog.test.tsx +8 -0
  51. package/src/MembersDialog.tsx +3 -11
  52. package/src/Menu.mdx +3 -0
  53. package/src/Menu.stories.tsx +23 -0
  54. package/src/Menu.tsx +13 -3
  55. package/src/NavItem.mdx +2 -0
  56. package/src/NavItem.tsx +5 -1
  57. package/src/NavTree.mdx +6 -0
  58. package/src/NavTree.stories.tsx +14 -0
  59. package/src/NavTree.test.tsx +18 -0
  60. package/src/NavTree.tsx +16 -1
  61. package/src/PageHeader.mdx +13 -2
  62. package/src/PageHeader.stories.tsx +35 -1
  63. package/src/PageHeader.test.tsx +21 -0
  64. package/src/PageHeader.tsx +17 -5
  65. package/src/SectionHeader.mdx +2 -0
  66. package/src/SectionHeader.test.tsx +16 -0
  67. package/src/SectionHeader.tsx +4 -2
  68. package/src/WhoFollowsDialog.mdx +2 -0
  69. package/src/WhoFollowsDialog.stories.tsx +19 -0
  70. package/src/WhoFollowsDialog.test.tsx +40 -0
  71. package/src/WhoFollowsDialog.tsx +66 -10
  72. package/src/index.ts +2 -0
  73. package/src/registry/registry.test.ts +5 -5
  74. 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. */
@@ -65,7 +64,7 @@ export interface MembersDialogProps {
65
64
  }
66
65
 
67
66
  // The icon in the accent as text: Ship's button blue read at 2.7:1 on its grey square (Katerina, 8 October).
68
- const LEADING_CLASSES = 'size-8 rounded-md bg-accent-muted flex items-center justify-center shrink-0 text-accent-text'
67
+ export const LEADING_CLASSES = 'size-8 rounded-md bg-accent-muted flex items-center justify-center shrink-0 text-accent-text'
69
68
 
70
69
  /** One person in a roster: a face, a name, a second line, and an optional control at the end. Shared with `WhoFollowsDialog`. */
71
70
  export function RosterRow({ member, trailing }: { member: MembersDialogMember; trailing?: ReactNode }) {
@@ -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/Menu.mdx CHANGED
@@ -28,6 +28,9 @@ definition either way.
28
28
  - A picker fed by typing: rows are `MenuItem size="tall"` — content height
29
29
  with a 40px floor, room for a 32px face via `leading` and a `description`
30
30
  line — with an `EnterHint` on the highlighted row.
31
+ - A row of two lines (a `description`) has its icon beside the first line, not centred
32
+ between the two; a tall row's face stays centred (`leadingAt` says either).
33
+ <Canvas of={MenuStories.TwoLines} />
31
34
  - Grouped choices where one is current: `MenuSection` over rows, `selected`
32
35
  on the chosen one.
33
36
 
@@ -46,6 +46,29 @@ export const Items: Story = {
46
46
  ),
47
47
  }
48
48
 
49
+ /** Rows of two lines: the icon beside the first line, a row with a `description` by default (Katerina, 16 November);
50
+ * `leadingAt="center"` keeps it centred on the whole row, and a row whose `children` run to two lines passes
51
+ * `leadingAt="top"`. */
52
+ export const TwoLines: Story = {
53
+ parameters: { controls: { disable: true } },
54
+ render: () => (
55
+ <MenuPanel className="w-80">
56
+ <MenuSection label="Section">
57
+ <MenuItem label="Item one" description="A second line that says more about it" leading={icon(IconSquareRounded)} onClick={() => {}} />
58
+ <MenuItem label="Item two" description="A second line that says more about it" leading={icon(IconSquareRounded)} selected onClick={() => {}} />
59
+ <MenuItem label="Item three" description="leadingAt center: the icon centred on both lines" leading={icon(IconSquareRounded)} leadingAt="center" onClick={() => {}} />
60
+ </MenuSection>
61
+ <MenuSeparator />
62
+ <MenuItem leading={icon(IconSquareRounded)} leadingAt="top" onClick={() => {}}>
63
+ <span className="flex min-w-0 flex-1 flex-col">
64
+ <span className="truncate text-body-2 text-text-primary">Item four</span>
65
+ <span className="truncate text-caption text-text-secondary">Its children run to a second line</span>
66
+ </span>
67
+ </MenuItem>
68
+ </MenuPanel>
69
+ ),
70
+ }
71
+
49
72
  /** Groups under headings, with a divider between them. The divider runs the
50
73
  * width of the rows it separates, not the width of the panel's text. */
51
74
  export const Sections: Story = {
package/src/Menu.tsx CHANGED
@@ -359,6 +359,13 @@ export interface MenuItemProps extends Omit<ComponentPropsWithRef<'button'>, 'ch
359
359
  aside?: string
360
360
  /** Before the label: a 16px icon (stroke 1.5, secondary), or an Avatar, for rows led by a face. */
361
361
  leading?: ReactNode
362
+ /**
363
+ * Where `leading` sits on a row of two lines: beside the first line, or centred on the whole row. Default: beside the
364
+ * first line on a default-size row with a `description` (Katerina, 16 November: an icon centred between two lines
365
+ * belongs to neither); centred otherwise, as a tall row's face is. A row whose `children` run to two lines passes
366
+ * `top`.
367
+ */
368
+ leadingAt?: 'center' | 'top'
362
369
  /** At the right edge: a hint, a value — anything. Wins over `shortcut` and `submenu`. */
363
370
  trailing?: ReactNode
364
371
  /**
@@ -442,9 +449,10 @@ export function menuItemClassName({ size, selected, shut = false, className }: {
442
449
  /** Everything inside the row — written once, for the same reason. Shared
443
450
  * inside the package like `menuItemClassName`: `CommandPalette` draws it
444
451
  * inside Base UI's `Autocomplete.Item`. Not exported from the index. */
445
- export function MenuItemBody({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected, shut = false }: Pick<MenuItemProps, 'label' | 'children' | 'size' | 'description' | 'aside' | 'leading' | 'trailing' | 'hint' | 'shortcut' | 'submenu' | 'destructive' | 'selected'> & { shut?: boolean }) {
452
+ export function MenuItemBody({ label, children, size = 'default', description, aside, leading, leadingAt, trailing, hint, shortcut, submenu, destructive, selected, shut = false }: Pick<MenuItemProps, 'label' | 'children' | 'size' | 'description' | 'aside' | 'leading' | 'leadingAt' | 'trailing' | 'hint' | 'shortcut' | 'submenu' | 'destructive' | 'selected'> & { shut?: boolean }) {
446
453
  // Shut, its words in the disabled colour, a destructive one's too.
447
454
  const labelColour = shut ? 'text-text-disabled' : destructive ? 'text-error-default' : 'text-text-primary'
455
+ const firstLine = (leadingAt ?? (size === 'default' && description ? 'top' : 'center')) === 'top'
448
456
  const edge =
449
457
  trailing ??
450
458
  (shortcut ? (
@@ -454,7 +462,8 @@ export function MenuItemBody({ label, children, size = 'default', description, a
454
462
  ) : null)
455
463
  return (
456
464
  <>
457
- {leading && <span className="flex shrink-0 items-center">{leading}</span>}
465
+ {/* Beside the first line: the 20px of a body-2 line, from the row's top, so a 16px icon is centred on that line. */}
466
+ {leading && <span className={cn('flex shrink-0 items-center', firstLine && 'h-5 self-start')}>{leading}</span>}
458
467
  {/* Sizes are arbitrary values (the body-2 and caption tokens): these
459
468
  lists merge with a colour, and tw-merge drops a token size beside a
460
469
  colour. Ship's copy said `text-sm`, which was never the ramp. */}
@@ -495,7 +504,7 @@ export function MenuItemBody({ label, children, size = 'default', description, a
495
504
  )
496
505
  }
497
506
 
498
- export function MenuItem({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected, disabledReason, className, ...props }: MenuItemProps) {
507
+ export function MenuItem({ label, children, size = 'default', description, aside, leading, leadingAt, trailing, hint, shortcut, submenu, destructive, selected, disabledReason, className, ...props }: MenuItemProps) {
499
508
  const shut = !!disabledReason
500
509
  const body = (
501
510
  <MenuItemBody
@@ -504,6 +513,7 @@ export function MenuItem({ label, children, size = 'default', description, aside
504
513
  description={description}
505
514
  aside={aside}
506
515
  leading={leading}
516
+ {...(leadingAt ? { leadingAt } : {})}
507
517
  trailing={trailing}
508
518
  hint={hint}
509
519
  shortcut={shortcut}
package/src/NavItem.mdx CHANGED
@@ -27,6 +27,8 @@ count — a muted mono number whose tooltip says what it counts.
27
27
  is pointed at or keyboard-focused, and moves the count aside for it. On a
28
28
  screen with no hover the ⋮ always shows, and the count or dot under it
29
29
  stays aside: the row reads as it does under a pointer.
30
+ Its menu opens toward the page: its left edge under the ⋮, spreading
31
+ right over what the column sits beside, not back over the list.
30
32
 
31
33
  <Canvas of={NavItemStories.WithMenu} />
32
34
 
package/src/NavItem.tsx CHANGED
@@ -300,8 +300,12 @@ export function NavItem({
300
300
  </IconButton>
301
301
  )}
302
302
  {menu != null && (
303
+ /*
304
+ Toward the page: the menu's left edge under the ⋮, spreading right over what the column sits beside,
305
+ not back over the list and the rail (Katerina, 16 November). At the screen's edge Base UI shifts it in.
306
+ */
303
307
  <Menu
304
- align="right"
308
+ align="left"
305
309
  trigger={
306
310
  <IconButton tooltip="More options" aria-label={name}>
307
311
  <IconDotsVertical size={16} stroke={1.5} />
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' })