@estiva-app/ui 0.88.1 → 0.90.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/dist/AppShell.d.ts +9 -1
- package/dist/AppShell.d.ts.map +1 -1
- package/dist/archivedLine.d.ts +11 -8
- package/dist/archivedLine.d.ts.map +1 -1
- package/dist/index.js +237 -213
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
- package/registry.json +13 -1
- package/src/AppShell.mdx +6 -0
- package/src/AppShell.stories.tsx +14 -0
- package/src/AppShell.test.tsx +47 -0
- package/src/AppShell.tsx +31 -3
- package/src/archivedLine.ts +14 -11
- package/src/archivedLine.test.ts +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.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",
|
|
@@ -133,8 +133,8 @@
|
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"@eslint/js": "^10.0.1",
|
|
136
|
-
"@estiva-app/conversation": "^0.
|
|
137
|
-
"@estiva-app/protocol": "^0.
|
|
136
|
+
"@estiva-app/conversation": "^0.22.0",
|
|
137
|
+
"@estiva-app/protocol": "^0.45.0",
|
|
138
138
|
"@storybook/addon-a11y": "^10.6.0",
|
|
139
139
|
"@storybook/addon-docs": "^10.5.10",
|
|
140
140
|
"@storybook/addon-vitest": "^10.6.0",
|
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.90.0",
|
|
8
8
|
"exports": 210,
|
|
9
9
|
"typeExports": 211,
|
|
10
10
|
"files": null
|
|
@@ -251,6 +251,18 @@
|
|
|
251
251
|
"required": true,
|
|
252
252
|
"note": "The navigation: a `Sidebar` in the solid manner, a `Rail` in the floating one."
|
|
253
253
|
},
|
|
254
|
+
{
|
|
255
|
+
"name": "navOpen",
|
|
256
|
+
"takes": "true/false",
|
|
257
|
+
"required": false,
|
|
258
|
+
"note": "Whether the navigation is shown, in the solid and inset manners."
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "onNavOpenChange",
|
|
262
|
+
"takes": "a handler",
|
|
263
|
+
"required": false,
|
|
264
|
+
"note": null
|
|
265
|
+
},
|
|
254
266
|
{
|
|
255
267
|
"name": "children",
|
|
256
268
|
"takes": "anything",
|
package/src/AppShell.mdx
CHANGED
|
@@ -85,6 +85,12 @@ import { AppShell, Banner, IdentityMenu, Rail, RailItem } from '@estiva-app/ui'
|
|
|
85
85
|
Ctrl+K.
|
|
86
86
|
- In the floating manner the card owns `overflow-hidden` — your content
|
|
87
87
|
manages its own scrolling inside it.
|
|
88
|
+
- **Folding the navigation**, in the solid and inset manners: pass `navOpen`
|
|
89
|
+
and `onNavOpenChange`, and the frame draws the fold as the top bar's menu
|
|
90
|
+
button ("Hide the sidebar" / "Show the sidebar") and, folded, keeps only
|
|
91
|
+
the content's own margin. Where the state is kept (remembered, started
|
|
92
|
+
folded in a narrow window) is yours. A `menu` you pass replaces the fold
|
|
93
|
+
button.
|
|
88
94
|
- Desktop only for now — no narrow-screen behaviour is provided.
|
|
89
95
|
- In the Signal theme the floating frame draws the control-room dot grid on
|
|
90
96
|
its ground, behind the card. Nothing to add: the preset makes it.
|
package/src/AppShell.stories.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { useState } from 'react'
|
|
2
3
|
import { IconMenu2, IconSquareRounded } from '@tabler/icons-react'
|
|
3
4
|
import { AppShell } from './AppShell'
|
|
4
5
|
import { Banner } from './Banner'
|
|
@@ -105,6 +106,19 @@ export const Inset: Story = {
|
|
|
105
106
|
),
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
/** The navigation folds away from the top bar's menu button, and comes back from the same place. */
|
|
110
|
+
export const InsetFolds: Story = {
|
|
111
|
+
args: { variant: 'inset' },
|
|
112
|
+
render: function Render(args) {
|
|
113
|
+
const [open, setOpen] = useState(true)
|
|
114
|
+
return (
|
|
115
|
+
<AppShell {...args} logo="Estiva" identity={identity} nav={sidebar} navOpen={open} onNavOpenChange={setOpen}>
|
|
116
|
+
<EmptyState message="Nothing here yet." />
|
|
117
|
+
</AppShell>
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
|
|
108
122
|
export const InsetWithBanner: Story = {
|
|
109
123
|
args: { variant: 'inset' },
|
|
110
124
|
render: (args) => (
|
package/src/AppShell.test.tsx
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* Chrome on Ship's four pages.
|
|
8
8
|
*/
|
|
9
9
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
10
|
+
import { useState } from 'react'
|
|
10
11
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
12
|
+
import userEvent from '@testing-library/user-event'
|
|
11
13
|
import { AppShell } from './AppShell'
|
|
12
14
|
import { Sidebar } from './Sidebar'
|
|
13
15
|
|
|
@@ -46,6 +48,51 @@ describe('AppShell', () => {
|
|
|
46
48
|
expect(panel?.className).toContain('mr-4')
|
|
47
49
|
})
|
|
48
50
|
|
|
51
|
+
it('folds the navigation from the top bar’s menu button and brings it back', async () => {
|
|
52
|
+
function Folding() {
|
|
53
|
+
const [open, setOpen] = useState(true)
|
|
54
|
+
return (
|
|
55
|
+
<AppShell variant="inset" nav={<Sidebar>Rows</Sidebar>} navOpen={open} onNavOpenChange={setOpen}>
|
|
56
|
+
<p>Page</p>
|
|
57
|
+
</AppShell>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
const user = userEvent.setup()
|
|
61
|
+
render(<Folding />)
|
|
62
|
+
await user.click(screen.getByRole('button', { name: 'Hide the sidebar' }))
|
|
63
|
+
expect(screen.queryByRole('navigation')).toBeNull()
|
|
64
|
+
expect(screen.getByText('Page')).toBeTruthy()
|
|
65
|
+
await user.click(screen.getByRole('button', { name: 'Show the sidebar' }))
|
|
66
|
+
expect(screen.getByRole('navigation').textContent).toBe('Rows')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('keeps a menu the caller passes in place of the fold, and draws no fold on the floating rail', () => {
|
|
70
|
+
const { unmount } = render(
|
|
71
|
+
<AppShell variant="inset" menu={<button>Own menu</button>} nav={<Sidebar>Rows</Sidebar>} navOpen onNavOpenChange={() => {}}>
|
|
72
|
+
<p>Page</p>
|
|
73
|
+
</AppShell>,
|
|
74
|
+
)
|
|
75
|
+
expect(screen.getByRole('button', { name: 'Own menu' })).toBeTruthy()
|
|
76
|
+
expect(screen.queryByRole('button', { name: /sidebar/ })).toBeNull()
|
|
77
|
+
unmount()
|
|
78
|
+
render(
|
|
79
|
+
<AppShell variant="floating" nav={<nav>Rail</nav>} navOpen onNavOpenChange={() => {}}>
|
|
80
|
+
<p>Page</p>
|
|
81
|
+
</AppShell>,
|
|
82
|
+
)
|
|
83
|
+
expect(screen.queryByRole('button', { name: /sidebar/ })).toBeNull()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('draws no fold when the caller does not keep one', () => {
|
|
87
|
+
render(
|
|
88
|
+
<AppShell variant="inset" nav={<Sidebar>Rows</Sidebar>}>
|
|
89
|
+
<p>Page</p>
|
|
90
|
+
</AppShell>,
|
|
91
|
+
)
|
|
92
|
+
expect(screen.queryByRole('button', { name: /sidebar/ })).toBeNull()
|
|
93
|
+
expect(screen.getByRole('navigation')).toBeTruthy()
|
|
94
|
+
})
|
|
95
|
+
|
|
49
96
|
it('leaves the floating manner’s card as it was', () => {
|
|
50
97
|
render(
|
|
51
98
|
<AppShell variant="floating" nav={<nav>Nav</nav>}>
|
package/src/AppShell.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
+
import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand } from '@tabler/icons-react'
|
|
2
3
|
import { cn } from './cn'
|
|
3
4
|
import { Card } from './Card'
|
|
5
|
+
import { IconButton } from './IconButton'
|
|
4
6
|
import { ScrollArea } from './ScrollArea'
|
|
5
7
|
import { SidebarOnGround } from './Sidebar'
|
|
6
8
|
import { TopBar } from './TopBar'
|
|
@@ -46,11 +48,31 @@ export interface AppShellProps {
|
|
|
46
48
|
banner?: ReactNode
|
|
47
49
|
/** The navigation: a `Sidebar` in the solid manner, a `Rail` in the floating one. */
|
|
48
50
|
nav: ReactNode
|
|
51
|
+
/**
|
|
52
|
+
* Whether the navigation is shown, in the solid and inset manners. With `onNavOpenChange`, the frame draws the
|
|
53
|
+
* fold as the top bar's menu button (unless `menu` is given) and, folded, leaves only the content's own margin
|
|
54
|
+
* (LED-3, Katerina, 28 October: the sidebar fold top left, on the top bar's menu button). Where it is kept is
|
|
55
|
+
* the caller's.
|
|
56
|
+
*/
|
|
57
|
+
navOpen?: boolean
|
|
58
|
+
onNavOpenChange?: (open: boolean) => void
|
|
49
59
|
children: ReactNode
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
export function AppShell({ variant = 'solid', menu, logo, search, onSearch, searchPlaceholder, identity, banner, nav, children }: AppShellProps) {
|
|
53
|
-
|
|
62
|
+
export function AppShell({ variant = 'solid', menu, logo, search, onSearch, searchPlaceholder, identity, banner, nav, navOpen = true, onNavOpenChange, children }: AppShellProps) {
|
|
63
|
+
// The floating manner's rail does not fold here: its collapse stays the app's.
|
|
64
|
+
const fold = onNavOpenChange && variant !== 'floating' && (
|
|
65
|
+
<IconButton
|
|
66
|
+
tooltip={navOpen ? 'Hide the sidebar' : 'Show the sidebar'}
|
|
67
|
+
tooltipPlacement="bottom"
|
|
68
|
+
aria-label={navOpen ? 'Hide the sidebar' : 'Show the sidebar'}
|
|
69
|
+
aria-expanded={navOpen}
|
|
70
|
+
onClick={() => onNavOpenChange(!navOpen)}
|
|
71
|
+
>
|
|
72
|
+
{navOpen ? <IconLayoutSidebarLeftCollapse size={16} stroke={1.5} /> : <IconLayoutSidebarLeftExpand size={16} stroke={1.5} />}
|
|
73
|
+
</IconButton>
|
|
74
|
+
)
|
|
75
|
+
const bar = <TopBar variant={variant} menu={menu ?? fold} logo={logo} search={search} onSearch={onSearch} searchPlaceholder={searchPlaceholder} right={identity} />
|
|
54
76
|
const inset = variant === 'inset'
|
|
55
77
|
|
|
56
78
|
if (variant === 'floating') {
|
|
@@ -113,7 +135,13 @@ export function AppShell({ variant = 'solid', menu, logo, search, onSearch, sear
|
|
|
113
135
|
<div className="relative flex h-full min-h-0 flex-col overflow-hidden bg-bg-base text-text-primary">
|
|
114
136
|
{bar}
|
|
115
137
|
<div className="flex min-h-0 flex-1">
|
|
116
|
-
|
|
138
|
+
{/* Folded, the navigation stays mounted and hidden, so it comes back as it was left (its scroll, its open
|
|
139
|
+
rows); open, `contents` keeps it a direct flex child of the row. */}
|
|
140
|
+
<div className="contents" hidden={!navOpen}>
|
|
141
|
+
<SidebarOnGround.Provider value={inset}>{nav}</SidebarOnGround.Provider>
|
|
142
|
+
</div>
|
|
143
|
+
{/* Folded: the inset card keeps a left margin as wide as its right one. */}
|
|
144
|
+
{!navOpen && inset && <div className="w-4 flex-none" />}
|
|
117
145
|
{/* `inset`: the content is a card on the ground, the Card's own surface look,
|
|
118
146
|
16px from the right and bottom as the floating card is, 8px corners (Katerina,
|
|
119
147
|
28 September). */}
|
package/src/archivedLine.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* archivedLine, the one sentence every app shows on an archived file (PEEKM-2).
|
|
3
|
+
* It lives in @estiva-app/conversation since PEEKM-8, so the agent prints the
|
|
4
|
+
* same words; this package hands it on unchanged.
|
|
3
5
|
*/
|
|
6
|
+
import { archivedLine as sentence } from '@estiva-app/conversation'
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* The line in the comment box's place on an archived file (CommentBox's
|
|
@@ -8,17 +11,17 @@
|
|
|
8
11
|
*
|
|
9
12
|
* A file archived itself says so; one archived with a file above it names the
|
|
10
13
|
* closest archived one by its kind — "Unarchive the page to comment." — so a
|
|
11
|
-
* person unarchives the right thing
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* person unarchives the right thing. `options.in` names where to unarchive, for
|
|
15
|
+
* an app with no Unarchive of its own; `options.to` is what waits, "comment"
|
|
16
|
+
* unless said.
|
|
17
|
+
*
|
|
18
|
+
* Typed here rather than inferred, so this package's types never point at
|
|
19
|
+
* @estiva-app/conversation (bundled, not a dependency of an app's).
|
|
14
20
|
*
|
|
15
21
|
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-file-is-archived-with-the-closest-archived-file-above-it.md
|
|
16
22
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const word = noun?.trim()
|
|
23
|
-
return `Unarchive the ${word === 'folder' ? 'Folder' : word || 'parent'} to comment.`
|
|
24
|
-
}
|
|
23
|
+
export const archivedLine: (
|
|
24
|
+
archive: { with?: string } | undefined,
|
|
25
|
+
noun?: string,
|
|
26
|
+
options?: { in?: string; to?: string },
|
|
27
|
+
) => string | undefined = sentence
|
package/src/archivedLine.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The line in the comment box's place on an archived file names what to
|
|
3
|
-
* unarchive: the file itself, or the closest archived one above it by its kind
|
|
4
|
-
* (PEEKM-2, record a-file-is-archived-with-the-closest-archived-file-above-it).
|
|
5
|
-
*/
|
|
6
|
-
import { describe, expect, it } from 'vitest'
|
|
7
|
-
import { archivedLine } from './archivedLine'
|
|
8
|
-
|
|
9
|
-
const ABOVE = '30023:aaaa:plan'
|
|
10
|
-
|
|
11
|
-
describe('archivedLine', () => {
|
|
12
|
-
it('says nothing for a file that is not archived', () => {
|
|
13
|
-
expect(archivedLine(undefined, 'page')).toBeUndefined()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('tells a person to unarchive the file itself when it is archived itself', () => {
|
|
17
|
-
expect(archivedLine({}, 'page')).toBe('Archived. Unarchive it to comment.')
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('names the closest archived file above by its kind', () => {
|
|
21
|
-
expect(archivedLine({ with: ABOVE }, 'page')).toBe('Unarchive the page to comment.')
|
|
22
|
-
expect(archivedLine({ with: ABOVE }, 'project')).toBe('Unarchive the project to comment.')
|
|
23
|
-
expect(archivedLine({ with: ABOVE }, 'PDF')).toBe('Unarchive the PDF to comment.')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('writes Folder as a proper noun', () => {
|
|
27
|
-
expect(archivedLine({ with: ABOVE }, 'folder')).toBe('Unarchive the Folder to comment.')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('still says what to do when the app has no noun for what is above', () => {
|
|
31
|
-
expect(archivedLine({ with: ABOVE })).toBe('Unarchive the parent to comment.')
|
|
32
|
-
expect(archivedLine({ with: ABOVE }, ' ')).toBe('Unarchive the parent to comment.')
|
|
33
|
-
})
|
|
34
|
-
})
|