oneslash-design-system 2.23.0 → 2.24.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 +13 -2
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +240 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +542 -0
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/dashboard/numbers-first.jsx +62 -1
- package/dist/cases/dashboard.md +75 -3
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/number-format.md +4 -2
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/stat-row.md +1 -1
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +645 -7
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +90 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/popover.jsx +7 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/native-mapping.json +19 -1
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +16 -0
- package/dist/stories/Cases.generated.stories.jsx +32 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +1 -0
- package/dist/stories/Popover.stories.jsx +17 -0
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -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.24.0 has 131: fourteen rules and 117 design cases for auth pages, confirms and modals, states, chat and agent interfaces, settings and menus, shells and navigation, dashboards and billing, marketing and content pages, forms with dates and files, onboarding, history and charts.
|
|
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
|
@@ -295,6 +295,7 @@ For each web component, the table gives the native control to use. System contro
|
|
|
295
295
|
| 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`. |
|
|
296
296
|
| 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. |
|
|
297
297
|
| avatarStack | An `HStack(spacing: -8)` of avatars, each with a ring in the background color and a count `Text` in a circle past the limit, with `.accessibilityElement(children: .combine)` and a label naming the people | A `Row` with `Arrangement.spacedBy((-8).dp)` of avatars and a count circle, with `semantics(mergeDescendants = true)` and a label naming the people | To list everyone, make the stack a `Button` that opens a popover (iPad, Mac) or a sheet (iPhone) / a `DropdownMenu` or `ModalBottomSheet`. |
|
|
298
|
+
| barChart | Swift Charts `Chart` of `BarMark`s with `.accessibilityLabel` and `.accessibilityValue` per mark | No system chart: draw the bars on a `Canvas` with `semantics` per bar, or show the table | Bars in `primary.main`, the highlighted one in `text.primary`, gridlines in `misc.divider`. The y axis starts at 0; ticks are short (`.compact`), the value and the table exact. A missing day draws no bar and reads "No data". Keep a way to show the values as a table. |
|
|
298
299
|
| 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`. |
|
|
299
300
|
| brandIcon | the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app | an asset in the app | |
|
|
300
301
|
| breadcrumb | Not applicable: web page pattern | Not applicable: web page pattern | The system back button and the navigation title say where the person is. |
|
|
@@ -321,6 +322,7 @@ For each web component, the table gives the native control to use. System contro
|
|
|
321
322
|
| layout | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `VStack` / `HStack` / `Grid`; Compose `Column` / `Row` / `LazyVerticalGrid`. `Center` and `Split` are for web pages; a native screen is already one column. |
|
|
322
323
|
| lightbox | `.fullScreenCover` holding a `TabView` with `.tabViewStyle(.page)`, one page per image; a `VideoPlayer` (AVKit) on a video page | A full-width `Dialog` (`usePlatformDefaultWidth = false`) holding a `HorizontalPager`; a Media3 `PlayerView` with subtitles on a video page | The system pager gives the swipe; keep a Close button and say "2 of 5" in the title. A video uses the system player and its captions, never starts by itself, and pauses when its page is left or the viewer closes. |
|
|
323
324
|
| line | `Divider` | `HorizontalDivider`, `VerticalDivider` | |
|
|
325
|
+
| lineChart | Swift Charts `Chart` of `LineMark`s, the second series told apart by `.lineStyle(StrokeStyle(dash:))` in place of `.foregroundStyle(by:)`, with an `AXChartDescriptor` | No system chart: draw each line as a `Path` on a `Canvas` with `semantics` per point, or show the table | One or two series: the first solid in `primary.main`, the second dashed in `text.secondary`, with a legend. A missing day breaks the line and reads "No data"; never draw it as 0. The y axis starts at 0; ticks are short (`.compact`), the readout and the table exact. Keep a way to show the values as a table. |
|
|
324
326
|
| link | `Link` | `Text` with a `LinkAnnotation.Url` in its `AnnotatedString` | |
|
|
325
327
|
| linkCard | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `NavigationLink` row in a `List` / a clickable `ListItem`. |
|
|
326
328
|
| list | `List` | `LazyColumn` of `ListItem` | A short bulleted passage inside text stays `Text` lines. |
|
|
@@ -365,7 +367,8 @@ For each web component, the table gives the native control to use. System contro
|
|
|
365
367
|
| textarea | `TextField(_:text:axis: .vertical)` or `TextEditor` | `OutlinedTextField` with `minLines` | |
|
|
366
368
|
| textField | `TextField` (`SecureField` for passwords) | `OutlinedTextField` or `TextField` | |
|
|
367
369
|
| timeStamp | `Text(_:style:)` (`.relative`) or `Text(_:format:)` (`.dateTime`) | `Text` with `DateUtils.getRelativeTimeSpanString` or `DateTimeFormatter.ofLocalizedDateTime` | |
|
|
368
|
-
|
|
|
370
|
+
| timeline | A `List` of rows with a leading `Circle` and a connecting `Rectangle` in an `.overlay`; a selectable row is a `Button` | A `LazyColumn` of rows with the dot and the connecting line drawn in `Modifier.drawBehind`; a selectable row is `Modifier.clickable` | The dot is the same for every row: color carries nothing. No line after the last row. Mark the selected row with `.accessibilityAddTraits(.isSelected)` / `semantics { selected = true }`. Format the time with `Text(_:format:)` / `DateTimeFormatter.ofLocalizedDateTime`. |
|
|
371
|
+
| 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`. The `meta` line is a `.navigationSubtitle` on Mac and a toolbar `principal` item on iPhone; on Android a second `Text` in the top bar's `title` slot. |
|
|
369
372
|
| 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. |
|
|
370
373
|
| tooltip | `.help` | `TooltipBox` | `.help` shows on pointer hover only. `TooltipBox` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
371
374
|
| userImage | `ODSAvatar` | `OdsAvatar` | Load the picture yourself and pass it as an `Image` / a `Painter`. |
|
|
@@ -487,7 +490,7 @@ File: cases/form-errors.md
|
|
|
487
490
|
|
|
488
491
|
A page shows counts, money, sizes, shares or changes.
|
|
489
492
|
|
|
490
|
-
Answer: Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
|
|
493
|
+
Answer: Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. On a chart's axis, a number from 10,000 up shows its short form too: '12.4K'. The chart's readout and its table show the exact number. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
|
|
491
494
|
|
|
492
495
|
File: cases/number-format.md
|
|
493
496
|
|
|
@@ -528,6 +531,7 @@ File: cases/success-feedback.md
|
|
|
528
531
|
| About page | A visitor wants to know who is behind the work and whether to get in touch. | cases/about-page.md |
|
|
529
532
|
| Invite link page | A person opens an invite link to join a workspace. | cases/accept-invite.md |
|
|
530
533
|
| Account menu | A person opens a menu for their own account to change settings, get help or log out. | cases/account-menu.md |
|
|
534
|
+
| History and activity | A person reads what happened on a task, or opens an older version of a document and brings it back. | cases/activity-timeline.md |
|
|
531
535
|
| Admin inbox | The owner of a site reads the messages that visitors sent through its contact form. | cases/admin-inbox.md |
|
|
532
536
|
| Agent options | The agent sees two to four ways forward and needs the person to pick one. These are ways forward for the agent's own work. For a fact or a decision only the person has, see the case 'Agent question'. | cases/agent-options.md |
|
|
533
537
|
| Agent at work | The agent is working on a request in the thread, and its reply is not ready yet. | cases/agent-pending-reply.md |
|
|
@@ -537,15 +541,18 @@ File: cases/success-feedback.md
|
|
|
537
541
|
| 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 |
|
|
538
542
|
| 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 |
|
|
539
543
|
| Document card | The agent made a document for the person, such as a plan or a report. | cases/artifact-card.md |
|
|
544
|
+
| Ask page | A page where a person asks the agent about their work across one or more workspaces, and reads the answers with their sources. | cases/ask-page.md |
|
|
540
545
|
| 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 |
|
|
541
546
|
| Billing page | A workspace pays for a plan. One page says what it pays for, what it has used, how it pays and what it has paid. | cases/billing-page.md |
|
|
542
547
|
| Blog index | A visitor opens the blog to see what was written lately and to pick a post to read. | cases/blog-index.md |
|
|
543
548
|
| Breadcrumb | A page on a site sits under other pages, and the person needs to see where it is and go back up. | cases/breadcrumb.md |
|
|
544
549
|
| Breakdown of a total | A page shows how a total splits into parts, such as responses by model or comments by project. | cases/breakdown-list.md |
|
|
545
550
|
| Changelog | A visitor or a customer wants to know what changed in the product lately, and may be sent to one change from a message. | cases/changelog.md |
|
|
551
|
+
| Chart | A dashboard shows how a count moved over its range, day by day or week by week. | cases/chart.md |
|
|
546
552
|
| Check your email | A person signed up, and the product sent a link to confirm their email. | cases/check-your-email.md |
|
|
547
553
|
| Code sample | A page shows code that a person reads, or copies to run. | cases/code-sample.md |
|
|
548
554
|
| Collapsible search | A person filters a list by a word, and the list should keep its room when they are not typing. | cases/collapsible-search.md |
|
|
555
|
+
| Comment and thread | A person reads comments left on a piece of work, opens one, and reads and answers its thread. | cases/comment-thread.md |
|
|
549
556
|
| Composer at a limit | The agent cannot be called from the composer because the workspace reached a limit, such as its AI agent responses for the month. | cases/composer-limit.md |
|
|
550
557
|
| Delete confirm | A person asks to delete or remove something, and it cannot be undone. | cases/confirm-destructive-action.md |
|
|
551
558
|
| Contact page | A visitor wants to reach the person behind a site. | cases/contact-page.md |
|
|
@@ -575,6 +582,7 @@ File: cases/success-feedback.md
|
|
|
575
582
|
| Member invite | A person invites someone to join a workspace. | cases/invite-member.md |
|
|
576
583
|
| Invoices | A billing page lists what the workspace has paid, so an admin can find an invoice, check an amount and keep a copy. | cases/invoice-list.md |
|
|
577
584
|
| Hero | A marketing page opens by saying what the product is and asking for one thing. | cases/landing-hero.md |
|
|
585
|
+
| Leaderboard | A dashboard shows who did the most of something over its range, such as who left the most comments this week. | cases/leaderboard.md |
|
|
578
586
|
| Legal page | A person reads the terms or the privacy policy to find one answer in it, or reads all of it before they agree. | cases/legal-page.md |
|
|
579
587
|
| Load failure | A list or a section could not load. | cases/load-failure.md |
|
|
580
588
|
| Log-out confirm | A person chooses Log Out. | cases/log-out-confirm.md |
|
|
@@ -595,6 +603,7 @@ File: cases/success-feedback.md
|
|
|
595
603
|
| 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 |
|
|
596
604
|
| On and off settings | A person turns things on and off, such as which notifications they get. | cases/on-off-settings.md |
|
|
597
605
|
| 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 |
|
|
606
|
+
| First-run setup | A person has just signed up, and the app needs a few things from them before it works or before it is fully set up. | cases/onboarding.md |
|
|
598
607
|
| 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 |
|
|
599
608
|
| Page end | A page has said what it had to say, and its last block decides what the visitor does next. | cases/page-end.md |
|
|
600
609
|
| Page header with actions | A page names itself at the top and offers what the person can do with it. | cases/page-header.md |
|
|
@@ -604,6 +613,7 @@ File: cases/success-feedback.md
|
|
|
604
613
|
| People on an item | A thread or a task shows who is on it, and the person can find out who they all are. | cases/people-row.md |
|
|
605
614
|
| Plan change confirm | An admin chose another plan. Before anything changes they need to know what it costs and when it starts. | cases/plan-change-confirm.md |
|
|
606
615
|
| Plan picker | An admin compares the plans a workspace can be on and chooses one. | cases/plan-picker.md |
|
|
616
|
+
| Plan sign-off | The agent wrote a plan for a task, and people approve it before the agent starts the work. | cases/plan-sign-off.md |
|
|
607
617
|
| Pricing section | A visitor to the public site compares the plans and signs up for one. | cases/pricing-section.md |
|
|
608
618
|
| Product cards | A maker lists its products on one page, and each product has its own site. | cases/product-cards.md |
|
|
609
619
|
| Profile | A person changes how they appear and how they sign in: their picture, their name and their password. | cases/profile-form.md |
|
|
@@ -628,6 +638,7 @@ File: cases/success-feedback.md
|
|
|
628
638
|
| Status in a row | A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job. | cases/status-label.md |
|
|
629
639
|
| Tabbed panels | A page shows several views of one thing, and a visitor reads one of them at a time. | cases/tabbed-panels.md |
|
|
630
640
|
| Tag filter | A person filters a list by a tag, and adds, renames and deletes the tags themselves. | cases/tag-filter.md |
|
|
641
|
+
| Task header | A task page shows its name, its state, who is on it and when it is due, with the panes and actions for it. | cases/task-header.md |
|
|
631
642
|
| Theme switcher | A person chooses between a light page, a dark page, or the one their device uses. | cases/theme-switcher.md |
|
|
632
643
|
| 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 |
|
|
633
644
|
| Typing line | Other people in the thread are writing a message that has not arrived yet. | cases/typing-and-status.md |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ActivityTimelineActivity(): import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import AppShell from '../../components/appShell';
|
|
4
|
+
import SidePane from '../../components/sidePane';
|
|
5
|
+
import Navigation from '../../components/navigation';
|
|
6
|
+
import MenuItem from '../../components/menuItem';
|
|
7
|
+
import TitleBar from '../../components/titleBar';
|
|
8
|
+
import IconButton from '../../components/iconButton';
|
|
9
|
+
import Tooltip from '../../components/tooltip';
|
|
10
|
+
import Timeline from '../../components/timeline';
|
|
11
|
+
import Paragraph from '../../components/paragraph';
|
|
12
|
+
import { Stack } from '../../components/layout';
|
|
13
|
+
var task = 'Launch checklist';
|
|
14
|
+
// Newest first. Each title says who did what, and each time is written in full.
|
|
15
|
+
var events = [
|
|
16
|
+
{ id: 'e6', title: 'Check failed', when: 'Nov 16, 2026, 3:05 PM', dateTime: '2026-11-16T15:05', detail: 'The sign-up form test failed on a phone.', tag: { label: 'Needs fixing', color: 'warning' } },
|
|
17
|
+
{ id: 'e5', title: 'Acme Agent opened a pull request', when: 'Nov 16, 2026, 2:58 PM', dateTime: '2026-11-16T14:58', actor: { name: 'Acme Agent', agent: true }, detail: 'Updates the home page and its tests', href: '/pulls/42' },
|
|
18
|
+
{ id: 'e4', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
19
|
+
{ id: 'e3', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
20
|
+
{ id: 'e2', title: 'Ben Carter added Omar Reyes to the task', when: 'Nov 15, 2026, 4:10 PM', dateTime: '2026-11-15T16:10', actor: { name: 'Ben Carter' } },
|
|
21
|
+
{ id: 'e1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
22
|
+
];
|
|
23
|
+
// The places. A real app lets each link go to its page.
|
|
24
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
25
|
+
<MenuItem size="small" label="Tasks" iconName="ListChecks" href="/tasks" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
|
|
26
|
+
</Navigation>);
|
|
27
|
+
export default function ActivityTimelineActivity() {
|
|
28
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
29
|
+
// The person opened the history from the task header. The example starts with the pane open.
|
|
30
|
+
var _b = useState(true), open = _b[0], setOpen = _b[1];
|
|
31
|
+
var pane = useRef(null);
|
|
32
|
+
return (<AppShell title="Tasks" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={open && (<SidePane ref={pane} title="History" onClose={function () { return setOpen(false); }}>
|
|
33
|
+
{/* A real app shows Skeleton rows while it loads, the case 'Load failure' if it fails, and EmptyBox when there is nothing yet. */}
|
|
34
|
+
<Timeline id="activity-timeline-events" aria-label={"History of ".concat(task)} items={events}/>
|
|
35
|
+
</SidePane>)}>
|
|
36
|
+
<Stack gap="large">
|
|
37
|
+
<TitleBar title={task} actions={<Tooltip title="History">
|
|
38
|
+
<IconButton color="iconOnly" state={open ? 'selected' : 'enabled'} size="medium" iconName="History" ariaLabel={"Show the history of ".concat(task)} aria-expanded={open} onClick={function () { var _a; return (open ? (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus() : setOpen(true)); }}/>
|
|
39
|
+
</Tooltip>}/>
|
|
40
|
+
<Paragraph tone="secondary" measure="none">Acme Agent opened a pull request for the new home page. One check failed.</Paragraph>
|
|
41
|
+
</Stack>
|
|
42
|
+
</AppShell>);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ActivityTimelineVersions(): import("react").JSX.Element;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useEffect, useRef, useState } from 'react';
|
|
23
|
+
import AppShell from '../../components/appShell';
|
|
24
|
+
import SidePane from '../../components/sidePane';
|
|
25
|
+
import Navigation from '../../components/navigation';
|
|
26
|
+
import MenuItem from '../../components/menuItem';
|
|
27
|
+
import TitleBar from '../../components/titleBar';
|
|
28
|
+
import IconButton from '../../components/iconButton';
|
|
29
|
+
import Tooltip from '../../components/tooltip';
|
|
30
|
+
import Timeline from '../../components/timeline';
|
|
31
|
+
import Heading from '../../components/heading';
|
|
32
|
+
import Paragraph from '../../components/paragraph';
|
|
33
|
+
import List from '../../components/list';
|
|
34
|
+
import Line from '../../components/line';
|
|
35
|
+
import Button from '../../components/button';
|
|
36
|
+
import Modal from '../../components/modal';
|
|
37
|
+
import Alert from '../../components/alert';
|
|
38
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
39
|
+
var task = 'Launch checklist';
|
|
40
|
+
// The plan's saved versions, newest first. The newest is the current plan.
|
|
41
|
+
var firstVersions = [
|
|
42
|
+
{ id: 'v5', title: 'Moved the launch to Nov 20, 2026', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', by: 'Dana Lee', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 20, 2026.'] },
|
|
43
|
+
{ id: 'v4', title: 'Added a check on a phone', when: 'Nov 16, 2026, 9:10 AM', dateTime: '2026-11-16T09:10', by: 'Acme Agent', agent: true, steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 18, 2026.'] },
|
|
44
|
+
{ id: 'v3', title: 'Gave the copy to Omar Reyes', when: 'Nov 15, 2026, 5:45 PM', dateTime: '2026-11-15T17:45', by: 'Ben Carter', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Merge on Nov 18, 2026.'] },
|
|
45
|
+
{ id: 'v2', title: 'Split the release into two steps', when: 'Nov 15, 2026, 1:00 PM', dateTime: '2026-11-15T13:00', by: 'Acme Agent', agent: true, steps: ['Update the home page.', 'Merge on Nov 18, 2026.'] },
|
|
46
|
+
{ id: 'v1', title: 'Wrote the first plan', when: 'Nov 14, 2026, 10:20 AM', dateTime: '2026-11-14T10:20', by: 'Acme Agent', agent: true, steps: ['Update the home page and merge it.'] },
|
|
47
|
+
];
|
|
48
|
+
// The places. A real app lets each link go to its page.
|
|
49
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
50
|
+
<MenuItem size="small" label="Tasks" iconName="ListChecks" href="/tasks" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
|
|
51
|
+
</Navigation>);
|
|
52
|
+
export default function ActivityTimelineVersions() {
|
|
53
|
+
var _a;
|
|
54
|
+
var _b = useState(false), navOpen = _b[0], setNavOpen = _b[1];
|
|
55
|
+
// The person opened the history from the task header and chose a version. The example starts there.
|
|
56
|
+
var _c = useState(true), open = _c[0], setOpen = _c[1];
|
|
57
|
+
var _d = useState(firstVersions), versions = _d[0], setVersions = _d[1];
|
|
58
|
+
var _e = useState('v4'), selectedId = _e[0], setSelectedId = _e[1];
|
|
59
|
+
var _f = useState(false), confirming = _f[0], setConfirming = _f[1];
|
|
60
|
+
var _g = useState(false), restoring = _g[0], setRestoring = _g[1];
|
|
61
|
+
var _h = useState(null), restored = _h[0], setRestored = _h[1];
|
|
62
|
+
var pane = useRef(null);
|
|
63
|
+
var timer = useRef();
|
|
64
|
+
// On unmount it stops the request.
|
|
65
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
66
|
+
var current = versions[0];
|
|
67
|
+
var chosen = (_a = versions.find(function (v) { return v.id === selectedId; })) !== null && _a !== void 0 ? _a : current;
|
|
68
|
+
// While the request runs, Escape and Cancel do nothing.
|
|
69
|
+
function keepCurrent() {
|
|
70
|
+
if (restoring)
|
|
71
|
+
return;
|
|
72
|
+
setConfirming(false);
|
|
73
|
+
}
|
|
74
|
+
// The current plan stays as a version. The restore is a new version on top, marked Current.
|
|
75
|
+
// The Modal gives focus back to 'Restore This Version', which stays: the chosen version is not the current one.
|
|
76
|
+
function restore() {
|
|
77
|
+
if (restoring)
|
|
78
|
+
return;
|
|
79
|
+
setRestoring(true);
|
|
80
|
+
// Stands in for the request to the server.
|
|
81
|
+
timer.current = setTimeout(function () {
|
|
82
|
+
setRestoring(false);
|
|
83
|
+
setConfirming(false);
|
|
84
|
+
setVersions(function (list) { return __spreadArray([
|
|
85
|
+
__assign(__assign({}, chosen), { id: "v".concat(list.length + 1), title: "Restored the version from ".concat(chosen.when), when: 'Nov 16, 2026, 2:55 PM', dateTime: '2026-11-16T14:55', by: 'Dana Lee', agent: false })
|
|
86
|
+
], list, true); });
|
|
87
|
+
setRestored(chosen.when);
|
|
88
|
+
}, 1200);
|
|
89
|
+
}
|
|
90
|
+
return (<AppShell title="Tasks" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={open && (<SidePane ref={pane} title="History" onClose={function () { return setOpen(false); }}>
|
|
91
|
+
<Stack gap="large">
|
|
92
|
+
{restored && (
|
|
93
|
+
// An inline Alert is a polite status, so a screen reader hears it.
|
|
94
|
+
<Alert variant="inline" type="success" autoDismiss={false} message={"Restored the version from ".concat(restored, ".")}/>)}
|
|
95
|
+
<Timeline id="activity-timeline-versions" aria-label={"Versions of the plan for ".concat(task)} items={versions.map(function (v, i) { return ({
|
|
96
|
+
id: v.id,
|
|
97
|
+
title: v.title,
|
|
98
|
+
when: v.when,
|
|
99
|
+
dateTime: v.dateTime,
|
|
100
|
+
actor: { name: v.by, agent: v.agent },
|
|
101
|
+
tag: i === 0 ? { label: 'Current' } : undefined,
|
|
102
|
+
}); })} selectedId={chosen.id} onSelect={setSelectedId}/>
|
|
103
|
+
<Line />
|
|
104
|
+
{/* The chosen version, under the list. */}
|
|
105
|
+
<Stack gap="medium">
|
|
106
|
+
<Stack gap="small">
|
|
107
|
+
<Heading level={3} size="subtitle1">{chosen.title}</Heading>
|
|
108
|
+
<Paragraph size="body2" tone="secondary" measure="none">Saved by {chosen.by}, {chosen.when}</Paragraph>
|
|
109
|
+
</Stack>
|
|
110
|
+
<List marker="number" items={chosen.steps}/>
|
|
111
|
+
{chosen.id !== current.id && (<Cluster>
|
|
112
|
+
<Button size="small" type="secondary" state="enabled" label="Restore This Version" onClickButton={function () { return setConfirming(true); }}/>
|
|
113
|
+
</Cluster>)}
|
|
114
|
+
</Stack>
|
|
115
|
+
</Stack>
|
|
116
|
+
</SidePane>)}>
|
|
117
|
+
<Stack gap="large">
|
|
118
|
+
<TitleBar title={task} actions={<Tooltip title="History">
|
|
119
|
+
<IconButton color="iconOnly" state={open ? 'selected' : 'enabled'} size="medium" iconName="History" ariaLabel={"Show the history of ".concat(task)} aria-expanded={open} onClick={function () { var _a; return (open ? (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus() : setOpen(true)); }}/>
|
|
120
|
+
</Tooltip>}/>
|
|
121
|
+
<Paragraph tone="secondary" measure="none">The plan for this task has {versions.length} saved versions.</Paragraph>
|
|
122
|
+
</Stack>
|
|
123
|
+
<Modal isOpen={confirming} size="small" title="Restore Version" onClose={keepCurrent} actions={<>
|
|
124
|
+
<Button size="small" type="tertiary" state={restoring ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepCurrent}/>
|
|
125
|
+
<Button size="small" type="primary" state="enabled" label="Restore" loading={restoring} onClickButton={restore}/>
|
|
126
|
+
</>}>
|
|
127
|
+
<Paragraph measure="none">This makes the version from {chosen.when} the current plan, and everyone signs it off again. Your current plan is kept as a version.</Paragraph>
|
|
128
|
+
</Modal>
|
|
129
|
+
</AppShell>);
|
|
130
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# History and activity
|
|
2
|
+
|
|
3
|
+
A person reads what happened on a task, or opens an older version of a document and brings it back.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Show the history in a `SidePane` titled 'History' beside the page, as the case 'Side pane' says.
|
|
8
|
+
- Use `Timeline`, newest first. It draws one dot per row and a line to the next.
|
|
9
|
+
- Write each event as who did what: 'Dana Lee approved the plan', 'Acme Agent opened a pull request'.
|
|
10
|
+
- Write each time in full in `when`, such as 'Nov 16, 2026, 2:40 PM', and the ISO value in `dateTime`.
|
|
11
|
+
- Pass `actor` with `agent: true` for the agent, so its row shows the agent face and no picture.
|
|
12
|
+
- Pass `href` when an event has a page of its own, such as a pull request. The title becomes the link.
|
|
13
|
+
- Mark an event that needs a look with a `tag`, such as a warning 'Needs fixing' on 'Check failed'. The word says it, not the dot.
|
|
14
|
+
- Pass `onSelect` and `selectedId` for versions. Each row is one button, and the chosen one has `aria-current`.
|
|
15
|
+
- Give the newest version the `tag` 'Current'.
|
|
16
|
+
- Show the chosen version under the list, with who saved it and when, and a secondary Button 'Restore This Version'. The current version has no Restore.
|
|
17
|
+
- Confirm a restore in a small Modal, as the rule 'A confirm says exactly what will happen' says. Title it 'Restore Version', with 'Cancel' and then 'Restore'.
|
|
18
|
+
- Say in the body what changes and what is kept: 'This makes the version from Nov 15, 2026, 5:45 PM the current plan, and everyone signs it off again. Your current plan is kept as a version.'
|
|
19
|
+
- Make 'Restore' `loading` with its label, disable 'Cancel' and ignore `onClose` while the request runs.
|
|
20
|
+
- Add the restore as the newest version once it works, marked Current, and say so in an inline success `Alert`.
|
|
21
|
+
- Show `Skeleton` rows while the history loads, then the list as soon as it loads.
|
|
22
|
+
- Say that it failed when the history cannot load, as the case 'Load failure' says: 'Could not load the history', with 'Try Again'.
|
|
23
|
+
- Show `EmptyBox` when there is nothing yet, as the rule 'An empty list says what will fill it' says: 'No changes yet' and 'Each saved edit shows here.'
|
|
24
|
+
|
|
25
|
+
## Don't
|
|
26
|
+
|
|
27
|
+
- Do not color the dots by the kind of event. A color with no word means nothing to a screen reader.
|
|
28
|
+
- Do not show a relative time alone, such as '2h'. Write the date and the time.
|
|
29
|
+
- Do not show the empty text when the history failed to load.
|
|
30
|
+
- Do not let a restore overwrite the current version. Keep it as a version first.
|
|
31
|
+
- Do not draw the dots and the line by hand. Use `Timeline`.
|
|
32
|
+
|
|
33
|
+
## Option: Activity
|
|
34
|
+
|
|
35
|
+
Use when: A person reads what happened on a task, in order.
|
|
36
|
+
|
|
37
|
+
Uses: `AppShell`, `IconButton`, `MenuItem`, `Navigation`, `Paragraph`, `SidePane`, `Stack`, `Timeline`, `TitleBar`, `Tooltip`
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
'use client';
|
|
41
|
+
import { useRef, useState } from 'react';
|
|
42
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
43
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
44
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
45
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
46
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
47
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
48
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
49
|
+
import Timeline, { type TimelineItem } from 'oneslash-design-system/components/timeline';
|
|
50
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
51
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
52
|
+
|
|
53
|
+
const task = 'Launch checklist';
|
|
54
|
+
|
|
55
|
+
// Newest first. Each title says who did what, and each time is written in full.
|
|
56
|
+
const events: TimelineItem[] = [
|
|
57
|
+
{ id: 'e6', title: 'Check failed', when: 'Nov 16, 2026, 3:05 PM', dateTime: '2026-11-16T15:05', detail: 'The sign-up form test failed on a phone.', tag: { label: 'Needs fixing', color: 'warning' } },
|
|
58
|
+
{ id: 'e5', title: 'Acme Agent opened a pull request', when: 'Nov 16, 2026, 2:58 PM', dateTime: '2026-11-16T14:58', actor: { name: 'Acme Agent', agent: true }, detail: 'Updates the home page and its tests', href: '/pulls/42' },
|
|
59
|
+
{ id: 'e4', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
60
|
+
{ id: 'e3', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
61
|
+
{ id: 'e2', title: 'Ben Carter added Omar Reyes to the task', when: 'Nov 15, 2026, 4:10 PM', dateTime: '2026-11-15T16:10', actor: { name: 'Ben Carter' } },
|
|
62
|
+
{ id: 'e1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
// The places. A real app lets each link go to its page.
|
|
66
|
+
const sidebar = (
|
|
67
|
+
<Navigation aria-label="Main">
|
|
68
|
+
<MenuItem
|
|
69
|
+
size="small"
|
|
70
|
+
label="Tasks"
|
|
71
|
+
iconName="ListChecks"
|
|
72
|
+
href="/tasks"
|
|
73
|
+
isSelected
|
|
74
|
+
aria-current="page"
|
|
75
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
76
|
+
/>
|
|
77
|
+
</Navigation>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export default function ActivityTimelineActivity() {
|
|
81
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
82
|
+
// The person opened the history from the task header. The example starts with the pane open.
|
|
83
|
+
const [open, setOpen] = useState(true);
|
|
84
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<AppShell
|
|
88
|
+
title="Tasks"
|
|
89
|
+
navOpen={navOpen}
|
|
90
|
+
onNavOpenChange={setNavOpen}
|
|
91
|
+
sidebar={sidebar}
|
|
92
|
+
pane={
|
|
93
|
+
open && (
|
|
94
|
+
<SidePane ref={pane} title="History" onClose={() => setOpen(false)}>
|
|
95
|
+
{/* A real app shows Skeleton rows while it loads, the case 'Load failure' if it fails, and EmptyBox when there is nothing yet. */}
|
|
96
|
+
<Timeline id="activity-timeline-events" aria-label={`History of ${task}`} items={events} />
|
|
97
|
+
</SidePane>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
>
|
|
101
|
+
<Stack gap="large">
|
|
102
|
+
<TitleBar
|
|
103
|
+
title={task}
|
|
104
|
+
actions={
|
|
105
|
+
<Tooltip title="History">
|
|
106
|
+
<IconButton
|
|
107
|
+
color="iconOnly"
|
|
108
|
+
state={open ? 'selected' : 'enabled'}
|
|
109
|
+
size="medium"
|
|
110
|
+
iconName="History"
|
|
111
|
+
ariaLabel={`Show the history of ${task}`}
|
|
112
|
+
aria-expanded={open}
|
|
113
|
+
onClick={() => (open ? pane.current?.focus() : setOpen(true))}
|
|
114
|
+
/>
|
|
115
|
+
</Tooltip>
|
|
116
|
+
}
|
|
117
|
+
/>
|
|
118
|
+
<Paragraph tone="secondary" measure="none">Acme Agent opened a pull request for the new home page. One check failed.</Paragraph>
|
|
119
|
+
</Stack>
|
|
120
|
+
</AppShell>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Option: Versions
|
|
126
|
+
|
|
127
|
+
Use when: A document has saved versions that a person can open and restore.
|
|
128
|
+
|
|
129
|
+
Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `Heading`, `IconButton`, `Line`, `List`, `MenuItem`, `Modal`, `Navigation`, `Paragraph`, `SidePane`, `Stack`, `Timeline`, `TitleBar`, `Tooltip`
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
'use client';
|
|
133
|
+
import { useEffect, useRef, useState } from 'react';
|
|
134
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
135
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
136
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
137
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
138
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
139
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
140
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
141
|
+
import Timeline from 'oneslash-design-system/components/timeline';
|
|
142
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
143
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
144
|
+
import List from 'oneslash-design-system/components/list';
|
|
145
|
+
import Line from 'oneslash-design-system/components/line';
|
|
146
|
+
import Button from 'oneslash-design-system/components/button';
|
|
147
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
148
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
149
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
150
|
+
|
|
151
|
+
type Version = {
|
|
152
|
+
id: string;
|
|
153
|
+
title: string;
|
|
154
|
+
when: string;
|
|
155
|
+
dateTime: string;
|
|
156
|
+
by: string;
|
|
157
|
+
agent?: boolean;
|
|
158
|
+
steps: string[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const task = 'Launch checklist';
|
|
162
|
+
|
|
163
|
+
// The plan's saved versions, newest first. The newest is the current plan.
|
|
164
|
+
const firstVersions: Version[] = [
|
|
165
|
+
{ id: 'v5', title: 'Moved the launch to Nov 20, 2026', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', by: 'Dana Lee', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 20, 2026.'] },
|
|
166
|
+
{ id: 'v4', title: 'Added a check on a phone', when: 'Nov 16, 2026, 9:10 AM', dateTime: '2026-11-16T09:10', by: 'Acme Agent', agent: true, steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 18, 2026.'] },
|
|
167
|
+
{ id: 'v3', title: 'Gave the copy to Omar Reyes', when: 'Nov 15, 2026, 5:45 PM', dateTime: '2026-11-15T17:45', by: 'Ben Carter', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Merge on Nov 18, 2026.'] },
|
|
168
|
+
{ id: 'v2', title: 'Split the release into two steps', when: 'Nov 15, 2026, 1:00 PM', dateTime: '2026-11-15T13:00', by: 'Acme Agent', agent: true, steps: ['Update the home page.', 'Merge on Nov 18, 2026.'] },
|
|
169
|
+
{ id: 'v1', title: 'Wrote the first plan', when: 'Nov 14, 2026, 10:20 AM', dateTime: '2026-11-14T10:20', by: 'Acme Agent', agent: true, steps: ['Update the home page and merge it.'] },
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
// The places. A real app lets each link go to its page.
|
|
173
|
+
const sidebar = (
|
|
174
|
+
<Navigation aria-label="Main">
|
|
175
|
+
<MenuItem
|
|
176
|
+
size="small"
|
|
177
|
+
label="Tasks"
|
|
178
|
+
iconName="ListChecks"
|
|
179
|
+
href="/tasks"
|
|
180
|
+
isSelected
|
|
181
|
+
aria-current="page"
|
|
182
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
183
|
+
/>
|
|
184
|
+
</Navigation>
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
export default function ActivityTimelineVersions() {
|
|
188
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
189
|
+
// The person opened the history from the task header and chose a version. The example starts there.
|
|
190
|
+
const [open, setOpen] = useState(true);
|
|
191
|
+
const [versions, setVersions] = useState(firstVersions);
|
|
192
|
+
const [selectedId, setSelectedId] = useState('v4');
|
|
193
|
+
const [confirming, setConfirming] = useState(false);
|
|
194
|
+
const [restoring, setRestoring] = useState(false);
|
|
195
|
+
const [restored, setRestored] = useState<string | null>(null);
|
|
196
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
197
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
198
|
+
|
|
199
|
+
// On unmount it stops the request.
|
|
200
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
201
|
+
|
|
202
|
+
const current = versions[0];
|
|
203
|
+
const chosen = versions.find((v) => v.id === selectedId) ?? current;
|
|
204
|
+
|
|
205
|
+
// While the request runs, Escape and Cancel do nothing.
|
|
206
|
+
function keepCurrent() {
|
|
207
|
+
if (restoring) return;
|
|
208
|
+
setConfirming(false);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// The current plan stays as a version. The restore is a new version on top, marked Current.
|
|
212
|
+
// The Modal gives focus back to 'Restore This Version', which stays: the chosen version is not the current one.
|
|
213
|
+
function restore() {
|
|
214
|
+
if (restoring) return;
|
|
215
|
+
setRestoring(true);
|
|
216
|
+
// Stands in for the request to the server.
|
|
217
|
+
timer.current = setTimeout(() => {
|
|
218
|
+
setRestoring(false);
|
|
219
|
+
setConfirming(false);
|
|
220
|
+
setVersions((list) => [
|
|
221
|
+
{ ...chosen, id: `v${list.length + 1}`, title: `Restored the version from ${chosen.when}`, when: 'Nov 16, 2026, 2:55 PM', dateTime: '2026-11-16T14:55', by: 'Dana Lee', agent: false },
|
|
222
|
+
...list,
|
|
223
|
+
]);
|
|
224
|
+
setRestored(chosen.when);
|
|
225
|
+
}, 1200);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<AppShell
|
|
230
|
+
title="Tasks"
|
|
231
|
+
navOpen={navOpen}
|
|
232
|
+
onNavOpenChange={setNavOpen}
|
|
233
|
+
sidebar={sidebar}
|
|
234
|
+
pane={
|
|
235
|
+
open && (
|
|
236
|
+
<SidePane ref={pane} title="History" onClose={() => setOpen(false)}>
|
|
237
|
+
<Stack gap="large">
|
|
238
|
+
{restored && (
|
|
239
|
+
// An inline Alert is a polite status, so a screen reader hears it.
|
|
240
|
+
<Alert variant="inline" type="success" autoDismiss={false} message={`Restored the version from ${restored}.`} />
|
|
241
|
+
)}
|
|
242
|
+
<Timeline
|
|
243
|
+
id="activity-timeline-versions"
|
|
244
|
+
aria-label={`Versions of the plan for ${task}`}
|
|
245
|
+
items={versions.map((v, i) => ({
|
|
246
|
+
id: v.id,
|
|
247
|
+
title: v.title,
|
|
248
|
+
when: v.when,
|
|
249
|
+
dateTime: v.dateTime,
|
|
250
|
+
actor: { name: v.by, agent: v.agent },
|
|
251
|
+
tag: i === 0 ? { label: 'Current' } : undefined,
|
|
252
|
+
}))}
|
|
253
|
+
selectedId={chosen.id}
|
|
254
|
+
onSelect={setSelectedId}
|
|
255
|
+
/>
|
|
256
|
+
<Line />
|
|
257
|
+
{/* The chosen version, under the list. */}
|
|
258
|
+
<Stack gap="medium">
|
|
259
|
+
<Stack gap="small">
|
|
260
|
+
<Heading level={3} size="subtitle1">{chosen.title}</Heading>
|
|
261
|
+
<Paragraph size="body2" tone="secondary" measure="none">Saved by {chosen.by}, {chosen.when}</Paragraph>
|
|
262
|
+
</Stack>
|
|
263
|
+
<List marker="number" items={chosen.steps} />
|
|
264
|
+
{chosen.id !== current.id && (
|
|
265
|
+
<Cluster>
|
|
266
|
+
<Button size="small" type="secondary" state="enabled" label="Restore This Version" onClickButton={() => setConfirming(true)} />
|
|
267
|
+
</Cluster>
|
|
268
|
+
)}
|
|
269
|
+
</Stack>
|
|
270
|
+
</Stack>
|
|
271
|
+
</SidePane>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
>
|
|
275
|
+
<Stack gap="large">
|
|
276
|
+
<TitleBar
|
|
277
|
+
title={task}
|
|
278
|
+
actions={
|
|
279
|
+
<Tooltip title="History">
|
|
280
|
+
<IconButton
|
|
281
|
+
color="iconOnly"
|
|
282
|
+
state={open ? 'selected' : 'enabled'}
|
|
283
|
+
size="medium"
|
|
284
|
+
iconName="History"
|
|
285
|
+
ariaLabel={`Show the history of ${task}`}
|
|
286
|
+
aria-expanded={open}
|
|
287
|
+
onClick={() => (open ? pane.current?.focus() : setOpen(true))}
|
|
288
|
+
/>
|
|
289
|
+
</Tooltip>
|
|
290
|
+
}
|
|
291
|
+
/>
|
|
292
|
+
<Paragraph tone="secondary" measure="none">The plan for this task has {versions.length} saved versions.</Paragraph>
|
|
293
|
+
</Stack>
|
|
294
|
+
<Modal
|
|
295
|
+
isOpen={confirming}
|
|
296
|
+
size="small"
|
|
297
|
+
title="Restore Version"
|
|
298
|
+
onClose={keepCurrent}
|
|
299
|
+
actions={
|
|
300
|
+
<>
|
|
301
|
+
<Button size="small" type="tertiary" state={restoring ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepCurrent} />
|
|
302
|
+
<Button size="small" type="primary" state="enabled" label="Restore" loading={restoring} onClickButton={restore} />
|
|
303
|
+
</>
|
|
304
|
+
}
|
|
305
|
+
>
|
|
306
|
+
<Paragraph measure="none">This makes the version from {chosen.when} the current plan, and everyone signs it off again. Your current plan is kept as a version.</Paragraph>
|
|
307
|
+
</Modal>
|
|
308
|
+
</AppShell>
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Native
|
|
314
|
+
|
|
315
|
+
On Apple use a `List` of rows with a `Circle` and a connecting line in an overlay, in an inspector, and a `confirmationDialog` for a restore. On Android use a `LazyColumn` with the dot and line drawn behind each row, in a side sheet.
|
|
@@ -31,6 +31,7 @@ The agent is about to change shared work and needs the person to approve it firs
|
|
|
31
31
|
- Move focus to the field when 'Edit' or 'Request Changes' opens it, and back to that button after 'Discard', or after 'Save' in an edit.
|
|
32
32
|
- Move focus to 'Stop' when the run's progress row appears.
|
|
33
33
|
- Move focus to the message box when the card's buttons or 'Stop' go away and nothing takes their place.
|
|
34
|
+
- Use the case 'Plan sign-off' when several people must approve one plan, or the plan is a document beside the task.
|
|
34
35
|
|
|
35
36
|
## Don't
|
|
36
37
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AskPageAnswered(): import("react").JSX.Element;
|