@estiva-app/ui 0.114.0 → 0.115.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.114.0",
3
+ "version": "0.115.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.114.0",
7
+ "packageVersion": "0.115.0",
8
8
  "exports": 253,
9
9
  "typeExports": 263,
10
10
  "files": null
@@ -4685,10 +4685,10 @@
4685
4685
  "note": "People rather than circles, as `LevelIcon`'s `people`."
4686
4686
  },
4687
4687
  {
4688
- "name": "offDescription",
4689
- "takes": "text",
4688
+ "name": "files",
4689
+ "takes": "true/false",
4690
4690
  "required": false,
4691
- "note": "The line under Not following."
4691
+ "note": "Whether the place lists files (a topic, a space): each level then says what of them it shows."
4692
4692
  },
4693
4693
  {
4694
4694
  "name": "backTo",
@@ -47,6 +47,11 @@ const level: 'all' | 'important' | undefined = 'important'
47
47
  - `backTo` is the name of the group whose default the viewer chose against.
48
48
  Leave it out when no default reaches them or they did not choose against it.
49
49
  - `people` draws people instead of circles, for a place that is a group's own.
50
+ - `files` says whether the place lists files (a topic, a space; the default).
51
+ Each level's line then says what of them the place shows and what lights:
52
+ "Shows its own conversation. Lights for new conversations, replies in yours,
53
+ and what names you on its files." Pass `false` for a place with none (a
54
+ team's chat): the lines say only what lights, "Lights for every message".
50
55
  - `label` is the place's name. The button's accessible name says the level and
51
56
  what pressing it does: "You follow it at Important: change how you follow
52
57
  Item one".
@@ -23,8 +23,8 @@ export const NotFollowing: Story = { args: { level: undefined } }
23
23
  /** Chose against a group's default: "Back to Group one’s default" is offered under the levels. */
24
24
  export const AgainstADefault: Story = { args: { level: 'all', backTo: 'Group one' } }
25
25
 
26
- /** A group's own place: people rather than circles. */
27
- export const People: Story = { args: { level: 'important', people: true } }
26
+ /** A group's own place: people rather than circles. With no files to list, each level says only what lights. */
27
+ export const People: Story = { args: { level: 'important', people: true, files: false } }
28
28
 
29
29
  /** No `onChoose`: it shows the level and cannot be changed. */
30
30
  export const ReadOnly: Story = { args: { level: undefined, onChoose: undefined } }
@@ -48,6 +48,26 @@ describe('FollowSwitch', () => {
48
48
  expect(onChoose).toHaveBeenCalledWith('default')
49
49
  })
50
50
 
51
+ it('says what the place shows and what lights at each level, by whether it lists files', async () => {
52
+ const user = userEvent.setup()
53
+ const { rerender } = render(<FollowSwitch level="important" label="Item one" onChoose={() => {}} />)
54
+ await user.click(screen.getByRole('button', { name: /change how you follow/ }))
55
+ // A topic or a space (the default): what of its files it shows, then what lights (ACT-5).
56
+ expect((await screen.findByRole('menuitem', { name: /^Not following/ })).textContent).toContain('Shows its own conversation. Nothing lights.')
57
+ expect(screen.getByRole('menuitem', { name: /^Important/ }).textContent).toContain(
58
+ 'Shows its own conversation. Lights for new conversations, replies in yours, and what names you on its files.',
59
+ )
60
+ expect(screen.getByRole('menuitem', { name: /^All/ }).textContent).toContain('Shows its files’ threads too. Lights for all of it.')
61
+ await user.keyboard('{Escape}')
62
+ // A place with no files (a team's chat): only what lights.
63
+ rerender(<FollowSwitch level="important" label="Item one" onChoose={() => {}} files={false} people />)
64
+ await user.click(screen.getByRole('button', { name: /change how you follow/ }))
65
+ expect((await screen.findByRole('menuitem', { name: /^Not following/ })).textContent).toContain('Nothing lights.')
66
+ expect(screen.getByRole('menuitem', { name: /^Not following/ }).textContent).not.toContain('Shows')
67
+ expect(screen.getByRole('menuitem', { name: /^Important/ }).textContent).toContain('Lights for new conversations and replies in yours.')
68
+ expect(screen.getByRole('menuitem', { name: /^All/ }).textContent).toContain('Lights for every message.')
69
+ })
70
+
51
71
  it('cannot be changed without onChoose', () => {
52
72
  render(<FollowSwitch level={undefined} label="Item one" />)
53
73
  expect(screen.getByRole('button', { name: /Not following/ }).hasAttribute('disabled')).toBe(true)
@@ -46,9 +46,28 @@ export function LevelIcon({ level, people = false }: LevelIconProps) {
46
46
  return <IconCircleDashedPlus {...ICON} aria-hidden className="text-text-muted" />
47
47
  }
48
48
 
49
- const WORDS: Record<FollowLevel, { label: string; description: string }> = {
50
- important: { label: 'Important', description: 'New conversations, and replies in the ones you are in' },
51
- all: { label: 'All', description: 'Every new conversation and every reply' },
49
+ const LABEL: Record<FollowLevel, string> = { important: 'Important', all: 'All' }
50
+
51
+ /**
52
+ * The line under each level: what the place shows at it, and what lights its
53
+ * dot (ACT-5; the activity indicator prototype Miky approved on 10 November).
54
+ * A place that lists files (a topic, a space) says what of them it shows; a
55
+ * place with none (a team's chat) says only what lights. Important's third
56
+ * part restates the record on what names you on a listed file.
57
+ *
58
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/at-important-what-names-you-on-a-listed-file-lights-the-topic.md
59
+ */
60
+ const WORDS: Record<'files' | 'noFiles', Record<'off' | FollowLevel, string>> = {
61
+ files: {
62
+ off: 'Shows its own conversation. Nothing lights.',
63
+ important: 'Shows its own conversation. Lights for new conversations, replies in yours, and what names you on its files.',
64
+ all: 'Shows its files’ threads too. Lights for all of it.',
65
+ },
66
+ noFiles: {
67
+ off: 'Nothing lights.',
68
+ important: 'Lights for new conversations and replies in yours.',
69
+ all: 'Lights for every message.',
70
+ },
52
71
  }
53
72
 
54
73
  export interface FollowSwitchProps {
@@ -62,8 +81,12 @@ export interface FollowSwitchProps {
62
81
  readOnlyReason?: string
63
82
  /** People rather than circles, as `LevelIcon`'s `people`. */
64
83
  people?: boolean
65
- /** The line under Not following. */
66
- offDescription?: string
84
+ /**
85
+ * Whether the place lists files (a topic, a space): each level then says what of
86
+ * them it shows. `false` for a place with none (a team's chat): the levels say only
87
+ * what lights.
88
+ */
89
+ files?: boolean
67
90
  /**
68
91
  * The name of the group whose default reaches the viewer, when they chose
69
92
  * against it: offers "Back to <name>’s default". Leave it out otherwise.
@@ -73,12 +96,14 @@ export interface FollowSwitchProps {
73
96
 
74
97
  /**
75
98
  * The one switch on a place: Not following, Important or All, each with what
76
- * it lights, and "Back to <name>’s default" when the viewer chose against a
77
- * group's default. It sits before the place's title, drawn as `LevelIcon`.
99
+ * the place shows at it and what lights, and "Back to <name>’s default" when
100
+ * the viewer chose against a group's default. It sits before the place's
101
+ * title, drawn as `LevelIcon`.
78
102
  */
79
- export function FollowSwitch({ level, label, onChoose, readOnlyReason, people = false, offDescription = 'Nothing here lights for you', backTo }: FollowSwitchProps) {
103
+ export function FollowSwitch({ level, label, onChoose, readOnlyReason, people = false, files = true, backTo }: FollowSwitchProps) {
80
104
  const [busy, setBusy] = useState(false)
81
- const now = level ? `You follow it at ${WORDS[level].label}` : 'Not following'
105
+ const words = WORDS[files ? 'files' : 'noFiles']
106
+ const now = level ? `You follow it at ${LABEL[level]}` : 'Not following'
82
107
  const button = (
83
108
  <IconButton aria-label={`${now}: change how you follow ${label}`} tooltip={now} disabled={!onChoose || busy} disabledReason={onChoose ? undefined : readOnlyReason}>
84
109
  <LevelIcon level={level} people={people} />
@@ -113,9 +138,9 @@ export function FollowSwitch({ level, label, onChoose, readOnlyReason, people =
113
138
  return (
114
139
  <Menu trigger={button}>
115
140
  <MenuSection label="How you follow it">
116
- {item('off', 'Not following', offDescription, undefined)}
117
- {item('important', WORDS.important.label, WORDS.important.description, 'important')}
118
- {item('all', WORDS.all.label, WORDS.all.description, 'all')}
141
+ {item('off', 'Not following', words.off, undefined)}
142
+ {item('important', LABEL.important, words.important, 'important')}
143
+ {item('all', LABEL.all, words.all, 'all')}
119
144
  </MenuSection>
120
145
  {backTo && (
121
146
  <MenuSection label={`${backTo} gives you Important`}>