@wallarm-org/design-system 4.7.0 → 4.8.0-rc-fix-claude-code.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/README.md +4 -2
- package/dist/components/BulkBar/index.d.ts +5 -0
- package/dist/components/Drawer/classes.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +65 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.d.ts +18 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.d.ts +5 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.js +42 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.d.ts +26 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.js +211 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.d.ts +9 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.js +148 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.d.ts +14 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.js +115 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.d.ts +10 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.js +77 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.d.ts +13 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.js +138 -0
- package/dist/components/NotificationCenter/index.d.ts +9 -0
- package/dist/components/NotificationCenter/index.js +9 -0
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +7 -5
- package/dist/components/SearchInput/SearchInput.js +119 -101
- package/dist/components/Select/SelectSearchInput.d.ts +1 -1
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Tabs/Tabs.js +30 -28
- package/dist/components/Tabs/TabsList/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/Tour/TourPositioner.d.ts +3 -0
- package/dist/components/Tour/TourPositioner.js +4 -4
- package/dist/guidelines/foundations/color.md +157 -0
- package/dist/guidelines/foundations/focus.md +122 -0
- package/dist/guidelines/foundations/layering.md +131 -0
- package/dist/guidelines/foundations/radius-elevation.md +111 -0
- package/dist/guidelines/foundations/spacing.md +117 -0
- package/dist/guidelines/foundations/typography.md +114 -0
- package/dist/guidelines/patterns/app-layout.md +1567 -0
- package/dist/guidelines/patterns/auth-page.md +668 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +605 -0
- package/dist/guidelines/patterns/create-edit-forms.md +768 -0
- package/dist/guidelines/patterns/detail-drawer.md +868 -0
- package/dist/guidelines/patterns/empty-states.md +461 -0
- package/dist/guidelines/patterns/entity-table.md +533 -0
- package/dist/guidelines/patterns/feedback-toasts.md +493 -0
- package/dist/guidelines/patterns/filtering.md +630 -0
- package/dist/guidelines/patterns/resource-list-page.md +558 -0
- package/dist/guidelines/patterns/settings-page.md +752 -0
- package/dist/guidelines/rules.md +25 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/metadata/components.json +12641 -9320
- package/dist/metadata/guidelines.json +1705 -0
- package/dist/theme/typography.css +5 -0
- package/dist/utils/formatDateTime.d.ts +6 -0
- package/dist/utils/formatDateTime.js +13 -1
- package/package.json +6 -1
|
@@ -0,0 +1,1567 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Application layout
|
|
3
|
+
description: Use when placing a screen in the console frame: the host AppShell, a product RemoteShell driven by a NavConfig, breadcrumbs and where Page goes.
|
|
4
|
+
components: [AppShell, AppShellHeader, AppShellRail, AppShellRemote, AppShellAside, TopHeader, TopHeaderLogo, TopHeaderActions, TopHeaderSeparator, NotificationCenter, NotificationCenterTrigger, ChatTrigger, DropdownMenu, NavRail, NavRailBody, NavRailItem, NavRailSeparator, NavRailFooter, NavRailSkeleton, RemoteShell, RemoteShellPanel, RemoteShellBreadcrumb, RemoteShellContent, Page, PageHeader, PageTitle, PageContent, Breadcrumbs, UtilityPage, SplashScreen, Skeleton]
|
|
5
|
+
keywords: [app shell, layout, application layout, frame, chrome, top bar, top header, header, sidebar, side nav, navigation, navigation rail, rail, 1st rail, 2nd rail, product menu, nav panel, nav config, left menu, collapsed sidebar, expanded sidebar, micro-frontend, MFE, host, remote, product group, breadcrumbs, drill down, scope switcher, content area, scroll, splash, loading screen, 404, error page, settings section, settings, notifications, notification center, bell, inbox, unread count, user menu, account menu, avatar, profile, sign out, theme, header actions]
|
|
6
|
+
order: 5
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Application layout
|
|
10
|
+
|
|
11
|
+
Two shells: `AppShell` (the host's chrome) and `RemoteShell` (a product's chrome, built from a `NavConfig`).
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
| Need | Use | Not |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| The console frame: top bar, product rail, content surface | `AppShell` › `AppShellHeader` + `AppShellRail` + `AppShellRemote`, rendered once by the host | An `AppShell` per page, or a hand-made grid |
|
|
18
|
+
| A product with its own menu | `RemoteShell config={navConfig}` › `RemoteShellPanel` + `RemoteShellBreadcrumb` + `RemoteShellContent` › `Page` | Hand-built panel markup, or `AppShell` in the product |
|
|
19
|
+
| A product inside a host group | Content only; the host wraps the group in one `RemoteShell` | A second `RemoteShell` in the product |
|
|
20
|
+
| A host-local section (Settings) | `RemoteShell` in the host route, with its own `NavConfig` | A remote for it |
|
|
21
|
+
| A product with one page | `RemoteShell` without `RemoteShellPanel`, or content only | An empty `NavConfig` |
|
|
22
|
+
| Home or a cross-product page | `Page` directly in `AppShellRemote` | `RemoteShell` with an empty config |
|
|
23
|
+
| The app cannot render (unknown URL, 500, offline, no tenant access) | `UtilityPage` instead of the shell | `UtilityPage` inside `AppShellRemote` |
|
|
24
|
+
| Cold start | `SplashScreen`, then `<AppShell reveal>` | A `Loader` on a blank page |
|
|
25
|
+
|
|
26
|
+
Pick the `NavConfig` node by what the entry does:
|
|
27
|
+
|
|
28
|
+
| Entry | Node | Not |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| A page | `type: 'link'` with `path` (a bare segment, no slash) | A `group` with one child |
|
|
31
|
+
| Nested pages with no page of their own | `type: 'group'`; `defaultExpanded` on the one holding the usual page | `drill` |
|
|
32
|
+
| Pick an entity, then its sub-pages | `type: 'drill'` with `param`, `entities` and `children` | A `Select` in the page header |
|
|
33
|
+
| A label over a run of entries | `type: 'section-header'` | A disabled link |
|
|
34
|
+
| A line between entries | `dividerAfter: true` on the entry above | An empty link |
|
|
35
|
+
|
|
36
|
+
## Rules
|
|
37
|
+
|
|
38
|
+
**Ownership**
|
|
39
|
+
|
|
40
|
+
- The host renders `AppShell` once at the root. It owns the product list in `NavRail` and knows nothing about a product's routes.
|
|
41
|
+
- The product owns its `NavConfig` (next to its routes) and renders its own `RemoteShell`. **Never** render `AppShell`, `TopHeader` or `NavRail` in a product.
|
|
42
|
+
- A product in a host group renders content only. The host draws the group `RemoteShell` for two or more children.
|
|
43
|
+
|
|
44
|
+
**Header and rail footer**
|
|
45
|
+
|
|
46
|
+
- Settings is a `NavRailItem` in `NavRailFooter`, never in the product panel or top header.
|
|
47
|
+
- The user menu is the last `NavRailFooter` item: an `avatar` `NavRailItem` in `DropdownMenuTrigger`.
|
|
48
|
+
- Notifications are a `NotificationCenter` in `TopHeaderActions`, never a hand-made bell and popover.
|
|
49
|
+
- `TopHeaderActions` order: search, `TopHeaderSeparator`, tenant switcher, `ChatTrigger`, `NotificationCenter`, help.
|
|
50
|
+
|
|
51
|
+
**URL is the only state**
|
|
52
|
+
|
|
53
|
+
- Pass the router's pathname to `pathname` and `onNavigate` to the router, always together.
|
|
54
|
+
- If the router has its own `basepath`, omit `basePath` on `RemoteShell`.
|
|
55
|
+
- The active item, drill level and trail come from `pathname`. **Never** keep them in state.
|
|
56
|
+
- Exactly one `NavRailItem` is `active`, from the first URL segment: Home on `/`, the product on `/edge/…`, Settings (in `NavRailFooter`) on `/settings/…`.
|
|
57
|
+
|
|
58
|
+
**Sizes (built in; do not override)**
|
|
59
|
+
|
|
60
|
+
- Top header 36px. Rail 48px collapsed, 184px expanded, 78px compact. Product panel 216px, 164–256px with `resizable`. Rail and panel items 32px.
|
|
61
|
+
- `AppShellRemote` owns the rounded surface and border. **Never** restyle it or add a `w-*` to the shell regions.
|
|
62
|
+
- Page gutters are 24px, owned by `Page` parts. **Never** pad `RemoteShellContent` or `AppShellRemote`.
|
|
63
|
+
|
|
64
|
+
**Scroll**
|
|
65
|
+
|
|
66
|
+
- The shell is `h-screen`. **Never** set `overflow` or `height` on `html` or `body`.
|
|
67
|
+
- The rail, the panel and `RemoteShellContent` scroll on their own. A table page uses `<Page fullSize fixedHeight>` so only `PageContent` scrolls.
|
|
68
|
+
|
|
69
|
+
**Breadcrumbs**
|
|
70
|
+
|
|
71
|
+
- In a product, the trail is `RemoteShellBreadcrumb`: product, groups as text, drills as a scope switcher, current page. **Never** also put `Breadcrumbs` in `PageHeader`.
|
|
72
|
+
- `RemoteShellBreadcrumb` ends at the last `NavConfig` entry. Past it (a record name), render your own `Breadcrumbs` from `useRemoteShellContext()`; a grouped product reports them through `@wallarm/sdk` `onBreadcrumbChange`.
|
|
73
|
+
- Trail-row controls are `RemoteShellBreadcrumb` children.
|
|
74
|
+
- Home and cross-product pages have no trail.
|
|
75
|
+
|
|
76
|
+
**Layering**
|
|
77
|
+
|
|
78
|
+
- In-shell sticky layers are `z-10`; overlays portal above the shell. **Never** add `z-*` to a shell region. See [Layering](../foundations/layering.md).
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
A standalone product: header actions, Settings and the user menu in the rail footer, a `NavConfig` panel, trail and page.
|
|
83
|
+
|
|
84
|
+
A standalone product at `/edge/api-sessions`. The host renders `AppShell` with the product
|
|
85
|
+
list in `NavRail`; the product renders `RemoteShell` with its own `NavConfig`, and its page
|
|
86
|
+
goes in `RemoteShellContent`. The panel, the active item and the trail all come from
|
|
87
|
+
`pathname`.
|
|
88
|
+
|
|
89
|
+
```tsx story=Default
|
|
90
|
+
import { type MouseEvent, useState } from 'react';
|
|
91
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
92
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
93
|
+
import { ChatTrigger } from '@wallarm-org/design-system/Chat';
|
|
94
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIcon, DropdownMenuItemText, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuTriggerItem } from '@wallarm-org/design-system/DropdownMenu';
|
|
95
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, LogOut, Paintbrush, PanelLeftDashed, Search, Settings, UserRound } from '@wallarm-org/design-system/icons';
|
|
96
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
97
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, type NavRailMode, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
98
|
+
import { NotificationCenter, NotificationCenterBody, NotificationCenterContent, NotificationCenterHeader, NotificationCenterHeaderAction, NotificationCenterHeaderActions, NotificationCenterItem, NotificationCenterItemDescription, NotificationCenterItemTime, NotificationCenterItemTitle, NotificationCenterList, NotificationCenterTabs, NotificationCenterTabsList, NotificationCenterTitle, NotificationCenterTrigger } from '@wallarm-org/design-system/NotificationCenter';
|
|
99
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
100
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
101
|
+
import { RemoteShell, RemoteShellBreadcrumb, RemoteShellContent, RemoteShellPanel } from '@wallarm-org/design-system/RemoteShell';
|
|
102
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
103
|
+
import { TabsContent, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
104
|
+
import { useTheme } from '@wallarm-org/design-system/ThemeProvider';
|
|
105
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo, TopHeaderSeparator } from '@wallarm-org/design-system/TopHeader';
|
|
106
|
+
|
|
107
|
+
export const Default = () => {
|
|
108
|
+
const [pathname, setPathname] = useState('/edge/api-sessions');
|
|
109
|
+
const [railMode, setRailMode] = useState<NavRailMode>('collapsed');
|
|
110
|
+
const { theme, setTheme } = useTheme();
|
|
111
|
+
const unread = NOTIFICATIONS.filter(item => item.unread);
|
|
112
|
+
const read = NOTIFICATIONS.filter(item => !item.unread);
|
|
113
|
+
|
|
114
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
117
|
+
};
|
|
118
|
+
const handleNavigate = (to: string) => {
|
|
119
|
+
onNavigate(to);
|
|
120
|
+
setPathname(to);
|
|
121
|
+
};
|
|
122
|
+
const handleRailModeChange = ({ value }: { value: string }) => {
|
|
123
|
+
const next = RAIL_MODES.find(mode => mode === value);
|
|
124
|
+
if (next) setRailMode(next);
|
|
125
|
+
};
|
|
126
|
+
const handleThemeChange = ({ value }: { value: string }) => {
|
|
127
|
+
const next = THEMES.find(option => option === value);
|
|
128
|
+
if (next) setTheme(next);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const columns: TableColumnDef<ApiSession>[] = [
|
|
132
|
+
{ accessorKey: 'id', header: 'Session', size: 160 },
|
|
133
|
+
{ accessorKey: 'application', header: 'Application', size: 240 },
|
|
134
|
+
{ accessorKey: 'requests', header: 'Requests', size: 120 },
|
|
135
|
+
{ accessorKey: 'started', header: 'Started', size: 200 },
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<AppShell data-testid='app-shell'>
|
|
140
|
+
<AppShellHeader>
|
|
141
|
+
<TopHeader data-testid='top-header'>
|
|
142
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
143
|
+
<Logo size='md' />
|
|
144
|
+
</TopHeaderLogo>
|
|
145
|
+
<TopHeaderActions>
|
|
146
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Search'>
|
|
147
|
+
<Search />
|
|
148
|
+
</Button>
|
|
149
|
+
<TopHeaderSeparator />
|
|
150
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
151
|
+
Acme Bank
|
|
152
|
+
<ChevronUpDown />
|
|
153
|
+
</Button>
|
|
154
|
+
<ChatTrigger onClick={onOpenAssistant} />
|
|
155
|
+
<NotificationCenter data-testid='notifications'>
|
|
156
|
+
<NotificationCenterTrigger count={unread.length} />
|
|
157
|
+
<NotificationCenterContent>
|
|
158
|
+
<NotificationCenterHeader>
|
|
159
|
+
<NotificationCenterTitle />
|
|
160
|
+
<NotificationCenterHeaderActions>
|
|
161
|
+
<NotificationCenterHeaderAction onClick={onMarkAllRead}>
|
|
162
|
+
Mark all as read
|
|
163
|
+
</NotificationCenterHeaderAction>
|
|
164
|
+
<NotificationCenterHeaderAction asChild aria-label='Notification settings'>
|
|
165
|
+
<a href='/settings/notifications' onClick={handleRailClick}>
|
|
166
|
+
<Settings />
|
|
167
|
+
</a>
|
|
168
|
+
</NotificationCenterHeaderAction>
|
|
169
|
+
</NotificationCenterHeaderActions>
|
|
170
|
+
</NotificationCenterHeader>
|
|
171
|
+
<NotificationCenterTabs defaultValue='new'>
|
|
172
|
+
<NotificationCenterTabsList>
|
|
173
|
+
<TabsTrigger value='new'>
|
|
174
|
+
New <NumericBadge size='small'>{unread.length}</NumericBadge>
|
|
175
|
+
</TabsTrigger>
|
|
176
|
+
<TabsTrigger value='read'>Read</TabsTrigger>
|
|
177
|
+
</NotificationCenterTabsList>
|
|
178
|
+
<TabsContent value='new'>
|
|
179
|
+
<NotificationCenterBody>
|
|
180
|
+
<NotificationCenterList>
|
|
181
|
+
{unread.map(item => (
|
|
182
|
+
<NotificationCenterItem key={item.id} unread>
|
|
183
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
184
|
+
{item.title}
|
|
185
|
+
</NotificationCenterItemTitle>
|
|
186
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
187
|
+
<NotificationCenterItemDescription>
|
|
188
|
+
{item.description}
|
|
189
|
+
</NotificationCenterItemDescription>
|
|
190
|
+
</NotificationCenterItem>
|
|
191
|
+
))}
|
|
192
|
+
</NotificationCenterList>
|
|
193
|
+
</NotificationCenterBody>
|
|
194
|
+
</TabsContent>
|
|
195
|
+
<TabsContent value='read'>
|
|
196
|
+
<NotificationCenterBody>
|
|
197
|
+
<NotificationCenterList>
|
|
198
|
+
{read.map(item => (
|
|
199
|
+
<NotificationCenterItem key={item.id}>
|
|
200
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
201
|
+
{item.title}
|
|
202
|
+
</NotificationCenterItemTitle>
|
|
203
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
204
|
+
<NotificationCenterItemDescription>
|
|
205
|
+
{item.description}
|
|
206
|
+
</NotificationCenterItemDescription>
|
|
207
|
+
</NotificationCenterItem>
|
|
208
|
+
))}
|
|
209
|
+
</NotificationCenterList>
|
|
210
|
+
</NotificationCenterBody>
|
|
211
|
+
</TabsContent>
|
|
212
|
+
</NotificationCenterTabs>
|
|
213
|
+
</NotificationCenterContent>
|
|
214
|
+
</NotificationCenter>
|
|
215
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
216
|
+
<CircleHelp />
|
|
217
|
+
</Button>
|
|
218
|
+
</TopHeaderActions>
|
|
219
|
+
</TopHeader>
|
|
220
|
+
</AppShellHeader>
|
|
221
|
+
|
|
222
|
+
<AppShellRail>
|
|
223
|
+
<NavRail mode={railMode} data-testid='nav-rail'>
|
|
224
|
+
<NavRailBody>
|
|
225
|
+
<NavRailItem
|
|
226
|
+
href='/'
|
|
227
|
+
icon={HomeIcon}
|
|
228
|
+
label='Home'
|
|
229
|
+
shortcut={['G', 'H']}
|
|
230
|
+
onClick={handleRailClick}
|
|
231
|
+
data-testid='nav-rail-home'
|
|
232
|
+
/>
|
|
233
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
234
|
+
<NavRailSeparator />
|
|
235
|
+
{PRODUCTS.map(product => (
|
|
236
|
+
<NavRailItem
|
|
237
|
+
key={product.id}
|
|
238
|
+
href={`/${product.id}`}
|
|
239
|
+
icon={product.icon}
|
|
240
|
+
label={product.label}
|
|
241
|
+
shortcut={product.shortcut}
|
|
242
|
+
active={product.id === 'edge'}
|
|
243
|
+
onClick={handleRailClick}
|
|
244
|
+
data-testid={`nav-rail-${product.id}`}
|
|
245
|
+
/>
|
|
246
|
+
))}
|
|
247
|
+
</NavRailBody>
|
|
248
|
+
<NavRailFooter>
|
|
249
|
+
<NavRailItem
|
|
250
|
+
href='/settings'
|
|
251
|
+
icon={Settings}
|
|
252
|
+
label='Settings'
|
|
253
|
+
shortcut={['G', 'S']}
|
|
254
|
+
onClick={handleRailClick}
|
|
255
|
+
data-testid='nav-rail-settings'
|
|
256
|
+
/>
|
|
257
|
+
<DropdownMenu
|
|
258
|
+
data-testid='account-menu'
|
|
259
|
+
positioning={{ placement: 'right-end', gutter: 6, offset: { crossAxis: 12 } }}
|
|
260
|
+
>
|
|
261
|
+
<DropdownMenuTrigger>
|
|
262
|
+
<NavRailItem
|
|
263
|
+
icon={UserRound}
|
|
264
|
+
label='Maria Lopez'
|
|
265
|
+
avatar
|
|
266
|
+
data-testid='nav-rail-account'
|
|
267
|
+
/>
|
|
268
|
+
</DropdownMenuTrigger>
|
|
269
|
+
<DropdownMenuContent className='w-200'>
|
|
270
|
+
<DropdownMenuItem onSelect={onOpenProfile}>
|
|
271
|
+
<DropdownMenuItemIcon>
|
|
272
|
+
<Settings />
|
|
273
|
+
</DropdownMenuItemIcon>
|
|
274
|
+
<DropdownMenuItemText>Profile settings</DropdownMenuItemText>
|
|
275
|
+
</DropdownMenuItem>
|
|
276
|
+
<DropdownMenu>
|
|
277
|
+
<DropdownMenuTriggerItem>
|
|
278
|
+
<DropdownMenuItemIcon>
|
|
279
|
+
<Paintbrush />
|
|
280
|
+
</DropdownMenuItemIcon>
|
|
281
|
+
<DropdownMenuItemText>Appearance</DropdownMenuItemText>
|
|
282
|
+
</DropdownMenuTriggerItem>
|
|
283
|
+
<DropdownMenuContent>
|
|
284
|
+
<DropdownMenuRadioGroup value={theme} onValueChange={handleThemeChange}>
|
|
285
|
+
{THEMES.map(option => (
|
|
286
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
287
|
+
<DropdownMenuItemText>{THEME_LABELS[option]}</DropdownMenuItemText>
|
|
288
|
+
</DropdownMenuRadioItem>
|
|
289
|
+
))}
|
|
290
|
+
</DropdownMenuRadioGroup>
|
|
291
|
+
</DropdownMenuContent>
|
|
292
|
+
</DropdownMenu>
|
|
293
|
+
<DropdownMenu>
|
|
294
|
+
<DropdownMenuTriggerItem>
|
|
295
|
+
<DropdownMenuItemIcon>
|
|
296
|
+
<PanelLeftDashed />
|
|
297
|
+
</DropdownMenuItemIcon>
|
|
298
|
+
<DropdownMenuItemText>Sidebar mode</DropdownMenuItemText>
|
|
299
|
+
</DropdownMenuTriggerItem>
|
|
300
|
+
<DropdownMenuContent>
|
|
301
|
+
<DropdownMenuRadioGroup value={railMode} onValueChange={handleRailModeChange}>
|
|
302
|
+
{RAIL_MODES.map(option => (
|
|
303
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
304
|
+
<DropdownMenuItemText>{RAIL_MODE_LABELS[option]}</DropdownMenuItemText>
|
|
305
|
+
</DropdownMenuRadioItem>
|
|
306
|
+
))}
|
|
307
|
+
</DropdownMenuRadioGroup>
|
|
308
|
+
</DropdownMenuContent>
|
|
309
|
+
</DropdownMenu>
|
|
310
|
+
<DropdownMenuSeparator />
|
|
311
|
+
<DropdownMenuItem onSelect={onSignOut}>
|
|
312
|
+
<DropdownMenuItemIcon>
|
|
313
|
+
<LogOut />
|
|
314
|
+
</DropdownMenuItemIcon>
|
|
315
|
+
<DropdownMenuItemText>Sign out</DropdownMenuItemText>
|
|
316
|
+
</DropdownMenuItem>
|
|
317
|
+
</DropdownMenuContent>
|
|
318
|
+
</DropdownMenu>
|
|
319
|
+
</NavRailFooter>
|
|
320
|
+
</NavRail>
|
|
321
|
+
</AppShellRail>
|
|
322
|
+
|
|
323
|
+
<AppShellRemote role='main'>
|
|
324
|
+
<RemoteShell
|
|
325
|
+
config={EDGE_NAV}
|
|
326
|
+
basePath='/edge'
|
|
327
|
+
pathname={pathname}
|
|
328
|
+
onNavigate={handleNavigate}
|
|
329
|
+
data-testid='product-shell'
|
|
330
|
+
>
|
|
331
|
+
<RemoteShellPanel resizable />
|
|
332
|
+
<RemoteShellBreadcrumb />
|
|
333
|
+
<RemoteShellContent>
|
|
334
|
+
<Page name='edge-api-sessions' fullSize fixedHeight data-testid='sessions-page'>
|
|
335
|
+
<PageHeader>
|
|
336
|
+
<PageTitle>API Sessions</PageTitle>
|
|
337
|
+
</PageHeader>
|
|
338
|
+
<PageContent>
|
|
339
|
+
<Table
|
|
340
|
+
aria-label='API sessions'
|
|
341
|
+
data={API_SESSIONS}
|
|
342
|
+
columns={columns}
|
|
343
|
+
data-testid='sessions-table'
|
|
344
|
+
/>
|
|
345
|
+
</PageContent>
|
|
346
|
+
</Page>
|
|
347
|
+
</RemoteShellContent>
|
|
348
|
+
</RemoteShell>
|
|
349
|
+
</AppShellRemote>
|
|
350
|
+
</AppShell>
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Home: a page straight in `AppShellRemote`, expanded rail, no panel.
|
|
356
|
+
|
|
357
|
+
Home is a host page, not a product: `Page` goes straight into `AppShellRemote`, with no
|
|
358
|
+
`RemoteShell`, no panel and no breadcrumbs. The rail is expanded at the top level.
|
|
359
|
+
|
|
360
|
+
```tsx story=Home
|
|
361
|
+
import { type MouseEvent, useState } from 'react';
|
|
362
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
363
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
364
|
+
import { ChatTrigger } from '@wallarm-org/design-system/Chat';
|
|
365
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIcon, DropdownMenuItemText, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuTriggerItem } from '@wallarm-org/design-system/DropdownMenu';
|
|
366
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, LogOut, Paintbrush, PanelLeftDashed, Search, Settings, UserRound } from '@wallarm-org/design-system/icons';
|
|
367
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
368
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, type NavRailMode, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
369
|
+
import { NotificationCenter, NotificationCenterBody, NotificationCenterContent, NotificationCenterHeader, NotificationCenterHeaderAction, NotificationCenterHeaderActions, NotificationCenterItem, NotificationCenterItemDescription, NotificationCenterItemTime, NotificationCenterItemTitle, NotificationCenterList, NotificationCenterTabs, NotificationCenterTabsList, NotificationCenterTitle, NotificationCenterTrigger } from '@wallarm-org/design-system/NotificationCenter';
|
|
370
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
371
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
372
|
+
import { TabsContent, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
373
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
374
|
+
import { useTheme } from '@wallarm-org/design-system/ThemeProvider';
|
|
375
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo, TopHeaderSeparator } from '@wallarm-org/design-system/TopHeader';
|
|
376
|
+
|
|
377
|
+
export const Home = () => {
|
|
378
|
+
const [railMode, setRailMode] = useState<NavRailMode>('expanded');
|
|
379
|
+
const { theme, setTheme } = useTheme();
|
|
380
|
+
const unread = NOTIFICATIONS.filter(item => item.unread);
|
|
381
|
+
const read = NOTIFICATIONS.filter(item => !item.unread);
|
|
382
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
383
|
+
event.preventDefault();
|
|
384
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
385
|
+
};
|
|
386
|
+
const handleRailModeChange = ({ value }: { value: string }) => {
|
|
387
|
+
const next = RAIL_MODES.find(mode => mode === value);
|
|
388
|
+
if (next) setRailMode(next);
|
|
389
|
+
};
|
|
390
|
+
const handleThemeChange = ({ value }: { value: string }) => {
|
|
391
|
+
const next = THEMES.find(option => option === value);
|
|
392
|
+
if (next) setTheme(next);
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
return (
|
|
396
|
+
<AppShell data-testid='app-shell'>
|
|
397
|
+
<AppShellHeader>
|
|
398
|
+
<TopHeader data-testid='top-header'>
|
|
399
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
400
|
+
<Logo size='md' />
|
|
401
|
+
</TopHeaderLogo>
|
|
402
|
+
<TopHeaderActions>
|
|
403
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Search'>
|
|
404
|
+
<Search />
|
|
405
|
+
</Button>
|
|
406
|
+
<TopHeaderSeparator />
|
|
407
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
408
|
+
Acme Bank
|
|
409
|
+
<ChevronUpDown />
|
|
410
|
+
</Button>
|
|
411
|
+
<ChatTrigger onClick={onOpenAssistant} />
|
|
412
|
+
<NotificationCenter data-testid='notifications'>
|
|
413
|
+
<NotificationCenterTrigger count={unread.length} />
|
|
414
|
+
<NotificationCenterContent>
|
|
415
|
+
<NotificationCenterHeader>
|
|
416
|
+
<NotificationCenterTitle />
|
|
417
|
+
<NotificationCenterHeaderActions>
|
|
418
|
+
<NotificationCenterHeaderAction onClick={onMarkAllRead}>
|
|
419
|
+
Mark all as read
|
|
420
|
+
</NotificationCenterHeaderAction>
|
|
421
|
+
<NotificationCenterHeaderAction asChild aria-label='Notification settings'>
|
|
422
|
+
<a href='/settings/notifications' onClick={handleRailClick}>
|
|
423
|
+
<Settings />
|
|
424
|
+
</a>
|
|
425
|
+
</NotificationCenterHeaderAction>
|
|
426
|
+
</NotificationCenterHeaderActions>
|
|
427
|
+
</NotificationCenterHeader>
|
|
428
|
+
<NotificationCenterTabs defaultValue='new'>
|
|
429
|
+
<NotificationCenterTabsList>
|
|
430
|
+
<TabsTrigger value='new'>
|
|
431
|
+
New <NumericBadge size='small'>{unread.length}</NumericBadge>
|
|
432
|
+
</TabsTrigger>
|
|
433
|
+
<TabsTrigger value='read'>Read</TabsTrigger>
|
|
434
|
+
</NotificationCenterTabsList>
|
|
435
|
+
<TabsContent value='new'>
|
|
436
|
+
<NotificationCenterBody>
|
|
437
|
+
<NotificationCenterList>
|
|
438
|
+
{unread.map(item => (
|
|
439
|
+
<NotificationCenterItem key={item.id} unread>
|
|
440
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
441
|
+
{item.title}
|
|
442
|
+
</NotificationCenterItemTitle>
|
|
443
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
444
|
+
<NotificationCenterItemDescription>
|
|
445
|
+
{item.description}
|
|
446
|
+
</NotificationCenterItemDescription>
|
|
447
|
+
</NotificationCenterItem>
|
|
448
|
+
))}
|
|
449
|
+
</NotificationCenterList>
|
|
450
|
+
</NotificationCenterBody>
|
|
451
|
+
</TabsContent>
|
|
452
|
+
<TabsContent value='read'>
|
|
453
|
+
<NotificationCenterBody>
|
|
454
|
+
<NotificationCenterList>
|
|
455
|
+
{read.map(item => (
|
|
456
|
+
<NotificationCenterItem key={item.id}>
|
|
457
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
458
|
+
{item.title}
|
|
459
|
+
</NotificationCenterItemTitle>
|
|
460
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
461
|
+
<NotificationCenterItemDescription>
|
|
462
|
+
{item.description}
|
|
463
|
+
</NotificationCenterItemDescription>
|
|
464
|
+
</NotificationCenterItem>
|
|
465
|
+
))}
|
|
466
|
+
</NotificationCenterList>
|
|
467
|
+
</NotificationCenterBody>
|
|
468
|
+
</TabsContent>
|
|
469
|
+
</NotificationCenterTabs>
|
|
470
|
+
</NotificationCenterContent>
|
|
471
|
+
</NotificationCenter>
|
|
472
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
473
|
+
<CircleHelp />
|
|
474
|
+
</Button>
|
|
475
|
+
</TopHeaderActions>
|
|
476
|
+
</TopHeader>
|
|
477
|
+
</AppShellHeader>
|
|
478
|
+
|
|
479
|
+
<AppShellRail>
|
|
480
|
+
<NavRail mode={railMode} data-testid='nav-rail'>
|
|
481
|
+
<NavRailBody>
|
|
482
|
+
<NavRailItem
|
|
483
|
+
href='/'
|
|
484
|
+
icon={HomeIcon}
|
|
485
|
+
label='Home'
|
|
486
|
+
shortcut={['G', 'H']}
|
|
487
|
+
active
|
|
488
|
+
onClick={handleRailClick}
|
|
489
|
+
data-testid='nav-rail-home'
|
|
490
|
+
/>
|
|
491
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
492
|
+
<NavRailSeparator />
|
|
493
|
+
{PRODUCTS.map(product => (
|
|
494
|
+
<NavRailItem
|
|
495
|
+
key={product.id}
|
|
496
|
+
href={`/${product.id}`}
|
|
497
|
+
icon={product.icon}
|
|
498
|
+
label={product.label}
|
|
499
|
+
shortcut={product.shortcut}
|
|
500
|
+
onClick={handleRailClick}
|
|
501
|
+
data-testid={`nav-rail-${product.id}`}
|
|
502
|
+
/>
|
|
503
|
+
))}
|
|
504
|
+
</NavRailBody>
|
|
505
|
+
<NavRailFooter>
|
|
506
|
+
<NavRailItem
|
|
507
|
+
href='/settings'
|
|
508
|
+
icon={Settings}
|
|
509
|
+
label='Settings'
|
|
510
|
+
shortcut={['G', 'S']}
|
|
511
|
+
onClick={handleRailClick}
|
|
512
|
+
data-testid='nav-rail-settings'
|
|
513
|
+
/>
|
|
514
|
+
<DropdownMenu
|
|
515
|
+
data-testid='account-menu'
|
|
516
|
+
positioning={{ placement: 'right-end', gutter: 6, offset: { crossAxis: 12 } }}
|
|
517
|
+
>
|
|
518
|
+
<DropdownMenuTrigger>
|
|
519
|
+
<NavRailItem
|
|
520
|
+
icon={UserRound}
|
|
521
|
+
label='Maria Lopez'
|
|
522
|
+
avatar
|
|
523
|
+
data-testid='nav-rail-account'
|
|
524
|
+
/>
|
|
525
|
+
</DropdownMenuTrigger>
|
|
526
|
+
<DropdownMenuContent className='w-200'>
|
|
527
|
+
<DropdownMenuItem onSelect={onOpenProfile}>
|
|
528
|
+
<DropdownMenuItemIcon>
|
|
529
|
+
<Settings />
|
|
530
|
+
</DropdownMenuItemIcon>
|
|
531
|
+
<DropdownMenuItemText>Profile settings</DropdownMenuItemText>
|
|
532
|
+
</DropdownMenuItem>
|
|
533
|
+
<DropdownMenu>
|
|
534
|
+
<DropdownMenuTriggerItem>
|
|
535
|
+
<DropdownMenuItemIcon>
|
|
536
|
+
<Paintbrush />
|
|
537
|
+
</DropdownMenuItemIcon>
|
|
538
|
+
<DropdownMenuItemText>Appearance</DropdownMenuItemText>
|
|
539
|
+
</DropdownMenuTriggerItem>
|
|
540
|
+
<DropdownMenuContent>
|
|
541
|
+
<DropdownMenuRadioGroup value={theme} onValueChange={handleThemeChange}>
|
|
542
|
+
{THEMES.map(option => (
|
|
543
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
544
|
+
<DropdownMenuItemText>{THEME_LABELS[option]}</DropdownMenuItemText>
|
|
545
|
+
</DropdownMenuRadioItem>
|
|
546
|
+
))}
|
|
547
|
+
</DropdownMenuRadioGroup>
|
|
548
|
+
</DropdownMenuContent>
|
|
549
|
+
</DropdownMenu>
|
|
550
|
+
<DropdownMenu>
|
|
551
|
+
<DropdownMenuTriggerItem>
|
|
552
|
+
<DropdownMenuItemIcon>
|
|
553
|
+
<PanelLeftDashed />
|
|
554
|
+
</DropdownMenuItemIcon>
|
|
555
|
+
<DropdownMenuItemText>Sidebar mode</DropdownMenuItemText>
|
|
556
|
+
</DropdownMenuTriggerItem>
|
|
557
|
+
<DropdownMenuContent>
|
|
558
|
+
<DropdownMenuRadioGroup value={railMode} onValueChange={handleRailModeChange}>
|
|
559
|
+
{RAIL_MODES.map(option => (
|
|
560
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
561
|
+
<DropdownMenuItemText>{RAIL_MODE_LABELS[option]}</DropdownMenuItemText>
|
|
562
|
+
</DropdownMenuRadioItem>
|
|
563
|
+
))}
|
|
564
|
+
</DropdownMenuRadioGroup>
|
|
565
|
+
</DropdownMenuContent>
|
|
566
|
+
</DropdownMenu>
|
|
567
|
+
<DropdownMenuSeparator />
|
|
568
|
+
<DropdownMenuItem onSelect={onSignOut}>
|
|
569
|
+
<DropdownMenuItemIcon>
|
|
570
|
+
<LogOut />
|
|
571
|
+
</DropdownMenuItemIcon>
|
|
572
|
+
<DropdownMenuItemText>Sign out</DropdownMenuItemText>
|
|
573
|
+
</DropdownMenuItem>
|
|
574
|
+
</DropdownMenuContent>
|
|
575
|
+
</DropdownMenu>
|
|
576
|
+
</NavRailFooter>
|
|
577
|
+
</NavRail>
|
|
578
|
+
</AppShellRail>
|
|
579
|
+
|
|
580
|
+
<AppShellRemote role='main'>
|
|
581
|
+
<Page name='home' data-testid='home-page'>
|
|
582
|
+
<PageHeader>
|
|
583
|
+
<PageTitle>Good morning, Maria</PageTitle>
|
|
584
|
+
</PageHeader>
|
|
585
|
+
<PageContent>
|
|
586
|
+
<Text size='sm' color='secondary'>
|
|
587
|
+
3 new incidents and 1 node update since your last visit.
|
|
588
|
+
</Text>
|
|
589
|
+
</PageContent>
|
|
590
|
+
</Page>
|
|
591
|
+
</AppShellRemote>
|
|
592
|
+
</AppShell>
|
|
593
|
+
);
|
|
594
|
+
};
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
Notifications, open from the header bell.
|
|
598
|
+
|
|
599
|
+
The notifications inbox open from the bell in `TopHeaderActions`: unread count on the bell,
|
|
600
|
+
New and Read tabs. The app owns the list and the unread count.
|
|
601
|
+
|
|
602
|
+
```tsx story=NotificationsOpen
|
|
603
|
+
import { type MouseEvent, useState } from 'react';
|
|
604
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
605
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
606
|
+
import { ChatTrigger } from '@wallarm-org/design-system/Chat';
|
|
607
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIcon, DropdownMenuItemText, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuTriggerItem } from '@wallarm-org/design-system/DropdownMenu';
|
|
608
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, LogOut, Paintbrush, PanelLeftDashed, Search, Settings, UserRound } from '@wallarm-org/design-system/icons';
|
|
609
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
610
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, type NavRailMode, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
611
|
+
import { NotificationCenter, NotificationCenterBody, NotificationCenterContent, NotificationCenterHeader, NotificationCenterHeaderAction, NotificationCenterHeaderActions, NotificationCenterItem, NotificationCenterItemDescription, NotificationCenterItemTime, NotificationCenterItemTitle, NotificationCenterList, NotificationCenterTabs, NotificationCenterTabsList, NotificationCenterTitle, NotificationCenterTrigger } from '@wallarm-org/design-system/NotificationCenter';
|
|
612
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
613
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
614
|
+
import { TabsContent, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
615
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
616
|
+
import { useTheme } from '@wallarm-org/design-system/ThemeProvider';
|
|
617
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo, TopHeaderSeparator } from '@wallarm-org/design-system/TopHeader';
|
|
618
|
+
|
|
619
|
+
export const NotificationsOpen = () => {
|
|
620
|
+
const [railMode, setRailMode] = useState<NavRailMode>('expanded');
|
|
621
|
+
const [notificationsOpen, setNotificationsOpen] = useState(true);
|
|
622
|
+
const { theme, setTheme } = useTheme();
|
|
623
|
+
const unread = NOTIFICATIONS.filter(item => item.unread);
|
|
624
|
+
const read = NOTIFICATIONS.filter(item => !item.unread);
|
|
625
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
626
|
+
event.preventDefault();
|
|
627
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
628
|
+
};
|
|
629
|
+
const handleRailModeChange = ({ value }: { value: string }) => {
|
|
630
|
+
const next = RAIL_MODES.find(mode => mode === value);
|
|
631
|
+
if (next) setRailMode(next);
|
|
632
|
+
};
|
|
633
|
+
const handleThemeChange = ({ value }: { value: string }) => {
|
|
634
|
+
const next = THEMES.find(option => option === value);
|
|
635
|
+
if (next) setTheme(next);
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
return (
|
|
639
|
+
<AppShell data-testid='app-shell'>
|
|
640
|
+
<AppShellHeader>
|
|
641
|
+
<TopHeader data-testid='top-header'>
|
|
642
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
643
|
+
<Logo size='md' />
|
|
644
|
+
</TopHeaderLogo>
|
|
645
|
+
<TopHeaderActions>
|
|
646
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Search'>
|
|
647
|
+
<Search />
|
|
648
|
+
</Button>
|
|
649
|
+
<TopHeaderSeparator />
|
|
650
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
651
|
+
Acme Bank
|
|
652
|
+
<ChevronUpDown />
|
|
653
|
+
</Button>
|
|
654
|
+
<ChatTrigger onClick={onOpenAssistant} />
|
|
655
|
+
<NotificationCenter
|
|
656
|
+
data-testid='notifications'
|
|
657
|
+
open={notificationsOpen}
|
|
658
|
+
onOpenChange={setNotificationsOpen}
|
|
659
|
+
>
|
|
660
|
+
<NotificationCenterTrigger count={unread.length} />
|
|
661
|
+
<NotificationCenterContent>
|
|
662
|
+
<NotificationCenterHeader>
|
|
663
|
+
<NotificationCenterTitle />
|
|
664
|
+
<NotificationCenterHeaderActions>
|
|
665
|
+
<NotificationCenterHeaderAction onClick={onMarkAllRead}>
|
|
666
|
+
Mark all as read
|
|
667
|
+
</NotificationCenterHeaderAction>
|
|
668
|
+
<NotificationCenterHeaderAction asChild aria-label='Notification settings'>
|
|
669
|
+
<a href='/settings/notifications' onClick={handleRailClick}>
|
|
670
|
+
<Settings />
|
|
671
|
+
</a>
|
|
672
|
+
</NotificationCenterHeaderAction>
|
|
673
|
+
</NotificationCenterHeaderActions>
|
|
674
|
+
</NotificationCenterHeader>
|
|
675
|
+
<NotificationCenterTabs defaultValue='new'>
|
|
676
|
+
<NotificationCenterTabsList>
|
|
677
|
+
<TabsTrigger value='new'>
|
|
678
|
+
New <NumericBadge size='small'>{unread.length}</NumericBadge>
|
|
679
|
+
</TabsTrigger>
|
|
680
|
+
<TabsTrigger value='read'>Read</TabsTrigger>
|
|
681
|
+
</NotificationCenterTabsList>
|
|
682
|
+
<TabsContent value='new'>
|
|
683
|
+
<NotificationCenterBody>
|
|
684
|
+
<NotificationCenterList>
|
|
685
|
+
{unread.map(item => (
|
|
686
|
+
<NotificationCenterItem key={item.id} unread>
|
|
687
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
688
|
+
{item.title}
|
|
689
|
+
</NotificationCenterItemTitle>
|
|
690
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
691
|
+
<NotificationCenterItemDescription>
|
|
692
|
+
{item.description}
|
|
693
|
+
</NotificationCenterItemDescription>
|
|
694
|
+
</NotificationCenterItem>
|
|
695
|
+
))}
|
|
696
|
+
</NotificationCenterList>
|
|
697
|
+
</NotificationCenterBody>
|
|
698
|
+
</TabsContent>
|
|
699
|
+
<TabsContent value='read'>
|
|
700
|
+
<NotificationCenterBody>
|
|
701
|
+
<NotificationCenterList>
|
|
702
|
+
{read.map(item => (
|
|
703
|
+
<NotificationCenterItem key={item.id}>
|
|
704
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
705
|
+
{item.title}
|
|
706
|
+
</NotificationCenterItemTitle>
|
|
707
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
708
|
+
<NotificationCenterItemDescription>
|
|
709
|
+
{item.description}
|
|
710
|
+
</NotificationCenterItemDescription>
|
|
711
|
+
</NotificationCenterItem>
|
|
712
|
+
))}
|
|
713
|
+
</NotificationCenterList>
|
|
714
|
+
</NotificationCenterBody>
|
|
715
|
+
</TabsContent>
|
|
716
|
+
</NotificationCenterTabs>
|
|
717
|
+
</NotificationCenterContent>
|
|
718
|
+
</NotificationCenter>
|
|
719
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
720
|
+
<CircleHelp />
|
|
721
|
+
</Button>
|
|
722
|
+
</TopHeaderActions>
|
|
723
|
+
</TopHeader>
|
|
724
|
+
</AppShellHeader>
|
|
725
|
+
|
|
726
|
+
<AppShellRail>
|
|
727
|
+
<NavRail mode={railMode} data-testid='nav-rail'>
|
|
728
|
+
<NavRailBody>
|
|
729
|
+
<NavRailItem
|
|
730
|
+
href='/'
|
|
731
|
+
icon={HomeIcon}
|
|
732
|
+
label='Home'
|
|
733
|
+
shortcut={['G', 'H']}
|
|
734
|
+
active
|
|
735
|
+
onClick={handleRailClick}
|
|
736
|
+
data-testid='nav-rail-home'
|
|
737
|
+
/>
|
|
738
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
739
|
+
<NavRailSeparator />
|
|
740
|
+
{PRODUCTS.map(product => (
|
|
741
|
+
<NavRailItem
|
|
742
|
+
key={product.id}
|
|
743
|
+
href={`/${product.id}`}
|
|
744
|
+
icon={product.icon}
|
|
745
|
+
label={product.label}
|
|
746
|
+
shortcut={product.shortcut}
|
|
747
|
+
onClick={handleRailClick}
|
|
748
|
+
data-testid={`nav-rail-${product.id}`}
|
|
749
|
+
/>
|
|
750
|
+
))}
|
|
751
|
+
</NavRailBody>
|
|
752
|
+
<NavRailFooter>
|
|
753
|
+
<NavRailItem
|
|
754
|
+
href='/settings'
|
|
755
|
+
icon={Settings}
|
|
756
|
+
label='Settings'
|
|
757
|
+
shortcut={['G', 'S']}
|
|
758
|
+
onClick={handleRailClick}
|
|
759
|
+
data-testid='nav-rail-settings'
|
|
760
|
+
/>
|
|
761
|
+
<DropdownMenu
|
|
762
|
+
data-testid='account-menu'
|
|
763
|
+
positioning={{ placement: 'right-end', gutter: 6, offset: { crossAxis: 12 } }}
|
|
764
|
+
>
|
|
765
|
+
<DropdownMenuTrigger>
|
|
766
|
+
<NavRailItem
|
|
767
|
+
icon={UserRound}
|
|
768
|
+
label='Maria Lopez'
|
|
769
|
+
avatar
|
|
770
|
+
data-testid='nav-rail-account'
|
|
771
|
+
/>
|
|
772
|
+
</DropdownMenuTrigger>
|
|
773
|
+
<DropdownMenuContent className='w-200'>
|
|
774
|
+
<DropdownMenuItem onSelect={onOpenProfile}>
|
|
775
|
+
<DropdownMenuItemIcon>
|
|
776
|
+
<Settings />
|
|
777
|
+
</DropdownMenuItemIcon>
|
|
778
|
+
<DropdownMenuItemText>Profile settings</DropdownMenuItemText>
|
|
779
|
+
</DropdownMenuItem>
|
|
780
|
+
<DropdownMenu>
|
|
781
|
+
<DropdownMenuTriggerItem>
|
|
782
|
+
<DropdownMenuItemIcon>
|
|
783
|
+
<Paintbrush />
|
|
784
|
+
</DropdownMenuItemIcon>
|
|
785
|
+
<DropdownMenuItemText>Appearance</DropdownMenuItemText>
|
|
786
|
+
</DropdownMenuTriggerItem>
|
|
787
|
+
<DropdownMenuContent>
|
|
788
|
+
<DropdownMenuRadioGroup value={theme} onValueChange={handleThemeChange}>
|
|
789
|
+
{THEMES.map(option => (
|
|
790
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
791
|
+
<DropdownMenuItemText>{THEME_LABELS[option]}</DropdownMenuItemText>
|
|
792
|
+
</DropdownMenuRadioItem>
|
|
793
|
+
))}
|
|
794
|
+
</DropdownMenuRadioGroup>
|
|
795
|
+
</DropdownMenuContent>
|
|
796
|
+
</DropdownMenu>
|
|
797
|
+
<DropdownMenu>
|
|
798
|
+
<DropdownMenuTriggerItem>
|
|
799
|
+
<DropdownMenuItemIcon>
|
|
800
|
+
<PanelLeftDashed />
|
|
801
|
+
</DropdownMenuItemIcon>
|
|
802
|
+
<DropdownMenuItemText>Sidebar mode</DropdownMenuItemText>
|
|
803
|
+
</DropdownMenuTriggerItem>
|
|
804
|
+
<DropdownMenuContent>
|
|
805
|
+
<DropdownMenuRadioGroup value={railMode} onValueChange={handleRailModeChange}>
|
|
806
|
+
{RAIL_MODES.map(option => (
|
|
807
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
808
|
+
<DropdownMenuItemText>{RAIL_MODE_LABELS[option]}</DropdownMenuItemText>
|
|
809
|
+
</DropdownMenuRadioItem>
|
|
810
|
+
))}
|
|
811
|
+
</DropdownMenuRadioGroup>
|
|
812
|
+
</DropdownMenuContent>
|
|
813
|
+
</DropdownMenu>
|
|
814
|
+
<DropdownMenuSeparator />
|
|
815
|
+
<DropdownMenuItem onSelect={onSignOut}>
|
|
816
|
+
<DropdownMenuItemIcon>
|
|
817
|
+
<LogOut />
|
|
818
|
+
</DropdownMenuItemIcon>
|
|
819
|
+
<DropdownMenuItemText>Sign out</DropdownMenuItemText>
|
|
820
|
+
</DropdownMenuItem>
|
|
821
|
+
</DropdownMenuContent>
|
|
822
|
+
</DropdownMenu>
|
|
823
|
+
</NavRailFooter>
|
|
824
|
+
</NavRail>
|
|
825
|
+
</AppShellRail>
|
|
826
|
+
|
|
827
|
+
<AppShellRemote role='main'>
|
|
828
|
+
<Page name='home' data-testid='home-page'>
|
|
829
|
+
<PageHeader>
|
|
830
|
+
<PageTitle>Good morning, Maria</PageTitle>
|
|
831
|
+
</PageHeader>
|
|
832
|
+
<PageContent>
|
|
833
|
+
<Text size='sm' color='secondary'>
|
|
834
|
+
3 new incidents and 1 node update since your last visit.
|
|
835
|
+
</Text>
|
|
836
|
+
</PageContent>
|
|
837
|
+
</Page>
|
|
838
|
+
</AppShellRemote>
|
|
839
|
+
</AppShell>
|
|
840
|
+
);
|
|
841
|
+
};
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
The user menu, open from the rail's avatar item.
|
|
845
|
+
|
|
846
|
+
The user menu open from the avatar item at the foot of `NavRailFooter`: profile settings,
|
|
847
|
+
appearance, sidebar mode and sign out.
|
|
848
|
+
|
|
849
|
+
```tsx story=AccountMenuOpen
|
|
850
|
+
import { type MouseEvent, useState } from 'react';
|
|
851
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
852
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
853
|
+
import { ChatTrigger } from '@wallarm-org/design-system/Chat';
|
|
854
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemIcon, DropdownMenuItemText, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuTriggerItem } from '@wallarm-org/design-system/DropdownMenu';
|
|
855
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, LogOut, Paintbrush, PanelLeftDashed, Search, Settings, UserRound } from '@wallarm-org/design-system/icons';
|
|
856
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
857
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, type NavRailMode, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
858
|
+
import { NotificationCenter, NotificationCenterBody, NotificationCenterContent, NotificationCenterHeader, NotificationCenterHeaderAction, NotificationCenterHeaderActions, NotificationCenterItem, NotificationCenterItemDescription, NotificationCenterItemTime, NotificationCenterItemTitle, NotificationCenterList, NotificationCenterTabs, NotificationCenterTabsList, NotificationCenterTitle, NotificationCenterTrigger } from '@wallarm-org/design-system/NotificationCenter';
|
|
859
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
860
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
861
|
+
import { TabsContent, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
862
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
863
|
+
import { useTheme } from '@wallarm-org/design-system/ThemeProvider';
|
|
864
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo, TopHeaderSeparator } from '@wallarm-org/design-system/TopHeader';
|
|
865
|
+
|
|
866
|
+
export const AccountMenuOpen = () => {
|
|
867
|
+
const [railMode, setRailMode] = useState<NavRailMode>('expanded');
|
|
868
|
+
const [accountMenuOpen, setAccountMenuOpen] = useState(true);
|
|
869
|
+
const { theme, setTheme } = useTheme();
|
|
870
|
+
const unread = NOTIFICATIONS.filter(item => item.unread);
|
|
871
|
+
const read = NOTIFICATIONS.filter(item => !item.unread);
|
|
872
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
873
|
+
event.preventDefault();
|
|
874
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
875
|
+
};
|
|
876
|
+
const handleRailModeChange = ({ value }: { value: string }) => {
|
|
877
|
+
const next = RAIL_MODES.find(mode => mode === value);
|
|
878
|
+
if (next) setRailMode(next);
|
|
879
|
+
};
|
|
880
|
+
const handleThemeChange = ({ value }: { value: string }) => {
|
|
881
|
+
const next = THEMES.find(option => option === value);
|
|
882
|
+
if (next) setTheme(next);
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
return (
|
|
886
|
+
<AppShell data-testid='app-shell'>
|
|
887
|
+
<AppShellHeader>
|
|
888
|
+
<TopHeader data-testid='top-header'>
|
|
889
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
890
|
+
<Logo size='md' />
|
|
891
|
+
</TopHeaderLogo>
|
|
892
|
+
<TopHeaderActions>
|
|
893
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Search'>
|
|
894
|
+
<Search />
|
|
895
|
+
</Button>
|
|
896
|
+
<TopHeaderSeparator />
|
|
897
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
898
|
+
Acme Bank
|
|
899
|
+
<ChevronUpDown />
|
|
900
|
+
</Button>
|
|
901
|
+
<ChatTrigger onClick={onOpenAssistant} />
|
|
902
|
+
<NotificationCenter data-testid='notifications'>
|
|
903
|
+
<NotificationCenterTrigger count={unread.length} />
|
|
904
|
+
<NotificationCenterContent>
|
|
905
|
+
<NotificationCenterHeader>
|
|
906
|
+
<NotificationCenterTitle />
|
|
907
|
+
<NotificationCenterHeaderActions>
|
|
908
|
+
<NotificationCenterHeaderAction onClick={onMarkAllRead}>
|
|
909
|
+
Mark all as read
|
|
910
|
+
</NotificationCenterHeaderAction>
|
|
911
|
+
<NotificationCenterHeaderAction asChild aria-label='Notification settings'>
|
|
912
|
+
<a href='/settings/notifications' onClick={handleRailClick}>
|
|
913
|
+
<Settings />
|
|
914
|
+
</a>
|
|
915
|
+
</NotificationCenterHeaderAction>
|
|
916
|
+
</NotificationCenterHeaderActions>
|
|
917
|
+
</NotificationCenterHeader>
|
|
918
|
+
<NotificationCenterTabs defaultValue='new'>
|
|
919
|
+
<NotificationCenterTabsList>
|
|
920
|
+
<TabsTrigger value='new'>
|
|
921
|
+
New <NumericBadge size='small'>{unread.length}</NumericBadge>
|
|
922
|
+
</TabsTrigger>
|
|
923
|
+
<TabsTrigger value='read'>Read</TabsTrigger>
|
|
924
|
+
</NotificationCenterTabsList>
|
|
925
|
+
<TabsContent value='new'>
|
|
926
|
+
<NotificationCenterBody>
|
|
927
|
+
<NotificationCenterList>
|
|
928
|
+
{unread.map(item => (
|
|
929
|
+
<NotificationCenterItem key={item.id} unread>
|
|
930
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
931
|
+
{item.title}
|
|
932
|
+
</NotificationCenterItemTitle>
|
|
933
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
934
|
+
<NotificationCenterItemDescription>
|
|
935
|
+
{item.description}
|
|
936
|
+
</NotificationCenterItemDescription>
|
|
937
|
+
</NotificationCenterItem>
|
|
938
|
+
))}
|
|
939
|
+
</NotificationCenterList>
|
|
940
|
+
</NotificationCenterBody>
|
|
941
|
+
</TabsContent>
|
|
942
|
+
<TabsContent value='read'>
|
|
943
|
+
<NotificationCenterBody>
|
|
944
|
+
<NotificationCenterList>
|
|
945
|
+
{read.map(item => (
|
|
946
|
+
<NotificationCenterItem key={item.id}>
|
|
947
|
+
<NotificationCenterItemTitle onClick={onOpenNotification}>
|
|
948
|
+
{item.title}
|
|
949
|
+
</NotificationCenterItemTitle>
|
|
950
|
+
<NotificationCenterItemTime value={item.createdAt} />
|
|
951
|
+
<NotificationCenterItemDescription>
|
|
952
|
+
{item.description}
|
|
953
|
+
</NotificationCenterItemDescription>
|
|
954
|
+
</NotificationCenterItem>
|
|
955
|
+
))}
|
|
956
|
+
</NotificationCenterList>
|
|
957
|
+
</NotificationCenterBody>
|
|
958
|
+
</TabsContent>
|
|
959
|
+
</NotificationCenterTabs>
|
|
960
|
+
</NotificationCenterContent>
|
|
961
|
+
</NotificationCenter>
|
|
962
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
963
|
+
<CircleHelp />
|
|
964
|
+
</Button>
|
|
965
|
+
</TopHeaderActions>
|
|
966
|
+
</TopHeader>
|
|
967
|
+
</AppShellHeader>
|
|
968
|
+
|
|
969
|
+
<AppShellRail>
|
|
970
|
+
<NavRail mode={railMode} data-testid='nav-rail'>
|
|
971
|
+
<NavRailBody>
|
|
972
|
+
<NavRailItem
|
|
973
|
+
href='/'
|
|
974
|
+
icon={HomeIcon}
|
|
975
|
+
label='Home'
|
|
976
|
+
shortcut={['G', 'H']}
|
|
977
|
+
active
|
|
978
|
+
onClick={handleRailClick}
|
|
979
|
+
data-testid='nav-rail-home'
|
|
980
|
+
/>
|
|
981
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
982
|
+
<NavRailSeparator />
|
|
983
|
+
{PRODUCTS.map(product => (
|
|
984
|
+
<NavRailItem
|
|
985
|
+
key={product.id}
|
|
986
|
+
href={`/${product.id}`}
|
|
987
|
+
icon={product.icon}
|
|
988
|
+
label={product.label}
|
|
989
|
+
shortcut={product.shortcut}
|
|
990
|
+
onClick={handleRailClick}
|
|
991
|
+
data-testid={`nav-rail-${product.id}`}
|
|
992
|
+
/>
|
|
993
|
+
))}
|
|
994
|
+
</NavRailBody>
|
|
995
|
+
<NavRailFooter>
|
|
996
|
+
<NavRailItem
|
|
997
|
+
href='/settings'
|
|
998
|
+
icon={Settings}
|
|
999
|
+
label='Settings'
|
|
1000
|
+
shortcut={['G', 'S']}
|
|
1001
|
+
onClick={handleRailClick}
|
|
1002
|
+
data-testid='nav-rail-settings'
|
|
1003
|
+
/>
|
|
1004
|
+
<DropdownMenu
|
|
1005
|
+
data-testid='account-menu'
|
|
1006
|
+
positioning={{ placement: 'right-end', gutter: 6, offset: { crossAxis: 12 } }}
|
|
1007
|
+
open={accountMenuOpen}
|
|
1008
|
+
onOpenChange={setAccountMenuOpen}
|
|
1009
|
+
>
|
|
1010
|
+
<DropdownMenuTrigger>
|
|
1011
|
+
<NavRailItem
|
|
1012
|
+
icon={UserRound}
|
|
1013
|
+
label='Maria Lopez'
|
|
1014
|
+
avatar
|
|
1015
|
+
data-testid='nav-rail-account'
|
|
1016
|
+
/>
|
|
1017
|
+
</DropdownMenuTrigger>
|
|
1018
|
+
<DropdownMenuContent className='w-200'>
|
|
1019
|
+
<DropdownMenuItem onSelect={onOpenProfile}>
|
|
1020
|
+
<DropdownMenuItemIcon>
|
|
1021
|
+
<Settings />
|
|
1022
|
+
</DropdownMenuItemIcon>
|
|
1023
|
+
<DropdownMenuItemText>Profile settings</DropdownMenuItemText>
|
|
1024
|
+
</DropdownMenuItem>
|
|
1025
|
+
<DropdownMenu>
|
|
1026
|
+
<DropdownMenuTriggerItem>
|
|
1027
|
+
<DropdownMenuItemIcon>
|
|
1028
|
+
<Paintbrush />
|
|
1029
|
+
</DropdownMenuItemIcon>
|
|
1030
|
+
<DropdownMenuItemText>Appearance</DropdownMenuItemText>
|
|
1031
|
+
</DropdownMenuTriggerItem>
|
|
1032
|
+
<DropdownMenuContent>
|
|
1033
|
+
<DropdownMenuRadioGroup value={theme} onValueChange={handleThemeChange}>
|
|
1034
|
+
{THEMES.map(option => (
|
|
1035
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
1036
|
+
<DropdownMenuItemText>{THEME_LABELS[option]}</DropdownMenuItemText>
|
|
1037
|
+
</DropdownMenuRadioItem>
|
|
1038
|
+
))}
|
|
1039
|
+
</DropdownMenuRadioGroup>
|
|
1040
|
+
</DropdownMenuContent>
|
|
1041
|
+
</DropdownMenu>
|
|
1042
|
+
<DropdownMenu>
|
|
1043
|
+
<DropdownMenuTriggerItem>
|
|
1044
|
+
<DropdownMenuItemIcon>
|
|
1045
|
+
<PanelLeftDashed />
|
|
1046
|
+
</DropdownMenuItemIcon>
|
|
1047
|
+
<DropdownMenuItemText>Sidebar mode</DropdownMenuItemText>
|
|
1048
|
+
</DropdownMenuTriggerItem>
|
|
1049
|
+
<DropdownMenuContent>
|
|
1050
|
+
<DropdownMenuRadioGroup value={railMode} onValueChange={handleRailModeChange}>
|
|
1051
|
+
{RAIL_MODES.map(option => (
|
|
1052
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
1053
|
+
<DropdownMenuItemText>{RAIL_MODE_LABELS[option]}</DropdownMenuItemText>
|
|
1054
|
+
</DropdownMenuRadioItem>
|
|
1055
|
+
))}
|
|
1056
|
+
</DropdownMenuRadioGroup>
|
|
1057
|
+
</DropdownMenuContent>
|
|
1058
|
+
</DropdownMenu>
|
|
1059
|
+
<DropdownMenuSeparator />
|
|
1060
|
+
<DropdownMenuItem onSelect={onSignOut}>
|
|
1061
|
+
<DropdownMenuItemIcon>
|
|
1062
|
+
<LogOut />
|
|
1063
|
+
</DropdownMenuItemIcon>
|
|
1064
|
+
<DropdownMenuItemText>Sign out</DropdownMenuItemText>
|
|
1065
|
+
</DropdownMenuItem>
|
|
1066
|
+
</DropdownMenuContent>
|
|
1067
|
+
</DropdownMenu>
|
|
1068
|
+
</NavRailFooter>
|
|
1069
|
+
</NavRail>
|
|
1070
|
+
</AppShellRail>
|
|
1071
|
+
|
|
1072
|
+
<AppShellRemote role='main'>
|
|
1073
|
+
<Page name='home' data-testid='home-page'>
|
|
1074
|
+
<PageHeader>
|
|
1075
|
+
<PageTitle>Good morning, Maria</PageTitle>
|
|
1076
|
+
</PageHeader>
|
|
1077
|
+
<PageContent>
|
|
1078
|
+
<Text size='sm' color='secondary'>
|
|
1079
|
+
3 new incidents and 1 node update since your last visit.
|
|
1080
|
+
</Text>
|
|
1081
|
+
</PageContent>
|
|
1082
|
+
</Page>
|
|
1083
|
+
</AppShellRemote>
|
|
1084
|
+
</AppShell>
|
|
1085
|
+
);
|
|
1086
|
+
};
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
A product inside a host group: the host's group shell around the product's page.
|
|
1090
|
+
|
|
1091
|
+
A product inside a host group. The host renders one group `RemoteShell` with a link per child
|
|
1092
|
+
product; the child renders its page only, with no shell of its own.
|
|
1093
|
+
|
|
1094
|
+
```tsx story=GroupedProduct
|
|
1095
|
+
import { type MouseEvent, useState } from 'react';
|
|
1096
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
1097
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
1098
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, Settings } from '@wallarm-org/design-system/icons';
|
|
1099
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
1100
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
1101
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
1102
|
+
import { RemoteShell, RemoteShellBreadcrumb, RemoteShellContent, RemoteShellPanel } from '@wallarm-org/design-system/RemoteShell';
|
|
1103
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
1104
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo } from '@wallarm-org/design-system/TopHeader';
|
|
1105
|
+
|
|
1106
|
+
export const GroupedProduct = () => {
|
|
1107
|
+
const [pathname, setPathname] = useState('/security-testing/threat-replay');
|
|
1108
|
+
|
|
1109
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
1110
|
+
event.preventDefault();
|
|
1111
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
1112
|
+
};
|
|
1113
|
+
const handleNavigate = (to: string) => {
|
|
1114
|
+
onNavigate(to);
|
|
1115
|
+
setPathname(to);
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const columns: TableColumnDef<ReplayRun>[] = [
|
|
1119
|
+
{ accessorKey: 'target', header: 'Target', size: 240 },
|
|
1120
|
+
{ accessorKey: 'attacks', header: 'Replayed attacks', size: 180 },
|
|
1121
|
+
{ accessorKey: 'status', header: 'Status', size: 160 },
|
|
1122
|
+
];
|
|
1123
|
+
|
|
1124
|
+
return (
|
|
1125
|
+
<AppShell data-testid='app-shell'>
|
|
1126
|
+
<AppShellHeader>
|
|
1127
|
+
<TopHeader data-testid='top-header'>
|
|
1128
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
1129
|
+
<Logo size='md' />
|
|
1130
|
+
</TopHeaderLogo>
|
|
1131
|
+
<TopHeaderActions>
|
|
1132
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
1133
|
+
Acme Bank
|
|
1134
|
+
<ChevronUpDown />
|
|
1135
|
+
</Button>
|
|
1136
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
1137
|
+
<CircleHelp />
|
|
1138
|
+
</Button>
|
|
1139
|
+
</TopHeaderActions>
|
|
1140
|
+
</TopHeader>
|
|
1141
|
+
</AppShellHeader>
|
|
1142
|
+
|
|
1143
|
+
<AppShellRail>
|
|
1144
|
+
<NavRail mode='collapsed' data-testid='nav-rail'>
|
|
1145
|
+
<NavRailBody>
|
|
1146
|
+
<NavRailItem
|
|
1147
|
+
href='/'
|
|
1148
|
+
icon={HomeIcon}
|
|
1149
|
+
label='Home'
|
|
1150
|
+
shortcut={['G', 'H']}
|
|
1151
|
+
onClick={handleRailClick}
|
|
1152
|
+
data-testid='nav-rail-home'
|
|
1153
|
+
/>
|
|
1154
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
1155
|
+
<NavRailSeparator />
|
|
1156
|
+
{PRODUCTS.map(product => (
|
|
1157
|
+
<NavRailItem
|
|
1158
|
+
key={product.id}
|
|
1159
|
+
href={`/${product.id}`}
|
|
1160
|
+
icon={product.icon}
|
|
1161
|
+
label={product.label}
|
|
1162
|
+
shortcut={product.shortcut}
|
|
1163
|
+
active={product.id === 'security-testing'}
|
|
1164
|
+
onClick={handleRailClick}
|
|
1165
|
+
data-testid={`nav-rail-${product.id}`}
|
|
1166
|
+
/>
|
|
1167
|
+
))}
|
|
1168
|
+
</NavRailBody>
|
|
1169
|
+
<NavRailFooter>
|
|
1170
|
+
<NavRailItem
|
|
1171
|
+
href='/settings'
|
|
1172
|
+
icon={Settings}
|
|
1173
|
+
label='Settings'
|
|
1174
|
+
shortcut={['G', 'S']}
|
|
1175
|
+
onClick={handleRailClick}
|
|
1176
|
+
data-testid='nav-rail-settings'
|
|
1177
|
+
/>
|
|
1178
|
+
</NavRailFooter>
|
|
1179
|
+
</NavRail>
|
|
1180
|
+
</AppShellRail>
|
|
1181
|
+
|
|
1182
|
+
<AppShellRemote role='main'>
|
|
1183
|
+
<RemoteShell
|
|
1184
|
+
config={SECURITY_TESTING_GROUP}
|
|
1185
|
+
basePath='/security-testing'
|
|
1186
|
+
pathname={pathname}
|
|
1187
|
+
onNavigate={handleNavigate}
|
|
1188
|
+
data-testid='group-shell'
|
|
1189
|
+
>
|
|
1190
|
+
<RemoteShellPanel resizable />
|
|
1191
|
+
<RemoteShellBreadcrumb />
|
|
1192
|
+
<RemoteShellContent>
|
|
1193
|
+
<Page name='threat-replay' fullSize fixedHeight data-testid='replay-page'>
|
|
1194
|
+
<PageHeader>
|
|
1195
|
+
<PageTitle>Threat Replay</PageTitle>
|
|
1196
|
+
</PageHeader>
|
|
1197
|
+
<PageContent>
|
|
1198
|
+
<Table
|
|
1199
|
+
aria-label='Replay runs'
|
|
1200
|
+
data={REPLAY_RUNS}
|
|
1201
|
+
columns={columns}
|
|
1202
|
+
data-testid='replay-table'
|
|
1203
|
+
/>
|
|
1204
|
+
</PageContent>
|
|
1205
|
+
</Page>
|
|
1206
|
+
</RemoteShellContent>
|
|
1207
|
+
</RemoteShell>
|
|
1208
|
+
</AppShellRemote>
|
|
1209
|
+
</AppShell>
|
|
1210
|
+
);
|
|
1211
|
+
};
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
Settings: a host route rendering `RemoteShell`, with no breadcrumbs in `PageHeader`.
|
|
1215
|
+
|
|
1216
|
+
Settings is a host route that renders `RemoteShell` itself. The trail comes from
|
|
1217
|
+
`RemoteShellBreadcrumb`, so `PageHeader` holds no `Breadcrumbs`.
|
|
1218
|
+
|
|
1219
|
+
```tsx story=SettingsSection
|
|
1220
|
+
import { type MouseEvent, useState } from 'react';
|
|
1221
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
1222
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
1223
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, Settings, Users } from '@wallarm-org/design-system/icons';
|
|
1224
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
1225
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
1226
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
1227
|
+
import { RemoteShell, RemoteShellBreadcrumb, RemoteShellContent, RemoteShellPanel } from '@wallarm-org/design-system/RemoteShell';
|
|
1228
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
1229
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo } from '@wallarm-org/design-system/TopHeader';
|
|
1230
|
+
|
|
1231
|
+
export const SettingsSection = () => {
|
|
1232
|
+
const [pathname, setPathname] = useState('/settings/users');
|
|
1233
|
+
|
|
1234
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
1235
|
+
event.preventDefault();
|
|
1236
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
1237
|
+
};
|
|
1238
|
+
const handleNavigate = (to: string) => {
|
|
1239
|
+
onNavigate(to);
|
|
1240
|
+
setPathname(to);
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
const columns: TableColumnDef<Member>[] = [
|
|
1244
|
+
{ accessorKey: 'name', header: 'Name', size: 200 },
|
|
1245
|
+
{ accessorKey: 'email', header: 'Email', size: 280 },
|
|
1246
|
+
{ accessorKey: 'role', header: 'Role', size: 160 },
|
|
1247
|
+
];
|
|
1248
|
+
|
|
1249
|
+
return (
|
|
1250
|
+
<AppShell data-testid='app-shell'>
|
|
1251
|
+
<AppShellHeader>
|
|
1252
|
+
<TopHeader data-testid='top-header'>
|
|
1253
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
1254
|
+
<Logo size='md' />
|
|
1255
|
+
</TopHeaderLogo>
|
|
1256
|
+
<TopHeaderActions>
|
|
1257
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
1258
|
+
Acme Bank
|
|
1259
|
+
<ChevronUpDown />
|
|
1260
|
+
</Button>
|
|
1261
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
1262
|
+
<CircleHelp />
|
|
1263
|
+
</Button>
|
|
1264
|
+
</TopHeaderActions>
|
|
1265
|
+
</TopHeader>
|
|
1266
|
+
</AppShellHeader>
|
|
1267
|
+
|
|
1268
|
+
<AppShellRail>
|
|
1269
|
+
<NavRail mode='collapsed' data-testid='nav-rail'>
|
|
1270
|
+
<NavRailBody>
|
|
1271
|
+
<NavRailItem
|
|
1272
|
+
href='/'
|
|
1273
|
+
icon={HomeIcon}
|
|
1274
|
+
label='Home'
|
|
1275
|
+
shortcut={['G', 'H']}
|
|
1276
|
+
onClick={handleRailClick}
|
|
1277
|
+
data-testid='nav-rail-home'
|
|
1278
|
+
/>
|
|
1279
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
1280
|
+
<NavRailSeparator />
|
|
1281
|
+
{PRODUCTS.map(product => (
|
|
1282
|
+
<NavRailItem
|
|
1283
|
+
key={product.id}
|
|
1284
|
+
href={`/${product.id}`}
|
|
1285
|
+
icon={product.icon}
|
|
1286
|
+
label={product.label}
|
|
1287
|
+
shortcut={product.shortcut}
|
|
1288
|
+
onClick={handleRailClick}
|
|
1289
|
+
data-testid={`nav-rail-${product.id}`}
|
|
1290
|
+
/>
|
|
1291
|
+
))}
|
|
1292
|
+
</NavRailBody>
|
|
1293
|
+
<NavRailFooter>
|
|
1294
|
+
<NavRailItem
|
|
1295
|
+
href='/settings'
|
|
1296
|
+
icon={Settings}
|
|
1297
|
+
label='Settings'
|
|
1298
|
+
shortcut={['G', 'S']}
|
|
1299
|
+
active
|
|
1300
|
+
onClick={handleRailClick}
|
|
1301
|
+
data-testid='nav-rail-settings'
|
|
1302
|
+
/>
|
|
1303
|
+
</NavRailFooter>
|
|
1304
|
+
</NavRail>
|
|
1305
|
+
</AppShellRail>
|
|
1306
|
+
|
|
1307
|
+
<AppShellRemote role='main'>
|
|
1308
|
+
<RemoteShell
|
|
1309
|
+
config={SETTINGS_NAV}
|
|
1310
|
+
basePath='/settings'
|
|
1311
|
+
pathname={pathname}
|
|
1312
|
+
onNavigate={handleNavigate}
|
|
1313
|
+
data-testid='settings-shell'
|
|
1314
|
+
>
|
|
1315
|
+
<RemoteShellPanel />
|
|
1316
|
+
<RemoteShellBreadcrumb />
|
|
1317
|
+
<RemoteShellContent>
|
|
1318
|
+
<Page name='settings-users' fullSize fixedHeight data-testid='users-page'>
|
|
1319
|
+
<PageHeader>
|
|
1320
|
+
<PageHeaderGroup className='flex-1'>
|
|
1321
|
+
<PageTitle>Users</PageTitle>
|
|
1322
|
+
<PageDescription>
|
|
1323
|
+
People who can sign in to your organization, with access set by roles.
|
|
1324
|
+
</PageDescription>
|
|
1325
|
+
</PageHeaderGroup>
|
|
1326
|
+
<PageActions>
|
|
1327
|
+
<Button size='medium' onClick={onCreateUser}>
|
|
1328
|
+
Create user
|
|
1329
|
+
</Button>
|
|
1330
|
+
</PageActions>
|
|
1331
|
+
</PageHeader>
|
|
1332
|
+
<PageContent>
|
|
1333
|
+
<Table
|
|
1334
|
+
aria-label='Users'
|
|
1335
|
+
data={MEMBERS}
|
|
1336
|
+
columns={columns}
|
|
1337
|
+
data-testid='users-table'
|
|
1338
|
+
/>
|
|
1339
|
+
</PageContent>
|
|
1340
|
+
</Page>
|
|
1341
|
+
</RemoteShellContent>
|
|
1342
|
+
</RemoteShell>
|
|
1343
|
+
</AppShellRemote>
|
|
1344
|
+
</AppShell>
|
|
1345
|
+
);
|
|
1346
|
+
};
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
A `drill` node: the entity level, the back button and the scope switcher.
|
|
1350
|
+
|
|
1351
|
+
A `drill` node at `/edge/data-planes/production/services`: the panel shows the entity level
|
|
1352
|
+
with a back button, and the trail gets a scope switcher for the entity.
|
|
1353
|
+
|
|
1354
|
+
```tsx story=DrillDown
|
|
1355
|
+
import { type MouseEvent, useState } from 'react';
|
|
1356
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
1357
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
1358
|
+
import { ChevronUpDown, CircleHelp, History, Home as HomeIcon, Settings } from '@wallarm-org/design-system/icons';
|
|
1359
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
1360
|
+
import { NavRail, NavRailBody, NavRailFooter, NavRailItem, NavRailSeparator } from '@wallarm-org/design-system/NavRail';
|
|
1361
|
+
import { Page, PageContent, PageHeader, PageTitle } from '@wallarm-org/design-system/Page';
|
|
1362
|
+
import { RemoteShell, RemoteShellBreadcrumb, RemoteShellContent, RemoteShellPanel } from '@wallarm-org/design-system/RemoteShell';
|
|
1363
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
1364
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo } from '@wallarm-org/design-system/TopHeader';
|
|
1365
|
+
|
|
1366
|
+
export const DrillDown = () => {
|
|
1367
|
+
const [pathname, setPathname] = useState('/edge/data-planes/production/services');
|
|
1368
|
+
|
|
1369
|
+
const handleRailClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
1370
|
+
event.preventDefault();
|
|
1371
|
+
onRailNavigate(event.currentTarget.getAttribute('href'));
|
|
1372
|
+
};
|
|
1373
|
+
const handleNavigate = (to: string) => {
|
|
1374
|
+
onNavigate(to);
|
|
1375
|
+
setPathname(to);
|
|
1376
|
+
};
|
|
1377
|
+
|
|
1378
|
+
const columns: TableColumnDef<Service>[] = [
|
|
1379
|
+
{ accessorKey: 'name', header: 'Service', size: 200 },
|
|
1380
|
+
{ accessorKey: 'nodes', header: 'Nodes', size: 120 },
|
|
1381
|
+
{ accessorKey: 'upstream', header: 'Upstream', size: 280 },
|
|
1382
|
+
];
|
|
1383
|
+
|
|
1384
|
+
return (
|
|
1385
|
+
<AppShell data-testid='app-shell'>
|
|
1386
|
+
<AppShellHeader>
|
|
1387
|
+
<TopHeader data-testid='top-header'>
|
|
1388
|
+
<TopHeaderLogo href='/' onClick={handleRailClick}>
|
|
1389
|
+
<Logo size='md' />
|
|
1390
|
+
</TopHeaderLogo>
|
|
1391
|
+
<TopHeaderActions>
|
|
1392
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
1393
|
+
Acme Bank
|
|
1394
|
+
<ChevronUpDown />
|
|
1395
|
+
</Button>
|
|
1396
|
+
<Button variant='ghost' color='neutral' size='small' aria-label='Help'>
|
|
1397
|
+
<CircleHelp />
|
|
1398
|
+
</Button>
|
|
1399
|
+
</TopHeaderActions>
|
|
1400
|
+
</TopHeader>
|
|
1401
|
+
</AppShellHeader>
|
|
1402
|
+
|
|
1403
|
+
<AppShellRail>
|
|
1404
|
+
<NavRail mode='collapsed' data-testid='nav-rail'>
|
|
1405
|
+
<NavRailBody>
|
|
1406
|
+
<NavRailItem
|
|
1407
|
+
href='/'
|
|
1408
|
+
icon={HomeIcon}
|
|
1409
|
+
label='Home'
|
|
1410
|
+
shortcut={['G', 'H']}
|
|
1411
|
+
onClick={handleRailClick}
|
|
1412
|
+
data-testid='nav-rail-home'
|
|
1413
|
+
/>
|
|
1414
|
+
<NavRailItem href='/recent' icon={History} label='Recent' onClick={handleRailClick} />
|
|
1415
|
+
<NavRailSeparator />
|
|
1416
|
+
{PRODUCTS.map(product => (
|
|
1417
|
+
<NavRailItem
|
|
1418
|
+
key={product.id}
|
|
1419
|
+
href={`/${product.id}`}
|
|
1420
|
+
icon={product.icon}
|
|
1421
|
+
label={product.label}
|
|
1422
|
+
shortcut={product.shortcut}
|
|
1423
|
+
active={product.id === 'edge'}
|
|
1424
|
+
onClick={handleRailClick}
|
|
1425
|
+
data-testid={`nav-rail-${product.id}`}
|
|
1426
|
+
/>
|
|
1427
|
+
))}
|
|
1428
|
+
</NavRailBody>
|
|
1429
|
+
<NavRailFooter>
|
|
1430
|
+
<NavRailItem
|
|
1431
|
+
href='/settings'
|
|
1432
|
+
icon={Settings}
|
|
1433
|
+
label='Settings'
|
|
1434
|
+
shortcut={['G', 'S']}
|
|
1435
|
+
onClick={handleRailClick}
|
|
1436
|
+
data-testid='nav-rail-settings'
|
|
1437
|
+
/>
|
|
1438
|
+
</NavRailFooter>
|
|
1439
|
+
</NavRail>
|
|
1440
|
+
</AppShellRail>
|
|
1441
|
+
|
|
1442
|
+
<AppShellRemote role='main'>
|
|
1443
|
+
<RemoteShell
|
|
1444
|
+
config={EDGE_NAV}
|
|
1445
|
+
basePath='/edge'
|
|
1446
|
+
pathname={pathname}
|
|
1447
|
+
onNavigate={handleNavigate}
|
|
1448
|
+
data-testid='product-shell'
|
|
1449
|
+
>
|
|
1450
|
+
<RemoteShellPanel resizable />
|
|
1451
|
+
<RemoteShellBreadcrumb />
|
|
1452
|
+
<RemoteShellContent>
|
|
1453
|
+
<Page name='edge-services' fullSize fixedHeight data-testid='services-page'>
|
|
1454
|
+
<PageHeader>
|
|
1455
|
+
<PageTitle>Services</PageTitle>
|
|
1456
|
+
</PageHeader>
|
|
1457
|
+
<PageContent>
|
|
1458
|
+
<Table
|
|
1459
|
+
aria-label='Services'
|
|
1460
|
+
data={SERVICES}
|
|
1461
|
+
columns={columns}
|
|
1462
|
+
data-testid='services-table'
|
|
1463
|
+
/>
|
|
1464
|
+
</PageContent>
|
|
1465
|
+
</Page>
|
|
1466
|
+
</RemoteShellContent>
|
|
1467
|
+
</RemoteShell>
|
|
1468
|
+
</AppShellRemote>
|
|
1469
|
+
</AppShell>
|
|
1470
|
+
);
|
|
1471
|
+
};
|
|
1472
|
+
```
|
|
1473
|
+
|
|
1474
|
+
Loading: rail and header skeletons, product panel rows and a content loader.
|
|
1475
|
+
|
|
1476
|
+
While the host loads the user and the product list, skeletons sit where the header actions
|
|
1477
|
+
and rail items land. While a product loads, its panel shows skeleton rows under the product
|
|
1478
|
+
name and its content shows a loader.
|
|
1479
|
+
|
|
1480
|
+
```tsx story=Loading
|
|
1481
|
+
import { AppShell, AppShellHeader, AppShellRail, AppShellRemote } from '@wallarm-org/design-system/AppShell';
|
|
1482
|
+
import { Home as HomeIcon } from '@wallarm-org/design-system/icons';
|
|
1483
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
1484
|
+
import { NavRail, NavRailBody, NavRailItem, NavRailSeparator, NavRailSkeleton } from '@wallarm-org/design-system/NavRail';
|
|
1485
|
+
import { RemoteShell, RemoteShellContent, RemoteShellPanel } from '@wallarm-org/design-system/RemoteShell';
|
|
1486
|
+
import { Skeleton } from '@wallarm-org/design-system/Skeleton';
|
|
1487
|
+
import { TopHeader, TopHeaderActions, TopHeaderLogo, TopHeaderSeparator } from '@wallarm-org/design-system/TopHeader';
|
|
1488
|
+
|
|
1489
|
+
export const Loading = () => (
|
|
1490
|
+
<AppShell data-testid='app-shell'>
|
|
1491
|
+
<AppShellHeader>
|
|
1492
|
+
<TopHeader data-testid='top-header'>
|
|
1493
|
+
<TopHeaderLogo href='/'>
|
|
1494
|
+
<Logo size='md' />
|
|
1495
|
+
</TopHeaderLogo>
|
|
1496
|
+
<TopHeaderActions>
|
|
1497
|
+
<Skeleton width='120px' height='20px' rounded={6} />
|
|
1498
|
+
<TopHeaderSeparator />
|
|
1499
|
+
<Skeleton width='60px' height='20px' rounded={6} />
|
|
1500
|
+
</TopHeaderActions>
|
|
1501
|
+
</TopHeader>
|
|
1502
|
+
</AppShellHeader>
|
|
1503
|
+
|
|
1504
|
+
<AppShellRail>
|
|
1505
|
+
<NavRail mode='collapsed' data-testid='nav-rail'>
|
|
1506
|
+
<NavRailBody>
|
|
1507
|
+
<NavRailItem href='/' icon={HomeIcon} label='Home' shortcut={['G', 'H']} />
|
|
1508
|
+
<NavRailSeparator />
|
|
1509
|
+
<NavRailSkeleton />
|
|
1510
|
+
</NavRailBody>
|
|
1511
|
+
</NavRail>
|
|
1512
|
+
</AppShellRail>
|
|
1513
|
+
|
|
1514
|
+
<AppShellRemote role='main'>
|
|
1515
|
+
<RemoteShell
|
|
1516
|
+
config={EDGE_NAV}
|
|
1517
|
+
basePath='/edge'
|
|
1518
|
+
pathname='/edge'
|
|
1519
|
+
onNavigate={onNavigate}
|
|
1520
|
+
data-testid='product-shell'
|
|
1521
|
+
>
|
|
1522
|
+
<RemoteShellPanel isLoading />
|
|
1523
|
+
<RemoteShellContent isLoading />
|
|
1524
|
+
</RemoteShell>
|
|
1525
|
+
</AppShellRemote>
|
|
1526
|
+
</AppShell>
|
|
1527
|
+
);
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
## States
|
|
1531
|
+
|
|
1532
|
+
| State | Show | Example component |
|
|
1533
|
+
| --- | --- | --- |
|
|
1534
|
+
| Cold start | Splash, then the shell | `SplashScreen`, `AppShell reveal` |
|
|
1535
|
+
| Host data loading | Skeletons where header actions and rail items land | `Skeleton`, `NavRailSkeleton` |
|
|
1536
|
+
| Product bundle loading | Splash in `AppShellRemote` | `SplashScreen` |
|
|
1537
|
+
| Product data loading | Product name and skeleton rows in the panel; loader in content | `RemoteShellPanel isLoading`, `RemoteShellContent isLoading` |
|
|
1538
|
+
| Page data loading | Real `PageHeader`, skeletons in content | `Table isLoading` |
|
|
1539
|
+
| Page or request failed | Shell stays; your message in `PageContent` | App-rendered |
|
|
1540
|
+
| Product bundle failed | Shell stays; your message in `AppShellRemote` | App-rendered |
|
|
1541
|
+
| Unknown URL, server down, offline, no tenant access | Replace the whole shell | `UtilityPage` |
|
|
1542
|
+
| No access to one product or page | Leave it out of the rail or `NavConfig` | `NavConfig` |
|
|
1543
|
+
|
|
1544
|
+
## What your app owns
|
|
1545
|
+
|
|
1546
|
+
| Concern | Rule |
|
|
1547
|
+
| --- | --- |
|
|
1548
|
+
| Router wiring | `pathname` from the router, `onNavigate={to => navigate({ to })}` |
|
|
1549
|
+
| Rail mode | Store the user's preference; "adaptive" (expanded on Home, collapsed in a product) is your logic |
|
|
1550
|
+
| Product list | From the microfrontends API; rail items with `href`, `label`, `icon` and a `shortcut` chord |
|
|
1551
|
+
| Recent and account menus | Your `DropdownMenu` compositions |
|
|
1552
|
+
| Notifications | Data, unread count, mark-read logic, the preferences page |
|
|
1553
|
+
| Permissions | Leave forbidden products and entries out of the rail and `NavConfig` |
|
|
1554
|
+
| Errors | An error boundary in `AppShellRemote` and in the product's content |
|
|
1555
|
+
| Prefetch on hover | `onPointerOver` and `onFocus` on `RemoteShellPanel` |
|
|
1556
|
+
| Panel width | `resizable` keeps it in memory only; it resets on remount |
|
|
1557
|
+
| Drill labels | `entities` are static; pass fresh ones in `NavConfig` when data changes |
|
|
1558
|
+
| Test IDs | Panel items and crumbs have none; use roles inside `{shell}--panel` and `{shell}--breadcrumb` |
|
|
1559
|
+
|
|
1560
|
+
## Related
|
|
1561
|
+
|
|
1562
|
+
- [Spacing](../foundations/spacing.md)
|
|
1563
|
+
- [Layering](../foundations/layering.md)
|
|
1564
|
+
- [Resource list page](./resource-list-page.md)
|
|
1565
|
+
- [Settings page](./settings-page.md)
|
|
1566
|
+
- [Empty states](./empty-states.md)
|
|
1567
|
+
- [Auth page](./auth-page.md)
|