oneslash-design-system 2.28.0 → 2.29.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 +31 -1
- package/dist/cases/about-page.md +2 -0
- package/dist/cases/accept-invite.md +2 -0
- package/dist/cases/account-menu.md +2 -0
- package/dist/cases/activity-timeline.md +2 -0
- package/dist/cases/admin-inbox.md +2 -0
- package/dist/cases/agent-asks-before-risky-action.md +3 -1
- package/dist/cases/agent-cancels-when-unanswered.md +2 -0
- package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
- package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
- package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
- package/dist/cases/agent-changes-review/per-change.jsx +203 -0
- package/dist/cases/agent-changes-review.md +585 -0
- package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
- package/dist/cases/agent-handoff/to-agent.jsx +53 -0
- package/dist/cases/agent-handoff/to-person.d.ts +1 -0
- package/dist/cases/agent-handoff/to-person.jsx +84 -0
- package/dist/cases/agent-handoff.md +231 -0
- package/dist/cases/agent-memory/list.d.ts +1 -0
- package/dist/cases/agent-memory/list.jsx +256 -0
- package/dist/cases/agent-memory.md +354 -0
- package/dist/cases/agent-options.md +2 -0
- package/dist/cases/agent-pending-reply/steps.jsx +70 -21
- package/dist/cases/agent-pending-reply.md +74 -27
- package/dist/cases/agent-permissions/levels.d.ts +3 -0
- package/dist/cases/agent-permissions/levels.jsx +49 -0
- package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
- package/dist/cases/agent-permissions/per-tool.jsx +178 -0
- package/dist/cases/agent-permissions.md +314 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
- package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
- package/dist/cases/agent-plan-proposal.md +36 -21
- package/dist/cases/agent-question.md +2 -0
- package/dist/cases/agent-refuses-clearly.md +2 -0
- package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
- package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
- package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
- package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
- package/dist/cases/agent-run-failure.md +500 -0
- package/dist/cases/agent-says-what-it-is.md +2 -0
- package/dist/cases/agent-says-where-it-stopped.md +27 -0
- package/dist/cases/agent-settings.md +2 -0
- package/dist/cases/agent-shows-progress.md +2 -0
- package/dist/cases/agent-shows-sources.md +2 -0
- package/dist/cases/api-keys/list.jsx +30 -3
- package/dist/cases/api-keys.md +37 -3
- package/dist/cases/app-shell.md +2 -0
- package/dist/cases/artifact-card.md +2 -0
- package/dist/cases/ask-page.md +2 -0
- package/dist/cases/auth-gate-loading.md +2 -0
- package/dist/cases/billing-page.md +2 -0
- package/dist/cases/blog-index.md +2 -0
- package/dist/cases/breadcrumb.md +2 -0
- package/dist/cases/breakdown-list.md +2 -0
- package/dist/cases/bulk-actions/list.d.ts +1 -0
- package/dist/cases/bulk-actions/list.jsx +209 -0
- package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
- package/dist/cases/bulk-actions/paged-table.jsx +246 -0
- package/dist/cases/bulk-actions.md +559 -0
- package/dist/cases/changelog.md +2 -0
- package/dist/cases/chart.md +2 -0
- package/dist/cases/check-your-email.md +2 -0
- package/dist/cases/code-sample.md +2 -0
- package/dist/cases/collapsible-search.md +2 -0
- package/dist/cases/comment-thread.md +2 -0
- package/dist/cases/comparison-page/table.d.ts +1 -0
- package/dist/cases/comparison-page/table.jsx +97 -0
- package/dist/cases/comparison-page.md +156 -0
- package/dist/cases/composer-limit.md +2 -0
- package/dist/cases/confirm-destructive-action.md +2 -0
- package/dist/cases/confirm-dialogs.md +2 -0
- package/dist/cases/connection-status/card.d.ts +1 -0
- package/dist/cases/connection-status/card.jsx +97 -0
- package/dist/cases/connection-status/row.d.ts +1 -0
- package/dist/cases/connection-status/row.jsx +120 -0
- package/dist/cases/connection-status.md +330 -0
- package/dist/cases/contact-page.md +2 -0
- package/dist/cases/conversation-starters.md +2 -0
- package/dist/cases/cookie-choice.md +2 -0
- package/dist/cases/create-modal.md +2 -0
- package/dist/cases/danger-zone.md +2 -0
- package/dist/cases/dashboard.md +2 -0
- package/dist/cases/data-table-page.md +2 -0
- package/dist/cases/date-field.md +2 -0
- package/dist/cases/device-login.md +2 -0
- package/dist/cases/docs-component-page.md +2 -0
- package/dist/cases/email-confirmed.md +2 -0
- package/dist/cases/empty-list.md +2 -0
- package/dist/cases/empty-lists.md +2 -0
- package/dist/cases/empty-not-set-up.md +2 -0
- package/dist/cases/empty-search.md +2 -0
- package/dist/cases/error-page.md +2 -0
- package/dist/cases/faq.md +2 -0
- package/dist/cases/feature-grid.md +2 -0
- package/dist/cases/feedback-form.md +2 -0
- package/dist/cases/file-upload.md +2 -0
- package/dist/cases/filter-menu.md +2 -0
- package/dist/cases/forgot-password.md +2 -0
- package/dist/cases/form-errors.md +2 -0
- package/dist/cases/image-viewer.md +2 -0
- package/dist/cases/import-checklist.md +2 -0
- package/dist/cases/inline-form-feedback.md +2 -0
- package/dist/cases/integrations-list/nested.jsx +1 -1
- package/dist/cases/integrations-list/rows.jsx +1 -1
- package/dist/cases/integrations-list.md +6 -4
- package/dist/cases/invite-member.md +2 -0
- package/dist/cases/invoice-list.md +2 -0
- package/dist/cases/landing-hero.md +2 -0
- package/dist/cases/leaderboard.md +2 -0
- package/dist/cases/legal-page.md +2 -0
- package/dist/cases/load-failure.md +2 -0
- package/dist/cases/log-out-confirm.md +2 -0
- package/dist/cases/login-page.md +2 -0
- package/dist/cases/long-form-page.md +2 -0
- package/dist/cases/master-detail.md +2 -0
- package/dist/cases/members-list/rows.jsx +37 -6
- package/dist/cases/members-list/table.jsx +37 -6
- package/dist/cases/members-list.md +83 -12
- package/dist/cases/mention-list.md +2 -0
- package/dist/cases/message-actions.md +2 -0
- package/dist/cases/message-attachments.md +2 -0
- package/dist/cases/message-composer/with-tools.jsx +17 -7
- package/dist/cases/message-composer.md +28 -11
- package/dist/cases/message-edit.md +2 -0
- package/dist/cases/message-reactions.md +2 -0
- package/dist/cases/message-row.md +2 -0
- package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
- package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
- package/dist/cases/message-send-failure/retrying.d.ts +1 -0
- package/dist/cases/message-send-failure/retrying.jsx +116 -0
- package/dist/cases/message-send-failure.md +308 -0
- package/dist/cases/mobile-menu.md +2 -0
- package/dist/cases/newsletter-signup.md +2 -0
- package/dist/cases/no-access/page.d.ts +1 -0
- package/dist/cases/no-access/page.jsx +37 -0
- package/dist/cases/no-access/read-only.d.ts +1 -0
- package/dist/cases/no-access/read-only.jsx +33 -0
- package/dist/cases/no-access.md +147 -0
- package/dist/cases/not-found-page.md +2 -0
- package/dist/cases/notification-menu.md +2 -0
- package/dist/cases/number-format.md +2 -0
- package/dist/cases/oauth-consent.md +2 -0
- package/dist/cases/on-off-settings.md +2 -0
- package/dist/cases/on-this-page.md +2 -0
- package/dist/cases/onboarding.md +2 -0
- package/dist/cases/one-main-action.md +2 -0
- package/dist/cases/overflow-menu.md +2 -0
- package/dist/cases/page-end.md +2 -0
- package/dist/cases/page-header.md +2 -0
- package/dist/cases/paged-card.md +2 -0
- package/dist/cases/password-gate.md +2 -0
- package/dist/cases/payment-method.md +2 -0
- package/dist/cases/people-row.md +2 -0
- package/dist/cases/phone-navigation.md +2 -0
- package/dist/cases/plan-change-confirm.md +2 -0
- package/dist/cases/plan-comparison.md +3 -1
- package/dist/cases/plan-picker.md +4 -1
- package/dist/cases/plan-sign-off.md +2 -0
- package/dist/cases/pricing-section.md +5 -1
- package/dist/cases/product-cards.md +2 -0
- package/dist/cases/product-demo/scripted.d.ts +3 -0
- package/dist/cases/product-demo/scripted.jsx +95 -0
- package/dist/cases/product-demo/still.d.ts +1 -0
- package/dist/cases/product-demo/still.jsx +20 -0
- package/dist/cases/product-demo.md +221 -0
- package/dist/cases/profile-form.md +2 -0
- package/dist/cases/quick-switcher.md +2 -0
- package/dist/cases/range-switch.md +2 -0
- package/dist/cases/rename.md +2 -0
- package/dist/cases/reply-feedback.md +2 -0
- package/dist/cases/reply-sources.md +2 -0
- package/dist/cases/route-loading.md +2 -0
- package/dist/cases/scope-picker.md +2 -0
- package/dist/cases/section-index.md +2 -0
- package/dist/cases/session-expired/in-place.d.ts +1 -0
- package/dist/cases/session-expired/in-place.jsx +63 -0
- package/dist/cases/session-expired/redirect.d.ts +1 -0
- package/dist/cases/session-expired/redirect.jsx +62 -0
- package/dist/cases/session-expired.md +204 -0
- package/dist/cases/set-new-password.md +2 -0
- package/dist/cases/settings-page.md +2 -0
- package/dist/cases/settings-save.md +2 -0
- package/dist/cases/side-pane.md +2 -0
- package/dist/cases/sidebar-nav.md +2 -0
- package/dist/cases/sign-up-page.md +3 -0
- package/dist/cases/signup-from-site/plain.d.ts +1 -0
- package/dist/cases/signup-from-site/plain.jsx +125 -0
- package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
- package/dist/cases/signup-from-site/with-plan.jsx +151 -0
- package/dist/cases/signup-from-site.md +351 -0
- package/dist/cases/site-footer.md +2 -0
- package/dist/cases/site-header/links.d.ts +3 -1
- package/dist/cases/site-header/links.jsx +6 -2
- package/dist/cases/site-header.md +11 -3
- package/dist/cases/site-matches-app.md +32 -0
- package/dist/cases/site-search.md +2 -0
- package/dist/cases/slash-command-list.md +2 -0
- package/dist/cases/stat-row.md +2 -0
- package/dist/cases/status-label.md +3 -1
- package/dist/cases/success-feedback.md +2 -0
- package/dist/cases/tabbed-panels.md +2 -0
- package/dist/cases/tag-filter.md +2 -0
- package/dist/cases/task-header.md +2 -0
- package/dist/cases/theme-switcher.md +2 -0
- package/dist/cases/type-to-confirm.md +2 -0
- package/dist/cases/typing-and-status.md +2 -0
- package/dist/cases/unsaved-changes-guard.md +2 -0
- package/dist/cases/upgrade-prompt.md +2 -0
- package/dist/cases/usage-meters.md +2 -0
- package/dist/cases.json +1494 -42
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +23 -9
- package/dist/components/diff.d.ts +29 -0
- package/dist/components/diff.jsx +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/diff.d.ts +17 -0
- package/dist/internal/diff.js +44 -0
- package/dist/native-mapping.json +9 -2
- package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
- package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
- package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
- package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
- package/dist/stories/Cases.generated.stories.d.ts +24 -0
- package/dist/stories/Cases.generated.stories.jsx +48 -0
- package/dist/stories/Checkbox.stories.d.ts +2 -0
- package/dist/stories/Checkbox.stories.jsx +18 -0
- package/dist/stories/Diff.stories.d.ts +9 -0
- package/dist/stories/Diff.stories.jsx +40 -0
- package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
- package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
- package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
- package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
- package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
- package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Product demo on a site
|
|
2
|
+
|
|
3
|
+
A page on the public site shows the product at work, so a visitor sees what it does before they sign up.
|
|
4
|
+
|
|
5
|
+
For: a marketing site
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Follow the rule 'A site promises only what the app does, in the app's words': show only the controls, labels and features the app has.
|
|
10
|
+
- Mark the demo as an example. Put a `Tag` 'Example' on a scripted demo, and say it in the caption of a picture.
|
|
11
|
+
- Use made-up people and made-up work in the demo, never a real customer.
|
|
12
|
+
- Put a picture in a `Figure` with a caption that says what it shows. Give the `Image` an `alt` that says the same for a screen reader.
|
|
13
|
+
- Build a scripted demo from the real parts, such as `Message`, `StepList` and `SourceCard`, in a `Surface`. Then it looks like the app and changes with it.
|
|
14
|
+
- Put one Button first, before the scenes and apart from them. It reads 'Pause' while the demo plays and 'Play' while it does not. This label says what a press does next, as 'Show Danger Zone' does. It is not a status, so it may change.
|
|
15
|
+
- Keep it the same Button when its label changes, so focus stays on it.
|
|
16
|
+
- Let the visitor pick a scene with a `SegmentedControl`. Picking a scene pauses the demo.
|
|
17
|
+
- Start a scripted demo stopped, with 'Play', when the visitor asks for reduced motion. It plays only when they press 'Play'.
|
|
18
|
+
- Show each scene for at least 6 seconds, so a visitor can read it.
|
|
19
|
+
- Keep the demo out of live regions, so a screen reader is not read each scene as it changes.
|
|
20
|
+
- Stop the timers when the demo leaves the page.
|
|
21
|
+
|
|
22
|
+
## Don't
|
|
23
|
+
|
|
24
|
+
- Do not pause the demo on hover only. A keyboard or touch visitor cannot hover.
|
|
25
|
+
- Do not rotate words in the page's h1.
|
|
26
|
+
- Do not show a control, a label or a plan the app does not have.
|
|
27
|
+
- Do not add a message box or other field a visitor might try to type into.
|
|
28
|
+
|
|
29
|
+
## Option: One picture
|
|
30
|
+
|
|
31
|
+
Use when: One picture of the product says enough.
|
|
32
|
+
|
|
33
|
+
Uses: `Figure`, `Image`, `PageSection`, `PageShell`, `SectionIntro`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
'use client';
|
|
37
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
38
|
+
import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
39
|
+
import Figure from 'oneslash-design-system/components/figure';
|
|
40
|
+
import Image from 'oneslash-design-system/components/image';
|
|
41
|
+
import { PageSection } from 'oneslash-design-system/components/layout';
|
|
42
|
+
|
|
43
|
+
// A stand-in for a screenshot of the app: a thread with a question, the agent's reply and two source cards.
|
|
44
|
+
// A real page passes a screenshot of the app as it is today, with made-up people and work in it.
|
|
45
|
+
const threadPicture =
|
|
46
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 400'%3E%3Crect width='640' height='400' fill='%23eef2f6'/%3E%3Crect width='150' height='400' fill='%23dfe7ef'/%3E%3Crect x='20' y='28' width='80' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='20' y='68' width='100' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='20' y='94' width='90' height='10' rx='5' fill='%23c2cfdb'/%3E%3Ccircle cx='190' cy='52' r='12' fill='%23aab8c6'/%3E%3Crect x='212' y='44' width='120' height='10' rx='5' fill='%23aab8c6'/%3E%3Crect x='212' y='64' width='300' height='10' rx='5' fill='%23c2cfdb'/%3E%3Ccircle cx='190' cy='132' r='12' fill='%232f6b4f'/%3E%3Crect x='212' y='124' width='100' height='10' rx='5' fill='%232f6b4f'/%3E%3Crect x='212' y='144' width='360' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='212' y='164' width='280' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='212' y='192' width='170' height='48' rx='10' fill='%23ffffff'/%3E%3Crect x='392' y='192' width='170' height='48' rx='10' fill='%23ffffff'/%3E%3Crect x='170' y='336' width='440' height='40' rx='10' fill='%23ffffff'/%3E%3C/svg%3E";
|
|
47
|
+
|
|
48
|
+
export default function ProductDemoStill() {
|
|
49
|
+
return (
|
|
50
|
+
<PageShell>
|
|
51
|
+
<PageSection gap="xxlarge">
|
|
52
|
+
<SectionIntro id="product-demo-still" name="Ask the agent in the thread" statement="Acme Agent reads the thread and the docs, then answers with its sources." />
|
|
53
|
+
{/* The caption says what the picture shows and that it is an example. The alt says it for a screen reader. */}
|
|
54
|
+
<Figure crop={16 / 10} caption="Example: Dana asks when the pricing page goes live, and Acme Agent answers with two sources. The names are made up.">
|
|
55
|
+
<Image
|
|
56
|
+
src={threadPicture}
|
|
57
|
+
alt="A thread in Acme. Dana Lee asks when the new pricing page goes live. Acme Agent answers Nov 20, 2026, and links the launch plan and a message in the launch channel."
|
|
58
|
+
width={640}
|
|
59
|
+
height={400}
|
|
60
|
+
/>
|
|
61
|
+
</Figure>
|
|
62
|
+
</PageSection>
|
|
63
|
+
</PageShell>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Option: Scripted scenes
|
|
69
|
+
|
|
70
|
+
Use when: The product is about a flow, such as asking an agent and getting an answer.
|
|
71
|
+
|
|
72
|
+
Uses: `Button`, `Cluster`, `Grid`, `Message`, `PageSection`, `PageShell`, `Paragraph`, `SectionIntro`, `SegmentedControl`, `SourceCard`, `Stack`, `StepList`, `Surface`, `Tag`, `TimeStamp`, `UserImage`
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
'use client';
|
|
76
|
+
import { useEffect, useRef, useState } from 'react';
|
|
77
|
+
import { BookOpen, Bot, MessageSquare } from 'lucide-react';
|
|
78
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
79
|
+
import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
80
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
81
|
+
import Message from 'oneslash-design-system/components/message';
|
|
82
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
83
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
84
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
85
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
86
|
+
import Button from 'oneslash-design-system/components/button';
|
|
87
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
88
|
+
import StepList from 'oneslash-design-system/components/stepList';
|
|
89
|
+
import SourceCard from 'oneslash-design-system/components/sourceCard';
|
|
90
|
+
import { Cluster, Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';
|
|
91
|
+
|
|
92
|
+
const agentName = 'Acme Agent';
|
|
93
|
+
|
|
94
|
+
// A made-up thread. Every label in it is one the app has: the agent's marks, its steps and its source cards.
|
|
95
|
+
const request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'When does the new pricing page go live?' };
|
|
96
|
+
const repliedAt = new Date('2026-11-16T14:31:00Z');
|
|
97
|
+
const reply = 'The new pricing page goes live on Nov 20, 2026. Ben moved it two days to finish the plan table.';
|
|
98
|
+
|
|
99
|
+
const scenes = [
|
|
100
|
+
{ value: 'ask', label: 'Ask' },
|
|
101
|
+
{ value: 'work', label: 'Work' },
|
|
102
|
+
{ value: 'answer', label: 'Answer' },
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
// Long enough to read each scene.
|
|
106
|
+
const sceneTime = 6000;
|
|
107
|
+
|
|
108
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
109
|
+
function agentMeta(at: Date) {
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
113
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
114
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// `autoPlay` starts the scenes when the page opens. A real site passes it only when the visitor has not asked for
|
|
120
|
+
// reduced motion, from `matchMedia('(prefers-reduced-motion: reduce)')`. Left out, the demo waits for the visitor.
|
|
121
|
+
export default function ProductDemoScripted({ autoPlay = false }: { autoPlay?: boolean } = {}) {
|
|
122
|
+
const [scene, setScene] = useState(autoPlay ? 'ask' : 'answer');
|
|
123
|
+
const [paused, setPaused] = useState(!autoPlay);
|
|
124
|
+
const timer = useRef<ReturnType<typeof setInterval>>();
|
|
125
|
+
|
|
126
|
+
// Moves to the next scene while the demo plays, and stops when it is paused or leaves the page.
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (paused) return undefined;
|
|
129
|
+
timer.current = setInterval(() => {
|
|
130
|
+
setScene((s) => scenes[(scenes.findIndex((x) => x.value === s) + 1) % scenes.length].value);
|
|
131
|
+
}, sceneTime);
|
|
132
|
+
return () => clearInterval(timer.current);
|
|
133
|
+
}, [paused]);
|
|
134
|
+
|
|
135
|
+
const at = scenes.findIndex((x) => x.value === scene);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<PageShell>
|
|
139
|
+
<PageSection gap="xxlarge">
|
|
140
|
+
<SectionIntro id="product-demo-scripted" name="Ask the agent in the thread" statement="Acme Agent reads the thread and the docs, then answers with its sources." />
|
|
141
|
+
{/* No live region: a screen reader is not read each scene as it changes. */}
|
|
142
|
+
<Surface padding="medium">
|
|
143
|
+
<Stack gap="large">
|
|
144
|
+
{/* Play or Pause comes first, so a keyboard reaches it before anything moves. It is one Button whose label
|
|
145
|
+
says what pressing it does, so focus stays on it when the label changes. Picking a scene pauses too. */}
|
|
146
|
+
<Cluster justify="between">
|
|
147
|
+
<Cluster gap="xlarge">
|
|
148
|
+
<Button
|
|
149
|
+
size="small"
|
|
150
|
+
type="secondary"
|
|
151
|
+
state="enabled"
|
|
152
|
+
label={paused ? 'Play' : 'Pause'}
|
|
153
|
+
onClickButton={() => setPaused((p) => !p)}
|
|
154
|
+
/>
|
|
155
|
+
<SegmentedControl
|
|
156
|
+
size="small"
|
|
157
|
+
width="fit"
|
|
158
|
+
aria-label="Scene"
|
|
159
|
+
options={scenes}
|
|
160
|
+
value={scene}
|
|
161
|
+
onChange={(value) => {
|
|
162
|
+
setPaused(true);
|
|
163
|
+
setScene(value);
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
</Cluster>
|
|
167
|
+
<Tag variant="textOnly" size="small" label="Example" />
|
|
168
|
+
</Cluster>
|
|
169
|
+
<Stack gap="small">
|
|
170
|
+
<Message
|
|
171
|
+
aria-label={request.from}
|
|
172
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
173
|
+
name={request.from}
|
|
174
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
175
|
+
>
|
|
176
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
177
|
+
</Message>
|
|
178
|
+
{at >= 1 && (
|
|
179
|
+
<Message
|
|
180
|
+
aria-label={`${agentName}, agent`}
|
|
181
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
182
|
+
name={agentName}
|
|
183
|
+
meta={agentMeta(repliedAt)}
|
|
184
|
+
footer={
|
|
185
|
+
at === 2 ? (
|
|
186
|
+
// Plain cards: a demo on the site opens nothing.
|
|
187
|
+
<Grid columns={2} gap="medium">
|
|
188
|
+
<SourceCard icon={BookOpen} title="Launch plan" meta="Docs · Nov 14, 2026" />
|
|
189
|
+
<SourceCard icon={MessageSquare} title="Pricing page date" meta="#launch · Nov 15, 2026" />
|
|
190
|
+
</Grid>
|
|
191
|
+
) : undefined
|
|
192
|
+
}
|
|
193
|
+
>
|
|
194
|
+
{at === 2 ? (
|
|
195
|
+
<Paragraph measure="none">{reply}</Paragraph>
|
|
196
|
+
) : (
|
|
197
|
+
<Stack gap="medium">
|
|
198
|
+
<Paragraph size="caption" tone="secondary" measure="none">Working for 4 seconds</Paragraph>
|
|
199
|
+
<StepList
|
|
200
|
+
aria-label="Acme Agent's steps"
|
|
201
|
+
steps={[
|
|
202
|
+
{ label: 'Read the thread in #launch', status: 'done' },
|
|
203
|
+
{ label: 'Read the launch plan', status: 'running' },
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
</Stack>
|
|
207
|
+
)}
|
|
208
|
+
</Message>
|
|
209
|
+
)}
|
|
210
|
+
</Stack>
|
|
211
|
+
</Stack>
|
|
212
|
+
</Surface>
|
|
213
|
+
</PageSection>
|
|
214
|
+
</PageShell>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Native
|
|
220
|
+
|
|
221
|
+
On Apple and Android an app has no product demo. The store page shows screenshots and an app preview video, with only what the app has.
|
package/dist/cases/rename.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A section of a site, such as the guides, has its own first page that shows the places inside it, so a person can pick one.
|
|
4
4
|
|
|
5
|
+
For: a marketing site
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
9
|
- Use `PageHeader` with `level={1}`: the section's name is the one level 1 heading, with a `lede` of one sentence.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SessionExpiredInPlace(): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import TitleBar from '../../components/titleBar';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import TextField from '../../components/textField';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import Modal from '../../components/modal';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
// A real app reads this from the session that ended.
|
|
10
|
+
var email = 'dana@acme.example';
|
|
11
|
+
export default function SessionExpiredInPlace() {
|
|
12
|
+
// Dana was typing a note when her login ended. The note stays on the page behind the Modal.
|
|
13
|
+
var _a = useState('Thanks for the order. The second box ships on Nov 20, 2026, and the invoice covers both.'), note = _a[0], setNote = _a[1];
|
|
14
|
+
// Opens on the Modal, as if the login just ended.
|
|
15
|
+
var _b = useState(true), loggedOut = _b[0], setLoggedOut = _b[1];
|
|
16
|
+
var _c = useState(''), password = _c[0], setPassword = _c[1];
|
|
17
|
+
var _d = useState(''), passwordError = _d[0], setPasswordError = _d[1];
|
|
18
|
+
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
19
|
+
var timer = useRef();
|
|
20
|
+
// Stops the request if the example goes away before it ends.
|
|
21
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
22
|
+
function logIn() {
|
|
23
|
+
if (loading)
|
|
24
|
+
return;
|
|
25
|
+
if (!password) {
|
|
26
|
+
setPasswordError('Enter your password.');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setPasswordError('');
|
|
30
|
+
setLoading(true);
|
|
31
|
+
// Stands in for the request to the server.
|
|
32
|
+
timer.current = setTimeout(function () {
|
|
33
|
+
setLoading(false);
|
|
34
|
+
setPassword('');
|
|
35
|
+
// The Modal gives focus back to the field the person was typing in.
|
|
36
|
+
setLoggedOut(false);
|
|
37
|
+
}, 1200);
|
|
38
|
+
}
|
|
39
|
+
return (<Center width="page">
|
|
40
|
+
<Stack gap="large">
|
|
41
|
+
<TitleBar title="INV-1291"/>
|
|
42
|
+
<Stack gap="medium">
|
|
43
|
+
{/* The field had focus when the login ended. A real app does not move it. */}
|
|
44
|
+
<TextField id="session-expired-note" label="Note to the customer" multiline maxRows={6} autoFocus value={note} onChange={function (e) { return setNote(e.target.value); }}/>
|
|
45
|
+
<Cluster>
|
|
46
|
+
<Button size="medium" type="primary" state="enabled" label="Save Note" onClickButton={function () { return console.info('Save the note'); }}/>
|
|
47
|
+
</Cluster>
|
|
48
|
+
</Stack>
|
|
49
|
+
</Stack>
|
|
50
|
+
{/* The page cannot save until the person logs in, so Escape and a click outside do not close it. */}
|
|
51
|
+
<Modal isOpen={loggedOut} size="small" title="Log In Again" initialFocus="body" onClose={function () { }} actions={<Button size="small" type="primary" state="enabled" label="Log In" loading={loading} onClickButton={logIn}/>}>
|
|
52
|
+
<Paragraph measure="none">{"Log in as ".concat(email, " to keep working. Your note stays on this page.")}</Paragraph>
|
|
53
|
+
<TextField id="session-expired-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }} onKeyDown={function (e) {
|
|
54
|
+
if (e.key === 'Enter') {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
logIn();
|
|
57
|
+
}
|
|
58
|
+
}}/>
|
|
59
|
+
{/* A new tab, so the note stays on this page. */}
|
|
60
|
+
<Button size="small" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" href="/forgot-password" openInNewTab/>
|
|
61
|
+
</Modal>
|
|
62
|
+
</Center>);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SessionExpiredRedirect(): import("react").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Image from '../../components/image';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Form from '../../components/form';
|
|
6
|
+
import Alert from '../../components/alert';
|
|
7
|
+
import TextField from '../../components/textField';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import Line from '../../components/line';
|
|
10
|
+
import BrandIcon from '../../components/brandIcon';
|
|
11
|
+
import { Center } from '../../components/layout';
|
|
12
|
+
// The product's mark. A real app passes its own file.
|
|
13
|
+
var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
|
|
14
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
15
|
+
var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
|
|
16
|
+
// The app sent the person here from '/invoices' with '/login?next=%2Finvoices'. A real app reads it from the address,
|
|
17
|
+
// and goes back only to a page of its own.
|
|
18
|
+
var next = { path: '/invoices', name: 'Invoices' };
|
|
19
|
+
export default function SessionExpiredRedirect() {
|
|
20
|
+
// The email the person used last, so they only type the password.
|
|
21
|
+
var _a = useState('dana@acme.example'), email = _a[0], setEmail = _a[1];
|
|
22
|
+
var _b = useState(''), password = _b[0], setPassword = _b[1];
|
|
23
|
+
var _c = useState(''), emailError = _c[0], setEmailError = _c[1];
|
|
24
|
+
var _d = useState(''), passwordError = _d[0], setPasswordError = _d[1];
|
|
25
|
+
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
26
|
+
var timer = useRef();
|
|
27
|
+
// Stops the request if the example goes away before it ends.
|
|
28
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
29
|
+
function handleSubmit() {
|
|
30
|
+
if (loading)
|
|
31
|
+
return;
|
|
32
|
+
setEmailError('');
|
|
33
|
+
setPasswordError('');
|
|
34
|
+
if (!email.trim()) {
|
|
35
|
+
setEmailError('Enter your email.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!password) {
|
|
39
|
+
setPasswordError('Enter your password.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setLoading(true);
|
|
43
|
+
// Stands in for the request to the server. After it, the person goes back to the page they were on.
|
|
44
|
+
timer.current = setTimeout(function () {
|
|
45
|
+
setLoading(false);
|
|
46
|
+
router.push(next.path);
|
|
47
|
+
}, 1200);
|
|
48
|
+
}
|
|
49
|
+
return (<Center fill>
|
|
50
|
+
<Image src={productMark} alt="Acme" width={40} height={40}/>
|
|
51
|
+
<Heading level={1} size="h5">Log in to Acme</Heading>
|
|
52
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
53
|
+
<Alert type="info" variant="inline" message={"You were logged out. Log in to go back to ".concat(next.name, ".")} autoDismiss={false}/>
|
|
54
|
+
<TextField id="session-expired-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
|
|
55
|
+
<TextField id="session-expired-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
|
|
56
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
|
|
57
|
+
<Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?"/>
|
|
58
|
+
</Form>
|
|
59
|
+
<Line label="or"/>
|
|
60
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
|
|
61
|
+
</Center>);
|
|
62
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Session that ended
|
|
2
|
+
|
|
3
|
+
A person is using the app when their login ends, such as after a long break or a password change somewhere else.
|
|
4
|
+
|
|
5
|
+
For: an app
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Follow the case 'Login page' for the fields, the errors and the loading Button.
|
|
10
|
+
- Open a small `Modal` titled 'Log In Again' over the page when the person has unsaved work, so the work stays where it is.
|
|
11
|
+
- Say whose login ended and that the work is safe: 'Log in as dana@acme.example to keep working. Your note stays on this page.'
|
|
12
|
+
- Ask only for the password in the Modal, or show the provider's Button, such as 'Continue with Google', for a person who logs in that way.
|
|
13
|
+
- Show 'Log In' as `loading` while it runs, and keep its label.
|
|
14
|
+
- Return focus to where it was when the Modal closes, such as the field with the typed text.
|
|
15
|
+
- Open the login page with an info `Alert` when nothing would be lost: 'You were logged out. Log in to go back to Invoices.'
|
|
16
|
+
- Keep the page the person was on in the address, and go back to it after they log in.
|
|
17
|
+
- Fill in the email the person used, so they only type the password.
|
|
18
|
+
|
|
19
|
+
## Don't
|
|
20
|
+
|
|
21
|
+
- Do not send the person to the login page without a word, and drop what they typed.
|
|
22
|
+
- Do not close the Modal on Escape or a click outside. The page cannot save until the person logs in.
|
|
23
|
+
- Do not land on the home page after the login when the person came from another page.
|
|
24
|
+
- Do not say 'Session expired' or 'Token invalid'. Say they were logged out and what to do.
|
|
25
|
+
|
|
26
|
+
## Option: Log in over the page
|
|
27
|
+
|
|
28
|
+
Use when: The person has unsaved work on the page, such as text they typed.
|
|
29
|
+
|
|
30
|
+
Uses: `Button`, `Center`, `Cluster`, `Modal`, `Paragraph`, `Stack`, `TextField`, `TitleBar`
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
'use client';
|
|
34
|
+
import { useEffect, useRef, useState } from 'react';
|
|
35
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
36
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
37
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
38
|
+
import Button from 'oneslash-design-system/components/button';
|
|
39
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
40
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
41
|
+
|
|
42
|
+
// A real app reads this from the session that ended.
|
|
43
|
+
const email = 'dana@acme.example';
|
|
44
|
+
|
|
45
|
+
export default function SessionExpiredInPlace() {
|
|
46
|
+
// Dana was typing a note when her login ended. The note stays on the page behind the Modal.
|
|
47
|
+
const [note, setNote] = useState('Thanks for the order. The second box ships on Nov 20, 2026, and the invoice covers both.');
|
|
48
|
+
// Opens on the Modal, as if the login just ended.
|
|
49
|
+
const [loggedOut, setLoggedOut] = useState(true);
|
|
50
|
+
const [password, setPassword] = useState('');
|
|
51
|
+
const [passwordError, setPasswordError] = useState('');
|
|
52
|
+
const [loading, setLoading] = useState(false);
|
|
53
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
54
|
+
|
|
55
|
+
// Stops the request if the example goes away before it ends.
|
|
56
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
57
|
+
|
|
58
|
+
function logIn() {
|
|
59
|
+
if (loading) return;
|
|
60
|
+
if (!password) {
|
|
61
|
+
setPasswordError('Enter your password.');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setPasswordError('');
|
|
65
|
+
setLoading(true);
|
|
66
|
+
// Stands in for the request to the server.
|
|
67
|
+
timer.current = setTimeout(() => {
|
|
68
|
+
setLoading(false);
|
|
69
|
+
setPassword('');
|
|
70
|
+
// The Modal gives focus back to the field the person was typing in.
|
|
71
|
+
setLoggedOut(false);
|
|
72
|
+
}, 1200);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Center width="page">
|
|
77
|
+
<Stack gap="large">
|
|
78
|
+
<TitleBar title="INV-1291" />
|
|
79
|
+
<Stack gap="medium">
|
|
80
|
+
{/* The field had focus when the login ended. A real app does not move it. */}
|
|
81
|
+
<TextField id="session-expired-note" label="Note to the customer" multiline maxRows={6} autoFocus value={note} onChange={(e) => setNote(e.target.value)} />
|
|
82
|
+
<Cluster>
|
|
83
|
+
<Button size="medium" type="primary" state="enabled" label="Save Note" onClickButton={() => console.info('Save the note')} />
|
|
84
|
+
</Cluster>
|
|
85
|
+
</Stack>
|
|
86
|
+
</Stack>
|
|
87
|
+
{/* The page cannot save until the person logs in, so Escape and a click outside do not close it. */}
|
|
88
|
+
<Modal
|
|
89
|
+
isOpen={loggedOut}
|
|
90
|
+
size="small"
|
|
91
|
+
title="Log In Again"
|
|
92
|
+
initialFocus="body"
|
|
93
|
+
onClose={() => {}}
|
|
94
|
+
actions={<Button size="small" type="primary" state="enabled" label="Log In" loading={loading} onClickButton={logIn} />}
|
|
95
|
+
>
|
|
96
|
+
<Paragraph measure="none">{`Log in as ${email} to keep working. Your note stays on this page.`}</Paragraph>
|
|
97
|
+
<TextField
|
|
98
|
+
id="session-expired-password"
|
|
99
|
+
label="Password"
|
|
100
|
+
type="password"
|
|
101
|
+
autoComplete="current-password"
|
|
102
|
+
value={password}
|
|
103
|
+
disabled={loading}
|
|
104
|
+
error={Boolean(passwordError)}
|
|
105
|
+
errorText={passwordError}
|
|
106
|
+
onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }}
|
|
107
|
+
onKeyDown={(e) => {
|
|
108
|
+
if (e.key === 'Enter') {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
logIn();
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
{/* A new tab, so the note stays on this page. */}
|
|
115
|
+
<Button size="small" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" href="/forgot-password" openInNewTab />
|
|
116
|
+
</Modal>
|
|
117
|
+
</Center>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Option: Log in, then go back
|
|
123
|
+
|
|
124
|
+
Use when: Nothing on the page would be lost, so the login page can take its place.
|
|
125
|
+
|
|
126
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Image`, `Line`, `TextField`
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
'use client';
|
|
130
|
+
import { useEffect, useRef, useState } from 'react';
|
|
131
|
+
import Image from 'oneslash-design-system/components/image';
|
|
132
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
133
|
+
import Form from 'oneslash-design-system/components/form';
|
|
134
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
135
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
136
|
+
import Button from 'oneslash-design-system/components/button';
|
|
137
|
+
import Line from 'oneslash-design-system/components/line';
|
|
138
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
139
|
+
import { Center } from 'oneslash-design-system/components/layout';
|
|
140
|
+
|
|
141
|
+
// The product's mark. A real app passes its own file.
|
|
142
|
+
const productMark =
|
|
143
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
|
|
144
|
+
|
|
145
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
146
|
+
const router = { push: (url: string) => console.info(`Go to ${url}`) };
|
|
147
|
+
|
|
148
|
+
// The app sent the person here from '/invoices' with '/login?next=%2Finvoices'. A real app reads it from the address,
|
|
149
|
+
// and goes back only to a page of its own.
|
|
150
|
+
const next = { path: '/invoices', name: 'Invoices' };
|
|
151
|
+
|
|
152
|
+
export default function SessionExpiredRedirect() {
|
|
153
|
+
// The email the person used last, so they only type the password.
|
|
154
|
+
const [email, setEmail] = useState('dana@acme.example');
|
|
155
|
+
const [password, setPassword] = useState('');
|
|
156
|
+
const [emailError, setEmailError] = useState('');
|
|
157
|
+
const [passwordError, setPasswordError] = useState('');
|
|
158
|
+
const [loading, setLoading] = useState(false);
|
|
159
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
160
|
+
|
|
161
|
+
// Stops the request if the example goes away before it ends.
|
|
162
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
163
|
+
|
|
164
|
+
function handleSubmit() {
|
|
165
|
+
if (loading) return;
|
|
166
|
+
setEmailError('');
|
|
167
|
+
setPasswordError('');
|
|
168
|
+
if (!email.trim()) {
|
|
169
|
+
setEmailError('Enter your email.');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!password) {
|
|
173
|
+
setPasswordError('Enter your password.');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
setLoading(true);
|
|
177
|
+
// Stands in for the request to the server. After it, the person goes back to the page they were on.
|
|
178
|
+
timer.current = setTimeout(() => {
|
|
179
|
+
setLoading(false);
|
|
180
|
+
router.push(next.path);
|
|
181
|
+
}, 1200);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Center fill>
|
|
186
|
+
<Image src={productMark} alt="Acme" width={40} height={40} />
|
|
187
|
+
<Heading level={1} size="h5">Log in to Acme</Heading>
|
|
188
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
189
|
+
<Alert type="info" variant="inline" message={`You were logged out. Log in to go back to ${next.name}.`} autoDismiss={false} />
|
|
190
|
+
<TextField id="session-expired-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
|
|
191
|
+
<TextField id="session-expired-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
|
|
192
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
|
|
193
|
+
<Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
|
|
194
|
+
</Form>
|
|
195
|
+
<Line label="or" />
|
|
196
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
197
|
+
</Center>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Native
|
|
203
|
+
|
|
204
|
+
On Apple show the login as a sheet over the screen with the password field, so the screen behind keeps its state; use `ASWebAuthenticationSession` for a provider. On Android show a dialog with the password field, and keep the screen's state in its `ViewModel`.
|