@estiva-app/ui 0.114.0 → 0.115.1
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/dist/FollowSwitch.d.ts +10 -5
- package/dist/FollowSwitch.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/registry.json +4 -4
- package/src/FollowSwitch.mdx +5 -0
- package/src/FollowSwitch.stories.tsx +2 -2
- package/src/FollowSwitch.test.tsx +20 -0
- package/src/FollowSwitch.tsx +39 -12
package/package.json
CHANGED
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.
|
|
7
|
+
"packageVersion": "0.115.1",
|
|
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": "
|
|
4689
|
-
"takes": "
|
|
4688
|
+
"name": "files",
|
|
4689
|
+
"takes": "true/false",
|
|
4690
4690
|
"required": false,
|
|
4691
|
-
"note": "
|
|
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",
|
package/src/FollowSwitch.mdx
CHANGED
|
@@ -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. Lights only when someone names you.')
|
|
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('Lights only when someone names you.')
|
|
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)
|
package/src/FollowSwitch.tsx
CHANGED
|
@@ -46,9 +46,30 @@ export function LevelIcon({ level, people = false }: LevelIconProps) {
|
|
|
46
46
|
return <IconCircleDashedPlus {...ICON} aria-hidden className="text-text-muted" />
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
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. Not following
|
|
57
|
+
* says a mention still lights: a message that names you lights a place at every
|
|
58
|
+
* level (`lightsOnPlace` in @estiva-app/conversation; Miky, 13 November).
|
|
59
|
+
*
|
|
60
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/at-important-what-names-you-on-a-listed-file-lights-the-topic.md
|
|
61
|
+
*/
|
|
62
|
+
const WORDS: Record<'files' | 'noFiles', Record<'off' | FollowLevel, string>> = {
|
|
63
|
+
files: {
|
|
64
|
+
off: 'Shows its own conversation. Lights only when someone names you.',
|
|
65
|
+
important: 'Shows its own conversation. Lights for new conversations, replies in yours, and what names you on its files.',
|
|
66
|
+
all: 'Shows its files’ threads too. Lights for all of it.',
|
|
67
|
+
},
|
|
68
|
+
noFiles: {
|
|
69
|
+
off: 'Lights only when someone names you.',
|
|
70
|
+
important: 'Lights for new conversations and replies in yours.',
|
|
71
|
+
all: 'Lights for every message.',
|
|
72
|
+
},
|
|
52
73
|
}
|
|
53
74
|
|
|
54
75
|
export interface FollowSwitchProps {
|
|
@@ -62,8 +83,12 @@ export interface FollowSwitchProps {
|
|
|
62
83
|
readOnlyReason?: string
|
|
63
84
|
/** People rather than circles, as `LevelIcon`'s `people`. */
|
|
64
85
|
people?: boolean
|
|
65
|
-
/**
|
|
66
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Whether the place lists files (a topic, a space): each level then says what of
|
|
88
|
+
* them it shows. `false` for a place with none (a team's chat): the levels say only
|
|
89
|
+
* what lights.
|
|
90
|
+
*/
|
|
91
|
+
files?: boolean
|
|
67
92
|
/**
|
|
68
93
|
* The name of the group whose default reaches the viewer, when they chose
|
|
69
94
|
* against it: offers "Back to <name>’s default". Leave it out otherwise.
|
|
@@ -73,12 +98,14 @@ export interface FollowSwitchProps {
|
|
|
73
98
|
|
|
74
99
|
/**
|
|
75
100
|
* The one switch on a place: Not following, Important or All, each with what
|
|
76
|
-
* it lights, and "Back to <name>’s default" when
|
|
77
|
-
* group's default. It sits before the place's
|
|
101
|
+
* the place shows at it and what lights, and "Back to <name>’s default" when
|
|
102
|
+
* the viewer chose against a group's default. It sits before the place's
|
|
103
|
+
* title, drawn as `LevelIcon`.
|
|
78
104
|
*/
|
|
79
|
-
export function FollowSwitch({ level, label, onChoose, readOnlyReason, people = false,
|
|
105
|
+
export function FollowSwitch({ level, label, onChoose, readOnlyReason, people = false, files = true, backTo }: FollowSwitchProps) {
|
|
80
106
|
const [busy, setBusy] = useState(false)
|
|
81
|
-
const
|
|
107
|
+
const words = WORDS[files ? 'files' : 'noFiles']
|
|
108
|
+
const now = level ? `You follow it at ${LABEL[level]}` : 'Not following'
|
|
82
109
|
const button = (
|
|
83
110
|
<IconButton aria-label={`${now}: change how you follow ${label}`} tooltip={now} disabled={!onChoose || busy} disabledReason={onChoose ? undefined : readOnlyReason}>
|
|
84
111
|
<LevelIcon level={level} people={people} />
|
|
@@ -113,9 +140,9 @@ export function FollowSwitch({ level, label, onChoose, readOnlyReason, people =
|
|
|
113
140
|
return (
|
|
114
141
|
<Menu trigger={button}>
|
|
115
142
|
<MenuSection label="How you follow it">
|
|
116
|
-
{item('off', 'Not following',
|
|
117
|
-
{item('important',
|
|
118
|
-
{item('all',
|
|
143
|
+
{item('off', 'Not following', words.off, undefined)}
|
|
144
|
+
{item('important', LABEL.important, words.important, 'important')}
|
|
145
|
+
{item('all', LABEL.all, words.all, 'all')}
|
|
119
146
|
</MenuSection>
|
|
120
147
|
{backTo && (
|
|
121
148
|
<MenuSection label={`${backTo} gives you Important`}>
|