Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(settings): make settings menu more beautiful (#4321)

Aidan Holloway-Bidwell03c75baf5052
diff --git a/js/app/packages/app/component/EmailAuth.tsx b/js/app/packages/app/component/EmailAuth.tsx
index 126564822a..5a8557eec3 100644
--- a/js/app/packages/app/component/EmailAuth.tsx
+++ b/js/app/packages/app/component/EmailAuth.tsx
@@ -119,7 +119,7 @@ function EmailLinkCallback(props: Pick<EmailAuthParams, 'successPath'>) {
navigateToSuccess();
return;
}
- setActiveTabId('Email');
+ setActiveTabId('Connected');
navigate('/component/mail/component/settings', { replace: true });
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
index 234b26bdc2..980f1ea1ca 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
@@ -59,7 +59,7 @@ export function InboxSelector() {
icon: () => <PlusIcon class="size-4" />,
onSelect: () =>
guardAddInbox(() => {
- openSettings('Email');
+ openSettings('Connected');
openAddInboxDialog();
}),
}
diff --git a/js/app/packages/app/component/settings/Account.tsx b/js/app/packages/app/component/settings/Account.tsx
index 6e1c2542a7..84a9c80a36 100644
--- a/js/app/packages/app/component/settings/Account.tsx
+++ b/js/app/packages/app/component/settings/Account.tsx
@@ -7,6 +7,7 @@ import { staticFileIdEndpoint } from '@core/constant/servers';
import { createStaticFile } from '@core/util/create';
import { openFilePicker } from '@core/util/upload';
import { Dialog, Button, Panel, Tooltip, ToggleSwitch, Dropdown } from '@ui';
+import { SettingsCard, SettingsPage, SettingsSection } from './primitives';
import {
blockNameToFileExtensions,
blockNameToMimeTypes,
@@ -338,88 +339,84 @@ export function Account() {
};
return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <Panel.Header class="px-6">
- <div class="flex items-center gap-2">
- <div class="text-sm font-semibold">Account</div>
- </div>
- </Panel.Header>
-
- <Panel.Body scroll class="text-ink">
- <div class="grid settings-row-dividers">
- <Show when={ENABLE_PROFILE_PICTURES}>
- <Show when={userId()} keyed>
- {(id) => <ProfilePictureRow userId={id} />}
- </Show>
- </Show>
-
- <Row label="Email">
- <span class="ph-no-capture text-sm text-ink-muted">
- {email() ?? ''}
- </span>
- </Row>
-
- <Row label="First Name">
- <NameInput
- value={firstName()}
- onSave={(newValue) =>
- saveUserName(
- newValue,
- 'first_name',
- updatedFirstName(),
- setUpdatedFirstName
- )
- }
- placeholder="Enter First Name"
- />
- </Row>
-
- <Row label="Last Name">
- <NameInput
- value={lastName()}
- onSave={(newValue) =>
- saveUserName(
- newValue,
- 'last_name',
- updatedLastName(),
- setUpdatedLastName
- )
- }
- placeholder="Enter Last Name"
- />
- </Row>
-
- <Show when={autoUpdateUIEnabled()}>
- <BundleVersionRow />
- <BundleUpdateRow />
- </Show>
-
- <NotificationToggle />
- </div>
-
- <Show when={isMobile()}>
- <div class="flex items-center justify-center px-6 py-6">
- <Button
- variant="base"
- size="md"
- depth={3}
- class="px-4"
- onClick={() => logout()}
- >
- <SignOutIcon class="size-4" />
- Log out
- </Button>
- </div>
+ <SettingsPage title="Account">
+ <SettingsSection>
+ <SettingsCard>
+ <Show when={ENABLE_PROFILE_PICTURES}>
+ <Show when={userId()} keyed>
+ {(id) => <ProfilePictureRow userId={id} />}
</Show>
+ </Show>
- <Show when={isNativeMobilePlatform()}>
- <div class="border-t border-edge pt-4">
- <Button variant="danger" depth={3} onClick={() => setShowDeleteModal(true)}>
- Delete Account
- </Button>
- <Dialog
+ <Row label="Email">
+ <span class="ph-no-capture text-sm text-ink-muted">
+ {email() ?? ''}
+ </span>
+ </Row>
+
+ <Row label="First Name">
+ <NameInput
+ value={firstName()}
+ onSave={(newValue) =>
+ saveUserName(
+ newValue,
+ 'first_name',
+ updatedFirstName(),
+ setUpdatedFirstName
+ )
+ }
+ placeholder="Enter First Name"
+ />
+ </Row>
+
+ <Row label="Last Name">
+ <NameInput
+ value={lastName()}
+ onSave={(newValue) =>
+ saveUserName(
+ newValue,
+ 'last_name',
+ updatedLastName(),
+ setUpdatedLastName
+ )
+ }
+ placeholder="Enter Last Name"
+ />
+ </Row>
+
+ <Show when={autoUpdateUIEnabled()}>
+ <BundleVersionRow />
+ <BundleUpdateRow />
+ </Show>
+
+ <NotificationToggle />
+ </SettingsCard>
+ </SettingsSection>
+
+ <Show when={isMobile()}>
+ <SettingsSection>
+ <div class="flex items-center justify-center">
+ <Button
+ variant="base"
+ size="md"
+ depth={3}
+ class="px-4"
+ onClick={() => logout()}
+ >
+ <SignOutIcon class="size-4" />
+ Log out
+ </Button>
+ </div>
+ </SettingsSection>
+ </Show>
+
+ <Show when={isNativeMobilePlatform()}>
+ <SettingsSection title="Danger zone">
+ <div>
+ <Button variant="danger" depth={3} onClick={() => setShowDeleteModal(true)}>
+ Delete Account
+ </Button>
+ <Dialog
open={showDeleteModal()}
onOpenChange={setShowDeleteModal}
position="center"
@@ -478,18 +475,16 @@ export function Account() {
</Panel.Body>
</Panel>
</Dialog>
- </div>
- </Show>
- </Panel.Body>
- </Panel>
- </div>
- </div>
+ </div>
+ </SettingsSection>
+ </Show>
+ </SettingsPage>
);
}
function Row(props: { label: string; children?: any }) {
return (
- <div class="bg-surface flex items-center justify-between h-15.25 px-6">
+ <div class="bg-surface flex items-center justify-between gap-4 min-h-15.25 px-6 py-3">
<div class="text-sm">{props.label}</div>
<div class="text-right">{props.children}</div>
</div>
@@ -548,10 +543,10 @@ function NameInput(props: {
};
return (
- <div class="ph-no-capture group relative flex items-center gap-1.5 rounded-lg h-7 mobile:h-9 px-2 border text-xs bg-transparent text-ink-muted border-edge-muted hover:text-ink focus-within:text-ink focus-within:border-accent">
+ <div class="ph-no-capture group relative flex items-center gap-1.5 rounded-lg h-9 px-3 border text-sm bg-transparent text-ink-muted border-edge-muted hover:text-ink focus-within:text-ink focus-within:border-accent">
<input
type="text"
- class="flex-1 min-w-0 bg-transparent outline-none border-0 p-0 text-xs placeholder:text-ink-extra-muted"
+ class="flex-1 min-w-0 bg-transparent outline-none border-0 p-0 text-sm placeholder:text-ink-extra-muted"
value={inputValue()}
onInput={(e) => setInputValue(e.currentTarget.value)}
onFocus={() => {
@@ -623,6 +618,7 @@ function NotificationSettings(props: {
return (
<Row label="Notifications">
<ToggleSwitch
+ size="md"
checked={props.settings.isEnabled()}
onChange={handleToggle}
/>
diff --git a/js/app/packages/app/component/settings/Admin.tsx b/js/app/packages/app/component/settings/Admin.tsx
index 7afa706fe5..9edf755823 100644
--- a/js/app/packages/app/component/settings/Admin.tsx
+++ b/js/app/packages/app/component/settings/Admin.tsx
@@ -1,5 +1,5 @@
import { For } from 'solid-js';
-import { Button, Panel, ToggleSwitch } from '@ui';
+import { Button, ToggleSwitch } from '@ui';
import {
type DebugSettingDef,
DEBUG_SETTINGS,
@@ -8,23 +8,19 @@ import {
getDebugSetting,
setDebugSetting,
} from '@app/lib/debugSettings';
+import { SettingsCard, SettingsPage, SettingsRow } from './primitives';
function DebugSettingRow(props: { setting: DebugSettingDef }) {
const checked = () => getDebugSetting(props.setting.key);
return (
- <div class="flex items-center justify-between gap-4 py-2 px-6">
- <div class="min-w-0">
- <div class="text-sm">{props.setting.label}</div>
- <div class="text-xs text-ink-extra-muted">
- {props.setting.description}
- </div>
- </div>
+ <SettingsRow label={props.setting.label} description={props.setting.description}>
<ToggleSwitch
+ size="md"
checked={checked()}
onChange={(value) => setDebugSetting(props.setting.key, value)}
/>
- </div>
+ </SettingsRow>
);
}
@@ -32,37 +28,26 @@ export function Admin() {
const hasActiveSettings = () => Object.keys(debugSettings()).length > 0;
return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- <Panel depth={2}>
- <Panel.Header>
- <div class="flex items-center justify-between gap-4 w-full px-2 py-2">
- <div>
- <div class="text-sm font-medium">Debug settings</div>
- <div class="text-xs text-ink-extra-muted">
- Local toggles for debugging — only visible to Macro staff.
- </div>
- </div>
- <Button
- variant="base"
- size="sm"
- disabled={!hasActiveSettings()}
- onClick={clearAllDebugSettings}
- >
- Reset all
- </Button>
- </div>
- </Panel.Header>
-
- <Panel.Body scroll>
- <div class="flex flex-col py-2">
- <For each={DEBUG_SETTINGS}>
- {(setting) => <DebugSettingRow setting={setting} />}
- </For>
- </div>
- </Panel.Body>
- </Panel>
- </div>
- </div>
+ <SettingsPage
+ title="Debug"
+ description="Local toggles for debugging — only visible to Macro staff."
+ actions={
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ disabled={!hasActiveSettings()}
+ onClick={clearAllDebugSettings}
+ >
+ Reset all
+ </Button>
+ }
+ >
+ <SettingsCard>
+ <For each={DEBUG_SETTINGS}>
+ {(setting) => <DebugSettingRow setting={setting} />}
+ </For>
+ </SettingsCard>
+ </SettingsPage>
);
}
diff --git a/js/app/packages/app/component/settings/Agent.tsx b/js/app/packages/app/component/settings/Agent.tsx
index ef0e90e14e..187e28e491 100644
--- a/js/app/packages/app/component/settings/Agent.tsx
+++ b/js/app/packages/app/component/settings/Agent.tsx
@@ -1,8 +1,7 @@
import { createEffect, createSignal, For, Show, Suspense } from 'solid-js';
-import { TabsInset } from '@core/component/TabsInset';
import PlusIcon from '@phosphor-icons/core/regular/plus.svg?component-solid';
import PlugIcon from '@phosphor-icons/core/regular/plug.svg?component-solid';
-import { Button, Layer, Panel, ToggleSwitch } from '@ui';
+import { Button, Dialog, Panel, ToggleSwitch } from '@ui';
import CheckIcon from '@phosphor-icons/core/regular/check.svg?component-solid';
import XIcon from '@phosphor-icons/core/regular/x.svg?component-solid';
import { McpSetupCards } from '@core/component/AI/component/McpSetupCards';
@@ -11,7 +10,6 @@ import type {
ServerResponse,
StartAuthResponse,
} from '@service-cognition/generated/schemas';
-import { ScopedPortal } from '@core/component/ScopedPortal';
import {
useMcpServersQuery,
useAddMcpServerMutation,
@@ -19,18 +17,26 @@ import {
useDeleteMcpServerMutation,
useStartMcpAuthMutation,
} from '@queries/mcp-servers';
-import {
- agentSettingsSubTab,
- setAgentSettingsSubTab,
- type AgentSettingsSubTab,
-} from '@core/constant/SettingsState';
import {
QUICK_CONNECT_SERVERS,
QUICK_CONNECT_ICON_MAP,
type SvgIcon,
} from '@core/component/AI/constant/mcpServers';
-
-type McpTab = AgentSettingsSubTab;
+import {
+ IntegrationRow,
+ SettingsCard,
+ SettingsPage,
+ SettingsSection,
+} from './primitives';
+
+/** Best-effort hostname for an MCP server URL — friendlier than the raw URL. */
+function hostFromUrl(url: string): string {
+ try {
+ return new URL(url).host;
+ } catch {
+ return url;
+ }
+}
function AddServerForm(props: {
open: boolean;
@@ -97,105 +103,110 @@ function AddServerForm(props: {
};
return (
- <ScopedPortal scope="local" show={props.open}>
- <Layer depth={3}>
- <div class="absolute inset-0 z-10 flex items-center justify-center bg-overlay">
- <div class="w-100 max-w-[calc(100%-2rem)]">
- <Panel active depth={3} class="shadow-md">
- <Panel.Header class="px-6">
- <span class="text-ink text-sm font-semibold">Add MCP Server</span>
- </Panel.Header>
- <Panel.Body class="p-6 flex flex-col gap-5">
- <div class="flex flex-col gap-2">
- <span class="text-xs text-ink-muted">Quick Connect</span>
- <div class="grid grid-cols-2 gap-2">
- <For each={QUICK_CONNECT_SERVERS}>
- {(server) => {
- const added = () => props.existingUrls.has(server.url);
- return (
- <button
- class="flex items-center justify-between px-3 py-2 rounded-sm border border-edge-muted text-sm transition-colors"
- classList={{
- 'bg-panel text-ink hover:bg-hover cursor-pointer': !added(),
- 'bg-panel text-ink-muted cursor-default': added(),
- }}
- disabled={added() || addMutation.isPending}
- onClick={() => handleQuickConnect(server)}
- >
- <span class="flex items-center gap-2 text-accent">
- <server.icon class="size-4" />
- <span class="text-ink">{server.server_name}</span>
- </span>
- <Show when={added()}>
- <span class="text-xs text-ink-muted">Added</span>
- </Show>
- </button>
- );
+ <Dialog
+ open={props.open}
+ onOpenChange={(open) => !open && props.onOpenChange(false)}
+ position="center"
+ class="w-100"
+ >
+ <Panel active depth={2} class="rounded-xl">
+ <Panel.Header class="px-6">
+ <span class="text-ink text-sm font-semibold">Add MCP Server</span>
+ </Panel.Header>
+ <Panel.Body class="p-6 flex flex-col gap-5">
+ <div class="flex flex-col gap-2">
+ <span class="text-xs text-ink-muted">Quick Connect</span>
+ <div class="grid grid-cols-2 gap-2">
+ <For each={QUICK_CONNECT_SERVERS}>
+ {(server) => {
+ const added = () => props.existingUrls.has(server.url);
+ return (
+ <button
+ class="flex items-center justify-between px-3 py-2 rounded-lg border border-edge-muted text-sm transition-colors"
+ classList={{
+ 'text-ink hover:bg-ink/4 cursor-pointer': !added(),
+ 'text-ink-muted cursor-default': added(),
}}
- </For>
- </div>
- </div>
+ disabled={added() || addMutation.isPending}
+ onClick={() => handleQuickConnect(server)}
+ >
+ <span class="flex items-center gap-2 text-accent">
+ <server.icon class="size-4" />
+ <span class="text-ink">{server.server_name}</span>
+ </span>
+ <Show when={added()}>
+ <span class="text-xs text-ink-muted">Added</span>
+ </Show>
+ </button>
+ );
+ }}
+ </For>
+ </div>
+ </div>
- <div class="flex flex-col gap-4">
- <span class="text-xs text-ink-muted">Custom Server</span>
- <label class="flex flex-col gap-1.5">
- <span class="text-xs text-ink-muted">Name</span>
- <input
- type="text"
- class="h-8 px-2.5 rounded-lg border border-edge-muted bg-input text-sm text-ink outline-none placeholder:text-ink-muted focus:border-accent"
- placeholder="My MCP Server"
- value={name()}
- onInput={(e) => setName(e.currentTarget.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter') handleSubmit();
- if (e.key === 'Escape') { reset(); props.onOpenChange(false); }
- }}
- />
- </label>
- <label class="flex flex-col gap-1.5">
- <span class="text-xs text-ink-muted">URL</span>
- <input
- type="url"
- class="h-8 px-2.5 rounded-lg border border-edge-muted bg-input text-sm text-ink outline-none placeholder:text-ink-muted focus:border-accent"
- placeholder="https://example.com/mcp"
- value={url()}
- onInput={(e) => setUrl(e.currentTarget.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter') handleSubmit();
- if (e.key === 'Escape') { reset(); props.onOpenChange(false); }
- }}
- />
- </label>
- </div>
+ <div class="flex flex-col gap-4">
+ <span class="text-xs text-ink-muted">Custom Server</span>
+ <label class="flex flex-col gap-1.5">
+ <span class="text-xs text-ink-muted">Name</span>
+ <input
+ type="text"
+ class="settings-input w-full"
+ placeholder="My MCP Server"
+ value={name()}
+ onInput={(e) => setName(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') handleSubmit();
+ if (e.key === 'Escape') {
+ reset();
+ props.onOpenChange(false);
+ }
+ }}
+ />
+ </label>
+ <label class="flex flex-col gap-1.5">
+ <span class="text-xs text-ink-muted">URL</span>
+ <input
+ type="url"
+ class="settings-input w-full"
+ placeholder="https://example.com/mcp"
+ value={url()}
+ onInput={(e) => setUrl(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') handleSubmit();
+ if (e.key === 'Escape') {
+ reset();
+ props.onOpenChange(false);
+ }
+ }}
+ />
+ </label>
+ </div>
- <div class="flex justify-end gap-2 pt-1">
- <Button
- variant="base"
- size="sm"
- depth={3}
- onClick={() => {
- reset();
- props.onOpenChange(false);
- }}
- >
- Cancel
- </Button>
- <Button
- variant="active"
- size="sm"
- depth={3}
- disabled={!name().trim() || !url().trim() || addMutation.isPending}
- onClick={handleSubmit}
- >
- {addMutation.isPending ? 'Adding...' : 'Add'}
- </Button>
- </div>
- </Panel.Body>
- </Panel>
+ <div class="flex justify-end gap-2 pt-1">
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ onClick={() => {
+ reset();
+ props.onOpenChange(false);
+ }}
+ >
+ Cancel
+ </Button>
+ <Button
+ variant="active"
+ size="sm"
+ depth={3}
+ disabled={!name().trim() || !url().trim() || addMutation.isPending}
+ onClick={handleSubmit}
+ >
+ {addMutation.isPending ? 'Adding...' : 'Add'}
+ </Button>
</div>
- </div>
- </Layer>
- </ScopedPortal>
+ </Panel.Body>
+ </Panel>
+ </Dialog>
);
}
@@ -293,130 +304,129 @@ function ServerRow(props: { server: ServerResponse }) {
QUICK_CONNECT_ICON_MAP.get(props.server.url) ?? (PlugIcon as SvgIcon);
return (
- <div class="bg-panel flex items-center gap-4 @max-[480px]:gap-2 px-6 @max-[480px]:px-3 py-3">
- {(() => {
+ <IntegrationRow
+ icon={(() => {
const C = Icon();
- return <C class="size-5 shrink-0 text-accent" />;
+ return <C class="size-5 text-accent" />;
})()}
- <div class="flex-1 min-w-0">
- <div class="flex items-center gap-1.5">
- <span class="min-w-0 truncate text-sm font-medium text-ink">
- {props.server.server_name}
- </span>
+ title={
+ <span class="flex items-center gap-1.5">
+ <span class="min-w-0 truncate">{props.server.server_name}</span>
<Show when={props.server.authenticated}>
<CheckIcon class="size-3 shrink-0 text-success" />
</Show>
<Show when={connectionFailed()}>
<XIcon class="size-3 shrink-0 text-failure" />
</Show>
- </div>
- <div class="text-xs text-ink-muted truncate">{props.server.url}</div>
- </div>
-
- <div class="flex items-center gap-2 shrink-0">
- <Show when={!props.server.authenticated}>
- <Show when={connectionFailed()}>
- <span class="text-xs text-failure whitespace-nowrap">
- Last connection attempt failed
- </span>
- </Show>
- <Button
- variant="active"
- size="sm"
- depth={3}
- disabled={authMutation.isPending}
- onClick={handleAuth}
- >
- {authMutation.isPending
- ? 'Connecting...'
- : connectionFailed()
- ? 'Try Again'
- : 'Connect'}
- </Button>
+ </span>
+ }
+ description={hostFromUrl(props.server.url)}
+ >
+ <Show when={!props.server.authenticated}>
+ <Show when={connectionFailed()}>
+ <span class="text-xs text-failure whitespace-nowrap">
+ Last attempt failed
+ </span>
</Show>
+ <Button
+ variant="active"
+ size="sm"
+ depth={3}
+ disabled={authMutation.isPending}
+ onClick={handleAuth}
+ >
+ {authMutation.isPending
+ ? 'Connecting...'
+ : connectionFailed()
+ ? 'Try Again'
+ : 'Connect'}
+ </Button>
+ </Show>
- <Show when={props.server.authenticated}>
- <ToggleSwitch
- checked={props.server.enabled}
- disabled={updateMutation.isPending}
- onChange={handleToggleEnabled}
- label={props.server.enabled ? 'Enabled' : 'Disabled'}
- labelClass="@max-[480px]:hidden inline-block w-14 text-left text-xs text-ink-muted whitespace-nowrap"
- />
- </Show>
+ <Show when={props.server.authenticated}>
+ <ToggleSwitch
+ size="md"
+ checked={props.server.enabled}
+ disabled={updateMutation.isPending}
+ onChange={handleToggleEnabled}
+ label={props.server.enabled ? 'Enabled' : 'Disabled'}
+ labelClass="inline-block w-14 text-left text-xs text-ink-muted whitespace-nowrap"
+ />
+ </Show>
- <Show
- when={!confirmDelete()}
- fallback={
- <div class="flex items-center gap-1">
- <Button
- variant="danger"
- size="sm"
- depth={3}
- disabled={deleteMutation.isPending}
- onClick={handleDelete}
- >
- {deleteMutation.isPending ? 'Removing...' : 'Confirm'}
- </Button>
- <Button
- variant="base"
- size="sm"
- depth={3}
- onClick={() => setConfirmDelete(false)}
- >
- Cancel
- </Button>
- </div>
- }
+ <Show
+ when={!confirmDelete()}
+ fallback={
+ <div class="flex items-center gap-1">
+ <Button
+ variant="danger"
+ size="sm"
+ depth={3}
+ disabled={deleteMutation.isPending}
+ onClick={handleDelete}
+ >
+ {deleteMutation.isPending ? 'Removing...' : 'Confirm'}
+ </Button>
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ onClick={() => setConfirmDelete(false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ }
+ >
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ tooltip="Remove"
+ onClick={() => setConfirmDelete(true)}
>
- <Button
- variant="base"
- size="sm"
- depth={3}
- tooltip="Remove"
- class="@max-[480px]:border-transparent"
- onClick={() => setConfirmDelete(true)}
- >
- <span class="@max-[480px]:hidden">Remove</span>
- <XIcon class="hidden size-4 @max-[480px]:block" />
- </Button>
- </Show>
- </div>
- </div>
+ <XIcon class="size-4" />
+ </Button>
+ </Show>
+ </IntegrationRow>
);
}
function Connectors() {
const serversQuery = useMcpServersQuery();
const [showAddDialog, setShowAddDialog] = createSignal(false);
- const hasServers = () => (serversQuery.data?.length ?? 0) > 0;
return (
- <div class="@container">
- <div class="px-6 @max-[480px]:px-2 py-4 flex flex-col gap-4">
- <Show when={!hasServers()}>
- <div class="text-sm">
- Connect the Macro agent to external MCP servers
- </div>
- </Show>
-
- <Show when={serversQuery.isLoading}>
- <div class="text-sm text-ink-muted py-8 text-center">Loading...</div>
- </Show>
-
+ <SettingsSection
+ title="Connectors"
+ description="Connect Macro's agent to external MCP servers."
+ actions={
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ onClick={() => setShowAddDialog(true)}
+ >
+ <PlusIcon class="size-4" />
+ Add server
+ </Button>
+ }
+ >
<Show when={serversQuery.isError}>
- <div class="text-sm text-red-500 py-8 text-center">
- Failed to load servers.
- <Button
- variant="base"
- size="sm"
- depth={3}
- onClick={() => serversQuery.refetch()}
- class="ml-2"
- >
- Retry
- </Button>
- </div>
+ <SettingsCard>
+ <div class="px-6 py-8 text-center text-sm text-ink-muted">
+ Failed to load servers.
+ <Button
+ variant="base"
+ size="sm"
+ depth={3}
+ onClick={() => serversQuery.refetch()}
+ class="ml-2"
+ >
+ Retry
+ </Button>
+ </div>
+ </SettingsCard>
</Show>
<Show when={serversQuery.data}>
@@ -424,81 +434,51 @@ function Connectors() {
<Show
when={servers().length > 0}
fallback={
- <div class="text-sm text-ink-muted py-8 text-center">
- No MCP servers configured yet.
- </div>
+ <SettingsCard>
+ <div class="px-6 py-8 text-center text-sm text-ink-muted">
+ No MCP servers connected yet.
+ </div>
+ </SettingsCard>
}
>
- <div class="flex flex-col rounded-sm overflow-hidden border border-edge-muted settings-row-dividers @max-[480px]:[&>*:not(:last-child)]:after:inset-x-3">
+ <SettingsCard>
<For each={servers()}>
{(server) => <ServerRow server={server} />}
</For>
- </div>
+ </SettingsCard>
</Show>
)}
</Show>
- <div class="flex justify-center">
- <Button
- variant="active"
- size="sm"
- depth={3}
- onClick={() => setShowAddDialog(true)}
- >
- <PlusIcon class="size-4" />
- Add Server
- </Button>
- </div>
-
<AddServerForm
open={showAddDialog()}
onOpenChange={setShowAddDialog}
existingUrls={new Set(serversQuery.data?.map((s) => s.url) ?? [])}
/>
- </div>
- </div>
- );
-}
-
-function McpServer() {
- return (
- <div class="px-6">
- <div class="text-sm py-4"> Connect agents to Macro's MCP Server </div>
- <McpSetupCards class="max-w-none" />
- </div>
+ </SettingsSection>
);
}
export function Agent() {
- const tabList = [
- { value: 'connectors', label: 'Connectors' },
- { value: 'mcp_server', label: 'MCP Server' },
- ];
-
return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- <Panel depth={2} class="relative portal-scope">
- <Panel.Header>
- <TabsInset
- list={tabList}
- value={agentSettingsSubTab()}
- defaultValue="connectors"
- onChange={(v) => setAgentSettingsSubTab(v as McpTab)}
- />
- </Panel.Header>
- <Panel.Body scroll>
- <Show when={agentSettingsSubTab() === 'connectors'}>
- <Suspense fallback={<div class="text-sm text-ink-muted py-8 text-center">Loading...</div>}>
- <Connectors />
- </Suspense>
- </Show>
- <Show when={agentSettingsSubTab() === 'mcp_server'}>
- <McpServer />
- </Show>
- </Panel.Body>
- </Panel>
- </div>
- </div>
+ <SettingsPage
+ title="MCPs"
+ description="Connect Macro's agent to external tools, or connect other agents to Macro."
+ >
+ <Suspense
+ fallback={
+ <div class="text-sm text-ink-muted py-8 text-center">Loading...</div>
+ }
+ >
+ <Connectors />
+ </Suspense>
+
+ <SettingsSection
+ title="Macro MCP server"
+ description="Connect other agents and tools to your Macro workspace."
+ >
+ <McpSetupCards class="max-w-none" />
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/js/app/packages/app/component/settings/Appearance.tsx b/js/app/packages/app/component/settings/Appearance.tsx
index bfb6dfda8c..81e903bd83 100644
--- a/js/app/packages/app/component/settings/Appearance.tsx
+++ b/js/app/packages/app/component/settings/Appearance.tsx
@@ -1,24 +1,81 @@
-import { monochromeIcons, setMonochromeIcons, setTooltipsEnabled, tooltipsEnabled } from '@ui/signals/signals';
+import {
+ monochromeIcons,
+ setMonochromeIcons,
+ setTooltipsEnabled,
+ tooltipsEnabled,
+} from '@ui/signals/signals';
import { ThemeEditorAdvanced } from '@theme/components/ThemeEditorAdvanced';
-import { ThemeEditorBasic, randomizeTheme } from '@theme/components/ThemeEditorBasic';
-import ThemeTools from '@theme/components/ThemeTools';
-import ThemeList from '@theme/components/ThemeList';
-import { isMobile } from '@core/mobile/isMobile';
+import {
+ ThemeEditorBasic,
+ randomizeTheme,
+} from '@theme/components/ThemeEditorBasic';
import { createSignal, For, Show } from 'solid-js';
import { TabsInset } from '@core/component/TabsInset';
-import IconDice from '@phosphor-icons/core/regular/dice-five.svg?component-solid';
-import IconFunnel from '@phosphor-icons/core/regular/funnel-simple.svg?component-solid';
-import { darkModeTheme, lightModeTheme, setDarkModeTheme, setLightModeTheme, setShowDarkThemes, setShowLightThemes, setThemeShouldMatchSystem, showDarkThemes, showLightThemes, themes, themeShouldMatchSystem } from '@theme/signals/themeSignals';
-import { isTokensDark } from '@theme/utils/themeUtils';
+import XIcon from '@phosphor/x.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import PencilIcon from '@phosphor/pencil-simple.svg';
+import TrashIcon from '@phosphor/trash.svg';
+import ClipboardIcon from '@phosphor/clipboard.svg';
+import ShuffleIcon from '@phosphor/shuffle.svg';
+import {
+ currentThemeId,
+ darkModeTheme,
+ lightModeTheme,
+ setDarkModeTheme,
+ setIsThemeSaved,
+ setLightModeTheme,
+ setThemeShouldMatchSystem,
+ themes,
+ themeShouldMatchSystem,
+ userThemes,
+} from '@theme/signals/themeSignals';
+import {
+ applyTheme,
+ deleteTheme,
+ exportTheme,
+ getLiveTheme,
+ isTokensDark,
+ saveTheme,
+ updateTheme,
+} from '@theme/utils/themeUtils';
+import { toast } from '@core/component/Toast/Toast';
+import { DEFAULT_THEMES } from '@theme/constants';
import { ThemeChips } from '@theme/components/ThemeChips';
import { ThemeChipPill } from '@theme/components/ThemeChipPill';
import type { ThemeV2 } from '@theme/types/themeTypes';
import { DropdownMenu as KobalteDropdownMenu } from '@kobalte/core/dropdown-menu';
-import { Button, cn, Dropdown, InlineCheckbox, Panel, ToggleSwitch } from '@ui';
+import { Button, cn, Dropdown, Layer, ToggleSwitch } from '@ui';
+import {
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from './primitives';
-type PanelA = 'basic' | 'advanced';
-type PanelB ='themes' | 'ui'
+type EditorTab = 'basic' | 'advanced';
+/** Copies a theme's JSON to the clipboard (for sharing / importing elsewhere). */
+function CopyThemeButton(props: { themeId: string; name: string }) {
+ return (
+ <button
+ type="button"
+ aria-label={`Copy ${props.name}`}
+ class="rounded p-0.5 hover:text-ink"
+ onPointerDown={(e) => e.stopPropagation()}
+ onPointerUp={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ exportTheme(props.themeId);
+ toast.success('Theme copied to clipboard');
+ }}
+ >
+ <ClipboardIcon class="size-3.5" />
+ </button>
+ );
+}
+
+/** A default/preferred-theme picker row, shown indented beneath auto-detect. */
function ThemePreferenceRow(props: {
label: string;
value: () => string;
@@ -35,228 +92,402 @@ function ThemePreferenceRow(props: {
<div
class={cn(
// Nested under the auto-detect toggle: the indent marks these as
- // sub-settings that only apply while auto-detect is on. Shorter than the
- // top-level rows so they cluster tightly beneath the toggle.
- 'bg-surface flex items-center justify-between h-11 px-6 pl-10 transition-opacity',
+ // sub-settings that only apply while auto-detect is on.
+ 'bg-surface flex items-center justify-between h-12 px-6 pl-10 transition-opacity',
props.disabled?.() && 'opacity-50 pointer-events-none'
)}
aria-disabled={props.disabled?.()}
>
<div class="text-sm">{props.label}</div>
<Dropdown>
- {/* Same pill as the theme mention chip; `as` makes it the dropdown trigger. */}
<KobalteDropdownMenu.Trigger
as={ThemeChipPill}
- class="h-auto"
+ class="h-auto text-xs rounded-lg border border-edge-muted py-1 pl-1 pr-2 hover:bg-ink/4"
disabled={props.disabled?.()}
theme={selectedTheme()}
name={selectedTheme()?.name ?? props.value()}
/>
- <Dropdown.Content>
- <Dropdown.Group>
- <For each={props.options()}>
- {(theme) => (
- <Dropdown.Item
- class="touch:min-h-10"
- onSelect={() => props.onSelect(theme.id)}
- >
- <span class="flex items-center gap-2">
- <ThemeChips theme={theme} size="sm" />
- {theme.name}
- </span>
- </Dropdown.Item>
- )}
- </For>
- </Dropdown.Group>
+ <Dropdown.Content
+ as="div"
+ class="overflow-hidden border border-ink/[0.05] bg-surface shadow-menu"
+ >
+ <Layer depth={3}>
+ <Dropdown.Group>
+ <For each={props.options()}>
+ {(theme) => (
+ <Dropdown.Item
+ class="group touch:min-h-10"
+ onSelect={() => props.onSelect(theme.id)}
+ >
+ <span class="flex min-w-0 flex-1 items-center gap-2">
+ <ThemeChips theme={theme} size="sm" />
+ <span class="truncate">{theme.name}</span>
+ </span>
+ <span class="ml-2 shrink-0 text-ink-extra-muted opacity-0 group-hover:opacity-100 touch:opacity-100">
+ <CopyThemeButton themeId={theme.id} name={theme.name} />
+ </span>
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Group>
+ </Layer>
</Dropdown.Content>
</Dropdown>
</div>
);
}
-function UserInterface() {
- const lightThemes = () =>
- themes().filter((theme) => !isTokensDark(theme.tokens));
- const darkThemes = () => themes().filter((theme) => isTokensDark(theme.tokens));
+/**
+ * The "Interface theme" picker: a swatch-chip trigger opening a filterable,
+ * scrollable dropdown of Default then Custom themes, plus a "New theme" action.
+ */
+function InterfaceThemeSelect(props: {
+ onPick: (id: string) => void;
+ onEdit: (id: string) => void;
+ onDelete: (theme: ThemeV2) => void;
+ onNewTheme: () => void;
+}) {
+ const [filter, setFilter] = createSignal('');
+ const [open, setOpen] = createSignal(false);
+ let inputRef: HTMLInputElement | undefined;
- return (
- <div class="flex flex-col settings-row-dividers">
- <div class="bg-surface flex items-center justify-between h-15.25 px-6">
- <div class="text-sm">Monochrome Icons</div>
- <ToggleSwitch
- onChange={setMonochromeIcons}
- checked={monochromeIcons()}
- />
- </div>
+ const current = () => themes().find((theme) => theme.id === currentThemeId());
+ const matches = (theme: ThemeV2) =>
+ theme.name.toLowerCase().includes(filter().trim().toLowerCase());
+ const defaults = () =>
+ (DEFAULT_THEMES as unknown as ThemeV2[]).filter(matches);
+ const customs = () => userThemes().filter(matches);
- <div class="bg-surface flex items-center justify-between h-15.25 px-6">
- <div class="text-sm">Show Tooltips</div>
- <ToggleSwitch
- onChange={setTooltipsEnabled}
- checked={tooltipsEnabled()}
- />
- </div>
+ // `editable` custom themes get an inline edit affordance that opens the
+ // editor for that theme (saving writes back to it).
+ const themeItem = (theme: ThemeV2, editable?: boolean) => (
+ <Dropdown.Item
+ class="group touch:min-h-10"
+ onSelect={() => props.onPick(theme.id)}
+ >
+ <span class="flex min-w-0 flex-1 items-center gap-2">
+ <ThemeChips theme={theme} size="sm" />
+ <span class="truncate">{theme.name}</span>
+ </span>
+ <span class="ml-2 flex shrink-0 items-center gap-0.5 text-ink-extra-muted opacity-0 group-hover:opacity-100 touch:opacity-100">
+ <CopyThemeButton themeId={theme.id} name={theme.name} />
+ <Show when={editable}>
+ <button
+ type="button"
+ aria-label={`Edit ${theme.name}`}
+ class="rounded p-0.5 hover:text-ink"
+ onPointerDown={(e) => e.stopPropagation()}
+ onPointerUp={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setOpen(false);
+ props.onEdit(theme.id);
+ }}
+ >
+ <PencilIcon class="size-3.5" />
+ </button>
+ <button
+ type="button"
+ aria-label={`Delete ${theme.name}`}
+ class="rounded p-0.5 hover:text-failure"
+ onPointerDown={(e) => e.stopPropagation()}
+ onPointerUp={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setOpen(false);
+ props.onDelete(theme);
+ }}
+ >
+ <TrashIcon class="size-3.5" />
+ </button>
+ </Show>
+ </span>
+ </Dropdown.Item>
+ );
- {/* Auto-detect and its dependent theme pickers form one group: keep the
- divider above the group, but none between it and its sub-settings. */}
- <div class="flex flex-col">
- <div class="bg-surface flex items-center justify-between h-15.25 px-6">
- <div class="flex flex-col gap-0.5">
- <div class="text-sm">Auto-detect color scheme</div>
- <div class="text-xs text-ink-muted">
- Switch theme with your system's light/dark mode
- </div>
+ return (
+ <Dropdown open={open()} onOpenChange={setOpen}>
+ <KobalteDropdownMenu.Trigger
+ as={ThemeChipPill}
+ class="h-auto text-xs rounded-lg border border-edge-muted py-1 pl-1 pr-2 hover:bg-ink/4"
+ // With no stored theme selected (e.g. the active theme was just
+ // deleted), fall back to the live tokens so the swatch still reflects
+ // the current colors and the label reads "Unsaved Theme".
+ theme={current() ?? getLiveTheme()}
+ name={current()?.name ?? 'Unsaved Theme'}
+ />
+ <Dropdown.Content
+ // Render as a plain div (not Surface) so the edge is a faint ink
+ // hairline like the settings cards, rather than the heavier b4 border.
+ as="div"
+ class="w-60 overflow-hidden border border-ink/[0.05] bg-surface shadow-menu"
+ onOpenAutoFocus={(e: Event) => {
+ // Focus the filter input instead of the first item.
+ e.preventDefault();
+ inputRef?.focus();
+ }}
+ onCloseAutoFocus={() => setFilter('')}
+ >
+ {/* Elevate the menu's fill a level so it reads distinct from the
+ settings cards, while the outer Surface keeps its subtle edges. */}
+ <Layer depth={3}>
+ <div class="bg-surface p-1.5">
+ <input
+ ref={inputRef}
+ type="text"
+ value={filter()}
+ onInput={(e) => setFilter(e.currentTarget.value)}
+ // Keep typing in the box rather than triggering the menu's typeahead.
+ onKeyDown={(e) => e.stopPropagation()}
+ placeholder="Filter themes…"
+ spellcheck={false}
+ class="h-8 w-full rounded-md border border-edge-muted bg-transparent px-2.5 text-sm text-ink outline-none placeholder:text-ink-extra-muted focus:border-accent"
+ />
</div>
- <ToggleSwitch
- onChange={setThemeShouldMatchSystem}
- checked={themeShouldMatchSystem()}
- />
- </div>
- <ThemePreferenceRow
- label="Default light theme"
- value={lightModeTheme}
- options={lightThemes}
- onSelect={setLightModeTheme}
- disabled={() => !themeShouldMatchSystem()}
- />
+ <div class="max-h-64 overflow-y-auto bg-surface">
+ <Show when={defaults().length > 0}>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Default</Dropdown.GroupLabel>
+ <For each={defaults()}>{(theme) => themeItem(theme)}</For>
+ </Dropdown.Group>
+ </Show>
+ <Show when={customs().length > 0}>
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>Custom</Dropdown.GroupLabel>
+ <For each={customs()}>{(theme) => themeItem(theme, true)}</For>
+ </Dropdown.Group>
+ </Show>
+ <Show when={defaults().length === 0 && customs().length === 0}>
+ <div class="px-3 py-4 text-center text-xs text-ink-muted">
+ No themes match “{filter()}”
+ </div>
+ </Show>
+ </div>
- <ThemePreferenceRow
- label="Default dark theme"
- value={darkModeTheme}
- options={darkThemes}
- onSelect={setDarkModeTheme}
- disabled={() => !themeShouldMatchSystem()}
- />
- </div>
- </div>
+ <Dropdown.Group>
+ <Dropdown.Item class="touch:min-h-10" onSelect={props.onNewTheme}>
+ <span class="flex items-center gap-2 text-ink-muted">
+ <PlusIcon class="size-4" />
+ New theme
+ </span>
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </Layer>
+ </Dropdown.Content>
+ </Dropdown>
);
}
export function Appearance() {
- const [activeTabA, setActiveTabA] = createSignal<PanelA>('basic');
- const [activeTabB, setActiveTabB] = createSignal<PanelB>('themes');
- const [showFilters, setShowFilters] = createSignal(false);
+ const [editorTab, setEditorTab] = createSignal<EditorTab>('basic');
+ const [editorOpen, setEditorOpen] = createSignal(false);
+ // The custom theme being edited (saving writes back to it); undefined for a
+ // brand-new theme.
+ const [editingThemeId, setEditingThemeId] = createSignal<string | undefined>(
+ undefined
+ );
+ // The editable name of the theme being edited.
+ const [themeName, setThemeName] = createSignal('New Theme');
+
+ const lightThemes = () =>
+ themes().filter((theme) => !isTokensDark(theme.tokens));
+ const darkThemes = () => themes().filter((theme) => isTokensDark(theme.tokens));
+
+ const chooseTheme = (id: string) => {
+ applyTheme(id);
+ setEditingThemeId(undefined);
+ setEditorOpen(false);
+ };
- // The top panel sizes to the active editor; Advanced needs a fixed, scrollable
- // height since its per-token list is taller than the panel.
- const rowA = () =>
- activeTabA() === 'advanced'
- ? isMobile()
- ? '322.5px'
- : '432.5px'
- : 'min-content';
- // On mobile the whole panel scrolls as one column, so the bottom panel sizes to
- // its content rather than filling (and being clipped by) a fixed viewport row.
- const rowB = () => (isMobile() ? 'min-content' : '1fr');
+ const startNewTheme = () => {
+ // Initialize the new theme from the current theme's variables (already live
+ // in the editor); mark it unsaved so the editor treats it as a new, nameable
+ // theme rather than the saved one it was copied from.
+ setEditingThemeId(undefined);
+ setIsThemeSaved(false);
+ setThemeName('New Theme');
+ setEditorTab('basic');
+ setEditorOpen(true);
+ };
+
+ // Edit an existing custom theme: apply it, then open the editor bound to its
+ // id so saving updates it in place.
+ const editTheme = (id: string) => {
+ applyTheme(id);
+ setEditingThemeId(id);
+ setThemeName(themes().find((t) => t.id === id)?.name ?? 'Theme');
+ setEditorTab('basic');
+ setEditorOpen(true);
+ };
+
+ const closeEditor = () => {
+ setEditorOpen(false);
+ setEditingThemeId(undefined);
+ };
+
+ // Save the live theme: update the bound custom theme in place, or create a
+ // new one (then keep editing it).
+ const saveCurrentTheme = () => {
+ const name = themeName().trim() || 'New Theme';
+ const editing = editingThemeId();
+ if (editing) {
+ updateTheme(editing, name);
+ } else {
+ saveTheme(name);
+ setEditingThemeId(currentThemeId());
+ }
+ toast.success('Theme saved');
+ };
+
+ const deleteThemeById = (theme: ThemeV2) => {
+ deleteTheme(theme.id);
+ // If the editor was open on the deleted theme, close it.
+ if (editingThemeId() === theme.id) closeEditor();
+ };
return (
- <div
- class={cn(
- 'h-full flex justify-center p-2',
- // Mobile: scroll the whole settings column. Desktop: fixed two-pane layout.
- isMobile() ? 'overflow-y-auto items-start' : 'overflow-hidden'
- )}
- >
- <div
- class={cn('max-w-200 w-full', !isMobile() && 'h-full')}
- style={{
- // Basic editor shrinks to fit its content; Advanced needs a fixed,
- // scrollable height since its per-token list is taller than the panel.
- 'grid-template-rows': `${rowA()} ${rowB()}`,
- 'grid-template-columns': '1fr',
- 'overflow': isMobile() ? 'visible' : 'hidden',
- 'display': 'grid',
- 'gap': '8px',
- }}
- >
- <Panel depth={2}>
- <Panel.Header>
- <TabsInset
- onChange={(value) => setActiveTabA(value as PanelA)}
- list={[
- { value: 'basic', label: 'Basic' },
- { value: 'advanced', label: 'Advanced' },
- ]}
- value={activeTabA()}
- defaultValue="basic"
- />
- <ThemeTools class="flex-1 min-w-0" />
- </Panel.Header>
+ // Soften any stray `b4` edge in the theme editor to the muted `b3` tone.
+ <div class="h-full" style={{ '--b4l': 'var(--b3l)' }}>
+ <SettingsPage title="Appearance">
+ <SettingsSection title="Color Theme">
+ <SettingsCard>
+ <SettingsRow
+ label="Interface theme"
+ description="The color theme used across the app."
+ >
+ <InterfaceThemeSelect
+ onPick={chooseTheme}
+ onEdit={editTheme}
+ onDelete={deleteThemeById}
+ onNewTheme={startNewTheme}
+ />
+ </SettingsRow>
- <Panel.Body scroll={activeTabA() === 'advanced'}>
- <Show when={activeTabA() === 'basic'}>
- <ThemeEditorBasic />
- </Show>
- <Show when={activeTabA() === 'advanced'}>
- <ThemeEditorAdvanced />
+ {/* The theme editor opens inline beneath "Interface theme" as a
+ distinct active-editing block: a neutral, slightly elevated
+ surface (one step lighter than the card via Layer depth), inset +
+ rounded so it reads as a nested element. No color-forward accent. */}
+ <Show when={editorOpen()}>
+ <Layer depth={3}>
+ <div class="mx-3 my-2 flex flex-col gap-3 rounded-xl border border-ink/[0.05] bg-surface px-4 py-4">
+ <div class="flex items-center gap-2">
+ <Button
+ label="Close editor"
+ onClick={closeEditor}
+ variant="ghost"
+ size="icon-sm"
+ >
+ <XIcon class="size-4" />
+ </Button>
+ <input
+ type="text"
+ value={themeName()}
+ onInput={(e) => setThemeName(e.currentTarget.value)}
+ spellcheck={false}
+ placeholder="Theme name"
+ aria-label="Theme name"
+ class="w-40 min-w-0 rounded-md border border-edge-muted bg-transparent px-2 py-1 text-xs text-ink outline-none placeholder:text-ink-extra-muted focus:border-accent"
+ />
+ <div class="flex-1" />
+ <Button
+ label="Randomize theme"
+ onPointerDown={randomizeTheme}
+ variant="ghost"
+ size="icon-sm"
+ >
+ <ShuffleIcon class="size-4" />
+ </Button>
+ <TabsInset
+ depth={3}
+ onChange={(value) => setEditorTab(value as EditorTab)}
+ list={[
+ { value: 'basic', label: 'Basic' },
+ { value: 'advanced', label: 'Variables' },
+ ]}
+ value={editorTab()}
+ defaultValue="basic"
+ />
+ </div>
+ <div class="relative overflow-hidden rounded-lg">
+ {/* The Basic view defines the box height; it stays mounted
+ (just hidden) on the Variables tab so the variables list
+ scrolls within that same height. Basic rows use dividers
+ only; the Variables list keeps a bordered container. */}
+ <div classList={{ invisible: editorTab() !== 'basic' }}>
+ <ThemeEditorBasic />
+ </div>
+ <Show when={editorTab() === 'advanced'}>
+ <div class="absolute inset-0 overflow-y-auto rounded-lg border border-ink/[0.05] bg-surface">
+ <ThemeEditorAdvanced />
+ </div>
+ </Show>
+ </div>
+ <div class="flex justify-end">
+ <Button variant="base" size="sm" onClick={saveCurrentTheme}>
+ Save theme
+ </Button>
+ </div>
+ </div>
+ </Layer>
</Show>
- </Panel.Body>
- </Panel>
- <Panel depth={2}>
- <Panel.Header>
- <TabsInset
- onChange={(value) => setActiveTabB(value as PanelB)}
- list={[
- { value: 'themes', label: 'Themes' },
- { value: 'ui', label: 'UI' },
- ]}
- value={activeTabB()}
- defaultValue="list"
- />
- <div class="flex-1" />
- <Show when={activeTabB() === 'themes'}>
- <Button
- label="Filter Themes"
- onPointerDown={() => setShowFilters((v) => !v)}
- variant={showFilters() ? 'cta' : 'ghost'}
- size="icon-sm"
- >
- <IconFunnel />
- </Button>
- </Show>
- <Button
- label="Randomize Theme"
- onPointerDown={randomizeTheme}
- variant="ghost"
- size="icon-sm"
- class="ml-1.5"
+ <SettingsRow
+ label="Auto-detect color scheme"
+ description="Switch theme with your system's light/dark mode."
>
- <IconDice />
- </Button>
- </Panel.Header>
- <Show when={activeTabB() === 'themes' && showFilters()}>
- <Panel.Toolbar class="gap-4 pl-5">
- <span class="text-xs text-ink-extra-muted">Filter themes</span>
- <button
- type="button"
- class="inline-flex items-center gap-1.5 text-xs text-ink-muted hover:text-ink touch:min-h-9 touch:pr-2"
- onClick={() => setShowLightThemes((v) => !v)}
- >
- <InlineCheckbox checked={showLightThemes()} />
- Light
- </button>
- <button
- type="button"
- class="inline-flex items-center gap-1.5 text-xs text-ink-muted hover:text-ink touch:min-h-9 touch:pr-2"
- onClick={() => setShowDarkThemes((v) => !v)}
- >
- <InlineCheckbox checked={showDarkThemes()} />
- Dark
- </button>
- </Panel.Toolbar>
- </Show>
- <Panel.Body scroll>
- <Show when={activeTabB() === 'themes'}>
- <ThemeList />
- </Show>
- <Show when={activeTabB() === 'ui'}>
- <UserInterface />
+ <ToggleSwitch
+ size="md"
+ onChange={setThemeShouldMatchSystem}
+ checked={themeShouldMatchSystem()}
+ />
+ </SettingsRow>
+
+ {/* Sub-settings collapse away while auto-detect is off. */}
+ <Show when={themeShouldMatchSystem()}>
+ <ThemePreferenceRow
+ label="Default light theme"
+ value={lightModeTheme}
+ options={lightThemes}
+ onSelect={setLightModeTheme}
+ />
+ <ThemePreferenceRow
+ label="Default dark theme"
+ value={darkModeTheme}
+ options={darkThemes}
+ onSelect={setDarkModeTheme}
+ />
</Show>
- </Panel.Body>
- </Panel>
- </div>
+ </SettingsCard>
+ </SettingsSection>
+
+ <SettingsSection title="Interface">
+ <SettingsCard>
+ <SettingsRow
+ label="Monochrome icons"
+ description="Use single-color icons across the app."
+ >
+ <ToggleSwitch
+ size="md"
+ onChange={setMonochromeIcons}
+ checked={monochromeIcons()}
+ />
+ </SettingsRow>
+ <SettingsRow
+ label="Show tooltips"
+ description="Show hover hints on buttons and controls."
+ >
+ <ToggleSwitch
+ size="md"
+ onChange={setTooltipsEnabled}
+ checked={tooltipsEnabled()}
+ />
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
+ </SettingsPage>
</div>
);
}
diff --git a/js/app/packages/app/component/settings/Billing.tsx b/js/app/packages/app/component/settings/Billing.tsx
index afdcda4df3..7e00dd4d0a 100644
--- a/js/app/packages/app/component/settings/Billing.tsx
+++ b/js/app/packages/app/component/settings/Billing.tsx
@@ -4,12 +4,13 @@ import { useHasPaidAccess } from '@core/auth';
import CheckIcon from '@phosphor/check.svg';
import ArrowSquareOutIcon from '@phosphor/arrow-square-out.svg';
import { stripeServiceClient } from '@service-stripe/client';
-import { Button, Layer, Surface } from '@ui';
+import { Button, Layer } from '@ui';
import { createMemo, For, Match, Show, Switch } from 'solid-js';
import { usePermissions, useUserId } from '@core/context/user';
import { PERMISSION_IDS } from '@core/constant/permissions';
import { useCurrentTeamQuery } from '@queries/team/teams';
import { plural } from '@core/util/string';
+import { SettingsCard, SettingsPage, SettingsSection } from './primitives';
const BILLING_PLAN_FEATURES: Record<PlanTier, string[]> = {
free: ['Access to Haiku', '5 GB storage'],
@@ -89,10 +90,10 @@ export const Billing = () => {
};
return (
- <section class="p-8 flex flex-col gap-8">
- <header class="flex flex-col">
- <h1 class="text-2xl text-ink font-semibold">Billing</h1>
- <p class="text-ink-extra-muted text-sm">
+ <SettingsPage
+ title="Billing"
+ description={
+ <>
For questions about billing,{' '}
<a
class="text-ink inline-flex items-center hover:text-accent"
@@ -103,68 +104,71 @@ export const Billing = () => {
contact us
<ArrowSquareOutIcon class="size-4 inline mx-1" />
</a>
- </p>
- </header>
-
- <Surface class="flex flex-col rounded-lg p-4" depth={2}>
- <section class="flex flex-col gap-4">
- <header class="flex items-center gap-2">
- <div class="flex flex-col gap-1">
- <div class="flex items-center gap-2">
- <h1 class="text-lg font-medium text-ink">
- <Show when={!hasPaid()} fallback={'Premium plan'}>
- Free plan
- </Show>
- </h1>
-
- <Layer depth={3}>
- <span class="text-xs text-ink-muted px-1.5 py-0.25 border border-edge-muted rounded-md bg-active">
- Current
- </span>
- </Layer>
- </div>
- <Switch>
- <Match when={teamRole() === 'member'}>
- <p class="text-ink-extra-muted text-xs">
- Your subscription is managed by your team owner. Contact
- them to make changes.
- </p>
- </Match>
- <Match when={hasPaid() && teamRole() === 'owner' && team.data}>
- {(team) => (
+ </>
+ }
+ >
+ <SettingsSection>
+ <SettingsCard>
+ <section class="flex flex-col gap-4 p-4">
+ <header class="flex items-center gap-2">
+ <div class="flex flex-col gap-1">
+ <div class="flex items-center gap-2">
+ <h2 class="text-lg font-medium text-ink">
+ <Show when={!hasPaid()} fallback={'Premium plan'}>
+ Free plan
+ </Show>
+ </h2>
+
+ <Layer depth={3}>
+ <span class="text-xs text-ink-muted px-1.5 py-0.25 border border-edge-muted rounded-md bg-active">
+ Current
+ </span>
+ </Layer>
+ </div>
+ <Switch>
+ <Match when={teamRole() === 'member'}>
<p class="text-ink-extra-muted text-xs">
- {team().members.length}{' '}
- {plural('user', team().members.length)} • $40 per seat/per
- month
+ Your subscription is managed by your team owner. Contact
+ them to make changes.
</p>
- )}
- </Match>
- </Switch>
- </div>
-
- <Show
- when={
- canManageSubscription() &&
- hasPaid() &&
- (!teamRole() || teamRole() === 'owner')
- }
- >
- <Button
- class="ml-auto rounded-full bg-active"
- size="sm"
- depth={2}
- variant="base"
- onClick={handleManage}
+ </Match>
+ <Match when={hasPaid() && teamRole() === 'owner' && team.data}>
+ {(team) => (
+ <p class="text-ink-extra-muted text-xs">
+ {team().members.length}{' '}
+ {plural('user', team().members.length)} • $40 per
+ seat/per month
+ </p>
+ )}
+ </Match>
+ </Switch>
+ </div>
+
+ <Show
+ when={
+ canManageSubscription() &&
+ hasPaid() &&
+ (!teamRole() || teamRole() === 'owner')
+ }
>
- Manage
- </Button>
- </Show>
- </header>
- <ul class="border-t border-t-edge-muted pt-4 flex flex-wrap gap-4 text-sm text-ink-muted">
- <PlanFeatures tier={hasPaid() ? 'premium' : 'free'} />
- </ul>
- </section>
- </Surface>
+ <Button
+ class="ml-auto rounded-full bg-active"
+ size="sm"
+ depth={2}
+ variant="base"
+ onClick={handleManage}
+ >
+ Manage
+ </Button>
+ </Show>
+ </header>
+ <ul class="border-t border-t-edge-muted pt-4 flex flex-wrap gap-4 text-sm text-ink-muted">
+ <PlanFeatures tier={hasPaid() ? 'premium' : 'free'} />
+ </ul>
+ </section>
+ </SettingsCard>
+ </SettingsSection>
+
<Show
when={
!hasPaid() &&
@@ -172,29 +176,33 @@ export const Billing = () => {
(!teamRole() || teamRole() === 'owner')
}
>
- <Surface class="flex flex-col rounded-lg p-4" depth={2}>
- <section class="flex flex-col gap-4">
- <header class="flex items-center gap-2">
- <div class="flex flex-col">
- <h1 class="text-lg font-medium text-ink">Premium</h1>
- <p class="text-ink-extra-muted text-xs">$40 per seat / month</p>
- </div>
-
- <Button
- class="ml-auto rounded-full py-1.5 px-3"
- depth={2}
- variant="cta"
- onClick={handleCheckout}
- >
- Upgrade now
- </Button>
- </header>
- <ul class="border-t border-t-edge-muted pt-4 flex flex-wrap gap-4 text-sm text-ink-muted">
- <PlanFeatures tier="premium" />
- </ul>
- </section>
- </Surface>
+ <SettingsSection>
+ <SettingsCard>
+ <section class="flex flex-col gap-4 p-4">
+ <header class="flex items-center gap-2">
+ <div class="flex flex-col">
+ <h2 class="text-lg font-medium text-ink">Premium</h2>
+ <p class="text-ink-extra-muted text-xs">
+ $40 per seat / month
+ </p>
+ </div>
+
+ <Button
+ class="ml-auto rounded-full py-1.5 px-3"
+ depth={2}
+ variant="cta"
+ onClick={handleCheckout}
+ >
+ Upgrade now
+ </Button>
+ </header>
+ <ul class="border-t border-t-edge-muted pt-4 flex flex-wrap gap-4 text-sm text-ink-muted">
+ <PlanFeatures tier="premium" />
+ </ul>
+ </section>
+ </SettingsCard>
+ </SettingsSection>
</Show>
- </section>
+ </SettingsPage>
);
};
diff --git a/js/app/packages/app/component/settings/ConnectedAccounts.tsx b/js/app/packages/app/component/settings/ConnectedAccounts.tsx
new file mode 100644
index 0000000000..f25cbf60fa
--- /dev/null
+++ b/js/app/packages/app/component/settings/ConnectedAccounts.tsx
@@ -0,0 +1,31 @@
+import { Show, Suspense } from 'solid-js';
+import { ENABLE_EMAIL } from '@core/constant/featureFlags';
+import { SettingsPage, SettingsSection } from './primitives';
+import { EmailCard } from './Email';
+import { GitHubCard } from './GitHub';
+
+/**
+ * Consolidated "Connected accounts" page: one card per external service the
+ * user can link (Gmail, GitHub). Replaces the separate Email / GitHub tabs.
+ */
+export function ConnectedAccounts() {
+ return (
+ <SettingsPage
+ title="Connected accounts"
+ description="Connect your accounts so Macro can work across the tools you already use."
+ >
+ <SettingsSection>
+ <div class="flex flex-col gap-3">
+ <Show when={ENABLE_EMAIL}>
+ <Suspense>
+ <EmailCard />
+ </Suspense>
+ </Show>
+ <Suspense>
+ <GitHubCard />
+ </Suspense>
+ </div>
+ </SettingsSection>
+ </SettingsPage>
+ );
+}
diff --git a/js/app/packages/app/component/settings/Email.tsx b/js/app/packages/app/component/settings/Email.tsx
index b46708f746..aab1fb0134 100644
--- a/js/app/packages/app/component/settings/Email.tsx
+++ b/js/app/packages/app/component/settings/Email.tsx
@@ -7,7 +7,7 @@ import {
ENABLE_INBOX_SYNC_STATUS,
ENABLE_MULTI_INBOX_OVERRIDE,
} from '@core/constant/featureFlags';
-import WideEmailIcon from '@icon/wide-email.svg';
+import GmailIcon from '@icon/mcp-gmail.svg';
import XIcon from '@phosphor-icons/core/regular/x.svg?component-solid';
import ArrowsClockwiseIcon from '@phosphor-icons/core/regular/arrows-clockwise.svg?component-solid';
import PlusIcon from '@phosphor-icons/core/regular/plus.svg?component-solid';
@@ -36,13 +36,16 @@ import {
useAddInboxGate,
} from '../AddInboxDialog';
import { useRemoveInboxMutation } from '@queries/email/link';
-import {
- ConnectionHero,
- IntegrationPanelShell,
- StatusPill,
-} from './integration-ui';
+import { IntegrationRow, SettingsCard, SettingsRow } from './primitives';
+import { ConnectAction, StatusDot } from './integration-ui';
-export function Email() {
+/**
+ * Gmail integration as a single Connected-accounts card: a header row with the
+ * connection state/action, and — once connected — a row per inbox plus add /
+ * disconnect controls. All the inbox + backfill logic is unchanged; only the
+ * surrounding chrome moved from a standalone panel to a shared card.
+ */
+export function EmailCard() {
const email = useEmail();
const userId = useUserId();
const multiInboxFlag = useFeatureFlag('enable-multi-inbox', {
@@ -50,11 +53,7 @@ export function Email() {
});
const guardAddInbox = useAddInboxGate();
- const {
- query: emailLinksQuery,
- disconnect: disconnectEmail,
- resyncInbox,
- } = useEmailLinks();
+ const { query: emailLinksQuery, resyncInbox } = useEmailLinks();
const emailActive = useEmailLinksStatus();
const startAddInbox = useAddInboxFlow();
@@ -89,7 +88,6 @@ export function Email() {
const [resyncingIds, setResyncingIds] = createSignal<ReadonlySet<string>>(
new Set()
);
- const [showDisableDialog, setShowDisableDialog] = createSignal(false);
const [isEmailActionPending, setIsEmailActionPending] = createSignal(false);
// The primary inbox is the user's own is_primary link; it sorts to the top
@@ -104,11 +102,6 @@ export function Email() {
return { primary, others };
});
- const hasAdditionalInboxes = createMemo(() => inboxes().others.length > 0);
- const hasConnectedInboxes = createMemo(
- () => inboxes().primary != null || inboxes().others.length > 0
- );
-
const onConnectEmail = async () => {
if (isEmailActionPending()) return;
setIsEmailActionPending(true);
@@ -119,19 +112,6 @@ export function Email() {
}
};
- const onDisconnectEmail = async () => {
- if (isEmailActionPending()) return;
- setIsEmailActionPending(true);
- await disconnectEmail().match(
- () => {
- setShowDisableDialog(false);
- toast.success('Email disabled — clearing your data.');
- },
- () => toast.failure('Failed to disable email. Please try again.')
- );
- setIsEmailActionPending(false);
- };
-
const handleResyncInbox = async (linkId: string) => {
setResyncingIds((prev) => new Set(prev).add(linkId));
await resyncInbox(linkId).match(
@@ -159,155 +139,94 @@ export function Email() {
};
return (
- <IntegrationPanelShell title="Email">
- <Show
- when={multiInboxFlag().enabled || hasAdditionalInboxes()}
- fallback={
- <ConnectionHero
- icon={WideEmailIcon}
- title="Email"
- description="Connect your Gmail account so Macro can read, organize, and act on your email."
- status={
- <StatusPill
- state={emailActive() ? 'connected' : 'disconnected'}
- label={emailActive() ? 'Connected' : 'Not connected'}
- />
- }
- >
- <Show
- when={emailActive()}
- fallback={
- <Button
- variant="cta"
- size="md"
- depth={3}
- disabled={isEmailActionPending()}
- onClick={onConnectEmail}
- >
- Connect Gmail
- </Button>
- }
- >
- <Button
- variant="base"
- size="md"
- depth={3}
- disabled={isEmailActionPending()}
- onClick={() => setShowDisableDialog(true)}
- >
- Disconnect
- </Button>
+ <>
+ <SettingsCard>
+ <IntegrationRow
+ icon={<GmailIcon />}
+ title="Gmail"
+ description="Read, organize, and act on your email."
+ status={
+ <Show when={emailActive()}>
+ <StatusDot state="connected" label="Connected" />
</Show>
- </ConnectionHero>
- }
- >
- <Show
- when={emailActive()}
- fallback={
- <ConnectionHero
- icon={WideEmailIcon}
- title="Email"
- description="Connect your Gmail accounts so Macro can read, organize, and act on your email."
- status={<StatusPill state="disconnected" label="Not connected" />}
- >
- <Button
- variant="cta"
- size="md"
- depth={3}
- disabled={isEmailActionPending()}
- onClick={onConnectEmail}
- >
- Connect Gmail
- </Button>
- </ConnectionHero>
}
>
- <Show when={!hasConnectedInboxes()}>
- <div class="px-6 py-8 flex items-center gap-4 border-b border-edge-muted">
- <div class="flex size-11 items-center justify-center rounded-xl bg-edge-muted shrink-0">
- <WideEmailIcon class="size-5 text-ink" />
- </div>
- <div class="flex flex-1 flex-col gap-1 min-w-0">
- <div class="text-base font-semibold text-ink">
- Connected inboxes
- </div>
- <p class="text-sm text-ink-muted">
- Gmail accounts Macro can read and act on.
- </p>
- </div>
- </div>
+ <Show when={!emailActive()}>
+ <ConnectAction
+ label="Connect"
+ onClick={onConnectEmail}
+ disabled={isEmailActionPending()}
+ />
</Show>
+ </IntegrationRow>
- <div class="grid settings-row-dividers">
- <Show when={inboxes().primary}>
- {(primary) => (
- <InboxRow
- link={primary()}
- isPrimary
- isOwn={primary().macro_id === userId()}
- hasCompletedBackfill={hasCompletedBackfill(primary().id)}
- resyncing={resyncingIds().has(primary().id)}
- onResync={() => handleResyncInbox(primary().id)}
- onReconnect={() => void startAddInbox()}
- onRemove={() =>
- setRemoveTarget({
- id: primary().id,
- email: primary().email_address,
- isOwn: primary().macro_id === userId(),
- })
- }
- />
- )}
- </Show>
- <Show when={!inboxes().primary && email()}>
- <DisabledPrimaryRow
- email={email() ?? ''}
- onEnable={onConnectEmail}
+ <Show when={emailActive()}>
+ <Show when={inboxes().primary}>
+ {(primary) => (
+ <InboxRow
+ link={primary()}
+ isPrimary
+ isOwn={primary().macro_id === userId()}
+ hasCompletedBackfill={hasCompletedBackfill(primary().id)}
+ resyncing={resyncingIds().has(primary().id)}
+ onResync={() => handleResyncInbox(primary().id)}
+ onReconnect={() => void startAddInbox()}
+ onRemove={() =>
+ setRemoveTarget({
+ id: primary().id,
+ email: primary().email_address,
+ isOwn: primary().macro_id === userId(),
+ })
+ }
/>
- </Show>
- <For each={inboxes().others}>
- {(link) => (
- <InboxRow
- link={link}
- isPrimary={false}
- isOwn={link.macro_id === userId()}
- hasCompletedBackfill={hasCompletedBackfill(link.id)}
- resyncing={resyncingIds().has(link.id)}
- onResync={() => handleResyncInbox(link.id)}
- onReconnect={() => void startAddInbox()}
- onRemove={() =>
- setRemoveTarget({
- id: link.id,
- email: link.email_address,
- isOwn: link.macro_id === userId(),
- })
- }
- />
- )}
- </For>
- <Show when={multiInboxFlag().enabled}>
- <div class="px-6 py-4 flex justify-center">
- <Show
- when={!emailLinksQuery.isLoading}
- fallback={
- <span class="text-sm text-ink-muted">Loading…</span>
- }
+ )}
+ </Show>
+ <Show when={!inboxes().primary && email()}>
+ <DisabledPrimaryRow
+ email={email() ?? ''}
+ onEnable={onConnectEmail}
+ />
+ </Show>
+ <For each={inboxes().others}>
+ {(link) => (
+ <InboxRow
+ link={link}
+ isPrimary={false}
+ isOwn={link.macro_id === userId()}
+ hasCompletedBackfill={hasCompletedBackfill(link.id)}
+ resyncing={resyncingIds().has(link.id)}
+ onResync={() => handleResyncInbox(link.id)}
+ onReconnect={() => void startAddInbox()}
+ onRemove={() =>
+ setRemoveTarget({
+ id: link.id,
+ email: link.email_address,
+ isOwn: link.macro_id === userId(),
+ })
+ }
+ />
+ )}
+ </For>
+ <Show when={multiInboxFlag().enabled}>
+ <SettingsRow
+ label="Add another inbox"
+ description="Connect more Gmail accounts."
+ >
+ <Tooltip label="Add inbox">
+ <Button
+ variant="base"
+ size="icon-sm"
+ depth={3}
+ aria-label="Add inbox"
+ onClick={() => guardAddInbox(openAddInboxDialog)}
>
- <Button
- variant="active"
- size="sm"
- depth={3}
- onClick={() => guardAddInbox(openAddInboxDialog)}
- >
- <PlusIcon class="size-4" />
- Add inbox
- </Button>
- </Show>
- </div>
- </Show>
- </div>
+ <PlusIcon class="size-4" />
+ </Button>
+ </Tooltip>
+ </SettingsRow>
+ </Show>
</Show>
- </Show>
+ </SettingsCard>
<AddInboxDialog />
@@ -357,46 +276,7 @@ export function Email() {
</Panel.Body>
</Panel>
</Dialog>
-
- <Dialog
- open={showDisableDialog()}
- onOpenChange={setShowDisableDialog}
- position="center"
- class="w-120"
- >
- <Panel active depth={2} class="rounded-xl">
- <Panel.Header class="px-6">
- <Dialog.Title class="text-ink text-sm font-semibold">
- Disconnect email
- </Dialog.Title>
- </Panel.Header>
- <Panel.Body class="p-6 font-sans flex flex-col gap-3">
- <Dialog.Description class="text-ink-muted text-sm/tight font-normal">
- Disconnecting will clear all email data from Macro. This cannot be
- undone.
- </Dialog.Description>
- <div class="pt-3 justify-end items-center gap-3 inline-flex">
- <Button
- variant="base"
- depth={3}
- disabled={isEmailActionPending()}
- onClick={() => setShowDisableDialog(false)}
- >
- Cancel
- </Button>
- <Button
- variant="danger"
- depth={3}
- disabled={isEmailActionPending()}
- onClick={onDisconnectEmail}
- >
- Disconnect
- </Button>
- </div>
- </Panel.Body>
- </Panel>
- </Dialog>
- </IntegrationPanelShell>
+ </>
);
}
@@ -574,7 +454,7 @@ function InboxRow(props: {
<Tooltip label="Force sync">
<Button
variant="base"
- size="sm"
+ size="icon-sm"
depth={3}
disabled={
props.resyncing ||
@@ -591,7 +471,7 @@ function InboxRow(props: {
<Tooltip label="Remove inbox">
<Button
variant="base"
- size="sm"
+ size="icon-sm"
depth={3}
onClick={props.onRemove}
aria-label={`Remove ${props.link.email_address}`}
diff --git a/js/app/packages/app/component/settings/GitHub.tsx b/js/app/packages/app/component/settings/GitHub.tsx
index 806f58761d..f48145de87 100644
--- a/js/app/packages/app/component/settings/GitHub.tsx
+++ b/js/app/packages/app/component/settings/GitHub.tsx
@@ -6,23 +6,29 @@ import {
useInitGithubLinkMutation,
useReauthenticateGithubMutation,
} from '@queries/auth';
-import { Show } from 'solid-js';
-import { match } from 'ts-pattern';
-import { Button } from '@ui';
-import {
- ConnectionHero,
- type ConnectionState,
- IntegrationPanelShell,
- StatusPill,
-} from './integration-ui';
+import { Match, Show, Switch } from 'solid-js';
+import { IntegrationRow, SettingsCard } from './primitives';
+import { ConnectAction, type ConnectionState, StatusDot } from './integration-ui';
-export function GitHub() {
+/** GitHub integration as a Connected-accounts card. */
+export function GitHubCard() {
const githubLink = useGithubLinkStatusQuery();
const initGithubLink = useInitGithubLinkMutation();
const deleteGithubLink = useDeleteGithubLinkMutation();
const reauthenticateGithub = useReauthenticateGithubMutation();
const status = () => githubLink.data?.status;
+ const username = () => githubLink.data?.username;
+
+ // Drives the connection dot shown beside the "GitHub" title.
+ const connectionState = (): ConnectionState | undefined =>
+ status() === 'linked'
+ ? 'connected'
+ : status() === 'reauthentication_required'
+ ? 'attention'
+ : undefined;
+ const connectionLabel = () =>
+ connectionState() === 'attention' ? 'Reconnect required' : 'Connected';
const handleGithubEnable = async () => {
try {
@@ -52,84 +58,56 @@ export function GitHub() {
}
};
- const pill = (): { state: ConnectionState; label: string } =>
- match(status())
- .with('linked', () => ({ state: 'connected', label: 'Connected' }) as const)
- .with(
- 'reauthentication_required',
- () => ({ state: 'attention', label: 'Reconnect required' }) as const
- )
- .otherwise(
- () => ({ state: 'disconnected', label: 'Not connected' }) as const
- );
-
return (
- <IntegrationPanelShell title="GitHub">
- <Show
- when={!githubLink.isLoading}
- fallback={
- <div class="flex items-center justify-center pt-24 text-sm text-ink-muted">
- Loading…
- </div>
+ <SettingsCard>
+ <IntegrationRow
+ icon={<GithubIcon />}
+ title="GitHub"
+ description="Surface pull requests and issues alongside your work."
+ status={
+ <Show when={connectionState()}>
+ {(state) => <StatusDot state={state()} label={connectionLabel()} />}
+ </Show>
}
>
- <ConnectionHero
- icon={GithubIcon}
- title="GitHub"
- description="Connect your GitHub account so Macro can surface pull requests and issues alongside your work."
+ <Show
+ when={!githubLink.isLoading}
+ fallback={<span class="text-xs text-ink-muted">Loading…</span>}
>
- <div class="flex flex-col items-center gap-2">
- <div class="flex items-center gap-3">
- <StatusPill state={pill().state} label={pill().label} />
- <Show when={status() === 'reauthentication_required'}>
- <Button
- variant="cta"
- size="sm"
- depth={3}
- onClick={handleGithubReconnect}
- disabled={reauthenticateGithub.isPending}
- >
- Reconnect
- </Button>
- </Show>
- <Show when={status() === 'linked'}>
- <Button
- variant="base"
- size="sm"
- depth={3}
- onClick={handleGithubDisable}
- disabled={deleteGithubLink.isPending}
- >
- Disconnect
- </Button>
- </Show>
- <Show
- when={
- status() !== 'linked' &&
- status() !== 'reauthentication_required'
- }
- >
- <Button
- variant="cta"
- size="sm"
- depth={3}
- onClick={handleGithubEnable}
- disabled={initGithubLink.isPending}
- >
- Connect GitHub
- </Button>
+ <Switch
+ fallback={
+ <ConnectAction
+ label="Connect"
+ onClick={handleGithubEnable}
+ disabled={initGithubLink.isPending}
+ />
+ }
+ >
+ <Match when={status() === 'linked'}>
+ <Show when={username()}>
+ {(name) => (
+ <span class="ph-no-capture text-xs text-ink-muted">
+ @{name()}
+ </span>
+ )}
</Show>
- </div>
- <Show when={status() === 'linked' && githubLink.data?.username}>
- {(username) => (
- <span class="ph-no-capture text-sm text-ink">
- @{username()}
- </span>
- )}
- </Show>
- </div>
- </ConnectionHero>
- </Show>
- </IntegrationPanelShell>
+ <ConnectAction
+ label="Disconnect"
+ variant="danger"
+ onClick={handleGithubDisable}
+ disabled={deleteGithubLink.isPending}
+ />
+ </Match>
+ <Match when={status() === 'reauthentication_required'}>
+ <ConnectAction
+ label="Reconnect"
+ onClick={handleGithubReconnect}
+ disabled={reauthenticateGithub.isPending}
+ />
+ </Match>
+ </Switch>
+ </Show>
+ </IntegrationRow>
+ </SettingsCard>
);
}
diff --git a/js/app/packages/app/component/settings/MobileApp.tsx b/js/app/packages/app/component/settings/MobileApp.tsx
index 57b18777f7..66650bacb6 100644
--- a/js/app/packages/app/component/settings/MobileApp.tsx
+++ b/js/app/packages/app/component/settings/MobileApp.tsx
@@ -1,32 +1,29 @@
import AppStoreQr from '@design/app-store.svg';
-import { Panel } from '@ui';
+import { SettingsCard, SettingsPage } from './primitives';
export function MobileApp() {
return (
- <div
- class="h-full overflow-hidden flex justify-center p-2"
+ <SettingsPage
+ title="Mobile app"
+ description="Scan the code to get Macro on your phone."
>
- <div class="max-w-200 size-full">
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <Panel.Header class="px-6">
- <div class="text-sm font-semibold">Mobile App</div>
- </Panel.Header>
- <Panel.Body class="flex flex-col items-center justify-center gap-6 py-8">
- <AppStoreQr style="display: block; max-width: 300px;" />
- <p class="text-sm text-ink text-center">
- Download on the<br/>
- <a
- href="https://apps.apple.com/us/app/macro-app/id6743133649"
- rel="noopener noreferrer"
- class="underline"
- target="_blank"
- >
- App Store
- </a>
- </p>
- </Panel.Body>
- </Panel>
- </div>
- </div>
+ <SettingsCard>
+ <div class="flex flex-col items-center justify-center gap-6 py-12">
+ <AppStoreQr style="display: block; max-width: 280px;" />
+ <p class="text-sm text-ink text-center">
+ Download on the
+ <br />
+ <a
+ href="https://apps.apple.com/us/app/macro-app/id6743133649"
+ rel="noopener noreferrer"
+ class="text-accent hover:underline"
+ target="_blank"
+ >
+ App Store
+ </a>
+ </p>
+ </div>
+ </SettingsCard>
+ </SettingsPage>
);
}
diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsx
index 885c0c1819..af668ae080 100644
--- a/js/app/packages/app/component/settings/Settings.tsx
+++ b/js/app/packages/app/component/settings/Settings.tsx
@@ -1,4 +1,11 @@
-import { For, onMount, Show, Suspense } from 'solid-js';
+import {
+ createSignal,
+ For,
+ onCleanup,
+ onMount,
+ Show,
+ Suspense,
+} from 'solid-js';
import { type SettingsTab, useSettingsState } from '@core/constant/SettingsState';
import { useSettingsTabs } from '@core/constant/settingsTabsConfig';
import { useLogout } from '@core/auth/logout';
@@ -8,8 +15,7 @@ import { Agent } from './Agent';
import { Admin } from './Admin';
import { Appearance } from './Appearance';
import { Account } from './Account';
-import { Email } from './Email';
-import { GitHub } from './GitHub';
+import { ConnectedAccounts } from './ConnectedAccounts';
import { Shortcuts } from './Shortcuts';
import { Team } from './Team';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
@@ -17,10 +23,11 @@ import type { ValidHotkey } from '@core/hotkey/types';
import { FloatRegion } from '../mobile/float-regions/FloatRegion';
import { PillTabs } from '../mobile/PillTabs';
import { HeaderIsland } from '../split-layout/components/HeaderIsland';
-import { Button, SideNav } from '@ui';
-import ColumnsPlusRight from '@phosphor/columns-plus-right.svg';
+import { TabsInsetDropdown } from '@core/component/TabsInsetDropdown';
+import { Button, cn, Layer, SideNav } from '@ui';
+import ArrowsIn from '@phosphor/arrows-in.svg';
import ArrowsOut from '@phosphor/arrows-out.svg';
-import CloseIcon from '@phosphor/x.svg';
+import CaretLeftIcon from '@phosphor/caret-left.svg';
import SignOutIcon from '@phosphor/sign-out.svg';
import {
SplitHeaderLeft,
@@ -31,6 +38,13 @@ import { Billing } from '@app/component/settings/Billing';
/** Where the settings panel is mounted, which determines its header chrome. */
export type SettingsVariant = 'split' | 'modal';
+// Panel-width breakpoints (the panel can be a full-screen modal or a resizable
+// split, so we measure the panel itself rather than the viewport). Below
+// `COMPACT` the sidebar collapses into a horizontal tab bar; between `COMPACT`
+// and `NARROW` the gutter around the content card tightens.
+const COMPACT_WIDTH = 660;
+const NARROW_WIDTH = 820;
+
export function SettingsPanelComponentWrapper() {
return (
<SettingsPanel />
@@ -46,7 +60,6 @@ type SettingsPanelProps = {
export function SettingsPanel(props: SettingsPanelProps) {
const {
closeSettings,
- closeModal,
moveSettingsToSplit,
moveSettingsToModal,
activeTabId,
@@ -62,17 +75,28 @@ export function SettingsPanel(props: SettingsPanelProps) {
const isCurrentTab = (tab: SettingsTab) =>
activeTabId() === tab && isAvailable(tab);
+ // Responsive state, driven by the panel's own width (see breakpoints above).
+ const [panelWidth, setPanelWidth] = createSignal(Number.POSITIVE_INFINITY);
+ const compact = () => !isMobile() && panelWidth() < COMPACT_WIDTH;
+ const narrow = () => !isMobile() && panelWidth() < NARROW_WIDTH;
+
// Set up hotkey scope for settings panel
const [attachHotkeys, settingsHotkeyScope] = useHotkeyDOMScope('settings');
let settingsContainerRef: HTMLDivElement | undefined;
+ let resizeObserver: ResizeObserver | undefined;
- // Attach hotkeys to the settings container
onMount(() => {
- if (settingsContainerRef) {
- attachHotkeys(settingsContainerRef);
- }
+ if (!settingsContainerRef) return;
+ attachHotkeys(settingsContainerRef);
+ resizeObserver = new ResizeObserver((entries) => {
+ const width = entries[0]?.contentRect.width;
+ if (width) setPanelWidth(width);
+ });
+ resizeObserver.observe(settingsContainerRef);
});
+ onCleanup(() => resizeObserver?.disconnect());
+
function handleEscapeKey() {
closeSettings();
return true;
@@ -152,7 +176,11 @@ export function SettingsPanel(props: SettingsPanelProps) {
if (flatTabs().some((tab) => tab.tab === value)) {
setActiveTabId(value as SettingsTab);
}
- }
+ };
+
+ // Tab list for the compact segmented control / dropdown.
+ const tabItems = () =>
+ flatTabs().map((tab) => ({ value: tab.tab, label: tab.label }));
function BottomTabs() {
return (
@@ -168,6 +196,28 @@ export function SettingsPanel(props: SettingsPanelProps) {
);
}
+ // "Back to app" — the modal's only close affordance. Laid out like a nav row.
+ const backToApp = () => (
+ <button
+ type="button"
+ onClick={() => closeSettings()}
+ class="flex items-center gap-2 px-2 py-1.5 rounded-md text-xs text-ink-extra-muted cursor-default hover:bg-ink/4 hover:text-ink-muted"
+ >
+ <CaretLeftIcon class="size-4 shrink-0" />
+ <span class="whitespace-nowrap">Back to app</span>
+ </button>
+ );
+
+ const moveToSplitButton = () => (
+ <Button
+ class="p-1 rounded-md"
+ label="Move to split"
+ onClick={() => moveSettingsToSplit()}
+ >
+ <ArrowsIn class="size-4" />
+ </Button>
+ );
+
return (
<div
class="size-full flex flex-col outline-none"
@@ -185,6 +235,19 @@ export function SettingsPanel(props: SettingsPanelProps) {
</h1>
</div>
</HeaderIsland>
+ {/* When the sidebar collapses, tab selection moves into the split's
+ top bar as a dropdown of the current tab. (Rendered directly
+ rather than via CollapsibleHeaderItem so the wide segmented
+ control never flashes before measuring.) */}
+ <Show when={compact()}>
+ <div class="mx-2 shrink-0">
+ <TabsInsetDropdown
+ list={tabItems()}
+ value={activeTabId()}
+ onChange={handleTabChange}
+ />
+ </div>
+ </Show>
</SplitHeaderLeft>
{/* Pop the split back out into the modal (desktop only). */}
<Show when={!isMobile()}>
@@ -200,34 +263,23 @@ export function SettingsPanel(props: SettingsPanelProps) {
</Show>
</Show>
- {/* The modal has no split header to portal into, so it renders its own. */}
- <Show when={variant() === 'modal'}>
- <div class="flex items-center justify-between h-11 shrink-0 px-2 border-b border-edge-muted">
- <h1 class="font-semibold text-ink select-none text-sm pl-1">
- Settings
- </h1>
- <div class="flex items-center gap-0.5">
- <Button
- class="p-1 rounded-lg"
- label="Open in split"
- onClick={() => moveSettingsToSplit()}
- >
- <ColumnsPlusRight class="size-4" />
- </Button>
- <Button
- class="p-1 rounded-lg"
- label="Close settings"
- onClick={() => closeModal()}
- >
- <CloseIcon class="size-4" />
- </Button>
- </div>
- </div>
- </Show>
-
<div class="flex grow min-h-1 overflow-hidden">
- <Show when={!isMobile()}>
- <SideNav class="w-[clamp(168px,22%,220px)]">
+ {/* Inline sidebar — hidden once the panel gets too narrow. */}
+ <Show when={!isMobile() && !compact()}>
+ <SideNav
+ class={cn(
+ 'w-[clamp(208px,20%,248px)] gap-3',
+ narrow() ? 'pr-1' : 'pr-2'
+ )}
+ >
+ {/* The full-screen modal has no surrounding chrome, so the sidebar
+ carries the "back" and "move to split" affordances itself. */}
+ <Show when={variant() === 'modal'}>
+ <div class="flex items-center justify-between gap-1">
+ {backToApp()}
+ {moveToSplitButton()}
+ </div>
+ </Show>
<For each={groups()}>
{(group) => (
<SideNav.Group label={group.label}>
@@ -237,6 +289,7 @@ export function SettingsPanel(props: SettingsPanelProps) {
icon={item.icon}
active={activeTabId() === item.tab}
onSelect={() => handleTabChange(item.tab)}
+ class="text-xs py-1.5"
>
{item.label}
</SideNav.Item>
@@ -249,7 +302,7 @@ export function SettingsPanel(props: SettingsPanelProps) {
<button
type="button"
onClick={() => logout()}
- class="flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-ink-extra-muted cursor-default hover:bg-ink/3 hover:text-ink"
+ class="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-ink-extra-muted cursor-default hover:bg-ink/3 hover:text-ink"
>
<SignOutIcon class="size-4 shrink-0" />
<span class="whitespace-nowrap">Log out</span>
@@ -258,47 +311,75 @@ export function SettingsPanel(props: SettingsPanelProps) {
</SideNav>
</Show>
- <div class="relative grow min-h-1 min-w-0 overflow-auto mobile:pt-(--mobile-content-inset-top) mobile:pb-(--mobile-content-inset-bottom)">
- <Show when={isCurrentTab('Account')}>
- <Suspense>
- <Account />
- </Suspense>
- </Show>
- <Show when={isCurrentTab('Billing')}>
- <Suspense>
- <Billing />
- </Suspense>
- </Show>
- <Show when={isCurrentTab('Appearance')}>
- <Appearance />
- </Show>
- <Show when={isCurrentTab('Shortcuts')}>
- <Shortcuts />
- </Show>
- <Show when={isCurrentTab('Team')}>
- <Suspense>
- <Team />
- </Suspense>
- </Show>
- <Show when={isCurrentTab('Email')}>
- <Suspense>
- <Email />
- </Suspense>
- </Show>
- <Show when={isCurrentTab('GitHub')}>
- <Suspense>
- <GitHub />
- </Suspense>
- </Show>
- <Show when={isCurrentTab('Mobile App')}>
- <MobileApp />
- </Show>
- <Show when={isCurrentTab('Agent')}>
- <Agent />
- </Show>
- <Show when={isCurrentTab('Admin')}>
- <Admin />
- </Show>
+ {/* Content sits in its own subtly-raised, rounded card. The gutter
+ around it tightens as the panel narrows, and goes uniform once the
+ sidebar collapses. Full-bleed on mobile. */}
+ <div
+ class="flex-1 min-w-0 overflow-hidden mobile:p-0"
+ classList={{
+ 'py-2 pr-2 pl-0': !compact() && !narrow(),
+ 'py-1 pr-1 pl-0': !compact() && narrow(),
+ 'p-1': compact(),
+ }}
+ >
+ <Layer depth={1}>
+ <div class="relative flex size-full flex-col overflow-hidden rounded-xl border border-ink/[0.06] bg-surface mobile:rounded-none mobile:border-0 mobile:bg-transparent">
+ {/* Compact modal chrome: no split header to host the tabs, so
+ the sidebar collapses into a top bar here — back / tab
+ dropdown / move-to-split. (Split mode puts the tabs in its
+ header.) */}
+ <Show when={variant() === 'modal' && compact()}>
+ <div class="flex shrink-0 items-center gap-2 h-13 px-2 border-b border-ink/[0.05]">
+ {backToApp()}
+ <TabsInsetDropdown
+ list={tabItems()}
+ value={activeTabId()}
+ onChange={handleTabChange}
+ />
+ <div class="flex-1" />
+ {moveToSplitButton()}
+ </div>
+ </Show>
+
+ <div class="relative min-h-0 flex-1 overflow-hidden mobile:pt-(--mobile-content-inset-top) mobile:pb-(--mobile-content-inset-bottom)">
+ <Show when={isCurrentTab('Account')}>
+ <Suspense>
+ <Account />
+ </Suspense>
+ </Show>
+ <Show when={isCurrentTab('Billing')}>
+ <Suspense>
+ <Billing />
+ </Suspense>
+ </Show>
+ <Show when={isCurrentTab('Appearance')}>
+ <Appearance />
+ </Show>
+ <Show when={isCurrentTab('Shortcuts')}>
+ <Shortcuts />
+ </Show>
+ <Show when={isCurrentTab('Team')}>
+ <Suspense>
+ <Team />
+ </Suspense>
+ </Show>
+ <Show when={isCurrentTab('Connected')}>
+ <Suspense>
+ <ConnectedAccounts />
+ </Suspense>
+ </Show>
+ <Show when={isCurrentTab('Mobile App')}>
+ <MobileApp />
+ </Show>
+ <Show when={isCurrentTab('Agent')}>
+ <Agent />
+ </Show>
+ <Show when={isCurrentTab('Admin')}>
+ <Admin />
+ </Show>
+ </div>
+ </div>
+ </Layer>
</div>
</div>
diff --git a/js/app/packages/app/component/settings/SettingsModal.tsx b/js/app/packages/app/component/settings/SettingsModal.tsx
index 55aca99de5..1bba8a0f44 100644
--- a/js/app/packages/app/component/settings/SettingsModal.tsx
+++ b/js/app/packages/app/component/settings/SettingsModal.tsx
@@ -16,10 +16,10 @@ export function SettingsModal() {
onOpenChange={(open) => {
if (!open) closeModal();
}}
- position="center"
- class="w-260 h-216 max-h-[88vh] rounded-xl border border-edge bg-surface shadow-lg shadow-drop-shadow"
+ fullscreen
+ class="bg-surface"
>
- <Layer depth={2}>
+ <Layer depth={0}>
<SettingsPanel variant="modal" />
</Layer>
</Dialog>
diff --git a/js/app/packages/app/component/settings/Shortcuts.tsx b/js/app/packages/app/component/settings/Shortcuts.tsx
index 74891126f7..e6ef58eef2 100644
--- a/js/app/packages/app/component/settings/Shortcuts.tsx
+++ b/js/app/packages/app/component/settings/Shortcuts.tsx
@@ -2,8 +2,8 @@ import { createSignal, For, Index, createMemo, type JSX } from 'solid-js';
import { IS_MAC } from '@core/constant/isMac';
import { enableScreencastHotkeys, setEnableScreencastHotkeys } from '@ui/components/ScreencastHotkeys';
import { Hotkey, ToggleSwitch } from '@ui';
-import { Panel } from '@ui';
import { cn } from '@ui';
+import { SettingsCard, SettingsPage } from './primitives';
interface ShortcutItem {
description: JSX.Element;
@@ -264,8 +264,8 @@ function ShortcutRow(props: { item: ShortcutItem; spacer?: string }) {
function ShortcutSectionComponent(props: { section: ShortcutSection }) {
return (
- <div class="mb-3">
- <h3 class="font-medium text-lg mb-2 flex items-center gap-2">
+ <div class="mb-4">
+ <h3 class="text-[15px] font-semibold text-ink mb-1.5 flex items-center gap-2">
{props.section.title}
</h3>
<div class="flex flex-col">
@@ -277,59 +277,46 @@ function ShortcutSectionComponent(props: { section: ShortcutSection }) {
);
}
-function ShortcutsContent() {
+export function Shortcuts() {
return (
- <>
- <Panel.Header class="px-6">
- <div class="text-sm font-semibold">Keyboard Shortcuts</div>
- <div class="flex items-center gap-2 ml-auto">
- <span class="text-sm text-ink-muted">Screencast Keys</span>
+ <SettingsPage
+ title="Keyboard shortcuts"
+ actions={
+ <div class="flex items-center gap-2">
+ <span class="text-sm text-ink-muted">Screencast keys</span>
<ToggleSwitch
+ size="md"
onChange={setEnableScreencastHotkeys}
checked={enableScreencastHotkeys()}
/>
</div>
- </Panel.Header>
-
- <Panel.Toolbar class="h-full px-6 py-2">
+ }
+ >
+ <SettingsCard class="px-5 py-4">
<Keyboard keys={hoveredCodes()} />
- </Panel.Toolbar>
+ </SettingsCard>
- <Panel.Body scroll>
- <div class="px-6 py-2 @container">
- <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-6">
- {/* Core - left column */}
- <ShortcutSectionComponent section={shortcutSections[0]} />
+ <div class="@container">
+ <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-8">
+ {/* Core - left column */}
+ <ShortcutSectionComponent section={shortcutSections[0]} />
- {/* Splits - right column */}
- <ShortcutSectionComponent section={shortcutSections[1]} />
+ {/* Splits - right column */}
+ <ShortcutSectionComponent section={shortcutSections[1]} />
- {/* Unified List - spans both columns with its own 2-column layout */}
- <div class="@[600px]:col-span-2">
- <h3 class="font-medium text-lg mb-2 flex items-center gap-2">
- {shortcutSections[2].title}
- </h3>
- <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-6">
- <For each={shortcutSections[2].items}>
- {(item) => <ShortcutRow item={item} spacer="or" />}
- </For>
- </div>
+ {/* Unified List - spans both columns with its own 2-column layout */}
+ <div class="@[600px]:col-span-2">
+ <h3 class="text-[15px] font-semibold text-ink mb-1.5 flex items-center gap-2">
+ {shortcutSections[2].title}
+ </h3>
+ <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-8">
+ <For each={shortcutSections[2].items}>
+ {(item) => <ShortcutRow item={item} spacer="or" />}
+ </For>
</div>
</div>
</div>
- </Panel.Body>
- </>
- );
-}
-
-export function Shortcuts() {
- return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <ShortcutsContent />
- </Panel>
</div>
- </div>
+ </SettingsPage>
);
}
diff --git a/js/app/packages/app/component/settings/Team.tsx b/js/app/packages/app/component/settings/Team.tsx
index c9e848e4b1..de5135fc47 100644
--- a/js/app/packages/app/component/settings/Team.tsx
+++ b/js/app/packages/app/component/settings/Team.tsx
@@ -1,6 +1,4 @@
-import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { UserIcon } from '@core/component/UserIcon';
-import { VList } from 'virtua/solid';
import PlusIcon from '@phosphor/plus.svg';
import UsersIcon from '@phosphor/users.svg';
import TrashIcon from '@phosphor/trash.svg';
@@ -10,12 +8,17 @@ import XIcon from '@phosphor/x.svg';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CheckIcon from '@phosphor/check.svg';
import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
-import InfoIcon from '@phosphor/info.svg';
import { Tooltip } from '@ui';
import { Button } from '@ui';
import { Dialog, Panel } from '@ui';
import { cn } from '@ui';
+import {
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from './primitives';
import { Select } from '@kobalte/core/select';
import { useUserId } from '@core/context/user';
import { useDisplayName, tryMacroId, macroIdToEmail } from '@core/user';
@@ -24,7 +27,6 @@ import {
createSignal,
For,
Index,
- type JSX,
mapArray,
Match,
Show,
@@ -298,7 +300,6 @@ function MemberRow(props: {
member: TeamMember;
isOwner: boolean;
isCurrentUser: boolean;
- isLast?: boolean;
onRemove: () => void;
onRoleChange: (role: TeamRole) => void;
}) {
@@ -314,12 +315,7 @@ function MemberRow(props: {
};
return (
- <div
- class={cn(
- 'flex items-center justify-between py-2 px-6 gap-2 bg-surface hover:bg-hover',
- !props.isLast && 'settings-row-divider'
- )}
- >
+ <div class="flex items-center justify-between gap-2 px-6 py-3 bg-surface">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="shrink-0">
<UserIcon id={props.member.user_id} isDeleted={false} size="lg" />
@@ -392,7 +388,7 @@ function InviteRow(props: {
onCancel: () => void;
}) {
return (
- <div class="flex items-center justify-between py-2 border-b border-edge-muted last:border-b-0 gap-2">
+ <div class="flex items-center justify-between gap-2 px-6 py-3 bg-surface">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="size-8 rounded-full bg-accent/10 flex items-center justify-center shrink-0">
<EnvelopeIcon class="size-4 text-accent" />
@@ -438,7 +434,7 @@ function UserInviteRow(props: {
onUpgrade: () => void;
}) {
return (
- <div class="flex items-center justify-between py-3 border-b border-edge-muted last:border-b-0 gap-3">
+ <div class="flex items-center justify-between gap-3 px-6 py-3 bg-surface">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="size-8 rounded-full bg-accent/10 flex items-center justify-center shrink-0">
<EnvelopeIcon class="size-4 text-accent" />
@@ -499,41 +495,34 @@ function TeamInvites() {
rejectMutation.variables?.teamInviteId === inviteId;
return (
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <Panel.Header class="px-6">
- <div class="text-sm font-semibold">Team</div>
- </Panel.Header>
- <Panel.Body>
- <Show when={invites().length > 0}>
- <section class="px-6 py-4">
- <header class="mb-2">
- <h3 class="text-sm font-medium">
- You've been invited to join a team
- </h3>
- </header>
- <div class="border border-edge rounded-sm px-3">
- <For each={invites()}>
- {(invite) => (
- <UserInviteRow
- invite={invite}
- onAccept={() =>
- joinTeamMutation.mutate({ teamInviteId: invite.id })
- }
- onDecline={() =>
- rejectMutation.mutate({ teamInviteId: invite.id })
- }
- isAccepting={isAccepting(invite.id)}
- isDeclining={isDeclining(invite.id)}
- requiresUpgrade={requiresUpgrade()}
- onUpgrade={() => showPaywall()}
- />
- )}
- </For>
- </div>
- </section>
- </Show>
- </Panel.Body>
- </Panel>
+ <SettingsPage title="Team">
+ <Show when={invites().length > 0}>
+ <SettingsSection
+ title="Invitations"
+ description="You've been invited to join a team."
+ >
+ <SettingsCard>
+ <For each={invites()}>
+ {(invite) => (
+ <UserInviteRow
+ invite={invite}
+ onAccept={() =>
+ joinTeamMutation.mutate({ teamInviteId: invite.id })
+ }
+ onDecline={() =>
+ rejectMutation.mutate({ teamInviteId: invite.id })
+ }
+ isAccepting={isAccepting(invite.id)}
+ isDeclining={isDeclining(invite.id)}
+ requiresUpgrade={requiresUpgrade()}
+ onUpgrade={() => showPaywall()}
+ />
+ )}
+ </For>
+ </SettingsCard>
+ </SettingsSection>
+ </Show>
+ </SettingsPage>
);
}
@@ -707,12 +696,9 @@ function EmptyTeamState() {
const { showPaywall } = usePaywallState();
return (
- <>
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <Panel.Header class="px-6">
- <div class="text-sm font-semibold">Team</div>
- </Panel.Header>
- <Panel.Body>
+ <SettingsPage title="Team">
+ <SettingsSection>
+ <SettingsCard>
<div class="flex flex-col items-center justify-center py-12 text-center px-6">
<div class="size-12 rounded-full bg-accent/10 flex items-center justify-center mb-4">
<UsersIcon class="size-6 text-accent" />
@@ -750,8 +736,8 @@ function EmptyTeamState() {
</Button>
</Show>
</div>
- </Panel.Body>
- </Panel>
+ </SettingsCard>
+ </SettingsSection>
<Show when={showCreateModal()}>
<CreateTeamDialog
@@ -759,46 +745,22 @@ function EmptyTeamState() {
onClose={() => setShowCreateModal(false)}
/>
</Show>
- </>
+ </SettingsPage>
);
}
-/** Shared styling for the editable Name/Slug fields in the team-details card. */
-const TEAM_FIELD_CLASS =
- 'w-48 h-8 px-2.5 rounded-lg border bg-surface text-sm text-ink outline-none focus:border-accent';
-
-/** A team-details row: label + info tooltip on the left, its control on the right. */
-function MetadataRow(props: {
- label: string;
- hint: string;
- children: JSX.Element;
-}) {
- return (
- <div class="flex items-center gap-3 w-full px-4 py-2">
- <div class="flex items-center gap-1.5 min-w-0">
- <span class="text-sm">{props.label}</span>
- <Tooltip label={props.hint} placement="top">
- <InfoIcon class="size-3.5 text-ink-muted hover:text-ink" />
- </Tooltip>
- </div>
- {props.children}
- </div>
- );
-}
+/** Shared styling for the editable Name/Slug fields in the team-details card.
+ * Narrows on mobile so the field + Save/Cancel cluster fits a phone width. */
+/** Width for the editable Name/Slug fields; pairs with the shared `settings-input`
+ * utility. Narrows on mobile so the field + Save/Cancel cluster fits a phone. */
+const TEAM_FIELD_CLASS = 'settings-input w-56 mobile:w-32';
-/** Disabled field shown to non-owners, with a tooltip explaining why it's locked. */
+/** Disabled field shown to non-owners, with a tooltip explaining why it's locked.
+ * The muted look comes from `settings-input`'s `:disabled` styling. */
function ReadOnlyField(props: { value: string; tooltip: string }) {
return (
<Tooltip label={props.tooltip} placement="top">
- <input
- type="text"
- value={props.value}
- disabled
- class={cn(
- TEAM_FIELD_CLASS,
- 'border-edge-muted text-ink-muted pointer-events-none opacity-70'
- )}
- />
+ <input type="text" value={props.value} disabled class={TEAM_FIELD_CLASS} />
</Tooltip>
);
}
@@ -881,18 +843,6 @@ function TeamManagement(props: {
undefined
);
- const [memberListWrapperRef, setMemberListWrapperRef] =
- createSignal<HTMLDivElement>();
- const memberListScrollContainer = () => {
- const el = memberListWrapperRef();
- if (!el) return undefined;
- return (
- (el.querySelector(
- '[data-team-members-list-container]'
- ) as HTMLElement | null) ?? undefined
- );
- };
-
const hasValidInvites = () => {
const inv = invites();
const hasNonEmptyEmail = inv.some((i) => i.email.trim() !== '');
@@ -1124,140 +1074,133 @@ function TeamManagement(props: {
return (
<>
- <div
- class="grid size-full min-h-0 gap-2"
- style={{ 'grid-template-rows': 'min-content minmax(0, 1fr)' }}
+ <SettingsPage
+ title="Team"
+ actions={
+ <Show when={isOwner()}>
+ <Button
+ variant="danger"
+ size="sm"
+ class="rounded-xs"
+ onClick={() => setShowDeleteTeamModal(true)}
+ >
+ <TrashIcon class="size-4" />
+ Delete Team
+ </Button>
+ </Show>
+ }
>
- <Panel depth={2} class="overflow-hidden text-ink">
- <Panel.Header class="justify-between px-6">
- <div class="text-sm font-semibold">Team</div>
- <Show when={isOwner()}>
- <Button
- variant="danger"
- size="sm"
- class="rounded-xs"
- onClick={() => setShowDeleteTeamModal(true)}
- >
- <TrashIcon class="size-4" />
- Delete Team
- </Button>
- </Show>
- </Panel.Header>
- <Panel.Body class="@container">
- <div class="grid grid-cols-1 items-start gap-2 px-2 py-2 @[680px]:grid-cols-2">
- <MetadataRow
- label="Name"
- hint="What your team is called — shown in invitations and billing."
+ <SettingsSection title="General">
+ <SettingsCard>
+ <SettingsRow
+ label="Name"
+ description="What your team is called — shown in invitations and billing."
+ hideDescriptionOnMobile
+ >
+ <Show
+ when={isOwner()}
+ fallback={
+ <ReadOnlyField
+ value={props.teamName}
+ tooltip="Only the team owner can change the team name."
+ />
+ }
>
- <Show
- when={isOwner()}
- fallback={
- <ReadOnlyField
- value={props.teamName}
- tooltip="Only the team owner can change the team name."
+ <div class="flex items-center gap-2">
+ <input
+ type="text"
+ value={teamNameValue()}
+ onInput={(e) => setEditingTeamName(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ if (hasTeamNameChanged() && editingTeamName()?.trim()) {
+ handleSaveTeamName();
+ }
+ } else if (e.key === 'Escape') {
+ handleCancelTeamNameEdit();
+ e.currentTarget.blur();
+ }
+ }}
+ placeholder="Enter team name"
+ class={TEAM_FIELD_CLASS}
+ />
+ <Show when={hasTeamNameChanged()}>
+ <SaveCancelButtons
+ onSave={handleSaveTeamName}
+ onCancel={handleCancelTeamNameEdit}
+ saveDisabled={
+ patchTeamMutation.isPending ||
+ !editingTeamName()?.trim()
+ }
+ pending={patchTeamMutation.isPending}
/>
- }
- >
- <div class="flex items-center gap-2">
+ </Show>
+ </div>
+ </Show>
+ </SettingsRow>
+
+ <SettingsRow
+ label="Slug"
+ description="Short code in task references like ENG-42 (GitHub, branch names)."
+ hideDescriptionOnMobile
+ >
+ <Show
+ when={isOwner()}
+ fallback={
+ <ReadOnlyField
+ value={props.teamSlug}
+ tooltip="Only the team owner can change the team slug."
+ />
+ }
+ >
+ <div class="flex items-center gap-2">
+ <div class="flex flex-col items-end gap-1 min-w-0">
<input
type="text"
- value={teamNameValue()}
- onInput={(e) => setEditingTeamName(e.currentTarget.value)}
+ value={teamSlugValue()}
+ onInput={(e) =>
+ handleTeamSlugChange(e.currentTarget.value)
+ }
onKeyDown={(e) => {
if (e.key === 'Enter') {
- if (
- hasTeamNameChanged() &&
- editingTeamName()?.trim()
- ) {
- handleSaveTeamName();
- }
+ if (canSaveTeamSlug()) handleSaveTeamSlug();
} else if (e.key === 'Escape') {
- handleCancelTeamNameEdit();
+ handleCancelTeamSlugEdit();
e.currentTarget.blur();
}
}}
- placeholder="Enter team name"
- class={cn(TEAM_FIELD_CLASS, 'border-edge-muted')}
+ placeholder="Enter team slug"
+ class={TEAM_FIELD_CLASS}
+ aria-invalid={!!teamSlugError()}
/>
- <Show when={hasTeamNameChanged()}>
- <SaveCancelButtons
- onSave={handleSaveTeamName}
- onCancel={handleCancelTeamNameEdit}
- saveDisabled={
- patchTeamMutation.isPending ||
- !editingTeamName()?.trim()
- }
- pending={patchTeamMutation.isPending}
- />
+ <Show when={teamSlugError()}>
+ <p class="text-xs text-failure-ink text-right">
+ {teamSlugError()}
+ </p>
</Show>
- </div>
- </Show>
- </MetadataRow>
- <MetadataRow
- label="Slug"
- hint="Short code in task references like ENG-42 (GitHub, branch names)."
- >
- <Show
- when={isOwner()}
- fallback={
- <ReadOnlyField
- value={props.teamSlug}
- tooltip="Only the team owner can change the team slug."
- />
- }
- >
- <div class="flex items-center gap-2">
- <div class="flex flex-col items-end gap-1 min-w-0">
- <input
- type="text"
- value={teamSlugValue()}
- onInput={(e) =>
- handleTeamSlugChange(e.currentTarget.value)
- }
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- if (canSaveTeamSlug()) handleSaveTeamSlug();
- } else if (e.key === 'Escape') {
- handleCancelTeamSlugEdit();
- e.currentTarget.blur();
- }
- }}
- placeholder="Enter team slug"
- class={TEAM_FIELD_CLASS}
- classList={{
- 'border-failure': !!teamSlugError(),
- 'border-edge-muted': !teamSlugError(),
- }}
- />
- <Show when={teamSlugError()}>
- <p class="text-xs text-failure-ink text-right">
- {teamSlugError()}
- </p>
- </Show>
- <Show when={normalizedTeamSlugPreview()}>
- <p class="text-xs text-ink-muted text-right">
- Will save as {normalizedTeamSlugPreview()}
- </p>
- </Show>
- </div>
- <Show when={hasTeamSlugInputChanged()}>
- <SaveCancelButtons
- onSave={handleSaveTeamSlug}
- onCancel={handleCancelTeamSlugEdit}
- saveDisabled={!canSaveTeamSlug()}
- pending={patchTeamMutation.isPending}
- />
+ <Show when={normalizedTeamSlugPreview()}>
+ <p class="text-xs text-ink-muted text-right">
+ Will save as {normalizedTeamSlugPreview()}
+ </p>
</Show>
</div>
- </Show>
- </MetadataRow>
- </div>
- </Panel.Body>
- </Panel>
+ <Show when={hasTeamSlugInputChanged()}>
+ <SaveCancelButtons
+ onSave={handleSaveTeamSlug}
+ onCancel={handleCancelTeamSlugEdit}
+ saveDisabled={!canSaveTeamSlug()}
+ pending={patchTeamMutation.isPending}
+ />
+ </Show>
+ </div>
+ </Show>
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
- <Panel depth={2} class="min-h-0 overflow-hidden text-ink">
- <Panel.Header class="justify-between px-6">
- <div class="text-sm font-semibold">Members</div>
+ <SettingsSection
+ title="Members"
+ actions={
<Show when={isOwner()}>
<Button
variant="base"
@@ -1276,119 +1219,97 @@ function TeamManagement(props: {
Invite
</Button>
</Show>
- </Panel.Header>
- <Panel.Body>
- <div class="flex h-full flex-col">
- <Show when={showMemberSearch()}>
- <div class="px-6 py-2 shrink-0">
- <label class="flex items-center gap-2 h-8 px-2.5 rounded-lg border border-edge-muted text-ink-muted focus-within:border-accent focus-within:text-ink">
- <MagnifyingGlassIcon class="size-4 shrink-0" />
- <input
- type="text"
- value={memberQuery()}
- onInput={(e) => setMemberQuery(e.currentTarget.value)}
- placeholder="Filter members"
- class="flex-1 min-w-0 bg-transparent text-sm text-ink outline-none placeholder:text-ink-extra-muted"
- />
- <Show when={memberQuery()}>
- <button
- type="button"
- class="shrink-0 text-ink-muted hover:text-ink"
- aria-label="Clear filter"
- onClick={() => setMemberQuery('')}
- >
- <XIcon class="size-4" />
- </button>
- </Show>
- </label>
- </div>
- </Show>
-
- <div class="relative min-h-0 flex-1">
- <Show
- when={!teamQuery.isLoading}
- fallback={
- <div class="animate-pulse bg-ink-extra-muted rounded h-16" />
- }
+ }
+ >
+ <Show when={showMemberSearch()}>
+ <label class="flex items-center gap-2 h-9 px-3 rounded-lg border border-edge-muted text-ink-muted focus-within:border-accent focus-within:text-ink">
+ <MagnifyingGlassIcon class="size-4 shrink-0" />
+ <input
+ type="text"
+ value={memberQuery()}
+ onInput={(e) => setMemberQuery(e.currentTarget.value)}
+ placeholder="Filter members"
+ class="flex-1 min-w-0 bg-transparent text-sm text-ink outline-none placeholder:text-ink-extra-muted"
+ />
+ <Show when={memberQuery()}>
+ <button
+ type="button"
+ class="shrink-0 text-ink-muted hover:text-ink"
+ aria-label="Clear filter"
+ onClick={() => setMemberQuery('')}
>
- <Show
- when={filteredMembers().length > 0}
- fallback={
- <div class="flex justify-center px-6 pt-4 text-center text-sm text-ink-muted">
- No members match “{memberQuery()}”
- </div>
- }
- >
- <div
- ref={setMemberListWrapperRef}
- class="relative h-full min-h-0"
- >
- <VList
- data={filteredMembers()}
- class="h-full scrollbar-hidden"
- style={{
- height: '100%',
- width: '100%',
- }}
- bufferSize={500}
- data-team-members-list-container
- >
- {(member, index) => (
- <MemberRow
- member={member}
- isOwner={isOwner()}
- isCurrentUser={member.user_id === userId()}
- isLast={index() === filteredMembers().length - 1}
- onRemove={() => setShowRemoveModal(member)}
- onRoleChange={(newRole) => {
- if (!props.teamId) return;
- patchTeamMutation.mutate({
- teamId: props.teamId,
- request: {
- user_role_updates: [
- {
- team_user_id: member.user_id,
- role: newRole,
- },
- ],
- },
- });
- }}
- />
- )}
- </VList>
- <CustomScrollbar
- scrollContainer={memberListScrollContainer}
- />
- </div>
- </Show>
- </Show>
- </div>
+ <XIcon class="size-4" />
+ </button>
+ </Show>
+ </label>
+ </Show>
- <Show
- when={
- isOwner() && (invitesQuery.data?.invites?.length ?? 0) > 0
- }
- >
- <section class="px-6 py-4 border-t border-edge-muted shrink-0">
- <h3 class="text-sm font-medium mb-2">Pending Invites</h3>
- <div class="border border-edge rounded-sm px-3">
- <For each={invitesQuery.data?.invites ?? []}>
- {(invite) => (
- <InviteRow
- invite={invite}
- isOwner={isOwner()}
- onCancel={() => setShowCancelInviteModal(invite)}
- />
- )}
- </For>
+ <Show
+ when={!teamQuery.isLoading}
+ fallback={
+ <SettingsCard>
+ <div class="animate-pulse bg-ink-extra-muted rounded h-16 m-4" />
+ </SettingsCard>
+ }
+ >
+ <Show
+ when={filteredMembers().length > 0}
+ fallback={
+ <SettingsCard>
+ <div class="px-6 py-8 text-center text-sm text-ink-muted">
+ No members match “{memberQuery()}”
</div>
- </section>
- </Show>
- </div>
- </Panel.Body>
- </Panel>
- </div>
+ </SettingsCard>
+ }
+ >
+ <SettingsCard>
+ <For each={filteredMembers()}>
+ {(member) => (
+ <MemberRow
+ member={member}
+ isOwner={isOwner()}
+ isCurrentUser={member.user_id === userId()}
+ onRemove={() => setShowRemoveModal(member)}
+ onRoleChange={(newRole) => {
+ if (!props.teamId) return;
+ patchTeamMutation.mutate({
+ teamId: props.teamId,
+ request: {
+ user_role_updates: [
+ {
+ team_user_id: member.user_id,
+ role: newRole,
+ },
+ ],
+ },
+ });
+ }}
+ />
+ )}
+ </For>
+ </SettingsCard>
+ </Show>
+ </Show>
+ </SettingsSection>
+
+ <Show
+ when={isOwner() && (invitesQuery.data?.invites?.length ?? 0) > 0}
+ >
+ <SettingsSection title="Pending invites">
+ <SettingsCard>
+ <For each={invitesQuery.data?.invites ?? []}>
+ {(invite) => (
+ <InviteRow
+ invite={invite}
+ isOwner={isOwner()}
+ onCancel={() => setShowCancelInviteModal(invite)}
+ />
+ )}
+ </For>
+ </SettingsCard>
+ </SettingsSection>
+ </Show>
+ </SettingsPage>
<Dialog
open={showDeleteTeamModal()}
@@ -1628,18 +1549,14 @@ function TeamContent() {
export function Team() {
return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- {/* Each state renders its own Panel(s): TeamManagement is a two-card
- layout (details + members); the others are a single card. */}
- <Suspense
- fallback={
- <div class="animate-pulse bg-ink-extra-muted rounded h-4 w-32 m-6" />
- }
- >
- <TeamContent />
- </Suspense>
- </div>
- </div>
+ // Each state renders its own SettingsPage (scrolling, centered column) so
+ // Team matches the Account/Appearance layout.
+ <Suspense
+ fallback={
+ <div class="animate-pulse bg-ink-extra-muted rounded h-4 w-32 m-6" />
+ }
+ >
+ <TeamContent />
+ </Suspense>
);
}
diff --git a/js/app/packages/app/component/settings/integration-ui.tsx b/js/app/packages/app/component/settings/integration-ui.tsx
index e933b62bba..d21126dc1b 100644
--- a/js/app/packages/app/component/settings/integration-ui.tsx
+++ b/js/app/packages/app/component/settings/integration-ui.tsx
@@ -1,77 +1,72 @@
-import { Panel } from '@ui';
-import { type Component, type JSX, Show } from 'solid-js';
-import { Dynamic } from 'solid-js/web';
+import { cn } from '@ui';
+import { Show } from 'solid-js';
+import ArrowUpRightIcon from '@phosphor/arrow-up-right.svg';
+import SpinnerIcon from '@phosphor/spinner-gap.svg';
-/**
- * Shared chrome for the spare, single-purpose integration panels (Email,
- * GitHub) nested under the Workspace settings group. Mirrors the Account
- * panel's centered, max-width column so the settings panels feel consistent.
+/*
+ * Shared bits for the Connected accounts integration cards: the trailing
+ * "Connect" action and the small connection-state label. The card chrome itself
+ * comes from the settings primitives (SettingsCard / IntegrationRow).
*/
-export function IntegrationPanelShell(props: {
- title: string;
- children: JSX.Element;
-}) {
- return (
- <div class="h-full overflow-hidden flex justify-center p-2">
- <div class="max-w-200 size-full">
- <Panel depth={2} class="h-full overflow-hidden text-ink">
- <Panel.Header class="px-6">
- <div class="text-sm font-semibold">{props.title}</div>
- </Panel.Header>
- <Panel.Body scroll class="text-ink">
- {props.children}
- </Panel.Body>
- </Panel>
- </div>
- </div>
- );
-}
+
+export type ConnectionState = 'connected' | 'attention' | 'disconnected';
/**
- * Generous, centered hero used as the resting state of an integration panel:
- * an icon tile, a title, a one-line explanation, an optional status pill and
- * the primary action(s). Leans on whitespace rather than filler to make a
- * sparse page feel intentional.
+ * The trailing action on an integration row. Defaults to a quiet text+arrow
+ * "Connect" affordance (mirrors Linear's link-style connect button); pass
+ * `variant` to render a neutral or destructive action (e.g. Disconnect).
*/
-export function ConnectionHero(props: {
- icon: Component<{ class?: string }>;
- title: string;
- description: string;
- status?: JSX.Element;
- children?: JSX.Element;
+export function ConnectAction(props: {
+ label: string;
+ onClick: () => void;
+ disabled?: boolean;
+ loading?: boolean;
+ /** 'connect' shows the external-link arrow; the others are plain buttons. */
+ variant?: 'connect' | 'neutral' | 'danger';
}) {
+ const variant = () => props.variant ?? 'connect';
return (
- <div class="flex flex-col items-center text-center gap-5 px-6 pt-20 pb-12">
- <div class="flex size-16 items-center justify-center rounded-2xl bg-edge-muted">
- <Dynamic component={props.icon} class="size-8 text-ink" />
- </div>
- <div class="flex flex-col items-center gap-2 max-w-100">
- <div class="text-lg font-semibold text-ink">{props.title}</div>
- <p class="text-sm/relaxed text-ink-muted">{props.description}</p>
- </div>
- <Show when={props.status}>{props.status}</Show>
- <Show when={props.children}>
- <div class="flex items-center gap-2 pt-1">{props.children}</div>
+ <button
+ type="button"
+ disabled={props.disabled || props.loading}
+ onClick={() => props.onClick()}
+ class={cn(
+ 'inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-sm font-medium',
+ 'cursor-default transition-colors disabled:opacity-50',
+ 'outline-none focus-visible:bg-ink/6',
+ variant() === 'danger'
+ ? 'text-ink-muted hover:bg-ink/4 hover:text-failure'
+ : 'text-ink-muted hover:bg-ink/4 hover:text-ink'
+ )}
+ >
+ <Show when={props.loading}>
+ <SpinnerIcon class="size-4 animate-spin" />
</Show>
- </div>
+ {props.label}
+ <Show when={variant() === 'connect' && !props.loading}>
+ <ArrowUpRightIcon class="size-3.5 opacity-70" />
+ </Show>
+ </button>
);
}
-export type ConnectionState = 'connected' | 'attention' | 'disconnected';
-
-/** Small dot-and-label pill conveying an integration's connection state. */
-export function StatusPill(props: { state: ConnectionState; label: string }) {
+/**
+ * A bare connection-state dot, sized to sit beside an integration's title. The
+ * state is conveyed by color (with a tooltip/aria-label for the word), so it
+ * stays legible at any width — including mobile, where a text label wouldn't fit.
+ */
+export function StatusDot(props: { state: ConnectionState; label?: string }) {
return (
<span
- class="inline-flex items-center gap-1.5 rounded-full border border-edge-muted bg-surface px-2.5 py-1 text-xs font-medium"
- classList={{
- 'text-success': props.state === 'connected',
- 'text-failure': props.state === 'attention',
- 'text-ink-muted': props.state === 'disconnected',
- }}
- >
- <span class="size-1.5 rounded-full bg-current" />
- {props.label}
- </span>
+ role="img"
+ title={props.label}
+ aria-label={props.label}
+ class={cn(
+ 'inline-block size-2 shrink-0 rounded-full',
+ props.state === 'connected' && 'bg-success',
+ props.state === 'attention' && 'bg-failure',
+ props.state === 'disconnected' && 'bg-ink-muted'
+ )}
+ />
);
}
diff --git a/js/app/packages/app/component/settings/primitives.tsx b/js/app/packages/app/component/settings/primitives.tsx
new file mode 100644
index 0000000000..8909a5d0b8
--- /dev/null
+++ b/js/app/packages/app/component/settings/primitives.tsx
@@ -0,0 +1,189 @@
+import { type JSX, Show } from 'solid-js';
+import { cn, Layer } from '@ui';
+
+/*
+ * Shared building blocks for the settings panels. Every settings tab composes
+ * these so the whole menu shares one rhythm: a generous, centered content
+ * column with a large page title, sections, and quiet outlined cards whose rows
+ * are separated by hairline dividers.
+ *
+ * <SettingsPage title="Account" description="…">
+ * <SettingsSection title="Profile">
+ * <SettingsCard>
+ * <SettingsRow label="Email">…</SettingsRow>
+ * <SettingsRow label="Full name">…</SettingsRow>
+ * </SettingsCard>
+ * </SettingsSection>
+ * </SettingsPage>
+ */
+
+/**
+ * Scrolling page shell: a centered, max-width column with a large title and an
+ * optional one-line description, followed by the page's sections.
+ */
+export function SettingsPage(props: {
+ title: string;
+ /** Optional one-line subtitle; accepts text or inline markup (e.g. a link). */
+ description?: JSX.Element;
+ /** Right-aligned controls beside the title (e.g. a global toggle). */
+ actions?: JSX.Element;
+ children: JSX.Element;
+}) {
+ return (
+ <div class="h-full overflow-y-auto">
+ <div class="mx-auto w-full max-w-[710px] px-10 pt-14 pb-24 mobile:px-5 mobile:pt-8 mobile:pb-12">
+ {/* Headers are inset by the card's inner padding so the title and
+ section labels line up with the leftmost content inside the cards,
+ while the cards themselves stay full-width. */}
+ <header class="flex items-start justify-between gap-4 px-6">
+ <div class="flex flex-col gap-1.5 min-w-0">
+ <h1 class="text-2xl/tight font-semibold text-ink">{props.title}</h1>
+ <Show when={props.description}>
+ <p class="text-sm text-ink-muted">{props.description}</p>
+ </Show>
+ </div>
+ <Show when={props.actions}>
+ <div class="shrink-0 pt-1">{props.actions}</div>
+ </Show>
+ </header>
+ <div class="mt-9 flex flex-col gap-10">{props.children}</div>
+ </div>
+ </div>
+ );
+}
+
+/**
+ * A titled group within a page. The heading/description are optional so a page
+ * can also drop a bare card straight under the title.
+ */
+export function SettingsSection(props: {
+ title?: string;
+ description?: string;
+ /** Right-aligned controls beside the section heading. */
+ actions?: JSX.Element;
+ class?: string;
+ children: JSX.Element;
+}) {
+ return (
+ <section class={cn('flex flex-col gap-3', props.class)}>
+ <Show when={props.title || props.actions}>
+ <div class="flex items-end justify-between gap-4 px-6">
+ <div class="flex flex-col gap-0.5 min-w-0">
+ <Show when={props.title}>
+ <h2 class="text-[15px] font-semibold text-ink">{props.title}</h2>
+ </Show>
+ <Show when={props.description}>
+ <p class="text-sm text-ink-muted">{props.description}</p>
+ </Show>
+ </div>
+ <Show when={props.actions}>
+ <div class="shrink-0">{props.actions}</div>
+ </Show>
+ </div>
+ </Show>
+ {props.children}
+ </section>
+ );
+}
+
+/**
+ * A quiet outlined card. Direct children are treated as rows and get a hairline
+ * divider between them (via `settings-row-dividers`); a single-child card draws
+ * no divider, so it doubles as a plain container.
+ */
+export function SettingsCard(props: { class?: string; children: JSX.Element }) {
+ // Raised a level above the content panel so the card reads as a subtly
+ // lighter surface (theme-safe via the depth system) rather than just an
+ // outline on the same fill.
+ return (
+ <Layer depth={2}>
+ <div
+ class={cn(
+ 'rounded-xl border border-ink/[0.05] bg-surface overflow-hidden settings-row-dividers',
+ props.class
+ )}
+ >
+ {props.children}
+ </div>
+ </Layer>
+ );
+}
+
+/**
+ * A label (with optional sub-text) on the left and its control on the right.
+ * `align="start"` top-aligns the two columns for taller controls.
+ */
+export function SettingsRow(props: {
+ label: JSX.Element;
+ description?: JSX.Element;
+ children?: JSX.Element;
+ align?: 'center' | 'start';
+ /** Hide the description on mobile, where the row is too cramped for it. */
+ hideDescriptionOnMobile?: boolean;
+ class?: string;
+}) {
+ return (
+ <div
+ class={cn(
+ 'flex justify-between gap-4 px-6 py-3.5 min-h-[60px]',
+ props.align === 'start' ? 'items-start' : 'items-center',
+ props.class
+ )}
+ >
+ <div class="flex flex-col gap-0.5 min-w-0">
+ <div class="text-sm text-ink">{props.label}</div>
+ <Show when={props.description}>
+ <div
+ class={cn(
+ 'text-xs text-ink-muted',
+ props.hideDescriptionOnMobile && 'mobile:hidden'
+ )}
+ >
+ {props.description}
+ </div>
+ </Show>
+ </div>
+ <Show when={props.children}>
+ <div class="shrink-0 flex items-center justify-end gap-2 text-right">
+ {props.children}
+ </div>
+ </Show>
+ </div>
+ );
+}
+
+/**
+ * A row for an integration / service: a brand icon, a title + one-line
+ * description, and a trailing action slot. Used by the Connected accounts and
+ * MCP cards so every integration reads the same.
+ */
+export function IntegrationRow(props: {
+ /** The brand icon, rendered at its native size inside a fixed slot. */
+ icon: JSX.Element;
+ title: JSX.Element;
+ description?: JSX.Element;
+ /** Optional indicator shown right after the title (e.g. a connection dot). */
+ status?: JSX.Element;
+ children?: JSX.Element;
+ class?: string;
+}) {
+ return (
+ <div class={cn('flex items-center gap-4 px-6 py-4', props.class)}>
+ <div class="flex size-9 shrink-0 items-center justify-center [&_svg]:size-6">
+ {props.icon}
+ </div>
+ <div class="flex-1 min-w-0 flex flex-col gap-0.5">
+ <div class="flex items-center gap-2 min-w-0">
+ <div class="text-sm font-medium text-ink truncate">{props.title}</div>
+ <Show when={props.status}>{props.status}</Show>
+ </div>
+ <Show when={props.description}>
+ <div class="text-sm text-ink-muted truncate">{props.description}</div>
+ </Show>
+ </div>
+ <Show when={props.children}>
+ <div class="shrink-0 flex items-center gap-2">{props.children}</div>
+ </Show>
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/split-layout/components/SplitLabel.tsx b/js/app/packages/app/component/split-layout/components/SplitLabel.tsx
index 4321b018f7..c5439daed9 100644
--- a/js/app/packages/app/component/split-layout/components/SplitLabel.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitLabel.tsx
@@ -57,7 +57,9 @@ export function StaticSplitLabel(props: {
<div class="shrink-0">{props.icon}</div>
</Show>
<Show when={props.badges}>{props.badges}</Show>
- <span class="inline-block text-sm truncate">{props.label}</span>
+ <span class="inline-block text-sm font-semibold truncate">
+ {props.label}
+ </span>
</div>
</HeaderIsland>
);
@@ -107,7 +109,7 @@ export function SplitLabel(props: {
return (
<span
- class="inline-block text-sm truncate"
+ class="inline-block text-sm font-semibold truncate"
onContextMenu={startEditing}
onDblClick={startEditing}
>
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.css
index ae955b1d5c..bc88d11b5d 100644
--- a/js/app/packages/app/index.css
+++ b/js/app/packages/app/index.css
@@ -406,6 +406,30 @@ a {
}
}
+/* Shared text-field styling so inputs look the same across every settings tab.
+ Apply to an <input>; pair with a width utility (e.g. `w-full`) as needed. */
+@utility settings-input {
+ @apply h-9 px-3 rounded-lg border border-edge-muted bg-transparent text-sm text-ink outline-none transition-colors;
+ &::placeholder {
+ @apply text-ink-extra-muted;
+ }
+ &:hover {
+ @apply border-edge;
+ }
+ &:focus {
+ @apply border-accent;
+ }
+ /* State styling owned by the utility so call sites toggle an attribute instead
+ of fighting the border/text classes. `aria-invalid` after `:focus` so the
+ error border wins even while focused; `:disabled` reads as a muted field. */
+ &[aria-invalid="true"] {
+ @apply border-failure;
+ }
+ &:disabled {
+ @apply text-ink-muted opacity-70;
+ }
+}
+
/* Subtle, inset divider between settings rows (Account/Appearance/Email/Agent).
Apply to a list container whose direct children are full-width rows with px-6
padding; draws the line under every row except the last. */
diff --git a/js/app/packages/core/component/TabsInset.tsx b/js/app/packages/core/component/TabsInset.tsx
index 0b8d649fa5..bd752e3ecb 100644
--- a/js/app/packages/core/component/TabsInset.tsx
+++ b/js/app/packages/core/component/TabsInset.tsx
@@ -29,6 +29,13 @@ export const TabsInset = (props: TabsInsetProps) => {
'depth',
]);
+ // The track sits at the control's depth (matching the panel it's on); the
+ // checked item is elevated two steps above it so the active pill still reads
+ // as raised regardless of the panel depth.
+ const trackDepth = () => local.depth ?? 0;
+ const itemDepth = () =>
+ Math.min(5, trackDepth() + 2) as 0 | 1 | 2 | 3 | 4 | 5;
+
return (
<KSegmentedControl
value={local.value}
@@ -37,11 +44,11 @@ export const TabsInset = (props: TabsInsetProps) => {
{...rootProps}
class={cn('h-full flex items-center', local.class)}
>
- <Layer depth={local.depth ?? 0}>
+ <Layer depth={trackDepth()}>
<div class="relative flex items-center bg-surface rounded-lg p-0.5 ring ring-edge-muted">
<For each={local.list}>
{(item) => (
- <Layer depth={2}>
+ <Layer depth={itemDepth()}>
<KSegmentedControl.Item
value={item.value}
disabled={local.disabled}
diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsx
index 266b7d0cc8..15266bb624 100644
--- a/js/app/packages/core/constant/SettingsState.tsx
+++ b/js/app/packages/core/constant/SettingsState.tsx
@@ -18,6 +18,7 @@ export type SettingsTab =
| 'Mobile App'
| 'Agent'
| 'Team'
+ | 'Connected'
| 'Email'
| 'GitHub'
| 'Admin';
diff --git a/js/app/packages/core/constant/settingsTabsConfig.tsx b/js/app/packages/core/constant/settingsTabsConfig.tsx
index 6277f59b60..84916a9b34 100644
--- a/js/app/packages/core/constant/settingsTabsConfig.tsx
+++ b/js/app/packages/core/constant/settingsTabsConfig.tsx
@@ -1,12 +1,11 @@
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import BugIcon from '@phosphor/bug.svg';
+import CpuIcon from '@phosphor/cpu.svg';
import CreditCardIcon from '@phosphor/credit-card.svg';
import DeviceMobileIcon from '@phosphor/device-mobile-speaker.svg';
-import EnvelopeIcon from '@phosphor/envelope.svg';
-import GithubLogoIcon from '@phosphor/github-logo.svg';
import KeyboardIcon from '@phosphor/keyboard.svg';
-import PaintBucketIcon from '@phosphor/paint-bucket.svg';
import PlugIcon from '@phosphor/plug.svg';
+import SwatchesIcon from '@phosphor/swatches.svg';
import UserIconPhosphor from '@phosphor/user.svg';
import UsersThreeIcon from '@phosphor/users-three.svg';
import { type Component, createMemo } from 'solid-js';
@@ -16,7 +15,6 @@ import { isTouchDevice } from '../mobile/isTouchDevice';
import {
DEV_MODE_ENV,
ENABLE_APP_STORE_QR_CODE,
- ENABLE_EMAIL,
ENABLE_TEAMS_OVERRIDE,
} from './featureFlags';
import { PERMISSION_IDS } from './permissions';
@@ -47,7 +45,7 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
items: [
{ tab: 'Account', label: 'Account', icon: UserIconPhosphor },
{ tab: 'Billing', label: 'Billing', icon: CreditCardIcon },
- { tab: 'Appearance', label: 'Appearance', icon: PaintBucketIcon },
+ { tab: 'Appearance', label: 'Appearance', icon: SwatchesIcon },
{ tab: 'Mobile App', label: 'Mobile App', icon: DeviceMobileIcon },
{ tab: 'Shortcuts', label: 'Shortcuts', icon: KeyboardIcon },
],
@@ -56,8 +54,11 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
label: 'Workspace',
items: [
{ tab: 'Team', label: 'Team', icon: UsersThreeIcon },
- { tab: 'Email', label: 'Email', icon: EnvelopeIcon },
- { tab: 'GitHub', label: 'GitHub', icon: GithubLogoIcon },
+ {
+ tab: 'Connected',
+ label: 'Connected accounts',
+ icon: CpuIcon,
+ },
{ tab: 'Agent', label: 'MCPs', icon: PlugIcon },
],
},
@@ -100,9 +101,7 @@ export const useSettingsTabAvailable = () => {
return true;
case 'Team':
return teamsFlag().enabled;
- case 'Email':
- return ENABLE_EMAIL;
- case 'GitHub':
+ case 'Connected':
return true;
case 'Shortcuts':
return !isTouchDevice();
diff --git a/js/app/packages/theme/components/ColorPickerPopover.tsx b/js/app/packages/theme/components/ColorPickerPopover.tsx
index e34af648d2..b281912dbd 100644
--- a/js/app/packages/theme/components/ColorPickerPopover.tsx
+++ b/js/app/packages/theme/components/ColorPickerPopover.tsx
@@ -1,73 +1,154 @@
import { Popover } from '@kobalte/core/popover';
+import { Slider } from '@kobalte/core/slider';
import { cn, Layer } from '@ui';
-import { batch, createEffect, createSignal, untrack } from 'solid-js';
+import {
+ batch,
+ createEffect,
+ createSignal,
+ type JSX,
+ onCleanup,
+ onMount,
+ Show,
+ untrack,
+} from 'solid-js';
import { convertOklchTo, getOklch, validateColor } from '../utils/colorUtil';
-import type { ThemeReactiveColor } from '../types/themeTypes';
import { ColorSwatch } from './ColorSwatch';
// Chroma axis maxes out at 0.37, matching the Basic editor's chroma slider.
const CHROMA_MAX = 0.37;
-/** One gradient-backed track + thumb + transparent range input, mirroring the
- * slider pattern in ThemeEditorBasic. The track gradient and thumb position are
- * reactive, so dragging any axis live-updates the preview of the others. */
-function Slider(props: {
- label: string;
- min: number;
- max: number;
- step: number;
- value: () => number;
- onValue: (n: number) => void;
- gradient: () => string;
- display: () => string;
+const RING =
+ 'pointer-events-none absolute size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_1px_3px_oklch(0_0_0/0.4)]';
+
+/** 2D field: chroma on X (0 → max), lightness on Y (top = light). Drag sets both. */
+function ColorField(props: {
+ l: () => number;
+ c: () => number;
+ h: () => number;
+ onL: (n: number) => void;
+ onC: (n: number) => void;
}) {
- const pct = () =>
- Math.max(0, Math.min(100, ((props.value() - props.min) / (props.max - props.min)) * 100));
+ let ref!: HTMLDivElement;
+ const [dragging, setDragging] = createSignal(false);
+
+ const apply = (e: PointerEvent) => {
+ const r = ref.getBoundingClientRect();
+ const x = Math.min(Math.max(e.clientX - r.left, 0), r.width) / r.width;
+ const y = Math.min(Math.max(e.clientY - r.top, 0), r.height) / r.height;
+ batch(() => {
+ props.onC(x * CHROMA_MAX);
+ props.onL(1 - y);
+ });
+ };
+
+ onMount(() => {
+ const move = (e: PointerEvent) => dragging() && apply(e);
+ const up = () => setDragging(false);
+ document.addEventListener('pointermove', move, { passive: true });
+ document.addEventListener('pointerup', up, { passive: true });
+ onCleanup(() => {
+ document.removeEventListener('pointermove', move);
+ document.removeEventListener('pointerup', up);
+ });
+ });
+
return (
- <div class="flex items-center gap-2">
- <div class="w-3 shrink-0 font-mono text-xs text-ink-muted">{props.label}</div>
- <div class="relative h-2.5 min-w-0 flex-1">
- <div
- class="absolute left-1/2 top-1/2 h-2.5 w-full -translate-x-1/2 -translate-y-1/2 rounded-sm border border-edge"
- style={{ background: props.gradient() }}
- />
- <div
- class="pointer-events-none absolute top-1/2 h-[18px] w-[7px] -translate-x-1/2 -translate-y-1/2 rounded-[1px] border border-edge bg-accent"
- style={{ left: `${pct()}%` }}
- />
- <input
- class="theme-color-picker-slider absolute -left-[9px] top-1/2 m-0 h-[18px] w-[calc(100%_+_18px)] -translate-y-1/2 cursor-pointer appearance-none bg-transparent outline-none"
- type="range"
- min={props.min}
- max={props.max}
- step={props.step}
- value={props.value().toString()}
- onInput={(e) => props.onValue(parseFloat(e.currentTarget.value))}
- />
- </div>
- <div class="w-10 shrink-0 text-right font-mono text-xs text-ink-muted">{props.display()}</div>
+ <div
+ ref={ref}
+ class="relative h-40 flex-1 cursor-crosshair touch-none rounded-md"
+ style={{
+ background: `linear-gradient(to bottom, transparent, oklch(0 0 ${props.h()}deg)), linear-gradient(to right, oklch(1 0 ${props.h()}deg), oklch(0.65 ${CHROMA_MAX} ${props.h()}deg))`,
+ }}
+ onPointerDown={(e) => {
+ setDragging(true);
+ apply(e);
+ }}
+ >
+ <div
+ class={RING}
+ style={{
+ left: `${(props.c() / CHROMA_MAX) * 100}%`,
+ top: `${(1 - props.l()) * 100}%`,
+ 'background-color': `oklch(${props.l()} ${props.c()} ${props.h()}deg)`,
+ }}
+ />
</div>
);
}
-/** Clickable swatch that opens a popover with L / C / H sliders and a hex field,
- * writing directly back into the reactive theme token. */
-export function ColorPickerPopover(props: { colorKey: string; colorValue: ThemeReactiveColor }) {
- const l = () => props.colorValue.l[0]();
- const c = () => props.colorValue.c[0]();
- const h = () => props.colorValue.h[0]();
- const oklch = () => `oklch(${l()} ${c()} ${h()}deg)`;
+// Vertical hue gradient, 0° at the top → 360° at the bottom. Pairs with the
+// slider's `inverted` flag so the thumb (value 0 at top) tracks the gradient.
+const HUE_GRADIENT =
+ 'linear-gradient(to bottom, oklch(0.7 0.2 0deg), oklch(0.7 0.2 60deg), oklch(0.7 0.2 120deg), oklch(0.7 0.2 180deg), oklch(0.7 0.2 240deg), oklch(0.7 0.2 300deg), oklch(0.7 0.2 360deg))';
+
+/** Vertical hue slider (0 → 360), backed by Kobalte's generic Slider so pointer
+ * dragging and keyboard control come for free; we only style the rail/thumb.
+ * `inverted` keeps 0° at the top (matching the prior hand-rolled slider). */
+function HueSlider(props: { h: () => number; onH: (n: number) => void }) {
+ return (
+ <Slider
+ class="relative flex h-40 w-3 shrink-0 touch-none select-none"
+ orientation="vertical"
+ inverted
+ minValue={0}
+ maxValue={360}
+ step={1}
+ value={[props.h()]}
+ onChange={(v) => props.onH(v[0] ?? 0)}
+ aria-label="Hue"
+ >
+ <Slider.Track
+ class="relative h-full w-full rounded-full"
+ style={{ background: HUE_GRADIENT }}
+ >
+ {/* Kobalte positions the thumb on the main (vertical) axis via `bottom` +
+ its own transform; we only center it horizontally and paint it. */}
+ <Slider.Thumb
+ class="absolute left-1/2 -ml-[7px] size-3.5 rounded-full border-2 border-white shadow-[0_1px_3px_oklch(0_0_0/0.4)] outline-none"
+ style={{ 'background-color': `oklch(0.7 0.2 ${props.h()}deg)` }}
+ >
+ <Slider.Input />
+ </Slider.Thumb>
+ </Slider.Track>
+ </Slider>
+ );
+}
+
+/**
+ * A clickable swatch that opens a color picker (2D chroma/lightness field + hue
+ * slider + hex field). Generic over how the color is read/written so it backs
+ * both the Variables tokens and the Basic editor's accent.
+ */
+export function ColorPickerPopover(props: {
+ l: () => number;
+ c: () => number;
+ h: () => number;
+ onL: (n: number) => void;
+ onC: (n: number) => void;
+ onH: (n: number) => void;
+ ariaLabel: string;
+ title?: string;
+ subtitle?: string;
+ /** Width passed to the default trigger swatch (full-width by default). */
+ triggerWidth?: string;
+ /** Custom trigger content (replaces the default swatch). */
+ trigger?: JSX.Element;
+}) {
+ const oklch = () => `oklch(${props.l()} ${props.c()} ${props.h()}deg)`;
- // Hex field keeps its own text state while typing so slider-driven updates
- // don't fight the user's keystrokes (same guard as ThemeEditorAdvanced).
+ // Hex field keeps its own text state while dragging so picker-driven updates
+ // don't fight the user's keystrokes.
const [hexText, setHexText] = createSignal('');
const [hexInvalid, setHexInvalid] = createSignal(false);
const [isSetByInput, setIsSetByInput] = createSignal(false);
createEffect(() => {
- const next = convertOklchTo(l(), c(), h(), 'hex');
- if (untrack(isSetByInput)) { setIsSetByInput(false); }
- else { setHexText(next); }
+ const next = convertOklchTo(props.l(), props.c(), props.h(), 'hex');
+ if (untrack(isSetByInput)) {
+ setIsSetByInput(false);
+ } else {
+ setHexText(next);
+ }
});
const setHex = (value: string) => {
@@ -79,9 +160,9 @@ export function ColorPickerPopover(props: { colorKey: string; colorValue: ThemeR
const next = getOklch(value);
batch(() => {
setIsSetByInput(true);
- props.colorValue.l[1](next.l || 0);
- props.colorValue.c[1](next.c || 0);
- props.colorValue.h[1](next.h || 0);
+ props.onL(next.l || 0);
+ props.onC(next.c || 0);
+ props.onH(next.h || 0);
});
setHexInvalid(false);
} catch (error) {
@@ -91,18 +172,19 @@ export function ColorPickerPopover(props: { colorKey: string; colorValue: ThemeR
};
return (
- <Popover placement="bottom-start" gutter={8}>
- <style>{`
- .theme-color-picker-slider { -webkit-appearance: none; }
- .theme-color-picker-slider::-webkit-slider-thumb { opacity: 0; }
- .theme-color-picker-slider::-moz-range-thumb { opacity: 0; }
- `}</style>
-
+ <Popover placement="bottom-end" gutter={8}>
<Popover.Trigger
- class="block w-full cursor-pointer appearance-none border-none bg-transparent p-0"
- aria-label={`Edit ${props.colorValue.description} (--${props.colorKey})`}
+ class="block cursor-pointer appearance-none border-none bg-transparent p-0"
+ aria-label={props.ariaLabel}
>
- <ColorSwatch color={oklch()} width="100%" />
+ <Show
+ when={props.trigger}
+ fallback={
+ <ColorSwatch color={oklch()} width={props.triggerWidth ?? '100%'} />
+ }
+ >
+ {props.trigger}
+ </Show>
</Popover.Trigger>
<Popover.Portal>
@@ -110,58 +192,42 @@ export function ColorPickerPopover(props: { colorKey: string; colorValue: ThemeR
<Popover.Content class="z-modal">
<Popover.Arrow class="fill-surface" />
<div
- class="flex w-64 flex-col gap-3 rounded-md bg-surface p-3 shadow-lg ring-1 ring-edge"
+ class="flex w-64 flex-col gap-3 rounded-xl bg-surface p-3 shadow-lg ring-1 ring-edge-muted"
role="dialog"
- aria-label={`Edit color --${props.colorKey}`}
+ aria-label={props.ariaLabel}
>
- <div class="flex items-center gap-2">
- <div
- class="h-8 w-8 shrink-0 rounded border border-edge"
- style={{ 'background-color': oklch() }}
- />
- <div class="min-w-0">
- <div class="truncate text-xs text-ink">{props.colorValue.description}</div>
- <div class="font-mono text-[0.67rem] text-ink-extra-muted">--{props.colorKey}</div>
+ <Show when={props.title}>
+ <div class="flex items-center gap-2">
+ <div
+ class="size-8 shrink-0 rounded border border-ink/[0.08]"
+ style={{ 'background-color': oklch() }}
+ />
+ <div class="min-w-0">
+ <div class="truncate text-xs text-ink">{props.title}</div>
+ <Show when={props.subtitle}>
+ <div class="font-mono text-[0.67rem] text-ink-extra-muted">
+ {props.subtitle}
+ </div>
+ </Show>
+ </div>
</div>
- </div>
+ </Show>
- <Slider
- label="L"
- min={0}
- max={1}
- step={0.01}
- value={l}
- onValue={(n) => props.colorValue.l[1](n)}
- gradient={() => `linear-gradient(to right, oklch(0 ${c()} ${h()}deg), oklch(1 ${c()} ${h()}deg))`}
- display={() => l().toFixed(2)}
- />
- <Slider
- label="C"
- min={0}
- max={CHROMA_MAX}
- step={0.005}
- value={c}
- onValue={(n) => props.colorValue.c[1](n)}
- gradient={() => `linear-gradient(to right, oklch(${l()} 0 ${h()}deg), oklch(${l()} ${CHROMA_MAX} ${h()}deg))`}
- display={() => c().toFixed(3)}
- />
- <Slider
- label="H"
- min={0}
- max={360}
- step={1}
- value={h}
- onValue={(n) => props.colorValue.h[1](n)}
- gradient={() =>
- `linear-gradient(to right, oklch(${l()} ${c()} 0deg), oklch(${l()} ${c()} 60deg), oklch(${l()} ${c()} 120deg), oklch(${l()} ${c()} 180deg), oklch(${l()} ${c()} 240deg), oklch(${l()} ${c()} 300deg), oklch(${l()} ${c()} 360deg))`
- }
- display={() => `${Math.round(h())}°`}
- />
+ <div class="flex gap-3">
+ <ColorField
+ l={props.l}
+ c={props.c}
+ h={props.h}
+ onL={props.onL}
+ onC={props.onC}
+ />
+ <HueSlider h={props.h} onH={props.onH} />
+ </div>
<input
class={cn(
- 'rounded border border-edge-muted bg-transparent px-2 py-1 font-mono text-xs text-ink outline-none',
- hexInvalid() && 'text-accent'
+ 'rounded-md border border-edge-muted bg-transparent px-2 py-1 font-mono text-xs text-ink outline-none focus:border-accent',
+ hexInvalid() && 'border-failure text-failure'
)}
value={hexText()}
onInput={(e) => setHex(e.currentTarget.value)}
diff --git a/js/app/packages/theme/components/ThemeChipPill.tsx b/js/app/packages/theme/components/ThemeChipPill.tsx
index 4b423971c5..921df886cb 100644
--- a/js/app/packages/theme/components/ThemeChipPill.tsx
+++ b/js/app/packages/theme/components/ThemeChipPill.tsx
@@ -14,11 +14,9 @@ type ThemeChipPillProps = {
} & ComponentProps<'button'>;
/**
- * A theme swatch + name inside a bordered, rounded-md pill: the swatch sits flush
- * on the left (its own border stripped, inner corners rounded-[5px]) and fills the
- * pill height. Polymorphic via `as` so the same pill can be a plain button (the
- * theme mention chip) or a dropdown trigger (the preferred-theme picker in
- * settings/Appearance) and stay visually identical.
+ * A theme swatch + name, outline-free. Polymorphic via `as` so the same chip can
+ * be a plain button (the theme mention chip) or a dropdown trigger (the theme
+ * pickers in settings/Appearance) and stay visually identical.
*/
export function ThemeChipPill(props: ThemeChipPillProps) {
const [local, rest] = splitProps(props, ['as', 'theme', 'name', 'class']);
@@ -26,19 +24,19 @@ export function ThemeChipPill(props: ThemeChipPillProps) {
<Dynamic
component={local.as ?? 'button'}
class={cn(
- 'inline-flex items-stretch gap-0.75 overflow-hidden rounded-md border border-edge-muted bg-transparent py-0 pl-0 pr-1',
+ 'inline-flex items-center gap-1.5 overflow-hidden rounded-md bg-transparent p-0',
local.class
)}
{...rest}
>
<Show when={local.theme}>
{(theme) => (
- <span class="inline-flex self-stretch rounded-md [&>span]:h-full [&>span]:rounded-[5px] [&>span]:border-0">
+ <span class="inline-flex shrink-0">
<ThemeChips theme={theme()} size="sm" />
</span>
)}
</Show>
- <span class="mx-0.5 flex items-center cursor-default">{local.name}</span>
+ <span class="flex items-center cursor-default">{local.name}</span>
</Dynamic>
);
}
diff --git a/js/app/packages/theme/components/ThemeChips.tsx b/js/app/packages/theme/components/ThemeChips.tsx
index 8983d06f59..3afb66a933 100644
--- a/js/app/packages/theme/components/ThemeChips.tsx
+++ b/js/app/packages/theme/components/ThemeChips.tsx
@@ -1,5 +1,5 @@
import type { ThemeV2 } from '@theme/types/themeTypes';
-import IconTextA from '@phosphor-icons/core/regular/text-a-underline.svg?component-solid';
+import IconTextA from '@phosphor-icons/core/regular/text-aa.svg?component-solid';
import { cn } from '@ui';
type Token = { l: number; c: number; h: number };
@@ -14,14 +14,14 @@ const sizeStyles: Record<
}
> = {
md: {
- root: 'gap-2 p-2 rounded-sm',
- accent: 'size-[13px]',
- icon: 'size-[18px]',
+ root: 'gap-2 px-2 py-2.5 rounded-xl',
+ accent: 'size-[9px]',
+ icon: 'size-[21px]',
},
sm: {
- root: 'gap-1 py-[3px] px-[5px] rounded-sm',
- accent: 'size-[9px]',
- icon: 'size-3',
+ root: 'gap-1 py-[5px] px-[5px] rounded-lg',
+ accent: 'size-[6px]',
+ icon: 'size-[15px]',
},
};
@@ -62,7 +62,7 @@ export function ThemeChips(props: { theme: ThemeV2; size?: ThemeChipsSize }) {
}}
>
<span
- class={cn('inline-block rounded-xs', styles().accent)}
+ class={cn('inline-block rounded-sm', styles().accent)}
style={{
'background-color': accent(),
}}
diff --git a/js/app/packages/theme/components/ThemeEditorAdvanced.tsx b/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
index a87438c51e..0cea0dc91c 100644
--- a/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
+++ b/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
@@ -47,7 +47,7 @@ export function ThemeEditorAdvanced(){
>
<div
style="
- background-color: var(--b3);
+ background-color: oklch(from var(--c0) l c h / 0.06);
box-sizing: border-box;
overflow-x: hidden;
display: grid;
@@ -82,7 +82,7 @@ export function ThemeEditorAdvanced(){
<div
style="
grid-template-columns: 104px calc(7ch + 40px) 1fr calc(4ch + 40px);
- background-color: var(--b3);
+ background-color: oklch(from var(--c0) l c h / 0.06);
align-items: center;
display: grid;
height: 61px;
@@ -100,7 +100,17 @@ export function ThemeEditorAdvanced(){
width: 100%;
"
>
- <ColorPickerPopover colorKey={colorKey} colorValue={colorValue} />
+ <ColorPickerPopover
+ l={() => colorValue.l[0]()}
+ c={() => colorValue.c[0]()}
+ h={() => colorValue.h[0]()}
+ onL={(n) => colorValue.l[1](n)}
+ onC={(n) => colorValue.c[1](n)}
+ onH={(n) => colorValue.h[1](n)}
+ title={colorValue.description}
+ subtitle={`--${colorKey}`}
+ ariaLabel={`Edit ${colorValue.description} (--${colorKey})`}
+ />
</div>
<div
diff --git a/js/app/packages/theme/components/ThemeEditorBasic.tsx b/js/app/packages/theme/components/ThemeEditorBasic.tsx
index 112bf65d8f..706f9edebf 100644
--- a/js/app/packages/theme/components/ThemeEditorBasic.tsx
+++ b/js/app/packages/theme/components/ThemeEditorBasic.tsx
@@ -1,9 +1,8 @@
-import { batch, createEffect, createSignal, type JSX, onCleanup, onMount, untrack } from 'solid-js';
+import { batch, createEffect, createSignal, type JSX, untrack } from 'solid-js';
import { setThemeDepth, themeDepth } from '../signals/themeSignals';
import { themeReactive } from '../signals/themeReactive';
-import { flipLightDark } from '../utils/themeUtils';
-import { isMobile } from '@core/mobile/isMobile';
-import IconFlip from '@phosphor-icons/core/regular/circle-half-tilt.svg?component-solid';
+import { convertOklchTo, getOklch, validateColor } from '../utils/colorUtil';
+import { ColorPickerPopover } from './ColorPickerPopover';
function setLightness(lightness: number) {
batch(() => {
@@ -114,11 +113,9 @@ export function randomizeTheme(){
});
}
-/** Numeric value box shown to the right of each slider. Displays/edits the value
- * on a display scale (default 0-100) mapped from the control's internal range.
- * Pass displayMin/displayMax for a centered scale, e.g. -100..100 for Contrast.
- * Keeps its own text state while typing (mirroring ThemeEditorAdvanced) so
- * reactive updates from the slider don't fight the user's input. */
+/** Numeric value box shown to the right of each slider, on a display scale
+ * (default 0-100). Pass displayMin/displayMax for a centered scale (e.g.
+ * -100..100 for Contrast). Keeps its own text state while typing. */
function NumberInput(props: {
get: () => number;
set: (n: number) => void;
@@ -126,7 +123,6 @@ function NumberInput(props: {
max: number;
displayMin?: number;
displayMax?: number;
- action?: JSX.Element;
}) {
const dMin = () => props.displayMin ?? 0;
const dMax = () => props.displayMax ?? 100;
@@ -145,21 +141,19 @@ function NumberInput(props: {
});
return (
- <div style="display: flex; align-items: center; gap: 4px; flex: none;">
- <div
- style="
- background-color: var(--b1);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- align-items: center;
- border-radius: 4px;
- padding: 3px 6px;
- display: flex;
- width: 8ch;
- gap: 3px;
- "
- >
- {props.action}
+ <div
+ style="
+ background-color: oklch(from var(--c0) l c h / 0.05);
+ box-sizing: border-box;
+ align-items: center;
+ border-radius: 6px;
+ padding: 3px 6px;
+ display: flex;
+ gap: 1px;
+ flex: none;
+ width: 6ch;
+ "
+ >
<input
class="theme-editor-basic-num"
type="number"
@@ -189,211 +183,180 @@ function NumberInput(props: {
flex: 1;
"
/>
- </div>
- <span style="color: var(--c2); font-size: 12px;">%</span>
+ <span style="color: var(--c2); font-size: 12px; flex: none;">%</span>
</div>
);
}
-export function ThemeEditorBasic(){
- const [canvasThumbDrag, setCanvasThumbDrag] = createSignal(false);
-
- let sliderSaturationRef!: HTMLInputElement;
- let sliderContrastRef!: HTMLInputElement;
- let sliderDepthRef!: HTMLInputElement;
- let chromaLocation: WebGLUniformLocation;
- let canvasContainerRef!: HTMLDivElement;
- let canvasThumbRef!: HTMLDivElement;
- let canvasRef!: HTMLCanvasElement;
- let gl: WebGL2RenderingContext;
- let program: WebGLProgram;
- let gridXLocation: WebGLUniformLocation;
- let gridYLocation: WebGLUniformLocation;
- let resizeObserver: ResizeObserver;
-
- function setupWebGL(){
- const context = canvasRef.getContext('webgl2', {colorSpace: 'display-p3'});
- if(!context || !(context instanceof WebGL2RenderingContext)){throw new Error('WebGL2 not supported')}
- gl = context;
- gl.viewport(0, 0, canvasRef.width, canvasRef.height);
- program = gl.createProgram()!;
-
- const vertBuffer = gl.createBuffer();
- const verts = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);
- gl.bindBuffer(gl.ARRAY_BUFFER, vertBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, verts, gl.STATIC_DRAW);
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
- gl.enableVertexAttribArray(0);
-
- const vertexShader = gl.createShader(gl.VERTEX_SHADER)!;
- const vertexShaderSource = `#version 300 es
- in vec2 position;
- out vec2 vUV;
- void main(){
- gl_Position = vec4(position, 0.0, 1.0);
- vUV = (position + 1.0) * 0.5;
- }
- `;
- gl.shaderSource(vertexShader, vertexShaderSource);
- gl.compileShader(vertexShader);
- gl.attachShader(program, vertexShader);
-
- const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER)!;
- const fragmentShaderSource = `#version 300 es
- precision mediump float;
- in vec2 vUV;
- out vec4 fragColor;
- uniform float chroma;
- uniform float gridX;
- uniform float gridY;
- const float PI = 3.14159265359;
- const float radius = 0.135;
-
- vec3 OKLCH_to_OKLab(float L, float C, float h){
- return vec3(
- L,
- C * cos(h * PI / 180.0),
- C * sin(h * PI / 180.0)
- );
- }
-
- vec3 OKLab_to_linear_sRGB(vec3 lab){
- float l = pow(lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z, 3.0);
- float m = pow(lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z, 3.0);
- float s = pow(lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z, 3.0);
- return vec3(
- +4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
- -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
- -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s
- );
- }
-
- vec3 linear_to_sRGB(vec3 rgb){
- return mix(1.055 * pow(rgb, vec3(1.0/2.4)) - 0.055, 12.92 * rgb, lessThanEqual(rgb, vec3(0.0031308)));
- }
-
- void main(){
- float L = vUV.y;
- float C = chroma;
- float h = vUV.x * 360.0;
- vec3 lab = OKLCH_to_OKLab(L, C, h);
- vec3 rgb_linear = OKLab_to_linear_sRGB(lab);
- vec3 rgb = linear_to_sRGB(rgb_linear);
-
- /* DOT GRID */
- float smoothing = gridY * 0.0013;
- float offsetX = fract(gridX) * 0.5 / gridX;
- float offsetY = fract(gridY) * 0.5 / gridY;
- vec2 centeredUV = vUV - vec2(offsetX, offsetY);
- float dist = 1.0 - smoothstep(
- radius - smoothing,
- radius + smoothing,
- distance(vec2(mod(centeredUV.x * gridX, 1.0), mod(centeredUV.y * gridY, 1.0)), vec2(0.5))
- );
-
- fragColor = vec4(rgb * dist, dist);
- }
- `;
-
- gl.shaderSource(fragmentShader, fragmentShaderSource);
- gl.compileShader(fragmentShader);
- gl.attachShader(program, fragmentShader);
-
- gl.linkProgram(program);
- gl.useProgram(program);
-
- chromaLocation = gl.getUniformLocation(program, 'chroma')!;
- gridXLocation = gl.getUniformLocation(program, 'gridX')!;
- gridYLocation = gl.getUniformLocation(program, 'gridY')!;
- }
-
- function setCanvasColor(e: PointerEvent){
- const rect = canvasContainerRef.getBoundingClientRect();
- const x =
- Math.min(Math.max(e.clientX - rect.left, 0), rect.width) / rect.width;
- const y =
- Math.min(Math.max(e.clientY - rect.top, 0), rect.height) / rect.height;
- batch(() => {
- setLightness(1 - y);
- setHue(x * 360);
- });
- }
-
- function handleCanvasPointerDown(e: PointerEvent){
- setCanvasThumbDrag(true);
- setCanvasColor(e);
- }
-
- function handlePointerMove(e: PointerEvent){
- if(canvasThumbDrag()){
- setCanvasColor(e);
+/** Accent control: a clickable circle swatch (opens the color picker) beside a
+ * validated, editable hex field. Both read/write the same accent color. */
+function AccentControl(props: {
+ l: () => number;
+ c: () => number;
+ h: () => number;
+ onL: (n: number) => void;
+ onC: (n: number) => void;
+ onH: (n: number) => void;
+}) {
+ const [hexText, setHexText] = createSignal('');
+ const [invalid, setInvalid] = createSignal(false);
+ const [bySelf, setBySelf] = createSignal(false);
+
+ createEffect(() => {
+ const next = convertOklchTo(props.l(), props.c(), props.h(), 'hex');
+ if (untrack(bySelf)) {
+ setBySelf(false);
+ } else {
+ setHexText(next);
}
- }
-
- function handlePointerUp(){
- setCanvasThumbDrag(false);
- }
-
- function handleChromaChange(e: Event){
- const value = Math.max(0.0, Math.min(0.37, parseFloat((e.target as HTMLInputElement).value)));
- setChroma(
- value,
- parseFloat(sliderSaturationRef.value)
- );
- }
-
- function handleSaturationChange(e: Event){
- const value = Math.max(0.0, Math.min(1.0, parseFloat((e.target as HTMLInputElement).value)));
- setSaturation(value);
- }
-
- function handleContrastChange(e: Event){
- const value = Math.max(0.0, Math.min(0.8, parseFloat((e.target as HTMLInputElement).value)));
- setContrast(value);
- }
-
- function handleDepthChange(e: Event){
- const value = Math.max(0.0, Math.min(0.4, parseFloat((e.target as HTMLInputElement).value)));
- setThemeDepth(value);
- }
-
- onMount(() => {
- setupWebGL();
-
- function updateCanvasSize(){
- const rect = canvasContainerRef.getBoundingClientRect();
- canvasRef.width = rect.width * devicePixelRatio;
- canvasRef.height = rect.height * devicePixelRatio;
- gl.viewport(0, 0, canvasRef.width, canvasRef.height);
- gl.uniform1f(gridXLocation, rect.width / 8.3);
- gl.uniform1f(gridYLocation, rect.height / 8.3);
- gl.uniform1f(chromaLocation, themeReactive.a0.c[0]());
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+ });
+
+ const apply = (value: string) => {
+ setBySelf(true);
+ setHexText(value);
+ if (!value || value.trim().length < 6 || !validateColor(value)) {
+ setInvalid(true);
+ return;
}
+ try {
+ const next = getOklch(value);
+ batch(() => {
+ props.onL(next.l || 0);
+ props.onC(next.c || 0);
+ props.onH(next.h || 0);
+ });
+ setInvalid(false);
+ } catch {
+ setInvalid(true);
+ }
+ };
- resizeObserver = new ResizeObserver(updateCanvasSize);
- resizeObserver.observe(canvasContainerRef);
- updateCanvasSize();
+ return (
+ <>
+ <ColorPickerPopover
+ l={props.l}
+ c={props.c}
+ h={props.h}
+ onL={props.onL}
+ onC={props.onC}
+ onH={props.onH}
+ ariaLabel="Edit accent color"
+ trigger={
+ <div
+ class="size-6 rounded-full border border-ink/[0.15]"
+ style={{
+ 'background-color': `oklch(${props.l()} ${props.c()} ${props.h()}deg)`,
+ }}
+ />
+ }
+ />
+ <input
+ type="text"
+ value={hexText()}
+ onInput={(e) => apply(e.currentTarget.value)}
+ spellcheck={false}
+ aria-label="Accent hex color"
+ class="w-[11ch] rounded-md bg-ink/5 px-2 py-1 text-right font-mono text-xs uppercase text-ink outline-none focus:bg-ink/8"
+ classList={{ 'text-failure': invalid() }}
+ />
+ </>
+ );
+}
+
+/** A stacked row: label on the left, control(s) right-aligned. The control
+ * cluster is capped (~half the row on wide layouts) so sliders don't run all
+ * the way back to the label. */
+function Control(props: { label: string; children: JSX.Element }) {
+ return (
+ <div class="flex min-h-10 items-center gap-3">
+ <div class="w-[8ch] shrink-0 text-ink-muted">{props.label}</div>
+ <div class="flex-1" />
+ <div class="flex w-1/2 min-w-0 max-w-72 items-center justify-end gap-2.5">
+ {props.children}
+ </div>
+ </div>
+ );
+}
+
+/** A simple, borderless slider: a rounded neutral track, an accent fill up to
+ * the value, and a round thumb. `fraction` (0..1) positions the thumb/fill;
+ * `value` drives the underlying range input on its own min/max scale. */
+function BasicSlider(props: {
+ fraction: number;
+ onInput: (e: Event) => void;
+ min: number;
+ max: number;
+ step?: number;
+ value?: string;
+}) {
+ const f = () => {
+ const v = props.fraction;
+ return Number.isFinite(v) ? Math.max(0, Math.min(1, v)) : 0;
+ };
+ return (
+ <div style="position:relative;height:16px;flex:1;min-width:0;">
+ {/* track */}
+ <div style="position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);height:4px;border-radius:999px;background:oklch(from var(--c0) l c h / 0.1);" />
+ {/* filled portion — muted ink */}
+ <div
+ style={{
+ position: 'absolute',
+ left: '0',
+ top: '50%',
+ transform: 'translateY(-50%)',
+ height: '4px',
+ 'border-radius': '999px',
+ background: 'oklch(from var(--c0) l c h / 0.25)',
+ width: `${f() * 100}%`,
+ }}
+ />
+ {/* thumb — ink */}
+ <div
+ style={{
+ position: 'absolute',
+ top: '50%',
+ left: `${f() * 100}%`,
+ transform: 'translate(-50%, -50%)',
+ width: '16px',
+ height: '16px',
+ 'border-radius': '50%',
+ 'background-color': 'var(--c0)',
+ 'box-shadow': '0 1px 2px oklch(0 0 0 / 0.25)',
+ }}
+ />
+ <input
+ class="theme-editor-basic-slider"
+ type="range"
+ min={props.min}
+ max={props.max}
+ step={props.step ?? 0.001}
+ value={props.value}
+ onInput={props.onInput}
+ style="appearance:none;-webkit-appearance:none;position:absolute;inset:0;width:100%;height:100%;margin:0;background:#0000;outline:none;cursor:pointer;"
+ />
+ </div>
+ );
+}
- createEffect(() => {
- gl.uniform1f(chromaLocation, themeReactive.a0.c[0]());
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
- });
+export function ThemeEditorBasic(){
+ const a0 = themeReactive.a0;
- createEffect(() => {
- canvasThumbRef.style.left = `${themeReactive.a0.h[0]() / 3.6}%`;
- canvasThumbRef.style.top = `${(1 - themeReactive.a0.l[0]()) * 100}%`;
- });
+ // Saturation is stored as a fraction of the accent's chroma; recover it so
+ // accent-chroma edits keep the same tint ratio.
+ const satFraction = () => {
+ const denom = a0.c[0]() * 0.37 * 0.6;
+ return denom ? themeReactive.b0.c[0]() / denom : 0;
+ };
- document.addEventListener('pointermove', handlePointerMove, {passive: true});
- document.addEventListener('pointerup', handlePointerUp, {passive: true});
- });
+ const clamp = (n: number, min: number, max: number) =>
+ Math.max(min, Math.min(max, n));
- onCleanup(() => {
- resizeObserver.disconnect();
- document.removeEventListener('pointermove', handlePointerMove);
- document.removeEventListener('pointerup', handlePointerUp);
- });
+ const handleSaturationChange = (e: Event) =>
+ setSaturation(clamp(parseFloat((e.target as HTMLInputElement).value), 0, 1));
+ const handleContrastChange = (e: Event) =>
+ setContrast(clamp(parseFloat((e.target as HTMLInputElement).value), 0, 0.8));
+ const handleDepthChange = (e: Event) =>
+ setThemeDepth(clamp(parseFloat((e.target as HTMLInputElement).value), 0, 0.4));
return (
<>
@@ -415,10 +378,9 @@ export function ThemeEditorBasic(){
`}</style>
<div
- class="@container"
style="
font-family: var(--font-sans);
- padding: 8px 20px 12px 20px;
+ padding: 10px 16px 12px 16px;
background-color: var(--b0);
box-sizing: border-box;
height: min-content;
@@ -426,424 +388,56 @@ export function ThemeEditorBasic(){
font-size: 12px;
"
>
- <div class="grid gap-5 @2xl:grid-cols-2 @2xl:items-start">
- <div
- onPointerDown={handleCanvasPointerDown}
- ref={canvasContainerRef}
- class={isMobile() ? 'h-[140px]' : 'h-[250px]'}
- style={{
- 'border': '1px solid var(--b4)',
- 'border-radius': '6px',
- 'position': 'relative',
- 'width': '100%',
- }}
- >
- <canvas
- style="
- background-color: #000c; /* scuffed */
- border-radius: 5px;
- touch-action: none;
- user-select: none;
- display: block;
- height: 100%;
- width: 100%;
- "
- ref={canvasRef}
- />
- <div
- style="
- transform: translate(-50%, -50%);
- background-color: var(--a0);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- height: 18px;
- width: 18px;
- "
- ref={canvasThumbRef}
- />
- </div>
-
- <div
- class="grid h-min w-full gap-3 @2xl:gap-5"
- style="
- --b4: color-mix(in oklch, oklch(var(--b4l) var(--b4c) var(--b4h)), oklch(var(--c4l) var(--c4c) var(--c4h)) 30%);
- "
- >
- <div class="flex items-center gap-2 @2xl:flex-col @2xl:items-stretch @2xl:gap-[3px]">
- <div class="w-[9ch] shrink-0 @2xl:w-auto">Chroma</div>
- <div class="flex flex-1 items-center gap-3 min-w-0 @2xl:flex-none">
- <div
- style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- min-width: 0;
- flex: 1;
- "
- >
- <div
- style="
- background: linear-gradient(to right, oklch(from var(--a0) l 0.0 h), oklch(from var(--a0) l 0.37 h));
- transform: translate(-50%, -50%);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- "
+ <div class="flex flex-col divide-y divide-ink/[0.05]">
+ <Control label="Accent">
+ <AccentControl
+ l={() => a0.l[0]()}
+ c={() => a0.c[0]()}
+ h={() => a0.h[0]()}
+ onL={(n) => setLightness(n)}
+ onC={(n) => setChroma(n, satFraction())}
+ onH={(n) => setHue(n)}
/>
-
- <div
- style={{
- 'left': `${themeReactive.a0.c[0]() * (100 / 0.37)}%`,
- 'transform': 'translate(-50%, -50%)',
- 'background-color': 'var(--a0)',
- 'border': '1px solid var(--b4)',
- 'box-sizing': 'border-box',
- 'border-radius': '2px',
- 'position': 'absolute',
- 'height': '18px',
- 'width': '9px',
- 'top': '50%',
- }}
+ </Control>
+
+ <Control label="Tint">
+ <BasicSlider
+ fraction={satFraction()}
+ value={satFraction().toString()}
+ onInput={handleSaturationChange}
+ min={0}
+ max={1}
/>
-
- <input
- onInput={(e) => { handleChromaChange(e);}}
- value={themeReactive.a0.c[0]().toString()}
- class="theme-editor-basic-slider"
- style="
- appearance: none;
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- background: #0000;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
- step="0.001"
- type="range"
- max="0.37"
- min="0.0"
+ <NumberInput get={satFraction} set={setSaturation} min={0} max={1} />
+ </Control>
+
+ <Control label="Lightness">
+ <BasicSlider
+ fraction={getContrastFromY(themeReactive.b0.l[0]()) / 0.8}
+ value={getContrastFromY(themeReactive.b0.l[0]()).toString()}
+ onInput={handleContrastChange}
+ min={0}
+ max={0.8}
/>
- </div>
- <NumberInput
- get={() => themeReactive.a0.c[0]()}
- set={(n) => setChroma(n, parseFloat(sliderSaturationRef.value))}
- min={0}
- max={0.37}
- />
- </div>
- </div>
-
- <div class="flex items-center gap-2 @2xl:flex-col @2xl:items-stretch @2xl:gap-[3px]">
- <div class="w-[9ch] shrink-0 @2xl:w-auto">Tint</div>
- <div class="flex flex-1 items-center gap-3 min-w-0 @2xl:flex-none">
- <div
- style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- min-width: 0;
- flex: 1;
- "
- >
- <div
- style="
- grid-template-columns: 50fr 40.5fr 32fr 24.5fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
- transform: translate(-50%, -50%);
- background-color: var(--b4);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- overflow: clip;
- display: grid;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- gap: 1px;
- "
- >
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- </div>
-
- <div
- style={{
- 'left': `${(themeReactive.b0.c[0]() / (themeReactive.a0.c[0]() * 0.6) / 0.37) * 100}%`,
- 'transform': 'translate(-50%, -50%)',
- 'border': '1px solid var(--b4)',
- 'background-color': 'var(--b0)',
- 'box-sizing': 'border-box',
- 'border-radius': '2px',
- 'position': 'absolute',
- 'height': '18px',
- 'width': '9px',
- 'top': '50%',
- }}
+ <NumberInput
+ get={() => getContrastFromY(themeReactive.b0.l[0]())}
+ set={setContrast}
+ min={0}
+ max={0.8}
/>
-
- <input
- onInput={(e) => {handleSaturationChange(e);}}
- class="theme-editor-basic-slider"
- style="
- appearance: none;
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- background: #0000;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
- ref={sliderSaturationRef}
- step="0.001"
- type="range"
- value="0"
- max="1.0"
- min="0.0"
+ </Control>
+
+ <Control label="Contrast">
+ <BasicSlider
+ fraction={themeDepth() / 0.4}
+ value={themeDepth().toString()}
+ onInput={handleDepthChange}
+ min={0}
+ max={0.4}
/>
- </div>
- <NumberInput
- get={() => {
- const denom = themeReactive.a0.c[0]() * 0.37 * 0.6;
- return denom ? themeReactive.b0.c[0]() / denom : 0;
- }}
- set={(n) => setSaturation(n)}
- min={0}
- max={1}
- />
- </div>
- </div>
-
- <div class="flex items-center gap-2 @2xl:flex-col @2xl:items-stretch @2xl:gap-[3px]">
- <div class="w-[9ch] shrink-0 @2xl:w-auto">Contrast</div>
- <div class="flex flex-1 items-center gap-3 min-w-0 @2xl:flex-none">
- <div
- style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- min-width: 0;
- flex: 1;
- "
- >
- <div
- style="
- grid-template-columns: 0.5fr 2fr 5fr 8fr 12.5fr 18fr 50fr 50fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
- transform: translate(-50%, -50%);
- background-color: var(--b4);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- overflow: clip;
- display: grid;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- gap: 1px;
- "
- >
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- </div>
-
- <div
- style={{
- 'left': `${(getContrastFromY(themeReactive.b0.l[0]()) / 0.8) * 100}%`,
- 'transform': 'translate(-50%, -50%)',
- 'background-color': 'var(--b0)',
- 'border': '1px solid var(--b4)',
- 'box-sizing': 'border-box',
- 'border-radius': '2px',
- 'position': 'absolute',
- 'height': '18px',
- 'width': '9px',
- 'top': '50%',
- }}
- />
-
- <input
- onInput={(e) => {
- handleContrastChange(e);
- }}
- class="theme-editor-basic-slider"
- style="
- appearance: none;
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- background: #0000;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
- ref={sliderContrastRef}
- type="range"
- step="0.001"
- value="0"
- max="0.8"
- min="0.0"
- />
- </div>
- <NumberInput
- get={() => getContrastFromY(themeReactive.b0.l[0]())}
- set={(n) => setContrast(n)}
- min={0}
- max={0.8}
- displayMin={-100}
- displayMax={100}
- action={
- <button
- type="button"
- aria-label="Flip light / dark"
- onPointerDown={flipLightDark}
- class="flex shrink-0 cursor-pointer items-center justify-center text-ink-muted hover:text-ink"
- style="width: 14px; height: 14px; padding: 0; border: none; background: none;"
- >
- <IconFlip style={{ width: '14px', height: '14px' }} />
- </button>
- }
- />
- </div>
- </div>
-
- <div class="flex items-center gap-2 @2xl:flex-col @2xl:items-stretch @2xl:gap-[3px]">
- <div class="w-[9ch] shrink-0 @2xl:w-auto">Depth</div>
- <div class="flex flex-1 items-center gap-3 min-w-0 @2xl:flex-none">
- <div
- style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- min-width: 0;
- flex: 1;
- "
- >
- <div
- style="
- grid-template-columns: 50fr 40.5fr 32fr 24.5fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
- transform: translate(-50%, -50%);
- background-color: var(--b4);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- overflow: clip;
- display: grid;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- gap: 1px;
- "
- >
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- <div style="background-color: var(--b0); height: 100%; width: 100%;" />
- </div>
-
- <div
- style={{
- 'left': `${(themeDepth() / 0.4) * 100}%`,
- 'transform': 'translate(-50%, -50%)',
- 'background-color': 'var(--b0)',
- 'border': '1px solid var(--b4)',
- 'box-sizing': 'border-box',
- 'border-radius': '2px',
- 'position': 'absolute',
- 'height': '18px',
- 'width': '9px',
- 'top': '50%',
- }}
- />
-
- <input
- onInput={(e) => {
- handleDepthChange(e);
- }}
- class="theme-editor-basic-slider"
- style="
- appearance: none;
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 2px;
- position: absolute;
- background: #0000;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
- value={themeDepth()}
- ref={sliderDepthRef}
- type="range"
- step="0.001"
- max="0.4"
- min="0.0"
- />
- </div>
- <NumberInput
- get={() => themeDepth()}
- set={(n) => setThemeDepth(n)}
- min={0}
- max={0.4}
- />
- </div>
- </div>
+ <NumberInput get={themeDepth} set={setThemeDepth} min={0} max={0.4} />
+ </Control>
</div>
- </div>
</div>
</>
);
diff --git a/js/app/packages/theme/components/ThemeTools.tsx b/js/app/packages/theme/components/ThemeTools.tsx
index e27b509869..db0649b8f2 100644
--- a/js/app/packages/theme/components/ThemeTools.tsx
+++ b/js/app/packages/theme/components/ThemeTools.tsx
@@ -1,21 +1,44 @@
import { currentThemeId, isThemeSaved, themes } from '../signals/themeSignals';
-import { saveTheme } from '../utils/themeUtils';
+import { saveTheme, updateTheme } from '../utils/themeUtils';
import IconSave from '@phosphor-icons/core/regular/floppy-disk-back.svg?component-solid';
+import IconShuffle from '@phosphor-icons/core/regular/shuffle.svg?component-solid';
import { isMobile } from '@core/mobile/isMobile';
import { createMemo, Show } from 'solid-js';
import { Button, cn } from '@ui';
-function ThemeTools(props: { class?: string }) {
+function ThemeTools(props: {
+ class?: string;
+ editingThemeId?: string;
+ onRandomize?: () => void;
+}) {
let themeName!: HTMLDivElement;
const defaultThemeName = 'New Theme';
+ const editingTheme = () =>
+ props.editingThemeId
+ ? themes().find((theme) => theme.id === props.editingThemeId)
+ : undefined;
+
const currentThemeName = createMemo(() => {
+ // While editing a custom theme, keep its name (even with unsaved edits).
+ const editing = editingTheme();
+ if (editing) return editing.name;
const theme = themes().find((theme) => theme.id === currentThemeId());
if(isThemeSaved()){return theme?.name}
else{return defaultThemeName}
});
+ // Editing an existing custom theme writes back to it; otherwise save a new one.
+ const commit = (rawName: string) => {
+ const name = rawName.trim() || editingTheme()?.name || defaultThemeName;
+ if (props.editingThemeId) {
+ updateTheme(props.editingThemeId, name);
+ } else {
+ saveTheme(name);
+ }
+ };
+
return (
<div
class={cn('flex items-center overflow-hidden w-full min-w-0', props.class)}
@@ -27,41 +50,26 @@ function ThemeTools(props: { class?: string }) {
'height': '39.5px',
}}
>
- <div style={{ flex: 1 }}/>
-
- <Show when={!isThemeSaved()}>
- <Button
- onPointerDown={() => {
- saveTheme(themeName.innerText);
- }}
- label="Save Theme"
- variant="ghost"
- size="icon-sm"
- >
- <IconSave />
- </Button>
- </Show>
-
<div
onKeyDown={(e) => {
if(e.key === 'Enter'){
e.preventDefault();
const name = themeName.innerText.trim();
if(name){
- saveTheme(name);
+ commit(name);
themeName.blur();
}
- else { themeName.innerText = defaultThemeName; }
+ else { themeName.innerText = currentThemeName() ?? defaultThemeName; }
}
}}
onBlur={() => {
if(!themeName.innerText.trim()){
- themeName.innerText = defaultThemeName;
+ themeName.innerText = currentThemeName() ?? defaultThemeName;
}
}}
class={cn(
'rounded-lg py-1.5 px-2 border text-xs outline-none',
- 'bg-transparent text-ink-muted border-edge-muted',
+ 'bg-transparent text-ink-muted border-ink/[0.06]',
'hover:bg-surface hover:text-ink',
'focus:bg-surface focus:text-ink focus:border-accent',
'min-w-0 overflow-hidden text-ellipsis',
@@ -77,6 +85,30 @@ function ThemeTools(props: { class?: string }) {
>
{currentThemeName()}
</div>
+
+ <Show when={props.onRandomize}>
+ <Button
+ onPointerDown={() => props.onRandomize?.()}
+ label="Randomize theme"
+ variant="ghost"
+ size="icon-sm"
+ >
+ <IconShuffle />
+ </Button>
+ </Show>
+
+ <Show when={!isThemeSaved()}>
+ <Button
+ onPointerDown={() => {
+ commit(themeName.innerText);
+ }}
+ label={props.editingThemeId ? 'Save changes' : 'Save theme'}
+ variant="ghost"
+ size="icon-sm"
+ >
+ <IconSave />
+ </Button>
+ </Show>
</div>
);
}
diff --git a/js/app/packages/theme/utils/themeUtils.ts b/js/app/packages/theme/utils/themeUtils.ts
index 7636420a1a..c29c98e89a 100644
--- a/js/app/packages/theme/utils/themeUtils.ts
+++ b/js/app/packages/theme/utils/themeUtils.ts
@@ -1,9 +1,9 @@
-import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setHtmlColor, setIsThemeSaved, setThemeDepth, setUserThemes, systemMode, themeDepth, themes, themeShouldMatchSystem, userThemes} from '../signals/themeSignals';
+import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setDarkModeTheme, setHtmlColor, setIsThemeSaved, setLightModeTheme, setThemeDepth, setUserThemes, systemMode, themeDepth, themes, themeShouldMatchSystem, userThemes} from '../signals/themeSignals';
import type { ThemeV2, ThemeV2Tokens } from '../types/themeTypes';
import { themeReactive } from '../signals/themeReactive';
import { toast } from '@core/component/Toast/Toast';
import { batch, createEffect, on } from 'solid-js';
-import { DEFAULT_DARK_THEME } from '../constants';
+import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME } from '../constants';
export function exportTheme(themeId?: string){
const id = themeId ?? currentThemeId();
@@ -179,14 +179,50 @@ export function saveTheme(name: string): void{
setIsThemeSaved(true);
}
+/** Save the live theme back onto an existing custom theme (same id), updating
+ * its name, depth, and tokens in place. */
+export function updateTheme(id: string, name: string): void{
+ const tokens = getCurrentTokens();
+ setUserThemes(
+ userThemes().map((theme) =>
+ theme.id === id
+ ? { ...theme, name, depth: themeDepth(), tokens }
+ : theme
+ )
+ );
+ setCurrentThemeId(id);
+ setIsThemeSaved(true);
+}
+
export function deleteTheme(id: string): void{
setUserThemes(userThemes().filter((theme) => theme.id !== id));
+ // A deleted theme can no longer serve as a per-mode default; fall back to the
+ // built-in Macro light/dark themes.
+ if(lightModeTheme() === id){setLightModeTheme(DEFAULT_LIGHT_THEME)}
+ if(darkModeTheme() === id){setDarkModeTheme(DEFAULT_DARK_THEME)}
if(currentThemeId() === id){
+ // Keep the live tokens in place so the picker still shows this theme's
+ // swatch, but mark it unsaved/unselected — it now reads as "Unsaved Theme"
+ // until the user saves it again.
setIsThemeSaved(false);
setCurrentThemeId('');
}
}
+/** A synthetic ThemeV2 snapshot of the live (in-editor) tokens. Lets the picker
+ * render a swatch for the active theme even when it isn't a stored theme — e.g.
+ * after the selected theme was deleted, leaving an unsaved live theme. Reading
+ * it inside a reactive scope subscribes to the live token signals. */
+export function getLiveTheme(): ThemeV2{
+ return {
+ id: '',
+ name: 'Unsaved Theme',
+ version: 2,
+ depth: themeDepth(),
+ tokens: getCurrentTokens(),
+ };
+}
+
/** Intrinsic darkness of a stored theme: dark when text is lighter than background. */
export function isTokensDark(tokens: ThemeV2Tokens): boolean {
return tokens.c0.l > tokens.b0.l;
diff --git a/js/app/packages/ui/components/Dialog.tsx b/js/app/packages/ui/components/Dialog.tsx
index 2614432392..33cb9a795a 100644
--- a/js/app/packages/ui/components/Dialog.tsx
+++ b/js/app/packages/ui/components/Dialog.tsx
@@ -9,6 +9,8 @@ export type DialogProps = {
onOpenChange?: (open: boolean) => void /* Forwarded to Kobalte */;
contentRef?: Ref<HTMLDivElement> /* content element ref */;
position?: 'top' | 'center' /* Vertical position */;
+ /** Edge-to-edge takeover: fills the viewport with no gutter or centering. */
+ fullscreen?: boolean /* Fill the viewport */;
children: JSX.Element /* Content children */;
class?: string /* classes for content */;
open: boolean /* if dialog is open */;
@@ -21,16 +23,22 @@ export function Dialog(props: DialogProps) {
<KobalteDialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay pattern-edge-muted pattern-diagonal-4" />
<div
class={cn(
- 'fixed top-0 bottom-(--virtual-keyboard-height,0) inset-x-0 z-modal flex justify-center px-2',
- props.position === 'center'
- ? 'items-center'
- : 'items-start pt-[10vh]'
+ 'fixed top-0 bottom-(--virtual-keyboard-height,0) inset-x-0 z-modal flex',
+ props.fullscreen
+ ? 'inset-0'
+ : cn(
+ 'justify-center px-2',
+ props.position === 'center'
+ ? 'items-center'
+ : 'items-start pt-[10vh]'
+ )
)}
>
<KobalteDialog.Content
ref={props.contentRef}
class={cn(
- 'w-200 max-w-[calc(100vw-16px)] overflow-hidden portal-scope isolate',
+ 'overflow-hidden portal-scope isolate',
+ props.fullscreen ? 'size-full' : 'w-200 max-w-[calc(100vw-16px)]',
props.class
)}
onCloseAutoFocus={props.onCloseAutoFocus}
diff --git a/js/app/packages/ui/components/SideNav.tsx b/js/app/packages/ui/components/SideNav.tsx
index f757aaebbc..c794e6621c 100644
--- a/js/app/packages/ui/components/SideNav.tsx
+++ b/js/app/packages/ui/components/SideNav.tsx
@@ -29,7 +29,7 @@ function SideNavRoot(props: SideNavProps) {
return (
<nav
class={cn(
- 'w-[220px] shrink-0 overflow-auto border-r border-edge-muted p-2 flex flex-col gap-2',
+ 'w-[220px] shrink-0 overflow-auto p-4 flex flex-col gap-2',
props.class
)}
>
diff --git a/js/app/packages/ui/components/ToggleSwitch.tsx b/js/app/packages/ui/components/ToggleSwitch.tsx
index f547afd9ba..8121f34a9f 100644
--- a/js/app/packages/ui/components/ToggleSwitch.tsx
+++ b/js/app/packages/ui/components/ToggleSwitch.tsx
@@ -10,9 +10,27 @@ export type ToggleSwitchProps = {
label?: JSX.Element;
disabled?: boolean;
checked?: boolean;
+ /** Visual size. `sm` (default) is the compact toolbar size; `md` is larger,
+ * used in settings rows. */
+ size?: 'sm' | 'md';
class?: string;
};
+const SWITCH_SIZES = {
+ sm: {
+ control: 'h-4 w-6',
+ thumb: 'top-0.5 left-0.5 h-3',
+ stretched: 'w-4 data-checked:translate-x-1',
+ normal: 'w-3 data-checked:translate-x-2',
+ },
+ md: {
+ control: 'h-5 w-9',
+ thumb: 'top-0.5 left-0.5 h-4',
+ stretched: 'w-5 data-checked:translate-x-3',
+ normal: 'w-4 data-checked:translate-x-4',
+ },
+} as const;
+
export const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => {
const [local, others] = splitProps(props, [
'defaultChecked',
@@ -22,7 +40,9 @@ export const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => {
'checked',
'class',
'label',
+ 'size',
]);
+ const sizing = () => SWITCH_SIZES[local.size ?? 'sm'];
const [isStretched, setIsStretched] = createSignal(false);
let stretchTimeout: ReturnType<typeof setTimeout> | undefined;
@@ -51,13 +71,17 @@ export const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => {
{...others}
>
<KobalteSwitch.Input class="sr-only" />
- <KobalteSwitch.Control class="relative h-4 w-6 rounded-full bg-ink-muted/40 transition-colors duration-100 data-checked:bg-accent">
+ <KobalteSwitch.Control
+ class={cn(
+ 'relative rounded-full bg-ink-muted/40 transition-colors duration-100 data-checked:bg-accent',
+ sizing().control
+ )}
+ >
<KobalteSwitch.Thumb
class={cn(
- 'absolute top-0.5 left-0.5 h-3 rounded-full bg-surface transition-all duration-100 ease-in-out',
- isStretched()
- ? 'w-4 data-checked:translate-x-1'
- : 'w-3 data-checked:translate-x-2'
+ 'absolute rounded-full bg-surface transition-all duration-100 ease-in-out',
+ sizing().thumb,
+ isStretched() ? sizing().stretched : sizing().normal
)}
/>
</KobalteSwitch.Control>