@siiway/ui-react 0.0.0 → 0.2.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/LICENSE +21 -0
- package/README.md +19 -1
- package/dist/components/AppShell.d.ts +29 -0
- package/dist/components/AppShell.d.ts.map +1 -0
- package/dist/components/AppShell.js +220 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/AuthShell.d.ts +21 -0
- package/dist/components/AuthShell.d.ts.map +1 -0
- package/dist/components/AuthShell.js +53 -0
- package/dist/components/AuthShell.js.map +1 -0
- package/dist/components/BrandMark.d.ts +11 -0
- package/dist/components/BrandMark.d.ts.map +1 -0
- package/dist/components/BrandMark.js +11 -0
- package/dist/components/BrandMark.js.map +1 -0
- package/dist/components/ButtonLink.d.ts +11 -0
- package/dist/components/ButtonLink.d.ts.map +1 -0
- package/dist/components/ButtonLink.js +15 -0
- package/dist/components/ButtonLink.js.map +1 -0
- package/dist/components/CheckboxField.d.ts +15 -0
- package/dist/components/CheckboxField.d.ts.map +1 -0
- package/dist/components/CheckboxField.js +23 -0
- package/dist/components/CheckboxField.js.map +1 -0
- package/dist/components/ColorPickerInput.d.ts +17 -0
- package/dist/components/ColorPickerInput.d.ts.map +1 -0
- package/dist/components/ColorPickerInput.js +97 -0
- package/dist/components/ColorPickerInput.js.map +1 -0
- package/dist/components/CommandPalette.d.ts +65 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +269 -0
- package/dist/components/CommandPalette.js.map +1 -0
- package/dist/components/CopyButton.d.ts +27 -0
- package/dist/components/CopyButton.d.ts.map +1 -0
- package/dist/components/CopyButton.js +20 -0
- package/dist/components/CopyButton.js.map +1 -0
- package/dist/components/CopyIdTrigger.d.ts +31 -0
- package/dist/components/CopyIdTrigger.d.ts.map +1 -0
- package/dist/components/CopyIdTrigger.js +72 -0
- package/dist/components/CopyIdTrigger.js.map +1 -0
- package/dist/components/DataList.d.ts +78 -0
- package/dist/components/DataList.d.ts.map +1 -0
- package/dist/components/DataList.js +150 -0
- package/dist/components/DataList.js.map +1 -0
- package/dist/components/DetailHeader.d.ts +26 -0
- package/dist/components/DetailHeader.d.ts.map +1 -0
- package/dist/components/DetailHeader.js +49 -0
- package/dist/components/DetailHeader.js.map +1 -0
- package/dist/components/DurationInput.d.ts +25 -0
- package/dist/components/DurationInput.d.ts.map +1 -0
- package/dist/components/DurationInput.js +83 -0
- package/dist/components/DurationInput.js.map +1 -0
- package/dist/components/EmptyState.d.ts +14 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +41 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FormPage.d.ts +22 -0
- package/dist/components/FormPage.d.ts.map +1 -0
- package/dist/components/FormPage.js +65 -0
- package/dist/components/FormPage.js.map +1 -0
- package/dist/components/GetStartedPanel.d.ts +16 -0
- package/dist/components/GetStartedPanel.d.ts.map +1 -0
- package/dist/components/GetStartedPanel.js +96 -0
- package/dist/components/GetStartedPanel.js.map +1 -0
- package/dist/components/LabeledLine.d.ts +12 -0
- package/dist/components/LabeledLine.d.ts.map +1 -0
- package/dist/components/LabeledLine.js +6 -0
- package/dist/components/LabeledLine.js.map +1 -0
- package/dist/components/ListSearch.d.ts +15 -0
- package/dist/components/ListSearch.d.ts.map +1 -0
- package/dist/components/ListSearch.js +23 -0
- package/dist/components/ListSearch.js.map +1 -0
- package/dist/components/LoadingBar.d.ts +8 -0
- package/dist/components/LoadingBar.d.ts.map +1 -0
- package/dist/components/LoadingBar.js +55 -0
- package/dist/components/LoadingBar.js.map +1 -0
- package/dist/components/LoadingPage.d.ts +6 -0
- package/dist/components/LoadingPage.d.ts.map +1 -0
- package/dist/components/LoadingPage.js +25 -0
- package/dist/components/LoadingPage.js.map +1 -0
- package/dist/components/MenuPanel.d.ts +34 -0
- package/dist/components/MenuPanel.d.ts.map +1 -0
- package/dist/components/MenuPanel.js +98 -0
- package/dist/components/MenuPanel.js.map +1 -0
- package/dist/components/Outline.d.ts +23 -0
- package/dist/components/Outline.d.ts.map +1 -0
- package/dist/components/Outline.js +150 -0
- package/dist/components/Outline.js.map +1 -0
- package/dist/components/Overview.d.ts +103 -0
- package/dist/components/Overview.d.ts.map +1 -0
- package/dist/components/Overview.js +286 -0
- package/dist/components/Overview.js.map +1 -0
- package/dist/components/PageHeader.d.ts +19 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader.js +41 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.d.ts +19 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +47 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/PasswordInput.d.ts +3 -0
- package/dist/components/PasswordInput.d.ts.map +1 -0
- package/dist/components/PasswordInput.js +29 -0
- package/dist/components/PasswordInput.js.map +1 -0
- package/dist/components/PrevNext.d.ts +16 -0
- package/dist/components/PrevNext.d.ts.map +1 -0
- package/dist/components/PrevNext.js +61 -0
- package/dist/components/PrevNext.js.map +1 -0
- package/dist/components/SearchButton.d.ts +16 -0
- package/dist/components/SearchButton.d.ts.map +1 -0
- package/dist/components/SearchButton.js +63 -0
- package/dist/components/SearchButton.js.map +1 -0
- package/dist/components/SearchField.d.ts +10 -0
- package/dist/components/SearchField.d.ts.map +1 -0
- package/dist/components/SearchField.js +67 -0
- package/dist/components/SearchField.js.map +1 -0
- package/dist/components/Segmented.d.ts +28 -0
- package/dist/components/Segmented.d.ts.map +1 -0
- package/dist/components/Segmented.js +74 -0
- package/dist/components/Segmented.js.map +1 -0
- package/dist/components/Select.d.ts +22 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +50 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Settings.d.ts +103 -0
- package/dist/components/Settings.d.ts.map +1 -0
- package/dist/components/Settings.js +246 -0
- package/dist/components/Settings.js.map +1 -0
- package/dist/components/SideNav.d.ts +47 -0
- package/dist/components/SideNav.d.ts.map +1 -0
- package/dist/components/SideNav.js +125 -0
- package/dist/components/SideNav.js.map +1 -0
- package/dist/components/Skeletons.d.ts +37 -0
- package/dist/components/Skeletons.d.ts.map +1 -0
- package/dist/components/Skeletons.js +109 -0
- package/dist/components/Skeletons.js.map +1 -0
- package/dist/components/StatusPage.d.ts +49 -0
- package/dist/components/StatusPage.d.ts.map +1 -0
- package/dist/components/StatusPage.js +110 -0
- package/dist/components/StatusPage.js.map +1 -0
- package/dist/components/ThemeMenu.d.ts +13 -0
- package/dist/components/ThemeMenu.d.ts.map +1 -0
- package/dist/components/ThemeMenu.js +18 -0
- package/dist/components/ThemeMenu.js.map +1 -0
- package/dist/components/ThemeSwitch.d.ts +17 -0
- package/dist/components/ThemeSwitch.d.ts.map +1 -0
- package/dist/components/ThemeSwitch.js +25 -0
- package/dist/components/ThemeSwitch.js.map +1 -0
- package/dist/components/TopBar.d.ts +49 -0
- package/dist/components/TopBar.d.ts.map +1 -0
- package/dist/components/TopBar.js +146 -0
- package/dist/components/TopBar.js.map +1 -0
- package/dist/components/ViewBanner.d.ts +17 -0
- package/dist/components/ViewBanner.d.ts.map +1 -0
- package/dist/components/ViewBanner.js +14 -0
- package/dist/components/ViewBanner.js.map +1 -0
- package/dist/hooks/platform.d.ts +7 -0
- package/dist/hooks/platform.d.ts.map +1 -0
- package/dist/hooks/platform.js +19 -0
- package/dist/hooks/platform.js.map +1 -0
- package/dist/hooks/useConfirm.d.ts +23 -0
- package/dist/hooks/useConfirm.d.ts.map +1 -0
- package/dist/hooks/useConfirm.js +55 -0
- package/dist/hooks/useConfirm.js.map +1 -0
- package/dist/hooks/useCopy.d.ts +12 -0
- package/dist/hooks/useCopy.d.ts.map +1 -0
- package/dist/hooks/useCopy.js +39 -0
- package/dist/hooks/useCopy.js.map +1 -0
- package/dist/hooks/useDebouncedSearch.d.ts +8 -0
- package/dist/hooks/useDebouncedSearch.d.ts.map +1 -0
- package/dist/hooks/useDebouncedSearch.js +19 -0
- package/dist/hooks/useDebouncedSearch.js.map +1 -0
- package/dist/hooks/usePageClamp.d.ts +4 -0
- package/dist/hooks/usePageClamp.d.ts.map +1 -0
- package/dist/hooks/usePageClamp.js +17 -0
- package/dist/hooks/usePageClamp.js.map +1 -0
- package/dist/hooks/useSearchShortcut.d.ts +8 -0
- package/dist/hooks/useSearchShortcut.d.ts.map +1 -0
- package/dist/hooks/useSearchShortcut.js +38 -0
- package/dist/hooks/useSearchShortcut.js.map +1 -0
- package/dist/hooks/useThemeMode.d.ts +29 -0
- package/dist/hooks/useThemeMode.d.ts.map +1 -0
- package/dist/hooks/useThemeMode.js +111 -0
- package/dist/hooks/useThemeMode.js.map +1 -0
- package/dist/hooks/useToastMessage.d.ts +22 -0
- package/dist/hooks/useToastMessage.d.ts.map +1 -0
- package/dist/hooks/useToastMessage.js +26 -0
- package/dist/hooks/useToastMessage.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/UiProvider.d.ts +60 -0
- package/dist/provider/UiProvider.d.ts.map +1 -0
- package/dist/provider/UiProvider.js +144 -0
- package/dist/provider/UiProvider.js.map +1 -0
- package/dist/provider/canvas.d.ts +7 -0
- package/dist/provider/canvas.d.ts.map +1 -0
- package/dist/provider/canvas.js +30 -0
- package/dist/provider/canvas.js.map +1 -0
- package/dist/provider/context.d.ts +69 -0
- package/dist/provider/context.d.ts.map +1 -0
- package/dist/provider/context.js +84 -0
- package/dist/provider/context.js.map +1 -0
- package/dist/theme/createTheme.d.ts +13 -0
- package/dist/theme/createTheme.d.ts.map +1 -0
- package/dist/theme/createTheme.js +18 -0
- package/dist/theme/createTheme.js.map +1 -0
- package/package.json +42 -2
- package/src/components/AppShell.tsx +337 -0
- package/src/components/AuthShell.tsx +104 -0
- package/src/components/BrandMark.tsx +28 -0
- package/src/components/ButtonLink.tsx +40 -0
- package/src/components/CheckboxField.tsx +50 -0
- package/src/components/ColorPickerInput.tsx +190 -0
- package/src/components/CommandPalette.tsx +479 -0
- package/src/components/CopyButton.tsx +76 -0
- package/src/components/CopyIdTrigger.tsx +127 -0
- package/src/components/DataList.tsx +332 -0
- package/src/components/DetailHeader.tsx +108 -0
- package/src/components/DurationInput.tsx +133 -0
- package/src/components/EmptyState.tsx +67 -0
- package/src/components/FormPage.tsx +109 -0
- package/src/components/GetStartedPanel.tsx +132 -0
- package/src/components/LabeledLine.tsx +28 -0
- package/src/components/ListSearch.tsx +64 -0
- package/src/components/LoadingBar.tsx +81 -0
- package/src/components/LoadingPage.tsx +41 -0
- package/src/components/MenuPanel.tsx +163 -0
- package/src/components/Outline.tsx +208 -0
- package/src/components/Overview.tsx +448 -0
- package/src/components/PageHeader.tsx +69 -0
- package/src/components/Pagination.tsx +105 -0
- package/src/components/PasswordInput.tsx +50 -0
- package/src/components/PrevNext.tsx +98 -0
- package/src/components/SearchButton.tsx +90 -0
- package/src/components/SearchField.tsx +97 -0
- package/src/components/Segmented.tsx +136 -0
- package/src/components/Select.tsx +110 -0
- package/src/components/Settings.tsx +432 -0
- package/src/components/SideNav.tsx +258 -0
- package/src/components/Skeletons.tsx +233 -0
- package/src/components/StatusPage.tsx +212 -0
- package/src/components/ThemeMenu.tsx +51 -0
- package/src/components/ThemeSwitch.tsx +49 -0
- package/src/components/TopBar.tsx +293 -0
- package/src/components/ViewBanner.tsx +51 -0
- package/src/hooks/platform.ts +22 -0
- package/src/hooks/useConfirm.tsx +97 -0
- package/src/hooks/useCopy.ts +39 -0
- package/src/hooks/useDebouncedSearch.ts +19 -0
- package/src/hooks/usePageClamp.ts +20 -0
- package/src/hooks/useSearchShortcut.ts +49 -0
- package/src/hooks/useThemeMode.ts +168 -0
- package/src/hooks/useToastMessage.ts +38 -0
- package/src/index.ts +156 -0
- package/src/provider/UiProvider.tsx +256 -0
- package/src/provider/canvas.ts +31 -0
- package/src/provider/context.tsx +145 -0
- package/src/theme/createTheme.ts +29 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Input that accepts free-form duration text (e.g. "60", "60min", "1 hour",
|
|
2
|
+
// "30 days") and commits an integer in the field's storage unit on blur.
|
|
3
|
+
// Empty input commits `null`, meaning "use the site default".
|
|
4
|
+
//
|
|
5
|
+
// Why a custom component (and not Fluent's SpinButton): SpinButton's
|
|
6
|
+
// controlled state diverges from `value`/`displayValue` on invalid intermediate
|
|
7
|
+
// input — typing "60min" and then clicking elsewhere left the box blank.
|
|
8
|
+
// This component keeps a local string buffer that's only synced from `value`
|
|
9
|
+
// when `value` changes externally, so user typing is preserved across blur
|
|
10
|
+
// until we successfully parse it.
|
|
11
|
+
|
|
12
|
+
import { Input, Text, tokens } from "@fluentui/react-components";
|
|
13
|
+
import { useEffect, useRef, useState } from "react";
|
|
14
|
+
import { useUiStrings } from "../provider/context.js";
|
|
15
|
+
import { UI_STRINGS, parseDuration, type DurationUnit } from "@siiway/ui-core";
|
|
16
|
+
|
|
17
|
+
interface DurationInputProps {
|
|
18
|
+
/** The length of time as a whole number in `unit`. `null` is blank. */
|
|
19
|
+
value: number | null;
|
|
20
|
+
/** Called with the new value, or `null` for blank, when the text is read
|
|
21
|
+
* (on blur or Enter), not on every keystroke. Text it can't read shows an
|
|
22
|
+
* error and doesn't call it. */
|
|
23
|
+
onChange: (value: number | null) => void;
|
|
24
|
+
/** The unit of `value`, `minutes` or `days`. A bare number is read in this
|
|
25
|
+
* unit. */
|
|
26
|
+
unit: DurationUnit;
|
|
27
|
+
/** Shown while the field is blank. */
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
/** Disables the field. */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Whether the field may be left blank, giving `null`. Default `true`:
|
|
32
|
+
* blank means "use the default". When `false`, a blank field shows
|
|
33
|
+
* "Required" and puts back the last value. */
|
|
34
|
+
allowBlank?: boolean;
|
|
35
|
+
/** The text input's `id`. */
|
|
36
|
+
id?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function DurationInput({
|
|
40
|
+
value,
|
|
41
|
+
onChange,
|
|
42
|
+
unit,
|
|
43
|
+
placeholder,
|
|
44
|
+
disabled,
|
|
45
|
+
allowBlank = true,
|
|
46
|
+
id,
|
|
47
|
+
}: DurationInputProps) {
|
|
48
|
+
const strings = useUiStrings();
|
|
49
|
+
// Local buffer of the displayed text. Synced from `value` only when value
|
|
50
|
+
// changes externally — typing while the field is focused doesn't cause
|
|
51
|
+
// a parent state round-trip on every keystroke.
|
|
52
|
+
const { duration } = strings;
|
|
53
|
+
const format = (next: number | null) => (next === null ? "" : duration(next, unit));
|
|
54
|
+
const [text, setText] = useState<string>(() => format(value));
|
|
55
|
+
const [error, setError] = useState<string | null>(null);
|
|
56
|
+
// Track focus via ref so the sync effect doesn't re-run on focus changes —
|
|
57
|
+
// that would overwrite a parse-error buffer the user is mid-edit. The
|
|
58
|
+
// effect only fires when the parent's `value` (or unit, or the language)
|
|
59
|
+
// actually changes.
|
|
60
|
+
const focusedRef = useRef(false);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (focusedRef.current) return;
|
|
64
|
+
setText(value === null ? "" : duration(value, unit));
|
|
65
|
+
}, [value, unit, duration]);
|
|
66
|
+
|
|
67
|
+
const commit = () => {
|
|
68
|
+
// The app's language, and English, which people type in any language.
|
|
69
|
+
const result = parseDuration(text, unit, [strings.durationUnits, UI_STRINGS.en.durationUnits]);
|
|
70
|
+
if (result.kind === "blank") {
|
|
71
|
+
if (allowBlank) {
|
|
72
|
+
setError(null);
|
|
73
|
+
onChange(null);
|
|
74
|
+
setText("");
|
|
75
|
+
} else {
|
|
76
|
+
setError(strings.required);
|
|
77
|
+
// Restore last known good value so the box doesn't go blank.
|
|
78
|
+
setText(format(value));
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (result.kind === "error") {
|
|
83
|
+
setError(
|
|
84
|
+
result.reason === "non_positive"
|
|
85
|
+
? strings.durationNotPositive
|
|
86
|
+
: result.reason === "unknown_unit"
|
|
87
|
+
? strings.durationUnknownUnit
|
|
88
|
+
: strings.durationInvalid,
|
|
89
|
+
);
|
|
90
|
+
// Keep the user's text so they can correct it; revert the canonical
|
|
91
|
+
// value parent-side to whatever it was.
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
setError(null);
|
|
95
|
+
onChange(result.value);
|
|
96
|
+
// Re-format so "60min" becomes "60 min" — gives feedback that we parsed
|
|
97
|
+
// it the way they expected.
|
|
98
|
+
setText(format(result.value));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
|
103
|
+
<Input
|
|
104
|
+
id={id}
|
|
105
|
+
value={text}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
placeholder={placeholder}
|
|
108
|
+
onChange={(_, d) => {
|
|
109
|
+
setText(d.value);
|
|
110
|
+
if (error) setError(null);
|
|
111
|
+
}}
|
|
112
|
+
onFocus={() => {
|
|
113
|
+
focusedRef.current = true;
|
|
114
|
+
}}
|
|
115
|
+
onBlur={() => {
|
|
116
|
+
focusedRef.current = false;
|
|
117
|
+
commit();
|
|
118
|
+
}}
|
|
119
|
+
onKeyDown={(e) => {
|
|
120
|
+
if (e.key === "Enter") {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
commit();
|
|
123
|
+
}
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
{error && (
|
|
127
|
+
<Text size={100} style={{ color: tokens.colorPaletteRedForeground1 }}>
|
|
128
|
+
{error}
|
|
129
|
+
</Text>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Shared empty-state block for lists and tables: muted icon in a circle,
|
|
2
|
+
// title, optional description, optional call-to-action.
|
|
3
|
+
|
|
4
|
+
import { Text, makeStyles, tokens } from "@fluentui/react-components";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles({
|
|
8
|
+
root: {
|
|
9
|
+
display: "flex",
|
|
10
|
+
flexDirection: "column",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
textAlign: "center",
|
|
13
|
+
gap: "8px",
|
|
14
|
+
padding: "48px 16px",
|
|
15
|
+
},
|
|
16
|
+
iconCircle: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
width: "56px",
|
|
21
|
+
height: "56px",
|
|
22
|
+
borderRadius: tokens.borderRadiusXLarge,
|
|
23
|
+
// Bordered tile rather than a grey disc: empty states often sit straight
|
|
24
|
+
// on the canvas, where a Background3 fill all but disappears.
|
|
25
|
+
background: tokens.colorNeutralBackground1,
|
|
26
|
+
border: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
27
|
+
color: tokens.colorNeutralForeground3,
|
|
28
|
+
fontSize: "28px",
|
|
29
|
+
marginBottom: "8px",
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
color: tokens.colorNeutralForeground3,
|
|
33
|
+
maxWidth: "380px",
|
|
34
|
+
},
|
|
35
|
+
action: {
|
|
36
|
+
marginTop: "8px",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
interface EmptyStateProps {
|
|
41
|
+
/** An icon, shown in a tile above the title. */
|
|
42
|
+
icon?: ReactNode;
|
|
43
|
+
/** What's missing, such as "No apps yet". */
|
|
44
|
+
title: ReactNode;
|
|
45
|
+
/** A line under the title. */
|
|
46
|
+
description?: ReactNode;
|
|
47
|
+
/** Under the text, such as the list's main button. */
|
|
48
|
+
action?: ReactNode;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function EmptyState({ icon, title, description, action }: EmptyStateProps) {
|
|
52
|
+
const styles = useStyles();
|
|
53
|
+
return (
|
|
54
|
+
<div className={styles.root}>
|
|
55
|
+
{icon && <div className={styles.iconCircle}>{icon}</div>}
|
|
56
|
+
<Text size={400} weight="semibold">
|
|
57
|
+
{title}
|
|
58
|
+
</Text>
|
|
59
|
+
{description && (
|
|
60
|
+
<Text size={300} className={styles.description}>
|
|
61
|
+
{description}
|
|
62
|
+
</Text>
|
|
63
|
+
)}
|
|
64
|
+
{action && <div className={styles.action}>{action}</div>}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Layout for full-page create flows (new app, new team, new token): a back
|
|
2
|
+
// link to the list, the page header, and the form in a single card whose
|
|
3
|
+
// footer holds the actions. Used instead of modal dialogs so a create flow
|
|
4
|
+
// has its own URL and room to explain each field.
|
|
5
|
+
|
|
6
|
+
import { makeStyles, tokens } from "@fluentui/react-components";
|
|
7
|
+
import { ArrowLeftRegular } from "@fluentui/react-icons";
|
|
8
|
+
import type { ReactNode } from "react";
|
|
9
|
+
import { UiLink } from "../provider/context.js";
|
|
10
|
+
import { PageHeader } from "./PageHeader.js";
|
|
11
|
+
|
|
12
|
+
const useStyles = makeStyles({
|
|
13
|
+
root: {
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column",
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: "720px",
|
|
18
|
+
},
|
|
19
|
+
back: {
|
|
20
|
+
display: "inline-flex",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
gap: "6px",
|
|
23
|
+
alignSelf: "flex-start",
|
|
24
|
+
marginBottom: "16px",
|
|
25
|
+
fontSize: "13px",
|
|
26
|
+
color: tokens.colorNeutralForeground3,
|
|
27
|
+
":hover": { color: tokens.colorNeutralForeground1 },
|
|
28
|
+
":focus-visible": {
|
|
29
|
+
outline: `2px solid ${tokens.colorStrokeFocus2}`,
|
|
30
|
+
outlineOffset: "2px",
|
|
31
|
+
borderRadius: "2px",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
card: {
|
|
35
|
+
borderRadius: tokens.borderRadiusXLarge,
|
|
36
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
37
|
+
background: tokens.colorNeutralBackground1,
|
|
38
|
+
},
|
|
39
|
+
body: {
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "column",
|
|
42
|
+
gap: "18px",
|
|
43
|
+
padding: "24px",
|
|
44
|
+
"@media (max-width: 600px)": {
|
|
45
|
+
padding: "16px",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
footer: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
justifyContent: "flex-end",
|
|
51
|
+
flexWrap: "wrap",
|
|
52
|
+
gap: "8px",
|
|
53
|
+
padding: "14px 24px",
|
|
54
|
+
borderTop: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
55
|
+
"@media (max-width: 600px)": {
|
|
56
|
+
padding: "12px 16px",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
interface FormPageProps {
|
|
62
|
+
/** The path of the back link above the header, opened through the app's router. */
|
|
63
|
+
backTo: string;
|
|
64
|
+
/** The back link's text, such as the list's name. */
|
|
65
|
+
backLabel: string;
|
|
66
|
+
/** The page's heading, its `h1`. */
|
|
67
|
+
title: ReactNode;
|
|
68
|
+
/** A line under the title. */
|
|
69
|
+
subtitle?: ReactNode;
|
|
70
|
+
/** The buttons at the card's foot; give the main one `type="submit"`. Leave out when
|
|
71
|
+
* the card shows a final result instead. */
|
|
72
|
+
actions?: ReactNode;
|
|
73
|
+
/** Called on submit; the page doesn't reload. Enter in a text field submits like the
|
|
74
|
+
* main button. */
|
|
75
|
+
onSubmit?: () => void;
|
|
76
|
+
/** The fields. */
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function FormPage({
|
|
81
|
+
backTo,
|
|
82
|
+
backLabel,
|
|
83
|
+
title,
|
|
84
|
+
subtitle,
|
|
85
|
+
actions,
|
|
86
|
+
onSubmit,
|
|
87
|
+
children,
|
|
88
|
+
}: FormPageProps) {
|
|
89
|
+
const styles = useStyles();
|
|
90
|
+
return (
|
|
91
|
+
<div className={styles.root}>
|
|
92
|
+
<UiLink to={backTo} className={styles.back}>
|
|
93
|
+
<ArrowLeftRegular />
|
|
94
|
+
{backLabel}
|
|
95
|
+
</UiLink>
|
|
96
|
+
<PageHeader title={title} subtitle={subtitle} />
|
|
97
|
+
<form
|
|
98
|
+
className={styles.card}
|
|
99
|
+
onSubmit={(e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
onSubmit?.();
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
<div className={styles.body}>{children}</div>
|
|
105
|
+
{actions && <div className={styles.footer}>{actions}</div>}
|
|
106
|
+
</form>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Full empty state for a main list page that has nothing in it yet (no apps,
|
|
2
|
+
// no teams, no tokens…). Where EmptyState is a one-liner for empty tables and
|
|
3
|
+
// searches, this explains what the page is for and how to start: an
|
|
4
|
+
// illustration beside a heading, a short description, numbered steps and the
|
|
5
|
+
// page's primary action. Modelled on the Cloudflare dashboard's empty pages.
|
|
6
|
+
|
|
7
|
+
import { Text, makeStyles, tokens } from "@fluentui/react-components";
|
|
8
|
+
import type { ReactNode } from "react";
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles({
|
|
11
|
+
root: {
|
|
12
|
+
display: "grid",
|
|
13
|
+
gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1.15fr)",
|
|
14
|
+
gap: "6px",
|
|
15
|
+
padding: "6px",
|
|
16
|
+
borderRadius: tokens.borderRadiusXLarge,
|
|
17
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
18
|
+
background: tokens.colorNeutralBackground1,
|
|
19
|
+
"@media (max-width: 720px)": {
|
|
20
|
+
gridTemplateColumns: "minmax(0, 1fr)",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
art: {
|
|
24
|
+
minHeight: "220px",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
borderRadius: tokens.borderRadiusLarge,
|
|
29
|
+
border: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
30
|
+
background: tokens.colorNeutralBackground2,
|
|
31
|
+
overflow: "hidden",
|
|
32
|
+
"& svg": {
|
|
33
|
+
display: "block",
|
|
34
|
+
width: "100%",
|
|
35
|
+
maxWidth: "360px",
|
|
36
|
+
height: "auto",
|
|
37
|
+
},
|
|
38
|
+
"@media (max-width: 720px)": {
|
|
39
|
+
minHeight: "170px",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
body: {
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
gap: "8px",
|
|
46
|
+
padding: "22px 22px 20px",
|
|
47
|
+
"@media (max-width: 720px)": {
|
|
48
|
+
padding: "14px 10px 10px",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
title: { margin: 0 },
|
|
52
|
+
desc: {
|
|
53
|
+
color: tokens.colorNeutralForeground3,
|
|
54
|
+
fontSize: "13px",
|
|
55
|
+
lineHeight: "20px",
|
|
56
|
+
},
|
|
57
|
+
steps: {
|
|
58
|
+
listStyleType: "none",
|
|
59
|
+
display: "flex",
|
|
60
|
+
flexDirection: "column",
|
|
61
|
+
gap: "10px",
|
|
62
|
+
margin: "8px 0 4px",
|
|
63
|
+
padding: 0,
|
|
64
|
+
},
|
|
65
|
+
step: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
alignItems: "flex-start",
|
|
68
|
+
gap: "10px",
|
|
69
|
+
fontSize: "13px",
|
|
70
|
+
lineHeight: "20px",
|
|
71
|
+
color: tokens.colorNeutralForeground2,
|
|
72
|
+
},
|
|
73
|
+
stepNum: {
|
|
74
|
+
flexShrink: 0,
|
|
75
|
+
width: "20px",
|
|
76
|
+
height: "20px",
|
|
77
|
+
borderRadius: "50%",
|
|
78
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
79
|
+
display: "flex",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
fontSize: "11px",
|
|
83
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
84
|
+
color: tokens.colorNeutralForeground3,
|
|
85
|
+
},
|
|
86
|
+
action: {
|
|
87
|
+
display: "flex",
|
|
88
|
+
gap: "8px",
|
|
89
|
+
flexWrap: "wrap",
|
|
90
|
+
marginTop: "auto",
|
|
91
|
+
paddingTop: "12px",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
interface GetStartedPanelProps {
|
|
96
|
+
/** An illustration beside the text, or above it on narrow screens. An SVG scales to fit. */
|
|
97
|
+
art: ReactNode;
|
|
98
|
+
/** The panel's heading, an `h2`. */
|
|
99
|
+
title: ReactNode;
|
|
100
|
+
/** What the page is for, under the title. */
|
|
101
|
+
description: ReactNode;
|
|
102
|
+
/** Numbered steps under the description. */
|
|
103
|
+
steps?: ReactNode[];
|
|
104
|
+
/** The first action, such as a "New app" button, at the foot. */
|
|
105
|
+
action?: ReactNode;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function GetStartedPanel({ art, title, description, steps, action }: GetStartedPanelProps) {
|
|
109
|
+
const styles = useStyles();
|
|
110
|
+
return (
|
|
111
|
+
<section className={styles.root}>
|
|
112
|
+
<div className={styles.art}>{art}</div>
|
|
113
|
+
<div className={styles.body}>
|
|
114
|
+
<Text as="h2" size={500} weight="semibold" className={styles.title}>
|
|
115
|
+
{title}
|
|
116
|
+
</Text>
|
|
117
|
+
<span className={styles.desc}>{description}</span>
|
|
118
|
+
{steps && steps.length > 0 && (
|
|
119
|
+
<ol className={styles.steps}>
|
|
120
|
+
{steps.map((step, i) => (
|
|
121
|
+
<li key={i} className={styles.step}>
|
|
122
|
+
<span className={styles.stepNum}>{i + 1}</span>
|
|
123
|
+
<span>{step}</span>
|
|
124
|
+
</li>
|
|
125
|
+
))}
|
|
126
|
+
</ol>
|
|
127
|
+
)}
|
|
128
|
+
{action && <div className={styles.action}>{action}</div>}
|
|
129
|
+
</div>
|
|
130
|
+
</section>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Text } from "@fluentui/react-components";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
interface LabeledLineProps {
|
|
5
|
+
/** The label, before the colon. */
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** The value. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Sets the value in monospace. */
|
|
10
|
+
mono?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function LabeledLine({ label, children, mono }: LabeledLineProps) {
|
|
14
|
+
return (
|
|
15
|
+
<Text size={200}>
|
|
16
|
+
<Text size={200} weight="semibold">
|
|
17
|
+
{label}:
|
|
18
|
+
</Text>{" "}
|
|
19
|
+
{mono ? (
|
|
20
|
+
<Text size={200} font="monospace">
|
|
21
|
+
{children}
|
|
22
|
+
</Text>
|
|
23
|
+
) : (
|
|
24
|
+
children
|
|
25
|
+
)}
|
|
26
|
+
</Text>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// The search box above a list: a search icon, and a clear button once
|
|
2
|
+
// something is typed. Callers debounce the value themselves.
|
|
3
|
+
|
|
4
|
+
import { Button, Input, makeStyles, mergeClasses } from "@fluentui/react-components";
|
|
5
|
+
import { DismissRegular, SearchRegular } from "@fluentui/react-icons";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import { useUiStrings } from "../provider/context.js";
|
|
8
|
+
|
|
9
|
+
const useStyles = makeStyles({
|
|
10
|
+
bar: {
|
|
11
|
+
display: "flex",
|
|
12
|
+
gap: "8px",
|
|
13
|
+
marginBottom: "12px",
|
|
14
|
+
flexWrap: "wrap",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
},
|
|
17
|
+
input: { minWidth: "220px", flex: "1 1 220px" },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** A search box above a list, with filters or buttons beside it. */
|
|
21
|
+
export function ListSearch({
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
placeholder,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
}: {
|
|
28
|
+
/** The text in the box. */
|
|
29
|
+
value: string;
|
|
30
|
+
/** Called with the new text as it's typed, and with "" when it's cleared. */
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
/** Shown while the box is empty, e.g. "Search teams". */
|
|
33
|
+
placeholder: string;
|
|
34
|
+
/** Filters or actions beside the box. */
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
/** Extra styles for the bar, e.g. padding inside a card. */
|
|
37
|
+
className?: string;
|
|
38
|
+
}) {
|
|
39
|
+
const styles = useStyles();
|
|
40
|
+
const strings = useUiStrings();
|
|
41
|
+
return (
|
|
42
|
+
<div className={mergeClasses(styles.bar, className)}>
|
|
43
|
+
<Input
|
|
44
|
+
className={styles.input}
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={(_, d) => onChange(d.value)}
|
|
47
|
+
placeholder={placeholder}
|
|
48
|
+
contentBefore={<SearchRegular />}
|
|
49
|
+
contentAfter={
|
|
50
|
+
value ? (
|
|
51
|
+
<Button
|
|
52
|
+
appearance="transparent"
|
|
53
|
+
size="small"
|
|
54
|
+
icon={<DismissRegular />}
|
|
55
|
+
aria-label={strings.clear}
|
|
56
|
+
onClick={() => onChange("")}
|
|
57
|
+
/>
|
|
58
|
+
) : undefined
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
{children}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// A thin brand-coloured bar across the top of the window while the next page
|
|
2
|
+
// loads, like NProgress: it creeps towards the end while `active`, then runs
|
|
3
|
+
// to the end and fades. Tie `active` to the router's navigation state (React
|
|
4
|
+
// Router's `useNavigation().state !== "idle"`, Vellum's `isNavigating`).
|
|
5
|
+
|
|
6
|
+
import { makeStyles, tokens } from "@fluentui/react-components";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
|
|
9
|
+
const START = 0.08;
|
|
10
|
+
// It never gets past this while loading: the end is for when it's done.
|
|
11
|
+
const CAP = 0.9;
|
|
12
|
+
|
|
13
|
+
const useStyles = makeStyles({
|
|
14
|
+
bar: {
|
|
15
|
+
position: "fixed",
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
height: "2px",
|
|
20
|
+
zIndex: 1000,
|
|
21
|
+
pointerEvents: "none",
|
|
22
|
+
transformOrigin: "left center",
|
|
23
|
+
backgroundColor: tokens.colorBrandBackground,
|
|
24
|
+
// The fade waits for the bar to reach the end.
|
|
25
|
+
transition: "transform 200ms ease-out, opacity 250ms ease-out 250ms",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
interface Bar {
|
|
30
|
+
progress: number;
|
|
31
|
+
visible: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function LoadingBar({
|
|
35
|
+
active,
|
|
36
|
+
}: {
|
|
37
|
+
/**
|
|
38
|
+
* True while the next page loads, e.g. React Router's
|
|
39
|
+
* `useNavigation().state !== "idle"`.
|
|
40
|
+
*/
|
|
41
|
+
active: boolean;
|
|
42
|
+
}) {
|
|
43
|
+
const styles = useStyles();
|
|
44
|
+
const [bar, setBar] = useState<Bar>(() =>
|
|
45
|
+
active ? { progress: START, visible: true } : { progress: 0, visible: false },
|
|
46
|
+
);
|
|
47
|
+
// Start and finish as `active` changes, in the render that sees it. A load
|
|
48
|
+
// that ends before the bar was drawn never shows it.
|
|
49
|
+
const [was, setWas] = useState(active);
|
|
50
|
+
if (active !== was) {
|
|
51
|
+
setWas(active);
|
|
52
|
+
if (active) setBar({ progress: START, visible: true });
|
|
53
|
+
else if (bar.visible) setBar({ progress: 1, visible: false });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (active) {
|
|
58
|
+
// Each step covers part of what's left, so it slows towards the cap.
|
|
59
|
+
let progress = START;
|
|
60
|
+
const tick = setInterval(() => {
|
|
61
|
+
progress = Math.min(CAP, progress + (CAP - progress) * 0.12);
|
|
62
|
+
setBar({ progress, visible: true });
|
|
63
|
+
}, 200);
|
|
64
|
+
return () => clearInterval(tick);
|
|
65
|
+
}
|
|
66
|
+
// Back to the start once it has faded out.
|
|
67
|
+
const reset = setTimeout(
|
|
68
|
+
() => setBar((now) => (now.progress === 0 ? now : { progress: 0, visible: false })),
|
|
69
|
+
500,
|
|
70
|
+
);
|
|
71
|
+
return () => clearTimeout(reset);
|
|
72
|
+
}, [active]);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
className={styles.bar}
|
|
77
|
+
style={{ transform: `scaleX(${bar.progress})`, opacity: bar.visible ? 1 : 0 }}
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// A whole page that is still loading: a large spinner centred on the canvas,
|
|
2
|
+
// with what's happening when it's known. Prism's sign-in steps and public
|
|
3
|
+
// pages, and Glint's start and sign-in callback, before the page they lead
|
|
4
|
+
// to can show.
|
|
5
|
+
|
|
6
|
+
import { Spinner, makeStyles, mergeClasses } from "@fluentui/react-components";
|
|
7
|
+
import { useCanvasClass } from "../provider/canvas.js";
|
|
8
|
+
import { useUiStrings } from "../provider/context.js";
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles({
|
|
11
|
+
page: {
|
|
12
|
+
minHeight: "100vh",
|
|
13
|
+
display: "flex",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
padding: "16px",
|
|
17
|
+
boxSizing: "border-box",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function LoadingPage({
|
|
22
|
+
label,
|
|
23
|
+
}: {
|
|
24
|
+
/** What's happening, under the spinner, such as "Signing you in…". Without
|
|
25
|
+
* it, the spinner is named with the library's "Loading". */
|
|
26
|
+
label?: string;
|
|
27
|
+
}) {
|
|
28
|
+
const styles = useStyles();
|
|
29
|
+
const strings = useUiStrings();
|
|
30
|
+
const canvas = useCanvasClass();
|
|
31
|
+
return (
|
|
32
|
+
<div className={mergeClasses(styles.page, canvas)}>
|
|
33
|
+
<Spinner
|
|
34
|
+
size="large"
|
|
35
|
+
label={label}
|
|
36
|
+
labelPosition="below"
|
|
37
|
+
aria-label={label ? undefined : strings.loading}
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|