@estiva-app/ui 0.121.0 → 0.122.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.121.0",
3
+ "version": "0.122.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.121.0",
7
+ "packageVersion": "0.122.0",
8
8
  "exports": 256,
9
9
  "typeExports": 270,
10
10
  "files": null
@@ -7128,6 +7128,12 @@
7128
7128
  "required": false,
7129
7129
  "note": "Opens the list — usually a `MembersDialog`."
7130
7130
  },
7131
+ {
7132
+ "name": "readOnly",
7133
+ "takes": "true/false",
7134
+ "required": false,
7135
+ "note": "Says who is in it and is nothing to press: the pill's own look, not greyed as a disabled one — in a list's row, which opens its thing (Katerina, 17 November: \"clicking on the pill should not show the members list."
7136
+ },
7131
7137
  {
7132
7138
  "name": "label",
7133
7139
  "takes": "text",
@@ -7150,6 +7156,7 @@
7150
7156
  "docPage": "src/MembersPill.mdx",
7151
7157
  "app": null,
7152
7158
  "looks": [
7159
+ "rounded-md border border-border-default font-sans font-medium text-btn-default text-text-primary",
7153
7160
  "text-caption text-text-secondary signal:font-mono signal:text-small signal:tabular-nums"
7154
7161
  ]
7155
7162
  },
@@ -18,7 +18,9 @@ One thing that happened, in a list of them: a mark for what kind of thing it is,
18
18
  - `did`: what they did, after their name, in the app's words.
19
19
  - `where`: the place it was said, before the words, on a list that mixes
20
20
  places; absent on the place's own list.
21
- - `seen`: an Earlier line — the name in the secondary text.
21
+ - `seen`: an Earlier line — the name in the secondary text, and no tint. A
22
+ new line (the default) wears the accent's wash, so what is new reads apart
23
+ at a glance; the pointer's fill still shows over it.
22
24
 
23
25
  <Canvas of={ActivityLineStories.Seen} />
24
26
 
@@ -44,4 +44,13 @@ describe('ActivityLine', () => {
44
44
  expect(row.className).toContain('rounded-lg')
45
45
  expect(row.className).not.toMatch(/\bborder\b/)
46
46
  })
47
+
48
+ it('a new line wears the accent’s wash, a seen one none; the pointer’s fill still shows over it (Katerina, 16 November)', () => {
49
+ const { rerender } = render(<ActivityLine {...line} />)
50
+ const row = () => screen.getByRole('button')
51
+ expect(row().className).toContain('bg-accent-wash')
52
+ expect(row().className).toContain('hover:bg-bg-hover')
53
+ rerender(<ActivityLine {...line} seen />)
54
+ expect(row().className).not.toContain('bg-accent-wash')
55
+ })
47
56
  })
@@ -58,7 +58,12 @@ export function ActivityLine({ person, did, time, mark, where, words, seen = fal
58
58
  </span>
59
59
  </MenuItemBody>
60
60
  )
61
- const row = menuItemClassName({ size: 'default', className })
61
+ /*
62
+ A new line wears the accent's wash, the open replies row's tint, so what is new reads apart from what was seen at a
63
+ glance, under its "New" heading too (Katerina, 6 November: "We also need to have new stuff with bg color"; 16
64
+ November: "let's use background color on new items"). Seen, it is plain. The pointer's fill still shows over it.
65
+ */
66
+ const row = menuItemClassName({ size: 'default', className: cn(!seen && 'bg-accent-wash', className) })
62
67
  if (href) {
63
68
  return (
64
69
  <Link href={href} variant="plain" className={row} {...(onClick ? { onClick } : {})} {...rest}>
package/src/ListTable.mdx CHANGED
@@ -46,10 +46,12 @@ A list of things on a page, under column headings: each row leads to its thing,
46
46
 
47
47
  <Canvas of={ListTableStories.NotReadYet} />
48
48
 
49
- - It takes the whole width it is given. The name is at most 384px and its
50
- facts sit beside it; the room left goes before the end, which keeps the
51
- list's right edge. A name stretched across the page sat far from its
52
- facts.
49
+ - It takes the whole width it is given. The name and what it is about take
50
+ the room on the left; the facts sit together on the right, before the end,
51
+ 24px apart, as are the name and the first fact (Katerina, 17 November:
52
+ "everything is crammed together on the left … we need air for them to
53
+ breathe"). From 16 November the name was capped at 384px with the facts
54
+ beside it; they read as one crammed block.
53
55
 
54
56
  <Canvas of={ListTableStories.OnAWidePage} />
55
57
 
@@ -105,7 +107,7 @@ import { Button, ListTable, ListTableRow } from '@estiva-app/ui'
105
107
  | Hides columns by its own width, `low` first | `hidden sm:block` on a column |
106
108
  | Draws a row's fill, its 8px corners and no edge | `rounded-md hover:bg-bg-hover` on a row |
107
109
  | Makes the whole row the link, its end above it | a covering link and `relative` by hand |
108
- | Keeps the name at most 384px, the facts beside it, the end at the right | a width of your own on the name |
110
+ | Gives the name the room on the left and puts the facts together on the right, 24px apart | a width of your own on the name, a gap by hand |
109
111
 
110
112
  ## Props
111
113
 
@@ -13,6 +13,23 @@ afterEach(cleanup)
13
13
  const columns = [{ label: 'Team', width: 'large' as const }, { label: 'Active', keep: 'low' as const }]
14
14
 
15
15
  describe('ListTable', () => {
16
+ // "Everything is crammed together on the left … names/desc at the left and the rest on the right" (Katerina, 17 November).
17
+ it('gives the name the room on the left and puts the facts together on the right, 24px apart', () => {
18
+ render(
19
+ <ListTable aria-label="Items" columns={columns}>
20
+ <ListTableRow href="/one" label="Item one" cells={['Group one', undefined]} />
21
+ </ListTable>,
22
+ )
23
+ const row = screen.getByText('Item one').closest('[role=row]') as HTMLElement
24
+ const name = within(row).getAllByRole('cell')[0]!
25
+ expect(name.className.split(' ')).toContain('flex-1')
26
+ expect(name.className.split(' ')).not.toContain('max-w-sm')
27
+ expect(row.className.split(' ')).toContain('gap-6')
28
+ const heads = screen.getAllByRole('columnheader')[0]!.parentElement!
29
+ expect(heads.className.split(' ')).toContain('gap-6')
30
+ expect(screen.getAllByRole('columnheader')[0]!.className.split(' ')).not.toContain('max-w-sm')
31
+ })
32
+
16
33
  it('heads its columns, and each row has one cell per heading, a dash where it is not read', () => {
17
34
  render(
18
35
  <ListTable aria-label="Items" columns={columns}>
package/src/ListTable.tsx CHANGED
@@ -71,8 +71,8 @@ const DEFAULT_WIDTH = 'medium'
71
71
  const sizeOf = (column: ListTableColumn) => column.width ?? DEFAULT_WIDTH
72
72
  /** The row's 12px either side, the icon and its 12px gap. */
73
73
  const ROW_FRAME_PX = 24 + 16 + 12
74
- /** Each column's 12px gap before it. */
75
- const GAP_PX = 12
74
+ /** Each column's 24px gap before it: room between the facts (Katerina, 17 November: "we need air for them to breathe"). */
75
+ const GAP_PX = 24
76
76
  const END_PX = 64
77
77
 
78
78
  type Shown = 'all' | 'high' | 'none'
@@ -87,8 +87,10 @@ const widthOf = (columns: ListTableColumn[], end: boolean) =>
87
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
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
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).
90
+ * and what it is about take the room on the left, the facts sit together on the right before the end, 24px apart
91
+ * (Katerina, 17 November: "everything is crammed together on the left … the names/desc at the left and the rest on the
92
+ * right was a more correct way"; from 16 November the name was capped at 384px with the facts beside it). The list
93
+ * takes the whole width it is given, as every page's body does (16 November).
92
94
  *
93
95
  * Peek's Explore topics, Ship's Topics and Leaf's Explore topics each drew this by hand, class for class, and their
94
96
  * columns hid only at the phone's width: in a narrow window the names were cut to two letters (Katerina, 16 November).
@@ -117,9 +119,9 @@ export function ListTable({ 'aria-label': label, nameLabel = 'Name', columns, en
117
119
  {/* 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
120
  {columns.length > 0 && (
119
121
  // 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')}>
122
+ <div role="row" className={cn('flex items-center gap-6 px-3 text-caption text-text-muted', !headings && 'sr-only')}>
121
123
  {/* 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">
124
+ <span role="columnheader" className="min-w-0 flex-1 pl-7">
123
125
  {nameLabel}
124
126
  </span>
125
127
  {columns.map((column) =>
@@ -147,9 +149,10 @@ export function ListTableRow({ href, label, description, icon, cells, end, onCli
147
149
  if (!table) throw new Error('ListTableRow is a row of a ListTable: put it inside one.')
148
150
  return (
149
151
  // 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">
152
+ // 24px between the name and each fact, and before the end (Katerina, 17 November): they touched at 12.
153
+ <div role="row" className="relative flex min-w-0 items-center gap-6 rounded-lg px-3 py-2 hover:bg-bg-hover" {...rest}>
154
+ {/* The name takes the room left, so the facts sit together on the right (Katerina, 17 November). */}
155
+ <span role="cell" className="flex min-w-0 flex-1 items-center gap-3">
153
156
  {icon != null && <span className="flex shrink-0 items-center text-text-secondary">{icon}</span>}
154
157
  {/* 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
158
  <Link href={href} variant="plain" cover className="flex min-w-0 flex-1 flex-col gap-0.5" {...(onClick ? { onClick } : {})}>
@@ -35,6 +35,12 @@ const [open, setOpen] = useState(false)
35
35
  - `count` is the number beside the faces when it is not `members.length` —
36
36
  pass three faces and the real total.
37
37
  - No `onClick` disables it; no members draws nothing.
38
+ - `readOnly` says who is in it and is nothing to press: the same pixels, not
39
+ greyed as a disabled pill — in a list's row, which opens its thing; the row
40
+ is what is pressed (Katerina, 17 November: "clicking on the pill should not
41
+ show the members list").
42
+
43
+ <Canvas of={MembersPillStories.ReadOnly} />
38
44
 
39
45
  ## What it owns
40
46
 
@@ -32,6 +32,11 @@ export const Disabled: Story = {
32
32
  args: { onClick: undefined },
33
33
  }
34
34
 
35
+ /** `readOnly`: who is in it and nothing to press — the pill's own look, not greyed — in a list's row, which opens its thing (Katerina, 17 November). */
36
+ export const ReadOnly: Story = {
37
+ args: { onClick: undefined, readOnly: true },
38
+ }
39
+
35
40
  /** No members draws nothing at all. */
36
41
  export const Empty: Story = {
37
42
  args: { members: [] },
@@ -0,0 +1,38 @@
1
+ // @vitest-environment jsdom
2
+ /**
3
+ * The pill: up to three faces and the number; it opens the list, is disabled with nothing to open, and read-only it is
4
+ * nothing to press at all, in its own look (Katerina, 17 November).
5
+ */
6
+ import { afterEach, describe, expect, it, vi } from 'vitest'
7
+ import { cleanup, render, screen } from '@testing-library/react'
8
+ import userEvent from '@testing-library/user-event'
9
+ import { MembersPill } from './MembersPill'
10
+
11
+ afterEach(cleanup)
12
+
13
+ const people = [{ name: 'Ana Duarte' }, { name: 'Ben Okafor' }, { name: 'Chloé Martin' }]
14
+
15
+ describe('MembersPill', () => {
16
+ it('opens the list when pressed', async () => {
17
+ const onClick = vi.fn()
18
+ render(<MembersPill members={people} count={9} onClick={onClick} />)
19
+ await userEvent.click(screen.getByRole('button', { name: '9 members' }))
20
+ expect(onClick).toHaveBeenCalled()
21
+ })
22
+
23
+ // "Clicking on the pill should not show the members list. And we need to use the estiva ui component" (Katerina, 17 November).
24
+ it('read-only, it says who is in it and is nothing to press, in the pill’s own look, not greyed', () => {
25
+ render(<MembersPill members={people} count={9} readOnly />)
26
+ expect(screen.queryByRole('button')).toBeNull()
27
+ const pill = screen.getByRole('img', { name: '9 members' })
28
+ expect(pill.textContent).toContain('9')
29
+ const classes = pill.className.split(' ')
30
+ expect(classes).toEqual(expect.arrayContaining(['h-8', 'border', 'border-border-default', 'text-text-primary']))
31
+ expect(classes).not.toContain('bg-bg-disabled')
32
+ })
33
+
34
+ it('read-only with nobody in it draws nothing', () => {
35
+ const { container } = render(<MembersPill members={[]} readOnly />)
36
+ expect(container.firstChild).toBeNull()
37
+ })
38
+ })
@@ -10,6 +10,12 @@ export interface MembersPillProps {
10
10
  count?: number
11
11
  /** Opens the list — usually a `MembersDialog`. Without it the pill is disabled. */
12
12
  onClick?: () => void
13
+ /**
14
+ * Says who is in it and is nothing to press: the pill's own look, not greyed as a disabled one — in a list's row,
15
+ * which opens its thing (Katerina, 17 November: "clicking on the pill should not show the members list. And we need to
16
+ * use the estiva ui component"). `onClick` is not taken with it.
17
+ */
18
+ readOnly?: boolean
13
19
  /** The button's accessible name, when the list it opens is not "members" — "Who follows <name>: 4". Defaults to "4 members". */
14
20
  label?: string
15
21
  className?: string
@@ -25,11 +31,21 @@ export interface MembersPillProps {
25
31
  * pick of 15 September). `disabled` rather than another element when there is
26
32
  * nothing to press, so one element keeps one set of pixels.
27
33
  */
28
- export function MembersPill({ members, count, onClick, label, className }: MembersPillProps) {
34
+ export function MembersPill({ members, count, onClick, readOnly = false, label, className }: MembersPillProps) {
29
35
  const total = count ?? members.length
30
36
  if (total === 0) return null
37
+ const name = label ?? `${total} ${total === 1 ? 'member' : 'members'}`
38
+ if (readOnly)
39
+ return (
40
+ // The outlined Button's own pixels — its height, corners, line and words — with nothing to press: one picture, read as one.
41
+ // @estiva-escape(no-copied-look): the read-only pill IS the outlined Button's look, drawn without a button
42
+ <span role="img" aria-label={name} className={cn('inline-flex h-8 min-h-8 shrink-0 items-center gap-2 rounded-md border border-border-default pl-[3px] pr-2 font-sans font-medium text-btn-default text-text-primary', className)}>
43
+ <AvatarGroup members={members} />
44
+ <span className={cn(MONO_CAPTION_CLASSES, 'signal:tabular-nums')}>{total}</span>
45
+ </span>
46
+ )
31
47
  return (
32
- <Button variant="outlined" aria-label={label ?? `${total} ${total === 1 ? 'member' : 'members'}`} disabled={!onClick} onClick={onClick} className={cn('gap-2 pl-[3px] pr-2', className)}>
48
+ <Button variant="outlined" aria-label={name} disabled={!onClick} onClick={onClick} className={cn('gap-2 pl-[3px] pr-2', className)}>
33
49
  <AvatarGroup members={members} />
34
50
  <span className={cn(MONO_CAPTION_CLASSES, 'signal:tabular-nums')}>{total}</span>
35
51
  </Button>