oneslash-design-system 2.19.0 → 2.21.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 +62 -5
- package/dist/cases/about-page/profile.d.ts +1 -0
- package/dist/cases/about-page/profile.jsx +64 -0
- package/dist/cases/about-page.md +114 -0
- package/dist/cases/admin-inbox/list.d.ts +1 -0
- package/dist/cases/admin-inbox/list.jsx +104 -0
- package/dist/cases/admin-inbox/split.d.ts +1 -0
- package/dist/cases/admin-inbox/split.jsx +68 -0
- package/dist/cases/admin-inbox.md +254 -0
- package/dist/cases/api-keys.md +1 -1
- package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
- package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
- package/dist/cases/billing-page/self-serve.d.ts +1 -0
- package/dist/cases/billing-page/self-serve.jsx +134 -0
- package/dist/cases/billing-page.md +247 -0
- package/dist/cases/blog-index/cards.d.ts +1 -0
- package/dist/cases/blog-index/cards.jsx +45 -0
- package/dist/cases/blog-index/list.d.ts +1 -0
- package/dist/cases/blog-index/list.jsx +46 -0
- package/dist/cases/blog-index.md +160 -0
- package/dist/cases/breakdown-list/bars.d.ts +1 -0
- package/dist/cases/breakdown-list/bars.jsx +47 -0
- package/dist/cases/breakdown-list/table.d.ts +1 -0
- package/dist/cases/breakdown-list/table.jsx +69 -0
- package/dist/cases/breakdown-list.md +158 -0
- package/dist/cases/changelog/by-month.d.ts +1 -0
- package/dist/cases/changelog/by-month.jsx +70 -0
- package/dist/cases/changelog/one-page.d.ts +1 -0
- package/dist/cases/changelog/one-page.jsx +70 -0
- package/dist/cases/changelog.md +200 -0
- package/dist/cases/code-sample/block.d.ts +1 -0
- package/dist/cases/code-sample/block.jsx +19 -0
- package/dist/cases/code-sample/command.d.ts +1 -0
- package/dist/cases/code-sample/command.jsx +17 -0
- package/dist/cases/code-sample.md +96 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
- package/dist/cases/composer-limit/notice.jsx +3 -3
- package/dist/cases/composer-limit.md +8 -8
- package/dist/cases/contact-page/form.d.ts +1 -0
- package/dist/cases/contact-page/form.jsx +83 -0
- package/dist/cases/contact-page/links.d.ts +1 -0
- package/dist/cases/contact-page/links.jsx +19 -0
- package/dist/cases/contact-page.md +142 -0
- package/dist/cases/dashboard/numbers-first.d.ts +1 -0
- package/dist/cases/dashboard/numbers-first.jsx +165 -0
- package/dist/cases/dashboard/work-first.d.ts +1 -0
- package/dist/cases/dashboard/work-first.jsx +165 -0
- package/dist/cases/dashboard.md +507 -0
- package/dist/cases/data-table-page/all-rows.d.ts +1 -0
- package/dist/cases/data-table-page/all-rows.jsx +226 -0
- package/dist/cases/data-table-page/paged.d.ts +1 -0
- package/dist/cases/data-table-page/paged.jsx +284 -0
- package/dist/cases/data-table-page.md +771 -0
- package/dist/cases/docs-component-page/reference.d.ts +1 -0
- package/dist/cases/docs-component-page/reference.jsx +93 -0
- package/dist/cases/docs-component-page.md +144 -0
- package/dist/cases/faq/accordion.d.ts +1 -0
- package/dist/cases/faq/accordion.jsx +25 -0
- package/dist/cases/faq/open-list.d.ts +1 -0
- package/dist/cases/faq/open-list.jsx +27 -0
- package/dist/cases/faq.md +110 -0
- package/dist/cases/feature-grid/cards.d.ts +1 -0
- package/dist/cases/feature-grid/cards.jsx +33 -0
- package/dist/cases/feature-grid/rows.d.ts +1 -0
- package/dist/cases/feature-grid/rows.jsx +30 -0
- package/dist/cases/feature-grid.md +132 -0
- package/dist/cases/image-viewer/gallery.d.ts +1 -0
- package/dist/cases/image-viewer/gallery.jsx +32 -0
- package/dist/cases/image-viewer/single.d.ts +1 -0
- package/dist/cases/image-viewer/single.jsx +25 -0
- package/dist/cases/image-viewer.md +123 -0
- package/dist/cases/invoice-list/table.d.ts +1 -0
- package/dist/cases/invoice-list/table.jsx +64 -0
- package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
- package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
- package/dist/cases/invoice-list.md +237 -0
- package/dist/cases/landing-hero/centered.d.ts +1 -0
- package/dist/cases/landing-hero/centered.jsx +22 -0
- package/dist/cases/landing-hero/split.d.ts +1 -0
- package/dist/cases/landing-hero/split.jsx +30 -0
- package/dist/cases/landing-hero.md +114 -0
- package/dist/cases/legal-page/sections.d.ts +1 -0
- package/dist/cases/legal-page/sections.jsx +61 -0
- package/dist/cases/legal-page.md +96 -0
- package/dist/cases/load-failure/inline.jsx +2 -2
- package/dist/cases/load-failure.md +2 -2
- package/dist/cases/long-form-page/article.d.ts +1 -0
- package/dist/cases/long-form-page/article.jsx +58 -0
- package/dist/cases/long-form-page/with-contents.d.ts +1 -0
- package/dist/cases/long-form-page/with-contents.jsx +41 -0
- package/dist/cases/long-form-page.md +170 -0
- package/dist/cases/members-list/rows.jsx +2 -1
- package/dist/cases/members-list/table.jsx +8 -9
- package/dist/cases/members-list.md +12 -13
- package/dist/cases/message-actions/hover-toolbar.jsx +11 -8
- package/dist/cases/message-actions/menu.jsx +10 -7
- package/dist/cases/message-actions.md +19 -13
- package/dist/cases/message-attachments/in-composer.jsx +2 -2
- package/dist/cases/message-attachments/in-message.jsx +16 -11
- package/dist/cases/message-attachments.md +29 -17
- package/dist/cases/number-format.md +36 -0
- package/dist/cases/one-main-action.md +33 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
- package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
- package/dist/cases/overflow-menu.md +16 -10
- package/dist/cases/page-end/cta-band.d.ts +1 -0
- package/dist/cases/page-end/cta-band.jsx +24 -0
- package/dist/cases/page-end/next-link.d.ts +1 -0
- package/dist/cases/page-end/next-link.jsx +18 -0
- package/dist/cases/page-end.md +88 -0
- package/dist/cases/paged-card/pager.d.ts +1 -0
- package/dist/cases/paged-card/pager.jsx +41 -0
- package/dist/cases/paged-card/see-all.d.ts +1 -0
- package/dist/cases/paged-card/see-all.jsx +34 -0
- package/dist/cases/paged-card.md +147 -0
- package/dist/cases/password-gate/inline.d.ts +1 -0
- package/dist/cases/password-gate/inline.jsx +94 -0
- package/dist/cases/password-gate/modal.d.ts +1 -0
- package/dist/cases/password-gate/modal.jsx +81 -0
- package/dist/cases/password-gate/page.d.ts +1 -0
- package/dist/cases/password-gate/page.jsx +82 -0
- package/dist/cases/password-gate.md +351 -0
- package/dist/cases/payment-method/none.d.ts +1 -0
- package/dist/cases/payment-method/none.jsx +17 -0
- package/dist/cases/payment-method/on-file.d.ts +1 -0
- package/dist/cases/payment-method/on-file.jsx +92 -0
- package/dist/cases/payment-method.md +182 -0
- package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
- package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
- package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
- package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
- package/dist/cases/plan-change-confirm.md +261 -0
- package/dist/cases/plan-picker/cards.d.ts +1 -0
- package/dist/cases/plan-picker/cards.jsx +97 -0
- package/dist/cases/plan-picker/list.d.ts +1 -0
- package/dist/cases/plan-picker/list.jsx +103 -0
- package/dist/cases/plan-picker.md +297 -0
- package/dist/cases/pricing-section/cards.d.ts +1 -0
- package/dist/cases/pricing-section/cards.jsx +40 -0
- package/dist/cases/pricing-section.md +85 -0
- package/dist/cases/product-cards/grid.d.ts +1 -0
- package/dist/cases/product-cards/grid.jsx +20 -0
- package/dist/cases/product-cards.md +71 -0
- package/dist/cases/range-switch/segmented.jsx +11 -7
- package/dist/cases/range-switch.md +16 -11
- package/dist/cases/reply-feedback/thumbs.jsx +11 -8
- package/dist/cases/reply-feedback/with-reason.jsx +11 -8
- package/dist/cases/reply-feedback.md +20 -14
- package/dist/cases/section-index/cards.d.ts +1 -0
- package/dist/cases/section-index/cards.jsx +25 -0
- package/dist/cases/section-index/list.d.ts +1 -0
- package/dist/cases/section-index/list.jsx +56 -0
- package/dist/cases/section-index.md +140 -0
- package/dist/cases/settings-page/top-tabs.jsx +4 -3
- package/dist/cases/settings-page.md +5 -4
- package/dist/cases/site-header.md +1 -1
- package/dist/cases/site-search/dialog.d.ts +1 -0
- package/dist/cases/site-search/dialog.jsx +131 -0
- package/dist/cases/site-search.md +176 -0
- package/dist/cases/stat-row/featured.d.ts +1 -0
- package/dist/cases/stat-row/featured.jsx +17 -0
- package/dist/cases/stat-row/tiles.d.ts +1 -0
- package/dist/cases/stat-row/tiles.jsx +34 -0
- package/dist/cases/stat-row.md +104 -0
- package/dist/cases/status-label/dot.d.ts +1 -0
- package/dist/cases/status-label/dot.jsx +39 -0
- package/dist/cases/status-label/text.d.ts +1 -0
- package/dist/cases/status-label/text.jsx +44 -0
- package/dist/cases/status-label.md +143 -0
- package/dist/cases/tabbed-panels/tabs.d.ts +1 -0
- package/dist/cases/tabbed-panels/tabs.jsx +40 -0
- package/dist/cases/tabbed-panels.md +81 -0
- package/dist/cases/upgrade-prompt/inline.jsx +4 -2
- package/dist/cases/upgrade-prompt/modal.jsx +2 -1
- package/dist/cases/upgrade-prompt.md +10 -6
- package/dist/cases/usage-meters/by-person.d.ts +1 -0
- package/dist/cases/usage-meters/by-person.jsx +72 -0
- package/dist/cases/usage-meters/meters.d.ts +1 -0
- package/dist/cases/usage-meters/meters.jsx +49 -0
- package/dist/cases/usage-meters/with-cap.d.ts +1 -0
- package/dist/cases/usage-meters/with-cap.jsx +73 -0
- package/dist/cases/usage-meters.md +303 -0
- package/dist/cases.json +2178 -97
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.jsx +103 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.jsx +11 -5
- package/dist/components/codeBlock.d.ts +26 -0
- package/dist/components/codeBlock.jsx +101 -0
- package/dist/components/formatNumber.d.ts +25 -0
- package/dist/components/formatNumber.js +125 -0
- package/dist/components/iconButton.jsx +12 -7
- package/dist/components/lightbox.d.ts +31 -0
- package/dist/components/lightbox.jsx +161 -0
- package/dist/components/linkCard.d.ts +10 -1
- package/dist/components/linkCard.jsx +32 -6
- package/dist/components/modal.d.ts +10 -2
- package/dist/components/modal.jsx +17 -12
- package/dist/components/pageHeader.jsx +1 -1
- package/dist/components/pagination.d.ts +28 -0
- package/dist/components/pagination.jsx +89 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.jsx +50 -0
- package/dist/components/searchDialog.d.ts +44 -0
- package/dist/components/searchDialog.jsx +152 -0
- package/dist/components/skeleton.d.ts +21 -0
- package/dist/components/skeleton.jsx +41 -0
- package/dist/components/statTile.d.ts +32 -0
- package/dist/components/statTile.jsx +61 -0
- package/dist/components/tab.d.ts +5 -1
- package/dist/components/tab.jsx +2 -2
- package/dist/components/tabPanel.d.ts +16 -0
- package/dist/components/tabPanel.jsx +12 -0
- package/dist/components/tableContainer.d.ts +5 -1
- package/dist/components/tableContainer.jsx +9 -1
- package/dist/components/tableHeaderCell.d.ts +3 -1
- package/dist/components/tableHeaderCell.jsx +2 -2
- package/dist/components/tabsContainer.d.ts +5 -1
- package/dist/components/tabsContainer.jsx +2 -2
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +4 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/internal/accordion.d.ts +4 -0
- package/dist/internal/accordion.js +53 -0
- package/dist/internal/combobox.d.ts +20 -0
- package/dist/internal/combobox.js +28 -0
- package/dist/internal/highlight.d.ts +5 -0
- package/dist/internal/highlight.js +18 -0
- package/dist/native-mapping.json +57 -3
- package/dist/stories/Accordion.stories.d.ts +11 -0
- package/dist/stories/Accordion.stories.jsx +93 -0
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +19 -1
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +120 -0
- package/dist/stories/CodeBlock.stories.d.ts +12 -0
- package/dist/stories/CodeBlock.stories.jsx +65 -0
- package/dist/stories/Lightbox.stories.d.ts +8 -0
- package/dist/stories/Lightbox.stories.jsx +40 -0
- package/dist/stories/LinkCard.stories.d.ts +6 -0
- package/dist/stories/LinkCard.stories.jsx +17 -0
- package/dist/stories/PageHeader.stories.d.ts +2 -0
- package/dist/stories/PageHeader.stories.jsx +13 -0
- package/dist/stories/Pagination.stories.d.ts +9 -0
- package/dist/stories/Pagination.stories.jsx +75 -0
- package/dist/stories/Progress.stories.d.ts +9 -0
- package/dist/stories/Progress.stories.jsx +43 -0
- package/dist/stories/SearchDialog.stories.d.ts +17 -0
- package/dist/stories/SearchDialog.stories.jsx +111 -0
- package/dist/stories/Skeleton.stories.d.ts +7 -0
- package/dist/stories/Skeleton.stories.jsx +27 -0
- package/dist/stories/StatTile.stories.d.ts +10 -0
- package/dist/stories/StatTile.stories.jsx +55 -0
- package/dist/stories/TabPanel.stories.d.ts +7 -0
- package/dist/stories/TabPanel.stories.jsx +31 -0
- package/dist/stories/Table.stories.d.ts +1 -0
- package/dist/stories/Table.stories.jsx +49 -1
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +7 -0
- package/package.json +5 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import AppShell from '../../components/appShell';
|
|
4
|
+
import TitleBar from '../../components/titleBar';
|
|
5
|
+
import SegmentedControl from '../../components/segmentedControl';
|
|
6
|
+
import SettingsSection from '../../components/settingsSection';
|
|
7
|
+
import Navigation from '../../components/navigation';
|
|
8
|
+
import MenuItem from '../../components/menuItem';
|
|
9
|
+
import StatTile from '../../components/statTile';
|
|
10
|
+
import Progress from '../../components/progress';
|
|
11
|
+
import Skeleton from '../../components/skeleton';
|
|
12
|
+
import Alert from '../../components/alert';
|
|
13
|
+
import Button from '../../components/button';
|
|
14
|
+
import Paragraph from '../../components/paragraph';
|
|
15
|
+
import EmptyBox from '../../components/emptyBox';
|
|
16
|
+
import List from '../../components/list';
|
|
17
|
+
import { formatCount } from '../../components/formatNumber';
|
|
18
|
+
import { Cluster, Grid, Stack } from '../../components/layout';
|
|
19
|
+
var ranges = [
|
|
20
|
+
{ value: 'week', label: 'Week' },
|
|
21
|
+
{ value: 'month', label: 'Month' },
|
|
22
|
+
{ value: 'quarter', label: 'Quarter' },
|
|
23
|
+
];
|
|
24
|
+
// A real app counts these on the server. One range drives every number on the page.
|
|
25
|
+
var data = {
|
|
26
|
+
week: {
|
|
27
|
+
stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8640000, 9200000] },
|
|
28
|
+
projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],
|
|
29
|
+
waiting: [
|
|
30
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
31
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
32
|
+
['Review the pricing copy', '/comments/3'],
|
|
33
|
+
],
|
|
34
|
+
questions: [],
|
|
35
|
+
},
|
|
36
|
+
month: {
|
|
37
|
+
stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7800000, 8100000] },
|
|
38
|
+
projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],
|
|
39
|
+
waiting: [
|
|
40
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
41
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
42
|
+
['Review the pricing copy', '/comments/3'],
|
|
43
|
+
['Confirm the release date', '/comments/4'],
|
|
44
|
+
['Approve the new onboarding text', '/comments/5'],
|
|
45
|
+
],
|
|
46
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],
|
|
47
|
+
},
|
|
48
|
+
quarter: {
|
|
49
|
+
stats: { comments: [15880, 12410], done: [3950, 3210], people: [44, 36], reply: [7200000, 7900000] },
|
|
50
|
+
projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],
|
|
51
|
+
waiting: [
|
|
52
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
53
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
54
|
+
['Review the pricing copy', '/comments/3'],
|
|
55
|
+
['Confirm the release date', '/comments/4'],
|
|
56
|
+
],
|
|
57
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
var noun = { week: 'this week', month: 'this month', quarter: 'this quarter' };
|
|
61
|
+
export default function DashboardWorkFirst() {
|
|
62
|
+
var _a = useState('week'), range = _a[0], setRange = _a[1];
|
|
63
|
+
// The numbers load again when the range changes.
|
|
64
|
+
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
65
|
+
// The projects section fails first, so the rest of the page shows that one section can fail alone.
|
|
66
|
+
var _c = useState(true), projectsFailed = _c[0], setProjectsFailed = _c[1];
|
|
67
|
+
var _d = useState(false), retrying = _d[0], setRetrying = _d[1];
|
|
68
|
+
var _e = useState(false), navOpen = _e[0], setNavOpen = _e[1];
|
|
69
|
+
var timer = useRef();
|
|
70
|
+
var retryTimer = useRef();
|
|
71
|
+
// Stops the requests if the example goes away before they end.
|
|
72
|
+
useEffect(function () { return function () {
|
|
73
|
+
clearTimeout(timer.current);
|
|
74
|
+
clearTimeout(retryTimer.current);
|
|
75
|
+
}; }, []);
|
|
76
|
+
function changeRange(next) {
|
|
77
|
+
clearTimeout(timer.current);
|
|
78
|
+
setRange(next);
|
|
79
|
+
setLoading(true);
|
|
80
|
+
// Stands in for the request to the server.
|
|
81
|
+
timer.current = setTimeout(function () { return setLoading(false); }, 600);
|
|
82
|
+
}
|
|
83
|
+
function tryAgain() {
|
|
84
|
+
if (retrying)
|
|
85
|
+
return;
|
|
86
|
+
setRetrying(true);
|
|
87
|
+
retryTimer.current = setTimeout(function () {
|
|
88
|
+
setRetrying(false);
|
|
89
|
+
setProjectsFailed(false);
|
|
90
|
+
}, 1200);
|
|
91
|
+
}
|
|
92
|
+
var d = data[range];
|
|
93
|
+
var period = range;
|
|
94
|
+
var projectTotal = d.projects.reduce(function (sum, p) { return sum + p[1]; }, 0);
|
|
95
|
+
var waitingCount = d.waiting.length;
|
|
96
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
97
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
98
|
+
{[
|
|
99
|
+
['Dashboard', 'LayoutDashboard', '/dashboard'],
|
|
100
|
+
['Comments', 'MessageSquare', '/comments'],
|
|
101
|
+
['Projects', 'FolderKanban', '/projects'],
|
|
102
|
+
].map(function (_a) {
|
|
103
|
+
var label = _a[0], icon = _a[1], href = _a[2];
|
|
104
|
+
return (<MenuItem key={href} size="small" label={label} iconName={icon} href={href} isSelected={href === '/dashboard'} aria-current={href === '/dashboard' ? 'page' : undefined} onClick={function (event) {
|
|
105
|
+
// A real app lets the link go to its page. The example stays here.
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
}}/>);
|
|
108
|
+
})}
|
|
109
|
+
</Navigation>);
|
|
110
|
+
var statRow = (<SettingsSection key="stats" title={"Numbers ".concat(noun[range])} id="dashboard-stats">
|
|
111
|
+
<Grid compact columns={4}>
|
|
112
|
+
<StatTile label="New comments" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading}/>
|
|
113
|
+
<StatTile label="Marked done" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading}/>
|
|
114
|
+
<StatTile label="People engaged" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading}/>
|
|
115
|
+
<StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading}/>
|
|
116
|
+
</Grid>
|
|
117
|
+
</SettingsSection>);
|
|
118
|
+
var projects = (<SettingsSection key="projects" title="Projects" description={"".concat(formatCount(projectTotal), " comments ").concat(noun[range], ", by project")} id="dashboard-projects">
|
|
119
|
+
{projectsFailed ? (<>
|
|
120
|
+
{/* Only this section failed. The rest of the page still shows. */}
|
|
121
|
+
<Alert type="error" variant="inline" message="Could not load projects." autoDismiss={false}/>
|
|
122
|
+
<Cluster>
|
|
123
|
+
<Button size="small" type="primary" state="enabled" label="Try Again" loading={retrying} onClickButton={tryAgain}/>
|
|
124
|
+
</Cluster>
|
|
125
|
+
</>) : loading ? (<Skeleton variant="text" lines={3} label="Loading projects"/>) : (<List size="body2" items={d.projects.map(function (_a) {
|
|
126
|
+
var name = _a[0], count = _a[1];
|
|
127
|
+
return (<Progress key={name} kind="share" label={name} value={count} max={projectTotal} unit="comments"/>);
|
|
128
|
+
})}/>)}
|
|
129
|
+
</SettingsSection>);
|
|
130
|
+
var waiting = (<SettingsSection key="waiting" title={loading ? 'Waiting on you' : "".concat(formatCount(waitingCount), " ").concat(waitingCount === 1 ? 'comment' : 'comments', " waiting on you")} description={"Asked of you ".concat(noun[range])} id="dashboard-waiting">
|
|
131
|
+
{loading ? (<Skeleton variant="text" lines={3} label="Loading what waits on you"/>) : (<Stack gap="small">
|
|
132
|
+
{d.waiting.map(function (_a) {
|
|
133
|
+
var text = _a[0], href = _a[1];
|
|
134
|
+
return (<MenuItem key={href} size="medium" label={text} href={href} onClick={function (event) {
|
|
135
|
+
// A real app lets the link go to its page. The example stays here.
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
}}/>);
|
|
138
|
+
})}
|
|
139
|
+
</Stack>)}
|
|
140
|
+
</SettingsSection>);
|
|
141
|
+
var questions = (<SettingsSection key="questions" title="Questions from your agents" id="dashboard-questions">
|
|
142
|
+
{loading ? (<Skeleton variant="text" lines={2} label="Loading questions"/>) : d.questions.length === 0 ? (
|
|
143
|
+
// A section with nothing keeps its place and says what will fill it.
|
|
144
|
+
<EmptyBox size="small" text={"No questions from your agents ".concat(noun[range])} secondText="Questions your agents ask you appear here."/>) : (<Stack gap="small">
|
|
145
|
+
{d.questions.map(function (_a) {
|
|
146
|
+
var text = _a[0], href = _a[1];
|
|
147
|
+
return (<MenuItem key={href} size="medium" label={text} href={href} onClick={function (event) {
|
|
148
|
+
// A real app lets the link go to its page. The example stays here.
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
}}/>);
|
|
151
|
+
})}
|
|
152
|
+
</Stack>)}
|
|
153
|
+
</SettingsSection>);
|
|
154
|
+
return (<AppShell title="Dashboard" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
155
|
+
<Stack gap="xlarge">
|
|
156
|
+
{/* One range drives every number below, and each heading says which one. */}
|
|
157
|
+
{/* Below md the range switch takes its own line under the title. */}
|
|
158
|
+
<TitleBar title="Dashboard" actionsBelow actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange}/>}/>
|
|
159
|
+
{waiting}
|
|
160
|
+
{questions}
|
|
161
|
+
{statRow}
|
|
162
|
+
{projects}
|
|
163
|
+
</Stack>
|
|
164
|
+
</AppShell>);
|
|
165
|
+
}
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# Dashboard
|
|
2
|
+
|
|
3
|
+
A page that opens an app and says how things are going and what waits on the person.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Put the page in `AppShell`, with a `TitleBar` named 'Dashboard' and a 'Range' `SegmentedControl` as its `actions`, as the case 'Range switch' says. Set `actionsBelow` so the switch takes its own line under the title on a phone.
|
|
9
|
+
- Let the one range drive every number on the page, and name it in every heading and caption: 'this week'.
|
|
10
|
+
- Show the stat row as the case 'Stat row' says, and a share of a total as the case 'Breakdown of a total' says.
|
|
11
|
+
- Make each section a `SettingsSection`: a hairline, a title and its content. Do not put a section in a box.
|
|
12
|
+
- Put the list of what waits on the person in a section titled with its count and unit: '3 comments waiting on you'. Make each row a link.
|
|
13
|
+
- Show a list that can be longer than its section as the case 'Short list on a dashboard' says.
|
|
14
|
+
- Show `EmptyBox size="small"` in a section with nothing, as the rule 'An empty list says what will fill it' says: 'No questions from your agents this week'. Keep the section.
|
|
15
|
+
- Show a failed section as the case 'Load failure' says, inline with 'Try Again', and keep the rest of the page.
|
|
16
|
+
- Show a `Skeleton` or the tile's own loading state while the range changes. Do not show 0.
|
|
17
|
+
|
|
18
|
+
## Don't
|
|
19
|
+
|
|
20
|
+
- Do not draw a chart. A trend is the change line on a tile, and a share is a ranked list.
|
|
21
|
+
- Do not count different sections over different ranges.
|
|
22
|
+
- Do not replace the whole page when one section failed.
|
|
23
|
+
- Do not put more than four tiles in the stat row.
|
|
24
|
+
- Do not hide a section that has nothing, or leave it blank.
|
|
25
|
+
- Do not box the sections in cards.
|
|
26
|
+
|
|
27
|
+
## Option: Numbers first
|
|
28
|
+
|
|
29
|
+
Use when: The page reports how things went, for a lead who checks on a team.
|
|
30
|
+
|
|
31
|
+
Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
'use client';
|
|
35
|
+
import { useEffect, useRef, useState } from 'react';
|
|
36
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
37
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
38
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
39
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
40
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
41
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
42
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
43
|
+
import Progress from 'oneslash-design-system/components/progress';
|
|
44
|
+
import Skeleton from 'oneslash-design-system/components/skeleton';
|
|
45
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
46
|
+
import Button from 'oneslash-design-system/components/button';
|
|
47
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
48
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
49
|
+
import List from 'oneslash-design-system/components/list';
|
|
50
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
51
|
+
import { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
52
|
+
|
|
53
|
+
type Range = 'week' | 'month' | 'quarter';
|
|
54
|
+
const ranges = [
|
|
55
|
+
{ value: 'week', label: 'Week' },
|
|
56
|
+
{ value: 'month', label: 'Month' },
|
|
57
|
+
{ value: 'quarter', label: 'Quarter' },
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
// A real app counts these on the server. One range drives every number on the page.
|
|
61
|
+
const data = {
|
|
62
|
+
week: {
|
|
63
|
+
stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },
|
|
64
|
+
projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],
|
|
65
|
+
waiting: [
|
|
66
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
67
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
68
|
+
['Review the pricing copy', '/comments/3'],
|
|
69
|
+
],
|
|
70
|
+
questions: [],
|
|
71
|
+
},
|
|
72
|
+
month: {
|
|
73
|
+
stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },
|
|
74
|
+
projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],
|
|
75
|
+
waiting: [
|
|
76
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
77
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
78
|
+
['Review the pricing copy', '/comments/3'],
|
|
79
|
+
['Confirm the release date', '/comments/4'],
|
|
80
|
+
['Approve the new onboarding text', '/comments/5'],
|
|
81
|
+
],
|
|
82
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],
|
|
83
|
+
},
|
|
84
|
+
quarter: {
|
|
85
|
+
stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },
|
|
86
|
+
projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],
|
|
87
|
+
waiting: [
|
|
88
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
89
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
90
|
+
['Review the pricing copy', '/comments/3'],
|
|
91
|
+
['Confirm the release date', '/comments/4'],
|
|
92
|
+
],
|
|
93
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],
|
|
94
|
+
},
|
|
95
|
+
} as const;
|
|
96
|
+
|
|
97
|
+
const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
|
|
98
|
+
|
|
99
|
+
export default function DashboardNumbersFirst() {
|
|
100
|
+
const [range, setRange] = useState<Range>('week');
|
|
101
|
+
// The numbers load again when the range changes.
|
|
102
|
+
const [loading, setLoading] = useState(false);
|
|
103
|
+
// The projects section fails first, so the rest of the page shows that one section can fail alone.
|
|
104
|
+
const [projectsFailed, setProjectsFailed] = useState(true);
|
|
105
|
+
const [retrying, setRetrying] = useState(false);
|
|
106
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
107
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
108
|
+
const retryTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
109
|
+
|
|
110
|
+
// Stops the requests if the example goes away before they end.
|
|
111
|
+
useEffect(() => () => {
|
|
112
|
+
clearTimeout(timer.current);
|
|
113
|
+
clearTimeout(retryTimer.current);
|
|
114
|
+
}, []);
|
|
115
|
+
|
|
116
|
+
function changeRange(next: string) {
|
|
117
|
+
clearTimeout(timer.current);
|
|
118
|
+
setRange(next as Range);
|
|
119
|
+
setLoading(true);
|
|
120
|
+
// Stands in for the request to the server.
|
|
121
|
+
timer.current = setTimeout(() => setLoading(false), 600);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function tryAgain() {
|
|
125
|
+
if (retrying) return;
|
|
126
|
+
setRetrying(true);
|
|
127
|
+
retryTimer.current = setTimeout(() => {
|
|
128
|
+
setRetrying(false);
|
|
129
|
+
setProjectsFailed(false);
|
|
130
|
+
}, 1200);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const d = data[range];
|
|
134
|
+
const period = range;
|
|
135
|
+
const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);
|
|
136
|
+
const waitingCount: number = d.waiting.length;
|
|
137
|
+
|
|
138
|
+
const sidebar = (
|
|
139
|
+
<Navigation aria-label="Main">
|
|
140
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
141
|
+
{[
|
|
142
|
+
['Dashboard', 'LayoutDashboard', '/dashboard'],
|
|
143
|
+
['Comments', 'MessageSquare', '/comments'],
|
|
144
|
+
['Projects', 'FolderKanban', '/projects'],
|
|
145
|
+
].map(([label, icon, href]) => (
|
|
146
|
+
<MenuItem
|
|
147
|
+
key={href}
|
|
148
|
+
size="small"
|
|
149
|
+
label={label}
|
|
150
|
+
iconName={icon}
|
|
151
|
+
href={href}
|
|
152
|
+
isSelected={href === '/dashboard'}
|
|
153
|
+
aria-current={href === '/dashboard' ? 'page' : undefined}
|
|
154
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
155
|
+
// A real app lets the link go to its page. The example stays here.
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
))}
|
|
160
|
+
</Navigation>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const statRow = (
|
|
164
|
+
<SettingsSection key="stats" title={`Numbers ${noun[range]}`} id="dashboard-stats">
|
|
165
|
+
<Grid compact columns={4}>
|
|
166
|
+
<StatTile label="New comments" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />
|
|
167
|
+
<StatTile label="Marked done" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />
|
|
168
|
+
<StatTile label="People engaged" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />
|
|
169
|
+
<StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading} />
|
|
170
|
+
</Grid>
|
|
171
|
+
</SettingsSection>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const projects = (
|
|
175
|
+
<SettingsSection key="projects" title="Projects" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id="dashboard-projects">
|
|
176
|
+
{projectsFailed ? (
|
|
177
|
+
<>
|
|
178
|
+
{/* Only this section failed. The rest of the page still shows. */}
|
|
179
|
+
<Alert type="error" variant="inline" message="Could not load projects." autoDismiss={false} />
|
|
180
|
+
<Cluster>
|
|
181
|
+
<Button size="small" type="primary" state="enabled" label="Try Again" loading={retrying} onClickButton={tryAgain} />
|
|
182
|
+
</Cluster>
|
|
183
|
+
</>
|
|
184
|
+
) : loading ? (
|
|
185
|
+
<Skeleton variant="text" lines={3} label="Loading projects" />
|
|
186
|
+
) : (
|
|
187
|
+
<List
|
|
188
|
+
size="body2"
|
|
189
|
+
items={d.projects.map(([name, count]) => (
|
|
190
|
+
<Progress key={name} kind="share" label={name} value={count} max={projectTotal} unit="comments" />
|
|
191
|
+
))}
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
194
|
+
</SettingsSection>
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const waiting = (
|
|
198
|
+
<SettingsSection key="waiting" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id="dashboard-waiting">
|
|
199
|
+
{loading ? (
|
|
200
|
+
<Skeleton variant="text" lines={3} label="Loading what waits on you" />
|
|
201
|
+
) : (
|
|
202
|
+
<Stack gap="small">
|
|
203
|
+
{d.waiting.map(([text, href]) => (
|
|
204
|
+
<MenuItem
|
|
205
|
+
key={href}
|
|
206
|
+
size="medium"
|
|
207
|
+
label={text}
|
|
208
|
+
href={href}
|
|
209
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
210
|
+
// A real app lets the link go to its page. The example stays here.
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
}}
|
|
213
|
+
/>
|
|
214
|
+
))}
|
|
215
|
+
</Stack>
|
|
216
|
+
)}
|
|
217
|
+
</SettingsSection>
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const questions = (
|
|
221
|
+
<SettingsSection key="questions" title="Questions from your agents" id="dashboard-questions">
|
|
222
|
+
{loading ? (
|
|
223
|
+
<Skeleton variant="text" lines={2} label="Loading questions" />
|
|
224
|
+
) : d.questions.length === 0 ? (
|
|
225
|
+
// A section with nothing keeps its place and says what will fill it.
|
|
226
|
+
<EmptyBox size="small" text={`No questions from your agents ${noun[range]}`} secondText="Questions your agents ask you appear here." />
|
|
227
|
+
) : (
|
|
228
|
+
<Stack gap="small">
|
|
229
|
+
{d.questions.map(([text, href]) => (
|
|
230
|
+
<MenuItem
|
|
231
|
+
key={href}
|
|
232
|
+
size="medium"
|
|
233
|
+
label={text}
|
|
234
|
+
href={href}
|
|
235
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
236
|
+
// A real app lets the link go to its page. The example stays here.
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
}}
|
|
239
|
+
/>
|
|
240
|
+
))}
|
|
241
|
+
</Stack>
|
|
242
|
+
)}
|
|
243
|
+
</SettingsSection>
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<AppShell title="Dashboard" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
248
|
+
<Stack gap="xlarge">
|
|
249
|
+
{/* One range drives every number below, and each heading says which one. */}
|
|
250
|
+
{/* Below md the range switch takes its own line under the title. */}
|
|
251
|
+
<TitleBar
|
|
252
|
+
title="Dashboard"
|
|
253
|
+
actionsBelow
|
|
254
|
+
actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
|
|
255
|
+
/>
|
|
256
|
+
{statRow}
|
|
257
|
+
{projects}
|
|
258
|
+
{waiting}
|
|
259
|
+
{questions}
|
|
260
|
+
</Stack>
|
|
261
|
+
</AppShell>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Option: Work first
|
|
267
|
+
|
|
268
|
+
Use when: The person starts their day here, so what waits on them comes before the numbers.
|
|
269
|
+
|
|
270
|
+
Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
'use client';
|
|
274
|
+
import { useEffect, useRef, useState } from 'react';
|
|
275
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
276
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
277
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
278
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
279
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
280
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
281
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
282
|
+
import Progress from 'oneslash-design-system/components/progress';
|
|
283
|
+
import Skeleton from 'oneslash-design-system/components/skeleton';
|
|
284
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
285
|
+
import Button from 'oneslash-design-system/components/button';
|
|
286
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
287
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
288
|
+
import List from 'oneslash-design-system/components/list';
|
|
289
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
290
|
+
import { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
291
|
+
|
|
292
|
+
type Range = 'week' | 'month' | 'quarter';
|
|
293
|
+
const ranges = [
|
|
294
|
+
{ value: 'week', label: 'Week' },
|
|
295
|
+
{ value: 'month', label: 'Month' },
|
|
296
|
+
{ value: 'quarter', label: 'Quarter' },
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
// A real app counts these on the server. One range drives every number on the page.
|
|
300
|
+
const data = {
|
|
301
|
+
week: {
|
|
302
|
+
stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },
|
|
303
|
+
projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],
|
|
304
|
+
waiting: [
|
|
305
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
306
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
307
|
+
['Review the pricing copy', '/comments/3'],
|
|
308
|
+
],
|
|
309
|
+
questions: [],
|
|
310
|
+
},
|
|
311
|
+
month: {
|
|
312
|
+
stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },
|
|
313
|
+
projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],
|
|
314
|
+
waiting: [
|
|
315
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
316
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
317
|
+
['Review the pricing copy', '/comments/3'],
|
|
318
|
+
['Confirm the release date', '/comments/4'],
|
|
319
|
+
['Approve the new onboarding text', '/comments/5'],
|
|
320
|
+
],
|
|
321
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],
|
|
322
|
+
},
|
|
323
|
+
quarter: {
|
|
324
|
+
stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },
|
|
325
|
+
projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],
|
|
326
|
+
waiting: [
|
|
327
|
+
['Ben Carter asked for the new screens', '/comments/1'],
|
|
328
|
+
['Omar Reyes mentioned you in Launch plan', '/comments/2'],
|
|
329
|
+
['Review the pricing copy', '/comments/3'],
|
|
330
|
+
['Confirm the release date', '/comments/4'],
|
|
331
|
+
],
|
|
332
|
+
questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],
|
|
333
|
+
},
|
|
334
|
+
} as const;
|
|
335
|
+
|
|
336
|
+
const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
|
|
337
|
+
|
|
338
|
+
export default function DashboardWorkFirst() {
|
|
339
|
+
const [range, setRange] = useState<Range>('week');
|
|
340
|
+
// The numbers load again when the range changes.
|
|
341
|
+
const [loading, setLoading] = useState(false);
|
|
342
|
+
// The projects section fails first, so the rest of the page shows that one section can fail alone.
|
|
343
|
+
const [projectsFailed, setProjectsFailed] = useState(true);
|
|
344
|
+
const [retrying, setRetrying] = useState(false);
|
|
345
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
346
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
347
|
+
const retryTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
348
|
+
|
|
349
|
+
// Stops the requests if the example goes away before they end.
|
|
350
|
+
useEffect(() => () => {
|
|
351
|
+
clearTimeout(timer.current);
|
|
352
|
+
clearTimeout(retryTimer.current);
|
|
353
|
+
}, []);
|
|
354
|
+
|
|
355
|
+
function changeRange(next: string) {
|
|
356
|
+
clearTimeout(timer.current);
|
|
357
|
+
setRange(next as Range);
|
|
358
|
+
setLoading(true);
|
|
359
|
+
// Stands in for the request to the server.
|
|
360
|
+
timer.current = setTimeout(() => setLoading(false), 600);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function tryAgain() {
|
|
364
|
+
if (retrying) return;
|
|
365
|
+
setRetrying(true);
|
|
366
|
+
retryTimer.current = setTimeout(() => {
|
|
367
|
+
setRetrying(false);
|
|
368
|
+
setProjectsFailed(false);
|
|
369
|
+
}, 1200);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const d = data[range];
|
|
373
|
+
const period = range;
|
|
374
|
+
const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);
|
|
375
|
+
const waitingCount: number = d.waiting.length;
|
|
376
|
+
|
|
377
|
+
const sidebar = (
|
|
378
|
+
<Navigation aria-label="Main">
|
|
379
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
380
|
+
{[
|
|
381
|
+
['Dashboard', 'LayoutDashboard', '/dashboard'],
|
|
382
|
+
['Comments', 'MessageSquare', '/comments'],
|
|
383
|
+
['Projects', 'FolderKanban', '/projects'],
|
|
384
|
+
].map(([label, icon, href]) => (
|
|
385
|
+
<MenuItem
|
|
386
|
+
key={href}
|
|
387
|
+
size="small"
|
|
388
|
+
label={label}
|
|
389
|
+
iconName={icon}
|
|
390
|
+
href={href}
|
|
391
|
+
isSelected={href === '/dashboard'}
|
|
392
|
+
aria-current={href === '/dashboard' ? 'page' : undefined}
|
|
393
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
394
|
+
// A real app lets the link go to its page. The example stays here.
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
}}
|
|
397
|
+
/>
|
|
398
|
+
))}
|
|
399
|
+
</Navigation>
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const statRow = (
|
|
403
|
+
<SettingsSection key="stats" title={`Numbers ${noun[range]}`} id="dashboard-stats">
|
|
404
|
+
<Grid compact columns={4}>
|
|
405
|
+
<StatTile label="New comments" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />
|
|
406
|
+
<StatTile label="Marked done" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />
|
|
407
|
+
<StatTile label="People engaged" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />
|
|
408
|
+
<StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading} />
|
|
409
|
+
</Grid>
|
|
410
|
+
</SettingsSection>
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
const projects = (
|
|
414
|
+
<SettingsSection key="projects" title="Projects" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id="dashboard-projects">
|
|
415
|
+
{projectsFailed ? (
|
|
416
|
+
<>
|
|
417
|
+
{/* Only this section failed. The rest of the page still shows. */}
|
|
418
|
+
<Alert type="error" variant="inline" message="Could not load projects." autoDismiss={false} />
|
|
419
|
+
<Cluster>
|
|
420
|
+
<Button size="small" type="primary" state="enabled" label="Try Again" loading={retrying} onClickButton={tryAgain} />
|
|
421
|
+
</Cluster>
|
|
422
|
+
</>
|
|
423
|
+
) : loading ? (
|
|
424
|
+
<Skeleton variant="text" lines={3} label="Loading projects" />
|
|
425
|
+
) : (
|
|
426
|
+
<List
|
|
427
|
+
size="body2"
|
|
428
|
+
items={d.projects.map(([name, count]) => (
|
|
429
|
+
<Progress key={name} kind="share" label={name} value={count} max={projectTotal} unit="comments" />
|
|
430
|
+
))}
|
|
431
|
+
/>
|
|
432
|
+
)}
|
|
433
|
+
</SettingsSection>
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
const waiting = (
|
|
437
|
+
<SettingsSection key="waiting" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id="dashboard-waiting">
|
|
438
|
+
{loading ? (
|
|
439
|
+
<Skeleton variant="text" lines={3} label="Loading what waits on you" />
|
|
440
|
+
) : (
|
|
441
|
+
<Stack gap="small">
|
|
442
|
+
{d.waiting.map(([text, href]) => (
|
|
443
|
+
<MenuItem
|
|
444
|
+
key={href}
|
|
445
|
+
size="medium"
|
|
446
|
+
label={text}
|
|
447
|
+
href={href}
|
|
448
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
449
|
+
// A real app lets the link go to its page. The example stays here.
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
}}
|
|
452
|
+
/>
|
|
453
|
+
))}
|
|
454
|
+
</Stack>
|
|
455
|
+
)}
|
|
456
|
+
</SettingsSection>
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
const questions = (
|
|
460
|
+
<SettingsSection key="questions" title="Questions from your agents" id="dashboard-questions">
|
|
461
|
+
{loading ? (
|
|
462
|
+
<Skeleton variant="text" lines={2} label="Loading questions" />
|
|
463
|
+
) : d.questions.length === 0 ? (
|
|
464
|
+
// A section with nothing keeps its place and says what will fill it.
|
|
465
|
+
<EmptyBox size="small" text={`No questions from your agents ${noun[range]}`} secondText="Questions your agents ask you appear here." />
|
|
466
|
+
) : (
|
|
467
|
+
<Stack gap="small">
|
|
468
|
+
{d.questions.map(([text, href]) => (
|
|
469
|
+
<MenuItem
|
|
470
|
+
key={href}
|
|
471
|
+
size="medium"
|
|
472
|
+
label={text}
|
|
473
|
+
href={href}
|
|
474
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
475
|
+
// A real app lets the link go to its page. The example stays here.
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
}}
|
|
478
|
+
/>
|
|
479
|
+
))}
|
|
480
|
+
</Stack>
|
|
481
|
+
)}
|
|
482
|
+
</SettingsSection>
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
return (
|
|
486
|
+
<AppShell title="Dashboard" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
487
|
+
<Stack gap="xlarge">
|
|
488
|
+
{/* One range drives every number below, and each heading says which one. */}
|
|
489
|
+
{/* Below md the range switch takes its own line under the title. */}
|
|
490
|
+
<TitleBar
|
|
491
|
+
title="Dashboard"
|
|
492
|
+
actionsBelow
|
|
493
|
+
actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
|
|
494
|
+
/>
|
|
495
|
+
{waiting}
|
|
496
|
+
{questions}
|
|
497
|
+
{statRow}
|
|
498
|
+
{projects}
|
|
499
|
+
</Stack>
|
|
500
|
+
</AppShell>
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## Native
|
|
506
|
+
|
|
507
|
+
On Apple use a `List` of `Section`s in a `NavigationStack`, with a `Picker` in the `.segmented` style in the toolbar. On Android use a `LazyColumn` with a `SingleChoiceSegmentedButtonRow` in the top bar.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DataTablePageAllRows(): import("react").JSX.Element;
|