oneslash-design-system 2.18.0 → 2.19.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/README.md +1 -1
- package/dist/DESIGN.md +26 -1
- package/dist/cases/app-shell/sidebar.d.ts +1 -0
- package/dist/cases/app-shell/sidebar.jsx +124 -0
- package/dist/cases/app-shell/top-tabs.d.ts +1 -0
- package/dist/cases/app-shell/top-tabs.jsx +106 -0
- package/dist/cases/app-shell.md +364 -0
- package/dist/cases/artifact-card/card.jsx +32 -6
- package/dist/cases/artifact-card.md +55 -7
- package/dist/cases/error-page/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -21
- package/dist/cases/master-detail/list-then-page.d.ts +1 -0
- package/dist/cases/master-detail/list-then-page.jsx +65 -0
- package/dist/cases/master-detail/split.d.ts +1 -0
- package/dist/cases/master-detail/split.jsx +49 -0
- package/dist/cases/master-detail.md +213 -0
- package/dist/cases/mobile-menu/links.d.ts +1 -0
- package/dist/cases/mobile-menu/links.jsx +24 -0
- package/dist/cases/mobile-menu/sections.d.ts +1 -0
- package/dist/cases/mobile-menu/sections.jsx +61 -0
- package/dist/cases/mobile-menu.md +170 -0
- package/dist/cases/not-found-page/in-shell.jsx +26 -17
- package/dist/cases/not-found-page.md +41 -20
- package/dist/cases/on-this-page/aside.d.ts +1 -0
- package/dist/cases/on-this-page/aside.jsx +39 -0
- package/dist/cases/on-this-page.md +80 -0
- package/dist/cases/page-header/actions.d.ts +1 -0
- package/dist/cases/page-header/actions.jsx +65 -0
- package/dist/cases/page-header/sub-page.d.ts +1 -0
- package/dist/cases/page-header/sub-page.jsx +37 -0
- package/dist/cases/page-header.md +195 -0
- package/dist/cases/phone-navigation.md +32 -0
- package/dist/cases/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -21
- package/dist/cases/side-pane/beside.d.ts +1 -0
- package/dist/cases/side-pane/beside.jsx +79 -0
- package/dist/cases/side-pane/over.d.ts +1 -0
- package/dist/cases/side-pane/over.jsx +58 -0
- package/dist/cases/side-pane.md +238 -0
- package/dist/cases/sidebar-nav/flat.d.ts +1 -0
- package/dist/cases/sidebar-nav/flat.jsx +81 -0
- package/dist/cases/sidebar-nav/nested.d.ts +1 -0
- package/dist/cases/sidebar-nav/nested.jsx +122 -0
- package/dist/cases/sidebar-nav.md +261 -0
- package/dist/cases/site-footer/columns.d.ts +1 -0
- package/dist/cases/site-footer/columns.jsx +51 -0
- package/dist/cases/site-footer/simple.d.ts +1 -0
- package/dist/cases/site-footer/simple.jsx +24 -0
- package/dist/cases/site-footer.md +133 -0
- package/dist/cases/site-header/links.d.ts +1 -0
- package/dist/cases/site-header/links.jsx +26 -0
- package/dist/cases/site-header/sections.d.ts +1 -0
- package/dist/cases/site-header/sections.jsx +64 -0
- package/dist/cases/site-header.md +183 -0
- package/dist/cases/theme-switcher/menu.d.ts +1 -0
- package/dist/cases/theme-switcher/menu.jsx +47 -0
- package/dist/cases/theme-switcher/segmented.d.ts +1 -0
- package/dist/cases/theme-switcher/segmented.jsx +26 -0
- package/dist/cases/theme-switcher.md +149 -0
- package/dist/cases.json +666 -19
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/link.d.ts +6 -1
- package/dist/components/link.jsx +11 -3
- package/dist/components/menuItem.d.ts +7 -1
- package/dist/components/menuItem.jsx +4 -3
- package/dist/components/modal.jsx +12 -23
- package/dist/components/onThisPage.d.ts +29 -0
- package/dist/components/onThisPage.jsx +151 -0
- package/dist/components/pageShell.d.ts +7 -1
- package/dist/components/pageShell.jsx +14 -1
- package/dist/components/popover.jsx +4 -0
- package/dist/components/settingsSection.d.ts +6 -1
- package/dist/components/settingsSection.jsx +10 -3
- package/dist/components/sidePane.d.ts +32 -0
- package/dist/components/sidePane.jsx +128 -0
- package/dist/components/siteFooter.d.ts +24 -0
- package/dist/components/siteFooter.jsx +48 -0
- package/dist/components/siteHeader.d.ts +55 -0
- package/dist/components/siteHeader.jsx +125 -0
- package/dist/components/titleBar.d.ts +17 -0
- package/dist/components/titleBar.jsx +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/internal/overlayStack.d.ts +24 -0
- package/dist/internal/overlayStack.js +71 -0
- package/dist/internal/resize.d.ts +9 -0
- package/dist/internal/resize.js +31 -0
- package/dist/internal/scrollSpy.d.ts +24 -0
- package/dist/internal/scrollSpy.js +53 -0
- package/dist/internal/siteBrand.d.ts +6 -0
- package/dist/internal/siteBrand.jsx +11 -0
- package/dist/native-mapping.json +43 -1
- package/dist/stories/AppShell.stories.d.ts +15 -0
- package/dist/stories/AppShell.stories.jsx +137 -0
- package/dist/stories/Cases.generated.stories.d.ts +19 -0
- package/dist/stories/Cases.generated.stories.jsx +38 -0
- package/dist/stories/Drawer.stories.d.ts +10 -0
- package/dist/stories/Drawer.stories.jsx +123 -0
- package/dist/stories/Link.stories.d.ts +1 -0
- package/dist/stories/Link.stories.jsx +8 -0
- package/dist/stories/OnThisPage.stories.d.ts +10 -0
- package/dist/stories/OnThisPage.stories.jsx +105 -0
- package/dist/stories/SettingsSection.stories.d.ts +1 -0
- package/dist/stories/SettingsSection.stories.jsx +27 -0
- package/dist/stories/SidePane.stories.d.ts +6 -0
- package/dist/stories/SidePane.stories.jsx +37 -0
- package/dist/stories/SiteFooter.stories.d.ts +7 -0
- package/dist/stories/SiteFooter.stories.jsx +63 -0
- package/dist/stories/SiteHeader.stories.d.ts +10 -0
- package/dist/stories/SiteHeader.stories.jsx +94 -0
- package/dist/stories/TitleBar.stories.d.ts +6 -0
- package/dist/stories/TitleBar.stories.jsx +34 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
|
70
70
|
|
|
71
71
|
## Design cases
|
|
72
72
|
|
|
73
|
-
A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.
|
|
73
|
+
A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.19.0 has 85: twelve rules and 73 design cases for auth pages, confirms and modals, states, chat and agent interfaces, settings and menus, shells and navigation.
|
|
74
74
|
|
|
75
75
|
- `oneslash-design-system/cases.json` lists every case with its rule text, options, Do and Don't lines, and the source of each example.
|
|
76
76
|
- `oneslash-design-system/cases/<id>.md` is one case as text, and `oneslash-design-system/cases/<id>/<option>.jsx` is the example itself.
|
package/dist/DESIGN.md
CHANGED
|
@@ -292,11 +292,13 @@ For each web component, the table gives the native control to use. System contro
|
|
|
292
292
|
| ODS | SwiftUI | Compose | Note |
|
|
293
293
|
| --- | --- | --- | --- |
|
|
294
294
|
| alert | `ODSBanner` for an inline message; `.alert` for one that needs a decision | `OdsBanner` for an inline message; `AlertDialog` for one that needs a decision | ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`. |
|
|
295
|
+
| appShell | `NavigationSplitView` with the sidebar, the content and an `.inspector`; on iPhone a `NavigationStack`, or a `TabView` of five places or fewer | `NavigationSuiteScaffold`; on a phone a `ModalNavigationDrawer` around a `Scaffold` | The split view collapses to a stack on iPhone and shows and hides the sidebar itself. The skip link is web only. |
|
|
295
296
|
| button | `Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary | `Button`, `OutlinedButton` | Tertiary and text-only: `.borderless` / `TextButton`. On Apple, apply `.odsProminentButton()` to every prominent button. Under `odsTheme` the label of a `.borderedProminent` or `.glassProminent` button takes `text.primary`, not the system white, which is below 4.5:1 on the accent in default dark, forest light, forest dark, clay dark, indigo light, indigo dark, wine light, wine dark. In forest light it is the same color as the fill, so the label cannot be seen. The modifier keeps the system style and sets the label to `accent.contrast`. Compose needs nothing: `onPrimary` is `accent.contrast`. |
|
|
296
297
|
| brandIcon | the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app | an asset in the app | |
|
|
297
298
|
| checkBox | `Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS) | `Checkbox` | |
|
|
298
299
|
| composer | `TextField(_:text:axis: .vertical)` with `.lineLimit(1...6)` over a toolbar `HStack` of the tool `Button`s and a send `Button` | `OutlinedTextField` with `maxLines = 6` over a `Row` of the tool `IconButton`s and a send `IconButton` | On iPhone and Android, Return adds a line and the send button sends. While an agent works, send becomes Stop. |
|
|
299
300
|
| copyField | A `LabeledContent` row with the value in a `Text` (`.textSelection(.enabled)`) and a `Button` that sets `UIPasteboard` / `NSPasteboard` | An `OutlinedTextField` with `readOnly = true` and a `trailingIcon` `TextButton` that calls `LocalClipboard` | Show "Copied" for 2 seconds only after the write succeeds. Announce it for VoiceOver / TalkBack. A secret shown once gets the line under it. |
|
|
301
|
+
| drawer | `.sheet` with `.presentationDetents` on iPhone; `.inspector` on iPad and Mac | `ModalNavigationDrawer` for `side="start"`; `ModalBottomSheet` for `side="end"` | The system sheet, inspector and drawer handle the scrim, swipe to close and focus. `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
300
302
|
| emptyBox | `ContentUnavailableView` | `OdsEmptyState` | The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does. |
|
|
301
303
|
| factsRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `LabeledContent` rows in a `Form` / `ListItem` rows. |
|
|
302
304
|
| figure | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: an `Image` with a caption `Text` in the caption text style. |
|
|
@@ -319,6 +321,7 @@ For each web component, the table gives the native control to use. System contro
|
|
|
319
321
|
| modal | `.sheet` or `.alert` | `ModalBottomSheet` or `AlertDialog` | `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
320
322
|
| navigation | `NavigationSplitView` with a sidebar `List` | `NavigationRail` or `ModalNavigationDrawer` with `NavigationDrawerItem` | |
|
|
321
323
|
| numberedRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: rows of a `List` / `ListItem`s. |
|
|
324
|
+
| onThisPage | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. A long screen is a `List` in sections. |
|
|
322
325
|
| pageHeader | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `.navigationTitle` / `TopAppBar`. |
|
|
323
326
|
| pageShell | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `NavigationStack` / `Scaffold`. |
|
|
324
327
|
| paragraph | `Text` with `.font(.body)` | `Text` with `MaterialTheme.typography.bodyLarge` | |
|
|
@@ -327,7 +330,10 @@ For each web component, the table gives the native control to use. System contro
|
|
|
327
330
|
| sectionIntro | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Section` header in a `List` or `Form` / a heading `Text`. |
|
|
328
331
|
| segmentedControl | `Picker` with `.pickerStyle(.segmented)` | `SingleChoiceSegmentedButtonRow` with `SegmentedButton` | It sets a value on the same screen. To switch panels use `TabView` / `PrimaryTabRow`. Give the picker an accessibility label. |
|
|
329
332
|
| select | `Picker` or `Menu` | `ExposedDropdownMenuBox` | |
|
|
330
|
-
| settingsSection | A `Section` with a header `Text` and footer `Text` in a grouped `Form` | A `Column` with a title `Text`, a supporting `Text` and the controls under a `HorizontalDivider` | A danger zone gets its own `Section` with the error color on the header. Settings Columns is a screen layout: one column on a phone. For Settings Layout, on a phone the nav is its own screen, pushed with `NavigationStack` / `NavHost`. |
|
|
333
|
+
| settingsSection | A `Section` with a header `Text` and footer `Text` in a grouped `Form` | A `Column` with a title `Text`, a supporting `Text` and the controls under a `HorizontalDivider` | A danger zone gets its own `Section` with the error color on the header. Settings Columns is a screen layout: one column on a phone. For Settings Layout, on a phone the nav is its own screen, pushed with `NavigationStack` / `NavHost`. `navWidth="wide"` (a list beside its detail) is a `NavigationSplitView` list column / `ListDetailPaneScaffold`. |
|
|
334
|
+
| sidePane | `.inspector(isPresented:)` with `.inspectorColumnWidth(min:ideal:max:)` | `SupportingPaneScaffold` | The system resizes the inspector on iPad and Mac and shows it as a sheet on iPhone. `SupportingPaneScaffold` is in the Material 3 adaptive library and needs `@OptIn(ExperimentalMaterial3AdaptiveApi::class)`. |
|
|
335
|
+
| siteFooter | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. An app has no footer: its links live in Settings, as rows. |
|
|
336
|
+
| siteHeader | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. In an app: `NavigationStack` with a toolbar, and a `TabView` or `NavigationSuiteScaffold` for the places. |
|
|
331
337
|
| sourceCard | `Link` or `Button` with a `Label` (icon, title) and the meta as a secondary line | A `Card` with `onClick`, or a `ListItem` with a leading `Icon` | With no destination it is a plain `Label`, not a button. |
|
|
332
338
|
| stepList | A `List` of `Label`s with an SF Symbol per status (`circle`, `checkmark.circle.fill`, `xmark.circle.fill`, `minus.circle`); `ProgressView` for the running one | A `Column` of `ListItem`s with an `Icon` per status; `CircularProgressIndicator` for the running one | Give each row a status text for VoiceOver / TalkBack, not color alone. |
|
|
333
339
|
| surface | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Form` section or `GroupBox` / `Card`. |
|
|
@@ -343,6 +349,7 @@ For each web component, the table gives the native control to use. System contro
|
|
|
343
349
|
| textarea | `TextField(_:text:axis: .vertical)` or `TextEditor` | `OutlinedTextField` with `minLines` | |
|
|
344
350
|
| textField | `TextField` (`SecureField` for passwords) | `OutlinedTextField` or `TextField` | |
|
|
345
351
|
| timeStamp | `Text(_:style:)` (`.relative`) or `Text(_:format:)` (`.dateTime`) | `Text` with `DateUtils.getRelativeTimeSpanString` or `DateTimeFormatter.ofLocalizedDateTime` | |
|
|
352
|
+
| titleBar | `.navigationTitle` with `.toolbar` items | `TopAppBar` with `navigationIcon` and `actions` | The main action stays in the toolbar; the rest go in a `Menu` / an overflow `DropdownMenu`. |
|
|
346
353
|
| toaster | `ODSBanner` for an inline message; a system banner (a local notification) when the app is not in front | `Snackbar` in a `SnackbarHost` | SwiftUI has no toast, so ODS adds none: show the message in the screen. |
|
|
347
354
|
| tooltip | `.help` | `TooltipBox` | `.help` shows on pointer hover only. `TooltipBox` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
348
355
|
| userImage | `ODSAvatar` | `OdsAvatar` | Load the picture yourself and pass it as an `Image` / a `Painter`. |
|
|
@@ -460,6 +467,14 @@ Answer: A problem with one field shows under that field, through the field's `er
|
|
|
460
467
|
|
|
461
468
|
File: cases/form-errors.md
|
|
462
469
|
|
|
470
|
+
### On a phone, a sidebar opens as a drawer and a list opens its detail
|
|
471
|
+
|
|
472
|
+
A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.
|
|
473
|
+
|
|
474
|
+
Answer: An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.
|
|
475
|
+
|
|
476
|
+
File: cases/phone-navigation.md
|
|
477
|
+
|
|
463
478
|
### A setting saves in place, or with one Save Button
|
|
464
479
|
|
|
465
480
|
A person changes a setting.
|
|
@@ -486,6 +501,7 @@ File: cases/success-feedback.md
|
|
|
486
501
|
| Agent question | The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'. | cases/agent-question.md |
|
|
487
502
|
| Agent settings | An admin sets which model the agent uses, how it picks one, what it should know about the team and how much it may spend. | cases/agent-settings.md |
|
|
488
503
|
| API keys | A person makes keys that let a script or a service use the product as them, and revokes keys they no longer use. | cases/api-keys.md |
|
|
504
|
+
| App shell | A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page. | cases/app-shell.md |
|
|
489
505
|
| Document card | The agent made a document for the person, such as a plan or a report. | cases/artifact-card.md |
|
|
490
506
|
| Login check loading | The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show. | cases/auth-gate-loading.md |
|
|
491
507
|
| Check your email | A person signed up, and the product sent a link to confirm their email. | cases/check-your-email.md |
|
|
@@ -511,6 +527,7 @@ File: cases/success-feedback.md
|
|
|
511
527
|
| Load failure | A list or a section could not load. | cases/load-failure.md |
|
|
512
528
|
| Log-out confirm | A person chooses Log Out. | cases/log-out-confirm.md |
|
|
513
529
|
| Login page | A person who already has an account opens the product and is not logged in. | cases/login-page.md |
|
|
530
|
+
| List and detail | A person opens an item from a list, such as a message or a report, and reads or acts on it. | cases/master-detail.md |
|
|
514
531
|
| Members | An admin sees who is in the workspace, changes their roles, removes people and invites more. | cases/members-list.md |
|
|
515
532
|
| Mention list | A person types @ in the message box to name someone, or the agent. | cases/mention-list.md |
|
|
516
533
|
| Message actions | A person acts on one message: reacts to it, copies it, edits or deletes it. | cases/message-actions.md |
|
|
@@ -519,11 +536,14 @@ File: cases/success-feedback.md
|
|
|
519
536
|
| Message edit | A person changes the text of a message they sent. | cases/message-edit.md |
|
|
520
537
|
| Reactions | People answer a message with an emoji instead of a reply. | cases/message-reactions.md |
|
|
521
538
|
| Message row | A thread shows messages from people, and sometimes from an agent. | cases/message-row.md |
|
|
539
|
+
| Menu on a phone | A site's links and actions do not fit in the bar on a phone, and the person still needs to reach every one. | cases/mobile-menu.md |
|
|
522
540
|
| Page not found | A person opens a link to a page that does not exist. | cases/not-found-page.md |
|
|
523
541
|
| Notification setting | A person chooses how much a channel or a thread notifies them. | cases/notification-menu.md |
|
|
524
542
|
| OAuth consent | Another app, such as a CLI or an MCP client, asks to act for a person who is logged in, and the person must allow it. | cases/oauth-consent.md |
|
|
525
543
|
| On and off settings | A person turns things on and off, such as which notifications they get. | cases/on-off-settings.md |
|
|
544
|
+
| On this page | A person reads a long page and wants to see its sections, jump to one and know which one they are in. | cases/on-this-page.md |
|
|
526
545
|
| More menu | A person opens a menu of less common actions, behind one button, for a thing or for the page. | cases/overflow-menu.md |
|
|
546
|
+
| Page header with actions | A page names itself at the top and offers what the person can do with it. | cases/page-header.md |
|
|
527
547
|
| Profile | A person changes how they appear and how they sign in: their picture, their name and their password. | cases/profile-form.md |
|
|
528
548
|
| Quick switcher | A person jumps to a channel, task or document by typing part of its name, from anywhere in the product. | cases/quick-switcher.md |
|
|
529
549
|
| Range switch | A person changes the time range of a chart or a list on the same page, such as Week, Month or Quarter. | cases/range-switch.md |
|
|
@@ -534,9 +554,14 @@ File: cases/success-feedback.md
|
|
|
534
554
|
| Scope picker | A person chooses where a search or a question looks, such as one workspace or all of them. | cases/scope-picker.md |
|
|
535
555
|
| Set new password | A person opened the link to reset their password and now chooses a new one. | cases/set-new-password.md |
|
|
536
556
|
| Settings page | A person opens the settings of the product and looks for one area, such as Profile or Billing. | cases/settings-page.md |
|
|
557
|
+
| Side pane | A person opens more about the page, such as its members, its history or a document, without leaving the page. | cases/side-pane.md |
|
|
558
|
+
| Sidebar with sections and counts | A person looks down the sidebar for a place, and for what has something new in it. | cases/sidebar-nav.md |
|
|
537
559
|
| Sign-up page | A person who has no account yet opens the product and wants one. | cases/sign-up-page.md |
|
|
560
|
+
| Site footer | A person reaches the end of a site's page and looks for the pages that are not in the header, and who runs the site. | cases/site-footer.md |
|
|
561
|
+
| Site header | A site's pages name the site at the top and show the person where to go and what to do next. | cases/site-header.md |
|
|
538
562
|
| Command list | A person types / at the start of the message box to run a command. | cases/slash-command-list.md |
|
|
539
563
|
| Tag filter | A person filters a list by a tag, and adds, renames and deletes the tags themselves. | cases/tag-filter.md |
|
|
564
|
+
| Theme switcher | A person chooses between a light page, a dark page, or the one their device uses. | cases/theme-switcher.md |
|
|
540
565
|
| Type to confirm | A person asks to delete something large that cannot be brought back, such as a workspace or an account. | cases/type-to-confirm.md |
|
|
541
566
|
| Typing line | Other people in the thread are writing a message that has not arrived yet. | cases/typing-and-status.md |
|
|
542
567
|
| Unsaved changes | A person closes or leaves something they changed and did not save. | cases/unsaved-changes-guard.md |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AppShellSidebar(): import("react").JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import AppShell from '../../components/appShell';
|
|
4
|
+
import TitleBar from '../../components/titleBar';
|
|
5
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
6
|
+
import MenuItem from '../../components/menuItem';
|
|
7
|
+
import Modal from '../../components/modal';
|
|
8
|
+
import Heading from '../../components/heading';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import UserImage from '../../components/userImage';
|
|
12
|
+
import Popover from '../../components/popover';
|
|
13
|
+
import Menu from '../../components/menu';
|
|
14
|
+
import Line from '../../components/line';
|
|
15
|
+
import useHotkey from '../../components/useHotkey';
|
|
16
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
17
|
+
// The places. The top bar on a phone names the place; the page's own title is the level 1 heading, so a phone never shows the same words twice.
|
|
18
|
+
var places = [
|
|
19
|
+
{ id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
|
|
20
|
+
{ id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail', page: 'Sent this week', text: 'You sent 4 messages this week.' },
|
|
21
|
+
{ id: 'website', label: 'Website', icon: 'Globe', group: 'Projects', page: 'Home page redesign', text: '12 tasks are open. The next review is on Thursday.' },
|
|
22
|
+
{ id: 'mobile', label: 'Mobile App', icon: 'Smartphone', group: 'Projects', page: 'Version 2 release', text: '5 tasks are open. Dana Lee owns the release.' },
|
|
23
|
+
];
|
|
24
|
+
var groups = ['Mail', 'Projects'];
|
|
25
|
+
// A real app reads this from the session.
|
|
26
|
+
var me = 'Dana Lee';
|
|
27
|
+
export default function AppShellSidebar() {
|
|
28
|
+
var _a;
|
|
29
|
+
var _b = useState('inbox'), placeId = _b[0], setPlaceId = _b[1];
|
|
30
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
31
|
+
var _c = useState(false), navOpen = _c[0], setNavOpen = _c[1];
|
|
32
|
+
// From md up the person can hide the column for room. The phone menu still has it.
|
|
33
|
+
var _d = useState(false), hidden = _d[0], setHidden = _d[1];
|
|
34
|
+
var _e = useState(null), accountAnchor = _e[0], setAccountAnchor = _e[1];
|
|
35
|
+
var _f = useState(false), accountOpen = _f[0], setAccountOpen = _f[1];
|
|
36
|
+
var _g = useState(false), confirming = _g[0], setConfirming = _g[1];
|
|
37
|
+
var _h = useState(false), loggingOut = _h[0], setLoggingOut = _h[1];
|
|
38
|
+
var _j = useState(false), loggedOut = _j[0], setLoggedOut = _j[1];
|
|
39
|
+
var timer = useRef();
|
|
40
|
+
var accountButton = useRef(null);
|
|
41
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
42
|
+
var focusNext = useRef();
|
|
43
|
+
// Stops the request if the example goes away before it ends.
|
|
44
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
var move = focusNext.current;
|
|
47
|
+
focusNext.current = undefined;
|
|
48
|
+
move === null || move === void 0 ? void 0 : move();
|
|
49
|
+
});
|
|
50
|
+
// Cmd+B, or Ctrl+B. It does nothing while the person types in a field, and nothing while the Log Out confirm is open.
|
|
51
|
+
useHotkey('b', function () {
|
|
52
|
+
if (!confirming)
|
|
53
|
+
setHidden(function (h) { return !h; });
|
|
54
|
+
});
|
|
55
|
+
var place = (_a = places.find(function (p) { return p.id === placeId; })) !== null && _a !== void 0 ? _a : places[0];
|
|
56
|
+
// Cancel, Escape and a click outside. 'Cancel' puts focus back on the account Button, inside the Drawer on a phone.
|
|
57
|
+
function cancelLogOut() {
|
|
58
|
+
if (loggingOut)
|
|
59
|
+
return;
|
|
60
|
+
setConfirming(false);
|
|
61
|
+
focusNext.current = function () { var _a; return (_a = accountButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
62
|
+
}
|
|
63
|
+
function logOut() {
|
|
64
|
+
if (loggingOut)
|
|
65
|
+
return;
|
|
66
|
+
setLoggingOut(true);
|
|
67
|
+
// Stands in for the request to the server.
|
|
68
|
+
timer.current = setTimeout(function () {
|
|
69
|
+
setLoggingOut(false);
|
|
70
|
+
setConfirming(false);
|
|
71
|
+
setLoggedOut(true);
|
|
72
|
+
}, 1200);
|
|
73
|
+
}
|
|
74
|
+
// A real app goes to its login page here. The example shows a short logged-out page instead.
|
|
75
|
+
if (loggedOut) {
|
|
76
|
+
return (<Center fill>
|
|
77
|
+
<Heading level={1} size="h5">You are logged out</Heading>
|
|
78
|
+
<Cluster>
|
|
79
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { setLoggedOut(false); setPlaceId('inbox'); }}/>
|
|
80
|
+
</Cluster>
|
|
81
|
+
</Center>);
|
|
82
|
+
}
|
|
83
|
+
// The sidebar is mounted once: in the column from md up, in the Drawer below it. Its Modal lives inside it.
|
|
84
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
85
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
86
|
+
{groups.map(function (group) { return (<NavigationGroup key={group} label={group}>
|
|
87
|
+
{places.filter(function (p) { return p.group === group; }).map(function (p) { return (<MenuItem key={p.id} size="small" label={p.label} iconName={p.icon} href={"/".concat(p.id)} isSelected={p.id === place.id} aria-current={p.id === place.id ? 'page' : undefined} onClick={function (event) {
|
|
88
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
setPlaceId(p.id);
|
|
91
|
+
}}/>); })}
|
|
92
|
+
</NavigationGroup>); })}
|
|
93
|
+
<Line />
|
|
94
|
+
{/* The account menu is last. */}
|
|
95
|
+
<Cluster>
|
|
96
|
+
<Button ref={accountButton} size="small" type="tertiary" state={accountOpen ? 'selected' : 'enabled'} label={me} decoIcon={<UserImage userHandle={me} size={20} decorative/>} aria-label={"".concat(me, ", account menu")} aria-haspopup="menu" aria-expanded={accountOpen} onClickButton={function (e) {
|
|
97
|
+
setAccountAnchor(e.currentTarget);
|
|
98
|
+
setAccountOpen(function (o) { return !o; });
|
|
99
|
+
}}/>
|
|
100
|
+
</Cluster>
|
|
101
|
+
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={function () { return setAccountOpen(false); }} returnFocus>
|
|
102
|
+
<Menu navigable aria-label="Account" width={200}>
|
|
103
|
+
{/* A choice in a Popover does not close the phone menu: close it here. */}
|
|
104
|
+
<MenuItem size="small" iconName="Settings" label="Settings" onClick={function () { setAccountOpen(false); setNavOpen(false); }}/>
|
|
105
|
+
<MenuItem size="small" iconName="CircleHelp" label="Help" onClick={function () { setAccountOpen(false); setNavOpen(false); }}/>
|
|
106
|
+
<Line />
|
|
107
|
+
<MenuItem size="small" iconName="LogOut" label="Log Out" onClick={function () { setAccountOpen(false); setConfirming(true); }}/>
|
|
108
|
+
</Menu>
|
|
109
|
+
</Popover>
|
|
110
|
+
<Modal isOpen={confirming} size="small" title="Log Out" onClose={cancelLogOut} actions={<>
|
|
111
|
+
<Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut}/>
|
|
112
|
+
<Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut}/>
|
|
113
|
+
</>}>
|
|
114
|
+
<Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
|
|
115
|
+
</Modal>
|
|
116
|
+
</Navigation>);
|
|
117
|
+
var newMessage = <Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus"/>;
|
|
118
|
+
return (<AppShell title={place.label} navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} sidebarHidden={hidden} onSidebarHiddenChange={setHidden}>
|
|
119
|
+
<Stack gap="large">
|
|
120
|
+
<TitleBar title={place.page} actions={newMessage}/>
|
|
121
|
+
<Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
|
|
122
|
+
</Stack>
|
|
123
|
+
</AppShell>);
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AppShellTopTabs(): import("react").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import TitleBar from '../../components/titleBar';
|
|
4
|
+
import TabsContainer from '../../components/tabsContainer';
|
|
5
|
+
import Tab from '../../components/tab';
|
|
6
|
+
import Modal from '../../components/modal';
|
|
7
|
+
import Heading from '../../components/heading';
|
|
8
|
+
import Paragraph from '../../components/paragraph';
|
|
9
|
+
import Button from '../../components/button';
|
|
10
|
+
import UserImage from '../../components/userImage';
|
|
11
|
+
import Popover from '../../components/popover';
|
|
12
|
+
import Menu from '../../components/menu';
|
|
13
|
+
import MenuItem from '../../components/menuItem';
|
|
14
|
+
import Line from '../../components/line';
|
|
15
|
+
import PageShell from '../../components/pageShell';
|
|
16
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
17
|
+
// Four fixed places, one short word each, so the tabs fit on a phone.
|
|
18
|
+
var places = [
|
|
19
|
+
{ id: 'inbox', label: 'Inbox', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
|
|
20
|
+
{ id: 'tasks', label: 'Tasks', page: 'My tasks', text: '7 tasks are open. 2 are due this week.' },
|
|
21
|
+
{ id: 'files', label: 'Files', page: 'Recent files', text: 'Omar Reyes added the new screens an hour ago.' },
|
|
22
|
+
{ id: 'team', label: 'Team', page: 'People and roles', text: 'Dana Lee, Ben Carter and Omar Reyes are in Acme.' },
|
|
23
|
+
];
|
|
24
|
+
// A real app reads this from the session.
|
|
25
|
+
var me = 'Dana Lee';
|
|
26
|
+
export default function AppShellTopTabs() {
|
|
27
|
+
var _a;
|
|
28
|
+
var _b = useState('inbox'), placeId = _b[0], setPlaceId = _b[1];
|
|
29
|
+
var _c = useState(null), accountAnchor = _c[0], setAccountAnchor = _c[1];
|
|
30
|
+
var _d = useState(false), accountOpen = _d[0], setAccountOpen = _d[1];
|
|
31
|
+
var _e = useState(false), confirming = _e[0], setConfirming = _e[1];
|
|
32
|
+
var _f = useState(false), loggingOut = _f[0], setLoggingOut = _f[1];
|
|
33
|
+
var _g = useState(false), loggedOut = _g[0], setLoggedOut = _g[1];
|
|
34
|
+
var timer = useRef();
|
|
35
|
+
var accountButton = useRef(null);
|
|
36
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
37
|
+
var focusNext = useRef();
|
|
38
|
+
// Stops the request if the example goes away before it ends.
|
|
39
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
var move = focusNext.current;
|
|
42
|
+
focusNext.current = undefined;
|
|
43
|
+
move === null || move === void 0 ? void 0 : move();
|
|
44
|
+
});
|
|
45
|
+
var place = (_a = places.find(function (p) { return p.id === placeId; })) !== null && _a !== void 0 ? _a : places[0];
|
|
46
|
+
// A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open place.
|
|
47
|
+
var router = { push: function (url) { var _a; return setPlaceId((_a = url.split('/').pop()) !== null && _a !== void 0 ? _a : 'inbox'); } };
|
|
48
|
+
// 'Cancel' puts focus back on the account Button.
|
|
49
|
+
function cancelLogOut() {
|
|
50
|
+
if (loggingOut)
|
|
51
|
+
return;
|
|
52
|
+
setConfirming(false);
|
|
53
|
+
focusNext.current = function () { var _a; return (_a = accountButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
54
|
+
}
|
|
55
|
+
function logOut() {
|
|
56
|
+
if (loggingOut)
|
|
57
|
+
return;
|
|
58
|
+
setLoggingOut(true);
|
|
59
|
+
// Stands in for the request to the server.
|
|
60
|
+
timer.current = setTimeout(function () {
|
|
61
|
+
setLoggingOut(false);
|
|
62
|
+
setConfirming(false);
|
|
63
|
+
setLoggedOut(true);
|
|
64
|
+
}, 1200);
|
|
65
|
+
}
|
|
66
|
+
// A real app goes to its login page here. The example shows a short logged-out page instead.
|
|
67
|
+
if (loggedOut) {
|
|
68
|
+
return (<Center fill>
|
|
69
|
+
<Heading level={1} size="h5">You are logged out</Heading>
|
|
70
|
+
<Cluster>
|
|
71
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { setLoggedOut(false); setPlaceId('inbox'); }}/>
|
|
72
|
+
</Cluster>
|
|
73
|
+
</Center>);
|
|
74
|
+
}
|
|
75
|
+
return (<PageShell>
|
|
76
|
+
<Stack gap="large">
|
|
77
|
+
{/* The app's name at the start, the account menu at the end. */}
|
|
78
|
+
<Cluster justify="between">
|
|
79
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
80
|
+
<Button ref={accountButton} size="small" type="tertiary" state={accountOpen ? 'selected' : 'enabled'} label={me} decoIcon={<UserImage userHandle={me} size={20} decorative/>} aria-label={"".concat(me, ", account menu")} aria-haspopup="menu" aria-expanded={accountOpen} onClickButton={function (e) {
|
|
81
|
+
setAccountAnchor(e.currentTarget);
|
|
82
|
+
setAccountOpen(function (o) { return !o; });
|
|
83
|
+
}}/>
|
|
84
|
+
</Cluster>
|
|
85
|
+
<TabsContainer fill>
|
|
86
|
+
{places.map(function (p) { return (<Tab key={p.id} label={p.label} href={"/".concat(p.id)} router={router} isSelected={p.id === place.id} onClickTab={function () { return setPlaceId(p.id); }}/>); })}
|
|
87
|
+
</TabsContainer>
|
|
88
|
+
<TitleBar title={place.page} actions={<Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus"/>}/>
|
|
89
|
+
<Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
|
|
90
|
+
</Stack>
|
|
91
|
+
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={function () { return setAccountOpen(false); }} returnFocus>
|
|
92
|
+
<Menu navigable aria-label="Account" width={200}>
|
|
93
|
+
<MenuItem size="small" iconName="Settings" label="Settings" onClick={function () { return setAccountOpen(false); }}/>
|
|
94
|
+
<MenuItem size="small" iconName="CircleHelp" label="Help" onClick={function () { return setAccountOpen(false); }}/>
|
|
95
|
+
<Line />
|
|
96
|
+
<MenuItem size="small" iconName="LogOut" label="Log Out" onClick={function () { setAccountOpen(false); setConfirming(true); }}/>
|
|
97
|
+
</Menu>
|
|
98
|
+
</Popover>
|
|
99
|
+
<Modal isOpen={confirming} size="small" title="Log Out" onClose={cancelLogOut} actions={<>
|
|
100
|
+
<Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut}/>
|
|
101
|
+
<Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut}/>
|
|
102
|
+
</>}>
|
|
103
|
+
<Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
|
|
104
|
+
</Modal>
|
|
105
|
+
</PageShell>);
|
|
106
|
+
}
|