@trypattern/sdk 0.0.0-stage → 0.1.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 +127 -2
- package/dist/access.d.ts +31 -0
- package/dist/access.js +72 -0
- package/dist/actions.d.ts +57 -0
- package/dist/actions.js +198 -0
- package/dist/api.d.ts +20 -0
- package/dist/api.js +34 -0
- package/dist/app.d.ts +106 -0
- package/dist/app.js +224 -0
- package/dist/appearance.d.ts +7 -0
- package/dist/appearance.js +2 -0
- package/dist/auth/sessionApi.d.ts +41 -0
- package/dist/auth/sessionApi.js +158 -0
- package/dist/auth/sessionStore.d.ts +20 -0
- package/dist/auth/sessionStore.js +40 -0
- package/dist/auth/user.d.ts +11 -0
- package/dist/auth/user.js +9 -0
- package/dist/builtins/Account.d.ts +25 -0
- package/dist/builtins/Account.js +15 -0
- package/dist/builtins/Palette.d.ts +29 -0
- package/dist/builtins/Palette.js +63 -0
- package/dist/builtins/SignIn.d.ts +28 -0
- package/dist/builtins/SignIn.js +60 -0
- package/dist/builtins/Toasts.d.ts +32 -0
- package/dist/builtins/Toasts.js +24 -0
- package/dist/builtins/actions.d.ts +2 -0
- package/dist/builtins/actions.js +45 -0
- package/dist/cache.d.ts +24 -0
- package/dist/cache.js +112 -0
- package/dist/cli/app.d.ts +2 -0
- package/dist/cli/app.js +1329 -0
- package/dist/cli/screenshot.d.ts +1 -0
- package/dist/cli/screenshot.js +96 -0
- package/dist/cli/tools.d.ts +12 -0
- package/dist/cli/tools.js +35 -0
- package/dist/components/AppFrame.d.ts +14 -0
- package/dist/components/AppFrame.js +64 -0
- package/dist/components/AppearancePicker.d.ts +1 -0
- package/dist/components/AppearancePicker.js +12 -0
- package/dist/components/Avatar.d.ts +9 -0
- package/dist/components/Avatar.js +63 -0
- package/dist/components/Badge.d.ts +11 -0
- package/dist/components/Badge.js +87 -0
- package/dist/components/Button.d.ts +23 -0
- package/dist/components/Button.js +249 -0
- package/dist/components/Card.d.ts +12 -0
- package/dist/components/Card.js +38 -0
- package/dist/components/CommandMenu.d.ts +23 -0
- package/dist/components/CommandMenu.js +214 -0
- package/dist/components/CommandPalette.d.ts +1 -0
- package/dist/components/CommandPalette.js +7 -0
- package/dist/components/Content.d.ts +7 -0
- package/dist/components/Content.js +24 -0
- package/dist/components/ContextMenu.d.ts +8 -0
- package/dist/components/ContextMenu.js +23 -0
- package/dist/components/Dialog.d.ts +11 -0
- package/dist/components/Dialog.js +81 -0
- package/dist/components/Divider.d.ts +6 -0
- package/dist/components/Divider.js +15 -0
- package/dist/components/EmptyState.d.ts +8 -0
- package/dist/components/EmptyState.js +24 -0
- package/dist/components/Form.d.ts +9 -0
- package/dist/components/Form.js +23 -0
- package/dist/components/Icon.d.ts +10 -0
- package/dist/components/Icon.js +22 -0
- package/dist/components/IconButton.d.ts +14 -0
- package/dist/components/IconButton.js +53 -0
- package/dist/components/Kbd.d.ts +6 -0
- package/dist/components/Kbd.js +67 -0
- package/dist/components/Link.d.ts +9 -0
- package/dist/components/Link.js +35 -0
- package/dist/components/ListRow.d.ts +12 -0
- package/dist/components/ListRow.js +62 -0
- package/dist/components/LoadingRows.d.ts +5 -0
- package/dist/components/LoadingRows.js +6 -0
- package/dist/components/Menu.d.ts +12 -0
- package/dist/components/Menu.js +33 -0
- package/dist/components/MenuItems.d.ts +21 -0
- package/dist/components/MenuItems.js +32 -0
- package/dist/components/Placement.d.ts +21 -0
- package/dist/components/Placement.js +1 -0
- package/dist/components/Popup.d.ts +8 -0
- package/dist/components/Popup.js +43 -0
- package/dist/components/PopupItem.d.ts +8 -0
- package/dist/components/PopupItem.js +51 -0
- package/dist/components/PropertyRow.d.ts +7 -0
- package/dist/components/PropertyRow.js +23 -0
- package/dist/components/Row.d.ts +16 -0
- package/dist/components/Row.js +27 -0
- package/dist/components/Screen.d.ts +13 -0
- package/dist/components/Screen.js +56 -0
- package/dist/components/Scrim.d.ts +8 -0
- package/dist/components/Scrim.js +40 -0
- package/dist/components/ScrollArea.d.ts +15 -0
- package/dist/components/ScrollArea.js +13 -0
- package/dist/components/SegmentedControl.d.ts +17 -0
- package/dist/components/SegmentedControl.js +68 -0
- package/dist/components/Select.d.ts +17 -0
- package/dist/components/Select.js +107 -0
- package/dist/components/SettingsRow.d.ts +8 -0
- package/dist/components/SettingsRow.js +32 -0
- package/dist/components/Sidebar.d.ts +20 -0
- package/dist/components/Sidebar.js +138 -0
- package/dist/components/SignInScreen.d.ts +1 -0
- package/dist/components/SignInScreen.js +40 -0
- package/dist/components/Size.d.ts +1 -0
- package/dist/components/Size.js +1 -0
- package/dist/components/Skeleton.d.ts +8 -0
- package/dist/components/Skeleton.js +48 -0
- package/dist/components/Spinner.d.ts +6 -0
- package/dist/components/Spinner.js +54 -0
- package/dist/components/Stack.d.ts +14 -0
- package/dist/components/Stack.js +19 -0
- package/dist/components/Switch.d.ts +10 -0
- package/dist/components/Switch.js +71 -0
- package/dist/components/Text.d.ts +21 -0
- package/dist/components/Text.js +77 -0
- package/dist/components/TextField.d.ts +25 -0
- package/dist/components/TextField.js +68 -0
- package/dist/components/Toaster.d.ts +1 -0
- package/dist/components/Toaster.js +83 -0
- package/dist/components/Tooltip.d.ts +8 -0
- package/dist/components/Tooltip.js +43 -0
- package/dist/components/controlLook.d.ts +60 -0
- package/dist/components/controlLook.js +67 -0
- package/dist/components/frame.d.ts +4 -0
- package/dist/components/frame.js +2 -0
- package/dist/components/icons.d.ts +58 -0
- package/dist/components/icons.js +105 -0
- package/dist/components/interaction.d.ts +12 -0
- package/dist/components/interaction.js +22 -0
- package/dist/components/spacing.d.ts +118 -0
- package/dist/components/spacing.js +46 -0
- package/dist/components/tones.d.ts +28 -0
- package/dist/components/tones.js +12 -0
- package/dist/entityStore.d.ts +46 -0
- package/dist/entityStore.js +160 -0
- package/dist/flows/accessFlows.d.ts +9 -0
- package/dist/flows/accessFlows.js +151 -0
- package/dist/flows/browser.d.ts +32 -0
- package/dist/flows/browser.js +164 -0
- package/dist/flows/contactSheet.d.ts +1 -0
- package/dist/flows/contactSheet.js +63 -0
- package/dist/flows/flowBrowser.d.ts +23 -0
- package/dist/flows/flowBrowser.js +21 -0
- package/dist/flows/flowSetup.d.ts +3 -0
- package/dist/flows/flowSetup.js +35 -0
- package/dist/flows/flows.d.ts +41 -0
- package/dist/flows/flows.js +148 -0
- package/dist/flows/screenshotName.d.ts +1 -0
- package/dist/flows/screenshotName.js +6 -0
- package/dist/gate.d.ts +8 -0
- package/dist/gate.js +52 -0
- package/dist/hooks/appContext.d.ts +14 -0
- package/dist/hooks/appContext.js +5 -0
- package/dist/hooks/appHooks.d.ts +21 -0
- package/dist/hooks/appHooks.js +24 -0
- package/dist/hooks/useAnimatesOnChange.d.ts +1 -0
- package/dist/hooks/useAnimatesOnChange.js +14 -0
- package/dist/hooks/useStoreState.d.ts +6 -0
- package/dist/hooks/useStoreState.js +5 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +19 -0
- package/dist/memoryApi.d.ts +19 -0
- package/dist/memoryApi.js +42 -0
- package/dist/model.d.ts +94 -0
- package/dist/model.js +243 -0
- package/dist/page.d.ts +11 -0
- package/dist/page.js +9 -0
- package/dist/platform.d.ts +1 -0
- package/dist/platform.js +5 -0
- package/dist/react.d.ts +46 -0
- package/dist/react.js +38 -0
- package/dist/registered.d.ts +54 -0
- package/dist/registered.js +17 -0
- package/dist/routes.d.ts +38 -0
- package/dist/routes.js +21 -0
- package/dist/rules/checkAllFiles.d.ts +1 -0
- package/dist/rules/checkAllFiles.js +741 -0
- package/dist/rules/checkApiRouting.d.ts +1 -0
- package/dist/rules/checkApiRouting.js +112 -0
- package/dist/rules/lintPlugin.d.ts +252 -0
- package/dist/rules/lintPlugin.js +1157 -0
- package/dist/rules/messages.d.ts +48 -0
- package/dist/rules/messages.js +48 -0
- package/dist/rules/themeTokens.d.ts +6 -0
- package/dist/rules/themeTokens.js +64 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +1 -0
- package/dist/server/auth.d.ts +115 -0
- package/dist/server/auth.js +131 -0
- package/dist/server/authService.d.ts +9 -0
- package/dist/server/authService.js +50 -0
- package/dist/server/createServer.d.ts +357 -0
- package/dist/server/createServer.js +62 -0
- package/dist/server/env.d.ts +15 -0
- package/dist/server/env.js +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +5 -0
- package/dist/server/session.d.ts +28 -0
- package/dist/server/session.js +54 -0
- package/dist/server/sessions.d.ts +92 -0
- package/dist/server/sessions.js +47 -0
- package/dist/server/signInWire.d.ts +52 -0
- package/dist/server/signInWire.js +22 -0
- package/dist/server/tables.d.ts +242 -0
- package/dist/server/tables.js +246 -0
- package/dist/server/users.d.ts +189 -0
- package/dist/server/users.js +49 -0
- package/dist/shortcuts.d.ts +3 -0
- package/dist/shortcuts.js +40 -0
- package/dist/start.d.ts +20 -0
- package/dist/start.js +121 -0
- package/dist/state.d.ts +14 -0
- package/dist/state.js +17 -0
- package/dist/store.d.ts +43 -0
- package/dist/store.js +198 -0
- package/dist/subscribers.d.ts +5 -0
- package/dist/subscribers.js +13 -0
- package/dist/table.d.ts +143 -0
- package/dist/table.js +91 -0
- package/dist/tables.d.ts +77 -0
- package/dist/tables.js +216 -0
- package/dist/theme/reset.css +84 -0
- package/dist/theme/scales.d.ts +76 -0
- package/dist/theme/scales.js +82 -0
- package/dist/theme/tokens.stylex.d.ts +218 -0
- package/dist/theme/tokens.stylex.js +233 -0
- package/dist/vite/commandBridge.d.ts +2 -0
- package/dist/vite/commandBridge.js +46 -0
- package/dist/vite/designManifest.d.ts +25 -0
- package/dist/vite/designManifest.js +191 -0
- package/dist/vite/localWorker.d.ts +4 -0
- package/dist/vite/localWorker.js +59 -0
- package/dist/vite/rootAlias.d.ts +2 -0
- package/dist/vite/rootAlias.js +15 -0
- package/dist/vite/vite.d.ts +7 -0
- package/dist/vite/vite.js +88 -0
- package/dist/wire.d.ts +7 -0
- package/dist/wire.js +1 -0
- package/package.json +99 -3
- package/presets/lintPlugin.js +7 -0
- package/presets/oxlint.json +167 -0
- package/presets/register.d.ts +19 -0
- package/presets/server.d.ts +2 -0
- package/presets/tsconfig.app.json +29 -0
- package/presets/tsconfig.server.json +27 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { launchChrome, openApp, viewportNames, viewports } from "../flows/browser.js";
|
|
4
|
+
const ROOT = process.cwd();
|
|
5
|
+
const SCREENSHOTS_DIRECTORY = join(ROOT, '.dev', 'screenshots');
|
|
6
|
+
function readRequest() {
|
|
7
|
+
const parsed = JSON.parse(process.argv[2] ?? '');
|
|
8
|
+
if (typeof parsed !== 'object' ||
|
|
9
|
+
parsed === null ||
|
|
10
|
+
!('url' in parsed) ||
|
|
11
|
+
!('path' in parsed) ||
|
|
12
|
+
!('name' in parsed) ||
|
|
13
|
+
!('commands' in parsed) ||
|
|
14
|
+
!('signedInAs' in parsed) ||
|
|
15
|
+
(typeof parsed.signedInAs !== 'string' && parsed.signedInAs !== null) ||
|
|
16
|
+
typeof parsed.url !== 'string' ||
|
|
17
|
+
typeof parsed.path !== 'string' ||
|
|
18
|
+
typeof parsed.name !== 'string' ||
|
|
19
|
+
!Array.isArray(parsed.commands)) {
|
|
20
|
+
throw new Error('screenshot.ts expects {url, path, name, commands, signedInAs} JSON');
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
url: parsed.url,
|
|
24
|
+
path: parsed.path,
|
|
25
|
+
name: parsed.name,
|
|
26
|
+
commands: parsed.commands,
|
|
27
|
+
signedInAs: parsed.signedInAs
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function captureAll(browser, request) {
|
|
31
|
+
const [first = 'desktop'] = viewportNames;
|
|
32
|
+
const app = await openApp(browser, request.url, request.path, first, request.signedInAs);
|
|
33
|
+
try {
|
|
34
|
+
let snapshot = await app.snapshot();
|
|
35
|
+
let commandError;
|
|
36
|
+
for (const command of request.commands) {
|
|
37
|
+
try {
|
|
38
|
+
snapshot = await app.send(command);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
commandError = `command ${JSON.stringify(command)} failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const shots = [];
|
|
46
|
+
for (const viewport of viewportNames) {
|
|
47
|
+
const seenBefore = app.problems.length;
|
|
48
|
+
const file = join(SCREENSHOTS_DIRECTORY, `${request.name}-${viewport}.png`);
|
|
49
|
+
writeFileSync(file, Buffer.from(await app.captureAt(viewport), 'base64'));
|
|
50
|
+
const problems = [
|
|
51
|
+
...(commandError === undefined ? [] : [commandError]),
|
|
52
|
+
...(viewport === first ? app.problems : app.problems.slice(seenBefore))
|
|
53
|
+
];
|
|
54
|
+
shots.push({ viewport, ...viewports[viewport], file, snapshot, problems });
|
|
55
|
+
}
|
|
56
|
+
return shots;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await app.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function main() {
|
|
63
|
+
try {
|
|
64
|
+
const request = readRequest();
|
|
65
|
+
mkdirSync(SCREENSHOTS_DIRECTORY, { recursive: true });
|
|
66
|
+
const browser = await launchChrome();
|
|
67
|
+
const shots = await captureAll(browser, request).finally(() => browser.close());
|
|
68
|
+
const viewportsByProblem = new Map();
|
|
69
|
+
for (const shot of shots) {
|
|
70
|
+
for (const problem of shot.problems) {
|
|
71
|
+
viewportsByProblem.set(problem, [
|
|
72
|
+
...(viewportsByProblem.get(problem) ?? []),
|
|
73
|
+
shot.viewport
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const result = {
|
|
78
|
+
screenshots: shots.map(({ viewport, width, height, file }) => ({
|
|
79
|
+
viewport,
|
|
80
|
+
width,
|
|
81
|
+
height,
|
|
82
|
+
file
|
|
83
|
+
})),
|
|
84
|
+
snapshot: shots[0]?.snapshot ?? null,
|
|
85
|
+
problems: [...viewportsByProblem].map(([message, seenIn]) => ({
|
|
86
|
+
message,
|
|
87
|
+
viewports: seenIn
|
|
88
|
+
}))
|
|
89
|
+
};
|
|
90
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
process.stdout.write(`${JSON.stringify({ error: error instanceof Error ? error.message : String(error) })}\n`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
await main();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const TOOLS: {
|
|
2
|
+
readonly tsc: readonly ["typescript", "tsc"];
|
|
3
|
+
readonly oxlint: readonly ["oxlint", "oxlint"];
|
|
4
|
+
readonly prettier: readonly ["prettier", "prettier"];
|
|
5
|
+
readonly vite: readonly ["vite", "vite"];
|
|
6
|
+
readonly vitest: readonly ["vitest", "vitest"];
|
|
7
|
+
readonly wrangler: readonly ["wrangler", "wrangler"];
|
|
8
|
+
readonly 'drizzle-kit': readonly ["drizzle-kit", "drizzle-kit"];
|
|
9
|
+
};
|
|
10
|
+
export type Tool = keyof typeof TOOLS;
|
|
11
|
+
export declare function toolBin(tool: Tool): string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const TOOLS = {
|
|
6
|
+
tsc: ['typescript', 'tsc'],
|
|
7
|
+
oxlint: ['oxlint', 'oxlint'],
|
|
8
|
+
prettier: ['prettier', 'prettier'],
|
|
9
|
+
vite: ['vite', 'vite'],
|
|
10
|
+
vitest: ['vitest', 'vitest'],
|
|
11
|
+
wrangler: ['wrangler', 'wrangler'],
|
|
12
|
+
'drizzle-kit': ['drizzle-kit', 'drizzle-kit']
|
|
13
|
+
};
|
|
14
|
+
export function toolBin(tool) {
|
|
15
|
+
const [name, bin] = TOOLS[tool];
|
|
16
|
+
const manifest = (require.resolve.paths(name) ?? [])
|
|
17
|
+
.map((directory) => join(directory, name, 'package.json'))
|
|
18
|
+
.find((path) => existsSync(path));
|
|
19
|
+
if (manifest === undefined) {
|
|
20
|
+
throw new Error(`${name} is not installed`);
|
|
21
|
+
}
|
|
22
|
+
const parsed = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
23
|
+
const bins = typeof parsed === 'object' && parsed !== null && 'bin' in parsed
|
|
24
|
+
? parsed.bin
|
|
25
|
+
: undefined;
|
|
26
|
+
const path = typeof bins === 'string'
|
|
27
|
+
? bins
|
|
28
|
+
: typeof bins === 'object' && bins !== null
|
|
29
|
+
? Reflect.get(bins, bin)
|
|
30
|
+
: undefined;
|
|
31
|
+
if (typeof path !== 'string') {
|
|
32
|
+
throw new Error(`${name} has no ${bin} command`);
|
|
33
|
+
}
|
|
34
|
+
return join(dirname(manifest), path);
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { MenuEntry } from './MenuItems.tsx';
|
|
3
|
+
import type { SidebarLink } from './Sidebar.tsx';
|
|
4
|
+
type AppFrameProps = {
|
|
5
|
+
links: readonly SidebarLink[];
|
|
6
|
+
workspaceMenu?: readonly MenuEntry[];
|
|
7
|
+
isSidebarToggled: boolean;
|
|
8
|
+
onToggleSidebar: () => void;
|
|
9
|
+
onCloseSidebar: () => void;
|
|
10
|
+
onSearch?: () => void;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export declare function AppFrame({ links, workspaceMenu, isSidebarToggled, onToggleSidebar, onCloseSidebar, onSearch, children }: AppFrameProps): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import { breakpoints, colors, radii, shadows, space } from "../theme/tokens.stylex.js";
|
|
4
|
+
import { useApp, useModel } from "../hooks/appContext.js";
|
|
5
|
+
import { FrameContext } from "./frame.js";
|
|
6
|
+
import { Scrim } from "./Scrim.js";
|
|
7
|
+
import { Sidebar } from "./Sidebar.js";
|
|
8
|
+
import { useAnimatesOnChange } from "../hooks/useAnimatesOnChange.js";
|
|
9
|
+
export function AppFrame({ links, workspaceMenu = [], isSidebarToggled, onToggleSidebar, onCloseSidebar, onSearch, children }) {
|
|
10
|
+
const app = useApp();
|
|
11
|
+
const account = useModel('account');
|
|
12
|
+
const menu = account.user === null
|
|
13
|
+
? workspaceMenu
|
|
14
|
+
: [
|
|
15
|
+
...workspaceMenu,
|
|
16
|
+
...(workspaceMenu.length > 0 ? ['separator'] : []),
|
|
17
|
+
{ id: 'signOut', label: 'Log out', onSelect: account.signOut }
|
|
18
|
+
];
|
|
19
|
+
const isSidebarAnimating = useAnimatesOnChange(isSidebarToggled, SIDEBAR_ANIMATION_MS);
|
|
20
|
+
return (_jsx(FrameContext, { value: { onToggleSidebar }, children: _jsxs("div", { ...stylex.props(styles.frame), children: [_jsx(Sidebar, { workspace: app.name, workspaceMenu: menu, links: links, isToggled: isSidebarToggled, isAnimating: isSidebarAnimating, onFollowLink: onCloseSidebar, onSearch: onSearch === undefined
|
|
21
|
+
? undefined
|
|
22
|
+
: () => {
|
|
23
|
+
onCloseSidebar();
|
|
24
|
+
onSearch();
|
|
25
|
+
} }), _jsx(Scrim, { label: "Close sidebar", isOpen: isSidebarToggled, isAnimating: isSidebarAnimating, onClose: onCloseSidebar }), _jsx("main", { ...stylex.props(styles.panel, isSidebarToggled && styles.panelAlone), children: children })] }) }));
|
|
26
|
+
}
|
|
27
|
+
const SIDEBAR_ANIMATION_MS = 400;
|
|
28
|
+
const styles = stylex.create({
|
|
29
|
+
frame: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
height: '100%',
|
|
32
|
+
backgroundColor: colors.shell
|
|
33
|
+
},
|
|
34
|
+
panel: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexGrow: 1,
|
|
37
|
+
flexDirection: 'column',
|
|
38
|
+
minWidth: 0,
|
|
39
|
+
marginBlock: {
|
|
40
|
+
default: space.xs,
|
|
41
|
+
[breakpoints.compact]: 0
|
|
42
|
+
},
|
|
43
|
+
marginInlineEnd: {
|
|
44
|
+
default: space.xs,
|
|
45
|
+
[breakpoints.compact]: 0
|
|
46
|
+
},
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
backgroundColor: colors.containerRecessed,
|
|
49
|
+
borderRadius: {
|
|
50
|
+
default: radii.xxxl,
|
|
51
|
+
[breakpoints.compact]: 0
|
|
52
|
+
},
|
|
53
|
+
boxShadow: {
|
|
54
|
+
default: shadows.default,
|
|
55
|
+
[breakpoints.compact]: null
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
panelAlone: {
|
|
59
|
+
marginInlineStart: {
|
|
60
|
+
default: space.xs,
|
|
61
|
+
[breakpoints.compact]: 0
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AppearancePicker(): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModel } from "../hooks/appContext.js";
|
|
3
|
+
import { SegmentedControl } from "./SegmentedControl.js";
|
|
4
|
+
export function AppearancePicker() {
|
|
5
|
+
const account = useModel('account');
|
|
6
|
+
return (_jsx(SegmentedControl, { label: "Appearance", value: account.appearance, options: options, onChange: (appearance) => account.setAppearance({ appearance }) }));
|
|
7
|
+
}
|
|
8
|
+
const options = [
|
|
9
|
+
{ value: 'system', label: 'System' },
|
|
10
|
+
{ value: 'light', label: 'Light' },
|
|
11
|
+
{ value: 'dark', label: 'Dark' }
|
|
12
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Placement } from './Placement.ts';
|
|
2
|
+
type AvatarProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
imageUrl?: string | null;
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
style?: Placement;
|
|
7
|
+
};
|
|
8
|
+
export declare function Avatar({ name, imageUrl, size, style }: AvatarProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import { borders, colors, fontSizes, fontWeights, lineHeights, radii } from "../theme/tokens.stylex.js";
|
|
5
|
+
export function Avatar({ name, imageUrl = null, size = 'md', style }) {
|
|
6
|
+
return (_jsxs(BaseAvatar.Root, { className: stylex.props(styles.avatar, sizes[size], style).className, children: [imageUrl === null ? null : (_jsx(BaseAvatar.Image, { src: imageUrl, alt: "", className: stylex.props(styles.image).className })), _jsx(BaseAvatar.Fallback, { className: stylex.props(styles.fallback).className, children: initialsOf(name) })] }));
|
|
7
|
+
}
|
|
8
|
+
function initialsOf(name) {
|
|
9
|
+
return name
|
|
10
|
+
.split(/\s+/)
|
|
11
|
+
.filter((word) => word !== '')
|
|
12
|
+
.slice(0, 2)
|
|
13
|
+
.map((word) => word.charAt(0).toUpperCase())
|
|
14
|
+
.join('');
|
|
15
|
+
}
|
|
16
|
+
const styles = stylex.create({
|
|
17
|
+
avatar: {
|
|
18
|
+
position: 'relative',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexShrink: 0,
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
fontWeight: fontWeights.semimedium,
|
|
23
|
+
outlineWidth: borders.hairline,
|
|
24
|
+
outlineStyle: 'solid',
|
|
25
|
+
outlineColor: colors.borderDefault,
|
|
26
|
+
outlineOffset: `calc(-1 * ${borders.hairline})`,
|
|
27
|
+
backgroundColor: colors.component,
|
|
28
|
+
borderRadius: radii.full
|
|
29
|
+
},
|
|
30
|
+
image: {
|
|
31
|
+
width: '100%',
|
|
32
|
+
height: '100%',
|
|
33
|
+
objectFit: 'cover'
|
|
34
|
+
},
|
|
35
|
+
fallback: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
width: '100%',
|
|
40
|
+
height: '100%',
|
|
41
|
+
color: colors.secondaryForeground
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const sizes = stylex.create({
|
|
45
|
+
sm: {
|
|
46
|
+
width: lineHeights.caption,
|
|
47
|
+
height: lineHeights.caption,
|
|
48
|
+
fontSize: fontSizes.captionXs,
|
|
49
|
+
lineHeight: lineHeights.captionXs
|
|
50
|
+
},
|
|
51
|
+
md: {
|
|
52
|
+
width: lineHeights.bodySm,
|
|
53
|
+
height: lineHeights.bodySm,
|
|
54
|
+
fontSize: fontSizes.captionXs,
|
|
55
|
+
lineHeight: lineHeights.captionXs
|
|
56
|
+
},
|
|
57
|
+
lg: {
|
|
58
|
+
width: lineHeights.body,
|
|
59
|
+
height: lineHeights.body,
|
|
60
|
+
fontSize: fontSizes.bodySm,
|
|
61
|
+
lineHeight: lineHeights.caption
|
|
62
|
+
}
|
|
63
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Placement } from './Placement.ts';
|
|
3
|
+
type BadgeProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
variant?: 'primary' | 'tertiary' | 'outline' | 'transparent';
|
|
6
|
+
tone?: 'neutral' | 'brand' | 'danger';
|
|
7
|
+
size?: 'sm' | 'md';
|
|
8
|
+
style?: Placement;
|
|
9
|
+
};
|
|
10
|
+
export declare function Badge({ children, variant, tone, size, style }: BadgeProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import { borders, colors, controls, fontSizes, lineHeights, radii, space } from "../theme/tokens.stylex.js";
|
|
4
|
+
export function Badge({ children, variant = 'tertiary', tone = 'neutral', size = 'md', style }) {
|
|
5
|
+
return (_jsx("span", { ...stylex.props(styles.badge, sizes[size], looks[`${variant}${toneKeys[tone]}`], style), children: children }));
|
|
6
|
+
}
|
|
7
|
+
const toneKeys = {
|
|
8
|
+
neutral: 'Neutral',
|
|
9
|
+
brand: 'Brand',
|
|
10
|
+
danger: 'Danger'
|
|
11
|
+
};
|
|
12
|
+
const styles = stylex.create({
|
|
13
|
+
badge: {
|
|
14
|
+
display: 'inline-flex',
|
|
15
|
+
flexShrink: 0,
|
|
16
|
+
gap: space.xs,
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
paddingInline: controls.paddingXs,
|
|
20
|
+
borderRadius: radii.sm
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const sizes = stylex.create({
|
|
24
|
+
sm: {
|
|
25
|
+
height: lineHeights.caption,
|
|
26
|
+
fontSize: fontSizes.captionBase,
|
|
27
|
+
lineHeight: lineHeights.caption
|
|
28
|
+
},
|
|
29
|
+
md: {
|
|
30
|
+
height: lineHeights.bodySm,
|
|
31
|
+
fontSize: fontSizes.captionLg,
|
|
32
|
+
lineHeight: lineHeights.caption
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const looks = stylex.create({
|
|
36
|
+
primaryNeutral: {
|
|
37
|
+
color: colors.onInvertedForeground,
|
|
38
|
+
backgroundColor: colors.invertedSolid
|
|
39
|
+
},
|
|
40
|
+
primaryBrand: {
|
|
41
|
+
color: colors.onBrandSolidForeground,
|
|
42
|
+
backgroundColor: colors.brandSolid
|
|
43
|
+
},
|
|
44
|
+
primaryDanger: {
|
|
45
|
+
color: colors.onDangerSolidForeground,
|
|
46
|
+
backgroundColor: colors.dangerSolid
|
|
47
|
+
},
|
|
48
|
+
tertiaryNeutral: {
|
|
49
|
+
color: colors.secondaryForeground,
|
|
50
|
+
backgroundColor: colors.component
|
|
51
|
+
},
|
|
52
|
+
tertiaryBrand: {
|
|
53
|
+
color: colors.onBrandSubtleForeground,
|
|
54
|
+
backgroundColor: colors.brandSubtle
|
|
55
|
+
},
|
|
56
|
+
tertiaryDanger: {
|
|
57
|
+
color: colors.dangerText,
|
|
58
|
+
backgroundColor: colors.dangerSubtleHover
|
|
59
|
+
},
|
|
60
|
+
outlineNeutral: {
|
|
61
|
+
color: colors.secondaryForeground,
|
|
62
|
+
backgroundColor: 'transparent',
|
|
63
|
+
boxShadow: `inset 0 0 0 ${borders.thin} ${colors.borderDefault}`
|
|
64
|
+
},
|
|
65
|
+
outlineBrand: {
|
|
66
|
+
color: colors.brandForeground,
|
|
67
|
+
backgroundColor: 'transparent',
|
|
68
|
+
boxShadow: `inset 0 0 0 ${borders.thin} ${colors.brandBorderDefault}`
|
|
69
|
+
},
|
|
70
|
+
outlineDanger: {
|
|
71
|
+
color: colors.dangerForeground,
|
|
72
|
+
backgroundColor: 'transparent',
|
|
73
|
+
boxShadow: `inset 0 0 0 ${borders.thin} ${colors.dangerBorderDefault}`
|
|
74
|
+
},
|
|
75
|
+
transparentNeutral: {
|
|
76
|
+
color: colors.secondaryForeground,
|
|
77
|
+
backgroundColor: 'transparent'
|
|
78
|
+
},
|
|
79
|
+
transparentBrand: {
|
|
80
|
+
color: colors.brandForeground,
|
|
81
|
+
backgroundColor: 'transparent'
|
|
82
|
+
},
|
|
83
|
+
transparentDanger: {
|
|
84
|
+
color: colors.dangerForeground,
|
|
85
|
+
backgroundColor: 'transparent'
|
|
86
|
+
}
|
|
87
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppPath } from '../registered.ts';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { IconName } from './icons.ts';
|
|
4
|
+
import type { Placement } from './Placement.ts';
|
|
5
|
+
import type { Size } from './Size.ts';
|
|
6
|
+
type ButtonProps = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'transparent';
|
|
9
|
+
tone?: 'neutral' | 'brand' | 'danger';
|
|
10
|
+
size?: Size;
|
|
11
|
+
to?: AppPath;
|
|
12
|
+
icon?: IconName;
|
|
13
|
+
trailingIcon?: IconName;
|
|
14
|
+
shortcut?: readonly string[];
|
|
15
|
+
type?: 'button' | 'submit';
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
isPending?: boolean;
|
|
18
|
+
isFullWidth?: boolean;
|
|
19
|
+
onClick?: () => void;
|
|
20
|
+
style?: Placement;
|
|
21
|
+
};
|
|
22
|
+
export declare function Button({ children, variant, tone, size, to, icon, trailingIcon, shortcut, type, disabled, isPending, isFullWidth, onClick, style }: ButtonProps): import("react").JSX.Element;
|
|
23
|
+
export {};
|