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.

style(core): restyle toasts (#2220)

Seamusb92a49547699
diff --git a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
index a18505ecb6..5c10d2f14c 100644
--- a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
@@ -1,3 +1,4 @@
+import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { toast } from '@core/component/Toast/Toast';
import type { EntityData } from '@entity';
import { openBulkEditModal } from '@app/component/bulk-edit-entity/BulkEditEntityModal';
@@ -77,16 +78,19 @@ export const makeDeleteAction = (options: MakeDeleteOptions) => {
? `Moved ${emailEntities.length} items to Trash`
: 'Moved to Trash',
undefined,
- {
- text: 'Undo',
- onClick: () => {
- if (toastId != null) toast.dismiss(toastId);
- handle.undo().then(
- () => toast.success('Restored from Trash'),
- () => toast.failure('Failed to restore from Trash')
- );
+ [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: () => {
+ if (toastId != null) toast.dismiss(toastId);
+ handle.undo().then(
+ () => toast.success('Restored from Trash'),
+ () => toast.failure('Failed to restore from Trash')
+ );
+ },
},
- },
+ ],
10_000
);
diff --git a/js/app/packages/app/util/handleFileUpload.ts b/js/app/packages/app/util/handleFileUpload.ts
index 74b59e4c85..514dc4e5fe 100644
--- a/js/app/packages/app/util/handleFileUpload.ts
+++ b/js/app/packages/app/util/handleFileUpload.ts
@@ -35,15 +35,17 @@ export function useHandleFileUpload({
refetchSoupEntity(createdProjectId, 'project');
- toast.success(`Uploaded ${upload.name}`, undefined, {
- text: 'Open folder',
- onClick: () => {
- openWithSplit(
- { type: 'project', id: createdProjectId },
- { referredFrom: 'file-upload', activate: true }
- );
+ toast.success(`Uploaded ${upload.name}`, undefined, [
+ {
+ label: 'Open folder',
+ onClick: () => {
+ openWithSplit(
+ { type: 'project', id: createdProjectId },
+ { referredFrom: 'file-upload', activate: true }
+ );
+ },
},
- });
+ ]);
});
}
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 0c57cc218c..14b3d98e74 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -25,6 +25,7 @@ import { TOKENS } from '@core/hotkey/tokens';
import { trackMention } from '@core/signal/mention';
import { tryMacroId, useDisplayName } from '@core/user';
import { handleFileFolderDrop } from '@core/util/upload';
+import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import ArrowUp from '@icon/bold/arrow-up-bold.svg';
import Spinner from '@icon/bold/spinner-gap-bold.svg';
import ReplyAll from '@icon/regular/arrow-bend-double-up-left.svg';
@@ -550,13 +551,16 @@ export function BaseInput(props: {
'Email sent',
undefined,
draftId
- ? {
- text: 'Undo',
- onClick: () => {
- if (toastId != null) toast.dismiss(toastId);
- void undoSend(draftId);
+ ? [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: () => {
+ if (toastId != null) toast.dismiss(toastId);
+ void undoSend(draftId);
+ },
},
- }
+ ]
: undefined,
10_000
);
diff --git a/js/app/packages/block-email/component/Compose.tsx b/js/app/packages/block-email/component/Compose.tsx
index 8f741bd807..a7961fe259 100644
--- a/js/app/packages/block-email/component/Compose.tsx
+++ b/js/app/packages/block-email/component/Compose.tsx
@@ -1,3 +1,4 @@
+import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import {
SplitHeaderBadge,
@@ -34,7 +35,7 @@ import {
Show,
Suspense,
} from 'solid-js';
-import { beveledCorners } from '../../block-theme/signals/themeSignals';
+import { beveledCorners } from '../../core/signal/beveledCorners';
import { ComposeEmailInput } from './ComposeEmailInput';
import {
createEmailFormState,
@@ -558,13 +559,16 @@ export function EmailCompose(props: EmailComposeProps) {
'Email sent',
undefined,
draftId
- ? {
- text: 'Undo',
- onClick: () => {
- if (toastId != null) toast.dismiss(toastId);
- void undoSend(draftId);
+ ? [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: () => {
+ if (toastId != null) toast.dismiss(toastId);
+ void undoSend(draftId);
+ },
},
- }
+ ]
: undefined,
10_000
);
diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsx
index 5ccba295a8..15dcec06bb 100644
--- a/js/app/packages/block-email/component/TopBar.tsx
+++ b/js/app/packages/block-email/component/TopBar.tsx
@@ -15,6 +15,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { toast } from '@core/component/Toast/Toast';
import { ENABLE_EMAIL_SHARING } from '@core/constant/featureFlags';
import { TOKENS } from '@core/hotkey/tokens';
@@ -77,16 +78,19 @@ export function TopBar(props: {
const toastId = toast.success(
'Moved to Trash',
undefined,
- {
- text: 'Undo',
- onClick: () => {
- if (toastId != null) toast.dismiss(toastId);
- handle.undo().then(
- () => toast.success('Restored from Trash'),
- () => toast.failure('Failed to restore from Trash')
- );
+ [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: () => {
+ if (toastId != null) toast.dismiss(toastId);
+ handle.undo().then(
+ () => toast.success('Restored from Trash'),
+ () => toast.failure('Failed to restore from Trash')
+ );
+ },
},
- },
+ ],
10_000
);
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsx
index ea47505ad3..c2cc3a2f15 100644
--- a/js/app/packages/block-md/component/ComposeTask.tsx
+++ b/js/app/packages/block-md/component/ComposeTask.tsx
@@ -4,7 +4,7 @@ import { CircleSpinner } from '@core/component/CircleSpinner';
import { EntityIcon } from '@core/component/EntityIcon';
import { MiniToggleSwitch } from '@core/component/FormControls/MiniToggleSwitch';
import { Hotkey } from '@core/component/Hotkey';
-import { BlockLink } from '@core/component/LexicalMarkdown/component/core/BlockLink';
+
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import { initializeEditorEmpty } from '@core/component/LexicalMarkdown/utils';
@@ -34,7 +34,9 @@ import { createTask } from '@core/util/create';
import { filterMap } from '@core/util/list';
import { isErr } from '@core/util/maybeResult';
import { buildSimpleEntityUrl } from '@core/util/url';
+import ArrowSquareOutIcon from '@icon/regular/arrow-square-out.svg';
import LinkIcon from '@icon/regular/link-simple.svg';
+import SplitIcon from '@icon/regular/square-half.svg';
import TrashIcon from '@icon/regular/trash.svg';
import XIcon from '@icon/regular/x.svg';
import { refetchSoupEntity } from '@queries/soup/cache';
@@ -100,15 +102,6 @@ async function createTaskWithProperties(
return null;
}
- toast.embed(
- () => (
- <TaskToastPreview id={documentId} title={taskTitle} body={taskContent} />
- ),
- {
- duration: 2_000,
- }
- );
-
// refetchSoupEntity is already called inside createTask — just upsert to history
refetchSoupEntity(documentId, 'document');
@@ -159,53 +152,6 @@ function extractPropertyValue(
* @param props
* @returns
*/
-function TaskToastPreview(props: { title: string; body: string; id: string }) {
- const [linkCopied, setLinkCopied] = createSignal(false);
- onMount(() => {
- try {
- const url = buildSimpleEntityUrl(
- {
- type: 'task',
- id: props.id,
- },
- {}
- );
- navigator.clipboard.writeText(url);
- setLinkCopied(true);
- } finally {
- }
- });
-
- return (
- <BlockLink blockOrFileName="task" id={props.id}>
- <div class="text-ink size-full w-96">
- <div class="flex row items-center gap-2 mb-4">
- <EntityIcon targetType="task" />
- <span class="text-base font-medium">
- {props.title ||
- itemToSafeName({
- type: 'document',
- subType: { type: 'task' },
- })}
- </span>
- </div>
- <div class="text-ink-muted text-sm h-fit max-h-18 w-full truncate">
- <StaticMarkdown
- markdown={props.body}
- theme={unifiedListMarkdownTheme}
- singleLine
- />
- </div>
- <Show when={linkCopied()}>
- <div class="text-xs flex items-center gap-2 bg-success-bg text-success-ink rounded-sm mt-2 p-1">
- <LinkIcon class="size-4" />
- Link Copied to Clipboard
- </div>
- </Show>
- </div>
- </BlockLink>
- );
-}
export interface ComposeTaskProps {
onCreateTask?: (title: string, content: string) => void;
@@ -217,7 +163,7 @@ export interface ComposeTaskProps {
export function ComposeTask(props: ComposeTaskProps) {
const splitPanel = useSplitPanelOrThrow();
- const { popoverSplit } = useSplitLayout();
+ const { popoverSplit, openWithSplit } = useSplitLayout();
const currentUserId = useUserId();
const getDefaultPropertyValues = (): Record<string, PropertyApiValues> => {
@@ -378,6 +324,69 @@ export function ComposeTask(props: ComposeTaskProps) {
},
};
+ const showTaskCreatedToast = (
+ documentId: string,
+ taskTitle: string,
+ taskContent: string
+ ) => {
+ const TaskEntityIcon = (p: { class?: string }) => (
+ <EntityIcon targetType="task" class={p.class} />
+ );
+
+ toast.custom(
+ {
+ title:
+ taskTitle ||
+ itemToSafeName({ type: 'document', subType: { type: 'task' } }),
+ icon: TaskEntityIcon,
+ color: 'var(--color-task)',
+ children: (
+ <div class="text-xs text-ink-extra-muted line-clamp-2 mb-4">
+ <StaticMarkdown
+ markdown={taskContent}
+ theme={unifiedListMarkdownTheme}
+ singleLine
+ />
+ </div>
+ ),
+ actions: [
+ {
+ label: 'Open',
+ icon: ArrowSquareOutIcon,
+ onClick: () => {
+ openWithSplit(
+ { type: 'task', id: documentId },
+ { referredFrom: null }
+ );
+ },
+ },
+ {
+ label: 'Open in New Split',
+ icon: SplitIcon,
+ onClick: () => {
+ openWithSplit(
+ { type: 'task', id: documentId },
+ { referredFrom: null, preferNewSplit: true }
+ );
+ },
+ },
+ {
+ label: 'Copy Link',
+ icon: LinkIcon,
+ onClick: () => {
+ const url = buildSimpleEntityUrl(
+ { type: 'task', id: documentId },
+ {}
+ );
+ navigator.clipboard.writeText(url);
+ },
+ },
+ ],
+ },
+ { duration: 5_000 }
+ );
+ };
+
const handleCreateTask = async () => {
if (isCreating()) return;
@@ -424,6 +433,7 @@ export function ComposeTask(props: ComposeTaskProps) {
return;
}
+ showTaskCreatedToast(documentId, taskTitle, taskContent);
props.onCreateTask?.(taskTitle, taskContent);
return;
}
@@ -444,6 +454,7 @@ export function ComposeTask(props: ComposeTaskProps) {
// Success: clear draft and notify
clearTaskComposerDraft();
+ showTaskCreatedToast(documentId, taskTitle, taskContent);
props.onCreateTask?.(taskTitle, taskContent);
if (createMore()) {
diff --git a/js/app/packages/block-theme/signals/themeSignals.ts b/js/app/packages/block-theme/signals/themeSignals.ts
index ec277de75d..f8b83954c9 100644
--- a/js/app/packages/block-theme/signals/themeSignals.ts
+++ b/js/app/packages/block-theme/signals/themeSignals.ts
@@ -1,4 +1,4 @@
-import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_THEMES, BEVELED_CORNERS, BLACK_BEZELS } from '../constants';
+import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_THEMES, BLACK_BEZELS } from '../constants';
import { createEffect, createMemo, createSignal } from 'solid-js';
import type { ThemeV0, ThemeV1 } from '../types/themeTypes';
import { convertThemev0v1 } from '../utils/themeMigrations';
@@ -75,10 +75,7 @@ export const [monochromeIcons, setMonochromeIcons] = makePersisted(
);
-export const [beveledCorners, setBeveledCorners] = makePersisted(
- createSignal<boolean>(BEVELED_CORNERS),
- {name: 'macro-beveled-corners'}
-);
+export { beveledCorners, setBeveledCorners } from '../../core/signal/beveledCorners';
export const [blackBezels, setBlackBezels] = makePersisted(
createSignal<boolean>(BLACK_BEZELS),
diff --git a/js/app/packages/core/component/ClippedPanel.tsx b/js/app/packages/core/component/ClippedPanel.tsx
index 59871518a1..cfd3f5124e 100644
--- a/js/app/packages/core/component/ClippedPanel.tsx
+++ b/js/app/packages/core/component/ClippedPanel.tsx
@@ -1,11 +1,12 @@
import { cornerClip } from '@core/util/clipPath';
import { createMemo, splitProps, type JSX } from 'solid-js';
-import { beveledCorners } from '../../block-theme/signals/themeSignals';
+import { beveledCorners } from '../signal/beveledCorners';
import { cn } from '@ui/utils/classname';
export type ClippedPanelProps = JSX.HTMLAttributes<HTMLDivElement> & {
active?: boolean;
edgeColor?: JSX.CSSProperties['color'];
+ highlightColor?: JSX.CSSProperties['color'];
/**
* When provided, this overrides all corner behavior:
* - bypasses clip-path (no corner clipping)
@@ -23,6 +24,7 @@ export function ClippedPanel(props: ClippedPanelProps) {
const [local, rest] = splitProps(props, [
'active',
'edgeColor',
+ 'highlightColor',
'cornerRadius',
'tr',
'tl',
@@ -34,9 +36,8 @@ export function ClippedPanel(props: ClippedPanelProps) {
const outerBgImage = createMemo(() => {
const edge = local.edgeColor || 'var(--color-edge-muted)';
- return `linear-gradient(${
- local.active ? `var(--color-accent), ${edge} 80%` : edge
- } )`;
+ const hl = local.highlightColor || 'var(--color-accent)';
+ return `linear-gradient(${local.active ? `${hl}, ${edge} 80%` : edge} )`;
});
const useCornerRadiusOverride = createMemo(() => local.cornerRadius != null);
diff --git a/js/app/packages/core/component/DocumentPreview.tsx b/js/app/packages/core/component/DocumentPreview.tsx
index 74b1056997..fc3df646ff 100644
--- a/js/app/packages/core/component/DocumentPreview.tsx
+++ b/js/app/packages/core/component/DocumentPreview.tsx
@@ -48,7 +48,7 @@ import { globalSplitManager } from 'app/signal/splitLayout';
import type { Component, JSX } from 'solid-js';
import { Match, Show, Suspense, Switch } from 'solid-js';
import { Dynamic } from 'solid-js/web';
-import { beveledCorners } from '../../block-theme/signals/themeSignals';
+import { beveledCorners } from '../signal/beveledCorners';
import { formatDate } from '../util/date';
import NotFound from './AccessErrorViews/NotFound';
import Unauthorized from './AccessErrorViews/Unauthorized';
diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsx
index f529b69acf..f27a17c595 100644
--- a/js/app/packages/core/component/ForwardToChannel.tsx
+++ b/js/app/packages/core/component/ForwardToChannel.tsx
@@ -182,10 +182,12 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
submitChannelPermissions(channelId);
props.refetch?.();
- toast.success('Message sent successfully', undefined, {
- onClick: navigateToChannel,
- text: 'View in channel',
- });
+ toast.success('Message sent successfully', undefined, [
+ {
+ label: 'View in channel',
+ onClick: navigateToChannel,
+ },
+ ]);
analytics.track('share_entity', { location: 'forward_to_channel' });
});
} else {
@@ -211,10 +213,12 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
props.refetch?.();
if (!multipleMessages) {
const { navigateToChannel } = res;
- toast.success('Message sent successfully', undefined, {
- onClick: () => navigateToChannel(),
- text: 'View in channel',
- });
+ toast.success('Message sent successfully', undefined, [
+ {
+ label: 'View in channel',
+ onClick: () => navigateToChannel(),
+ },
+ ]);
}
analytics.track('share_entity', {
location: 'forward_to_channel',
@@ -238,10 +242,12 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
props.refetch?.();
if (!multipleMessages) {
- toast.success('Message sent successfully', undefined, {
- onClick: () => navigateToChannel(),
- text: 'View in channel',
- });
+ toast.success('Message sent successfully', undefined, [
+ {
+ label: 'View in channel',
+ onClick: () => navigateToChannel(),
+ },
+ ]);
}
analytics.track('share_entity', { location: 'forward_to_channel' });
});
diff --git a/js/app/packages/core/component/Toast/Toast.tsx b/js/app/packages/core/component/Toast/Toast.tsx
index f4592ad081..fc653685a1 100644
--- a/js/app/packages/core/component/Toast/Toast.tsx
+++ b/js/app/packages/core/component/Toast/Toast.tsx
@@ -3,9 +3,12 @@ import ExclamationIcon from '@icon/regular/exclamation-mark.svg';
import Spinner from '@icon/regular/spinner.svg';
import XIcon from '@icon/regular/x.svg';
import { Toast, toaster } from '@kobalte/core/toast';
-import type { Component } from 'solid-js';
+import type { Component, JSX } from 'solid-js';
import {
Show,
+ For,
+ Switch,
+ Match,
createSignal,
onMount,
onCleanup,
@@ -13,6 +16,9 @@ import {
on,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { ClippedPanel } from '../ClippedPanel';
+import { Button } from '@ui/components/Button';
+import { cn } from '@ui/utils/classname';
export enum ToastType {
SUCCESS = 'success',
@@ -47,7 +53,7 @@ const TOAST_STYLES: Record<ToastType, ToastStyle> = {
[ToastType.SUCCESS]: {
background: 'bg-success/10',
accent: 'bg-success',
- borderColor: 'border-success',
+ borderColor: 'var(--color-success)',
titleText: 'text-success-ink',
subtitleText: 'text-success-ink/70',
icon: CheckIcon,
@@ -61,8 +67,8 @@ const TOAST_STYLES: Record<ToastType, ToastStyle> = {
[ToastType.FAILURE]: {
background: 'bg-failure/10',
accent: 'bg-failure',
- borderColor: 'border-failure',
titleText: 'text-failure-ink',
+ borderColor: 'var(--color-failure)',
subtitleText: 'text-failure-ink/70',
icon: ExclamationIcon,
button: {
@@ -75,7 +81,7 @@ const TOAST_STYLES: Record<ToastType, ToastStyle> = {
[ToastType.ALERT]: {
background: 'bg-alert/10',
accent: 'bg-alert',
- borderColor: 'border-alert',
+ borderColor: 'var(--color-alert)',
titleText: 'text-alert-ink',
subtitleText: 'text-alert-ink/70',
icon: ExclamationIcon,
@@ -89,7 +95,7 @@ const TOAST_STYLES: Record<ToastType, ToastStyle> = {
[ToastType.LOADING]: {
background: 'bg-accent/10',
accent: 'bg-accent',
- borderColor: 'border-accent',
+ borderColor: 'var(--color-edge)',
titleText: 'text-ink',
subtitleText: 'text-ink-muted',
icon: Spinner,
@@ -102,6 +108,27 @@ const TOAST_STYLES: Record<ToastType, ToastStyle> = {
},
};
+/** A single entry in the actions row — icon and label rendered as a button */
+export interface ToastAction {
+ label: string;
+ icon?: Component<{ class?: string }>;
+ onClick: () => void;
+}
+
+/**
+ * Config for a fully custom toast.
+ * Replaces the icon, title, and accent color of the standard layout while
+ * still using the shared ClippedPanel chrome and progress/dismiss machinery.
+ */
+export interface CustomToastConfig {
+ title: string;
+ children?: JSX.Element;
+ icon?: Component<{ class?: string }>;
+ /** Any CSS color value, e.g. 'var(--color-success)' or '#ff6600' */
+ color?: string;
+ actions?: ToastAction[];
+}
+
interface ToastMessage {
message: string;
toastType: ToastType;
@@ -109,10 +136,7 @@ interface ToastMessage {
timeoutId: ReturnType<typeof setTimeout>;
toastId?: number;
subtext?: string;
- action?: {
- text: string;
- onClick: () => void;
- };
+ actions?: ToastAction[];
}
const recentToasts: Map<string, ToastMessage> = new Map();
@@ -140,11 +164,11 @@ function dismissIfRecent(message: string, type: ToastType): void {
function success(
message: string,
subtext?: string,
- action?: { text: string; onClick: () => void },
+ actions?: ToastAction[],
duration?: number
): number | undefined {
dismissIfRecent(message, ToastType.SUCCESS);
- return createToast(message, ToastType.SUCCESS, subtext, action, duration);
+ return createToast(message, ToastType.SUCCESS, subtext, actions, duration);
}
function dismiss(toastId: number) {
@@ -163,25 +187,64 @@ function alert(message: string, subtext?: string, duration?: number) {
createToast(message, ToastType.ALERT, subtext, undefined, duration);
}
+// ─── Shared actions row ──────────────────────────────────────────────────────
+
+function ActionsRow(props: { actions: ToastAction[] }) {
+ return (
+ <div class="flex flex-row flex-wrap justify-end gap-2 mt-2">
+ <For each={props.actions}>
+ {(action) => (
+ <Button
+ onClick={action.onClick}
+ variant="secondary"
+ class="flex items-center gap-1.5 rounded py-1.5 px-3 text-sm font-semibold"
+ >
+ <Show when={action.icon}>
+ {(icon) => (
+ <Dynamic component={icon()} class="size-3.5 shrink-0" />
+ )}
+ </Show>
+ {action.label}
+ </Button>
+ )}
+ </For>
+ </div>
+ );
+}
+
+// ─── Toast content ───────────────────────────────────────────────────────────
+
function ToastContent(props: {
toastId: number;
- toastType: ToastType;
- message: string;
+ toastType?: ToastType;
+ message?: string;
subtext?: string;
- action?: { text: string; onClick: () => void };
+ actions?: ToastAction[];
persistent?: boolean;
+ /** When provided, drives the auto-dismiss timer AND shows the progress bar. */
duration?: number;
+ embed?: Component;
+ custom?: CustomToastConfig;
}) {
- const styles = () => TOAST_STYLES[props.toastType];
+ const styles = () => (props.toastType ? TOAST_STYLES[props.toastType] : null);
- // Track progress until disappearance (1 = full duration remaining, 0 = time to disappear)
+ const accentColor = () => {
+ if (props.custom?.color) return props.custom.color;
+ return styles()?.borderColor ?? 'var(--color-edge)';
+ };
+
+ // progress: 1 = full time remaining, 0 = expired.
+ // Only meaningful (and only rendered) when props.duration is explicitly set.
const [progress, setProgress] = createSignal(1);
+
+ const showProgress = () => false;
+
const [isHovered, setIsHovered] = createSignal(false);
let elapsed = 0;
onMount(() => {
- // Skip countdown for persistent toasts
+ // Persistent toasts never auto-dismiss
if (props.persistent) return;
const duration = props.duration ?? 3000;
@@ -191,7 +254,6 @@ function ToastContent(props: {
const update = () => {
const currentTime = performance.now();
- // Initialize lastTime on first frame
if (lastTime === null) {
lastTime = currentTime;
}
@@ -208,21 +270,18 @@ function ToastContent(props: {
if (remaining > 0) {
rafId = requestAnimationFrame(update);
} else {
- // Dismiss the toast when countdown completes
toaster.dismiss(props.toastId);
}
};
rafId = requestAnimationFrame(update);
-
onCleanup(() => cancelAnimationFrame(rafId));
});
- // Reset timer immediately when user starts hovering
+ // Reset timer when user starts hovering
createEffect(
on(isHovered, (hovered) => {
if (hovered && !props.persistent) {
- // User started hovering - reset timer and progress immediately
elapsed = 0;
setProgress(1);
}
@@ -232,74 +291,126 @@ function ToastContent(props: {
return (
<Toast
toastId={props.toastId}
- class={`relative overflow-visible rounded-xs pointer-events-auto
- bg-panel
+ class={`relative overflow-visible pointer-events-auto shadow-md rounded-lg
data-opened:animate-slide-in data-closed:animate-hide transition-transform data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)]
data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:ease-out data-[swipe=cancel]:duration-200 data-[swipe=end]:animate-swipe-out`}
persistent={true}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
- {/* Animated border that fades from opacity 1 to 0 */}
- <Show when={!props.persistent}>
- <div
- class={`absolute inset-0 rounded-xs border-1 pointer-events-none ${styles().borderColor}`}
- style={{ opacity: progress() }}
- />
- </Show>
-
- <div class="flex">
- {/* Left accent area with icon */}
- <div
- class={`flex items-center justify-center w-12 shrink-0 ${styles().accent}/20`}
- >
- <Dynamic
- component={styles().icon}
- class={`size-6 ${styles().titleText} ${props.toastType === ToastType.LOADING ? 'animate-spin' : ''}`}
- />
- </div>
-
- {/* Content area */}
- <div class="flex-1 pt-2 px-3 pb-3 pr-10">
- <Toast.Title class={`font-semibold text-ink`}>
- {props.message}
- </Toast.Title>
- <Show when={props.subtext}>
- <Toast.Description class={`text-sm text-ink-extra-muted`}>
- {props.subtext}
- </Toast.Description>
- </Show>
-
- {/* Action button */}
- <Show when={props.action}>
- {(action) => (
- <button
- onClick={action().onClick}
- class={`mt-2 w-full text-sm font-semibold py-1.5 px-3 rounded
- ${styles().button.background}/20
- ${styles().button.hover}
- ${styles().button.text}
- `}
- >
- {action().text}
- </button>
+ <ClippedPanel
+ edgeColor="var(--color-edge-muted)"
+ highlightColor={accentColor()}
+ active
+ cornerRadius={'8px'}
+ class="relative w-md p-3 overflow-clip"
+ >
+ <Switch>
+ {/* ── Embed layout ── */}
+ <Match when={props.embed}>
+ {(embed) => (
+ <>
+ <Dynamic component={embed()} />
+ <Toast.CloseButton class="absolute top-2 right-2 z-1">
+ <Button variant="ghost" size="icon-sm" class="rounded-xs">
+ <XIcon />
+ </Button>
+ </Toast.CloseButton>
+ </>
)}
- </Show>
- </div>
-
- {/* Close button */}
- <Toast.CloseButton class="absolute top-2 right-2 p-1 rounded">
- <XIcon
- class={`size-4 text-ink-extra-muted transition-colors ${styles().closeButtonHover}`}
+ </Match>
+
+ {/* ── Custom layout ── */}
+ <Match when={props.custom}>
+ {(customConfig) => (
+ <>
+ <div class="flex items-center gap-2 justify-between">
+ <Show when={customConfig().icon}>
+ {(icon) => (
+ <div class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75">
+ <Dynamic component={icon()} />
+ </div>
+ )}
+ </Show>
+ <Toast.Title class="font-semibold text-ink grow shrink truncate">
+ {customConfig().title}
+ </Toast.Title>
+ <Toast.CloseButton>
+ <Button variant="ghost" size="icon-sm" class="rounded-xs">
+ <XIcon />
+ </Button>
+ </Toast.CloseButton>
+ </div>
+ <Show when={customConfig().children}>
+ <div class="my-2 ml-7">{customConfig().children}</div>
+ </Show>
+ <Show when={customConfig().actions?.length}>
+ <ActionsRow actions={customConfig().actions!} />
+ </Show>
+ </>
+ )}
+ </Match>
+
+ {/* ── Standard layout ── */}
+ <Match when={styles()}>
+ {(s) => (
+ <>
+ <div class="flex items-center gap-2 justify-between">
+ <div
+ class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75"
+ style={{ 'background-color': s().borderColor }}
+ >
+ <Dynamic
+ component={s().icon}
+ class={cn(
+ 'size-3.5 text-panel',
+ props.toastType === ToastType.LOADING
+ ? 'animate-spin'
+ : ''
+ )}
+ />
+ </div>
+ <Toast.Title class="font-semibold text-ink grow shrink truncate">
+ {props.message}
+ </Toast.Title>
+ <Toast.CloseButton>
+ <Button variant="ghost" size="icon-sm" class="rounded-xs">
+ <XIcon />
+ </Button>
+ </Toast.CloseButton>
+ </div>
+ <Show when={props.subtext}>
+ <Toast.Description class="text-sm text-ink-extra-muted ml-7">
+ {props.subtext}
+ </Toast.Description>
+ </Show>
+ <Show when={props.actions?.length}>
+ <ActionsRow actions={props.actions!} />
+ </Show>
+ </>
+ )}
+ </Match>
+ </Switch>
+
+ {/* Progress bar — only rendered when an explicit duration was passed */}
+ <Show when={showProgress()}>
+ <div
+ class="absolute bottom-0 h-1 left-0"
+ style={{
+ 'background-color': accentColor(),
+ width: `${(1 - progress()) * 100}%`,
+ }}
/>
- </Toast.CloseButton>
- </div>
+ </Show>
+ </ClippedPanel>
</Toast>
);
}
+// ─── promise helper ──────────────────────────────────────────────────────────
+
async function promise<T>(
- promise: Promise<T>,
+ promiseArg: Promise<T>,
options: {
loading: string;
success?: string | ((result: T) => string);
@@ -321,7 +432,7 @@ async function promise<T>(
{ region: 'toast-region' }
);
- return promise
+ return promiseArg
.then((result) => {
toaster.dismiss(toastId);
@@ -352,11 +463,15 @@ async function promise<T>(
});
}
+// ─── createToast (internal) ──────────────────────────────────────────────────
+
function createToast(
message: string,
toastType: ToastType,
subtext?: string,
- action?: { text: string; onClick: () => void },
+ actions?: ToastAction[],
+ // When undefined, the toast auto-dismisses after a default delay but shows NO progress bar.
+ // When explicitly set, the toast uses that duration AND shows the progress bar.
duration?: number
) {
const key = createToastKey(message, toastType);
@@ -377,8 +492,10 @@ function createToast(
toastType={toastType}
message={message}
subtext={subtext}
- action={action}
- duration={duration ?? THROTTLE_DURATION + 100}
+ actions={actions}
+ // Pass duration only when explicitly provided — this is what gates the progress bar.
+ // When undefined, ToastContent falls back to its own default dismiss timing internally.
+ duration={duration}
/>
),
{ region: 'toast-region' }
@@ -391,12 +508,14 @@ function createToast(
timeoutId,
toastId,
subtext,
- action,
+ actions,
});
return toastId;
}
+// ─── embed ───────────────────────────────────────────────────────────────────
+
function embed(
component: Component,
options?: {
@@ -407,56 +526,69 @@ function embed(
) {
return toaster.show(
(props) => (
- <Toast
+ <ToastContent
toastId={props.toastId}
- class="flex flex-col items-center justify-between gap-2 border rounded-md p-3 pointer-events-auto border-edge-muted bg-panel relative
- data-opened:animate-slide-in data-closed:animate-hide transition-transform data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)]
- data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:ease-out data-[swipe=cancel]:duration-200 data-[swipe=end]:animate-swipe-out"
+ embed={component}
+ persistent={options?.persistent}
duration={options?.duration}
+ />
+ ),
+ { region: options?.region || 'toast-region' }
+ );
+}
+
+// ─── custom ──────────────────────────────────────────────────────────────────
+
+/**
+ * Show a toast with a fully custom title, icon, accent color, body content,
+ * and actions row — while still using the shared ClippedPanel chrome and
+ * progress/dismiss machinery.
+ */
+function custom(
+ config: CustomToastConfig,
+ options?: {
+ persistent?: boolean;
+ duration?: number;
+ region?: string;
+ }
+): number {
+ return toaster.show(
+ (props) => (
+ <ToastContent
+ toastId={props.toastId}
+ custom={config}
persistent={options?.persistent}
- >
- <div class="size-full">
- <Dynamic component={component} />
- </div>
- <Toast.CloseButton class="ml-auto absolute top-2 right-2 z-1">
- <XIcon class="h-5 ml-4 text-[oklch(0.551_0.027_264.364)]" />
- </Toast.CloseButton>
- </Toast>
+ duration={options?.duration}
+ />
),
{ region: options?.region || 'toast-region' }
);
}
+// ─── upload helper (kept for backwards compat) ───────────────────────────────
+
export function createUploadToast(message: string) {
return toaster.show(
(props) => (
- <Toast
+ <ToastContent
toastId={props.toastId}
+ toastType={ToastType.LOADING}
+ message={message}
persistent={true}
- class={`flex flex-col items-center justify-between gap-2 border rounded-md p-3 shadow-lg bg-menu border-edge-muted pointer-events-auto
- data-opened:animate-slide-in data-closed:animate-hide transition-transform data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)]
- data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:ease-out data-[swipe=cancel]:duration-200 data-[swipe=end]:animate-swipe-out`}
- >
- <div class="flex items-center w-full">
- <Spinner class="mr-3 h-7 animate-spin shrink-0" />
- <div>
- <Toast.Title>{message}</Toast.Title>
- </div>
- <Toast.CloseButton class="ml-auto">
- <XIcon class={`h-5 ml-4`} />
- </Toast.CloseButton>
- </div>
- </Toast>
+ />
),
{ region: 'stable-toast' }
);
}
+// ─── public API ──────────────────────────────────────────────────────────────
+
export const toast = {
success,
failure,
alert,
promise,
embed,
+ custom,
dismiss,
};
diff --git a/js/app/packages/core/component/Toast/ToastRegion.tsx b/js/app/packages/core/component/Toast/ToastRegion.tsx
index 10bc9dcfd7..81ca694fe5 100644
--- a/js/app/packages/core/component/Toast/ToastRegion.tsx
+++ b/js/app/packages/core/component/Toast/ToastRegion.tsx
@@ -10,7 +10,7 @@ export function ToastRegion() {
duration={Infinity}
pauseOnInteraction={false}
>
- <Toast.List class="absolute bottom-0 right-0 flex-col p-4 gap-2" />
+ <Toast.List class="absolute bottom-0 right-0 flex flex-col p-4 gap-2" />
</Toast.Region>
<Toast.Region regionId="stable-toast" duration={Infinity}>
<Toast.List class="absolute bottom-0 right-0 flex flex-col p-4 gap-2" />
diff --git a/js/app/packages/core/component/UserTooltip.tsx b/js/app/packages/core/component/UserTooltip.tsx
index 9d92435385..7809d5a39c 100644
--- a/js/app/packages/core/component/UserTooltip.tsx
+++ b/js/app/packages/core/component/UserTooltip.tsx
@@ -1,6 +1,6 @@
import { useSplitLayout } from '@app/component/split-layout/layout';
import { ClippedPanel } from '@core/component/ClippedPanel';
-import { beveledCorners } from '../../block-theme/signals/themeSignals';
+import { beveledCorners } from '../signal/beveledCorners';
import { toast } from '@core/component/Toast/Toast';
import { isOk } from '@core/util/maybeResult';
import IconCheck from '@icon/regular/check.svg';
diff --git a/js/app/packages/core/signal/beveledCorners.ts b/js/app/packages/core/signal/beveledCorners.ts
new file mode 100644
index 0000000000..f0b79e98fa
--- /dev/null
+++ b/js/app/packages/core/signal/beveledCorners.ts
@@ -0,0 +1,9 @@
+import { createSignal } from 'solid-js';
+import { makePersisted } from '@solid-primitives/storage';
+
+const BEVELED_CORNERS_DEFAULT = true;
+
+export const [beveledCorners, setBeveledCorners] = makePersisted(
+ createSignal<boolean>(BEVELED_CORNERS_DEFAULT),
+ { name: 'macro-beveled-corners' }
+);
diff --git a/js/app/packages/queries/email/thread.ts b/js/app/packages/queries/email/thread.ts
index 06705f7fc2..a6d5108188 100644
--- a/js/app/packages/queries/email/thread.ts
+++ b/js/app/packages/queries/email/thread.ts
@@ -1,3 +1,4 @@
+import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { toast } from '@core/component/Toast/Toast';
import { DEFAULT_THREAD_MESSAGES_LIMIT } from '@core/constant/pagination';
import { catchToResult, isErr, ok, throwOnErr } from '@core/util/maybeResult';
@@ -397,19 +398,22 @@ export async function blockSenderWithToast(senderEmail: string) {
toast.success(
'Sender blocked',
`All new messages will be trashed for ${senderEmail}`,
- {
- text: 'Undo',
- onClick: async () => {
- const undoResult = await emailClient.unblockSender({
- email_address: senderEmail,
- });
- if (isErr(undoResult)) {
- toast.failure('Failed to unblock sender', senderEmail);
- } else {
- toast.success('Sender unblocked');
- }
+ [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: async () => {
+ const undoResult = await emailClient.unblockSender({
+ email_address: senderEmail,
+ });
+ if (isErr(undoResult)) {
+ toast.failure('Failed to unblock sender', senderEmail);
+ } else {
+ toast.success('Sender unblocked');
+ }
+ },
},
- }
+ ]
);
}
@@ -435,20 +439,23 @@ async function upsertSenderFilterWithToast(
toast.success(
`Sender marked as ${label}`,
`Messages from ${senderEmail} will appear in ${label}`,
- {
- text: 'Undo',
- onClick: async () => {
- const undoResult = await emailClient.deleteEmailFilter({
- id: filterId,
- });
- if (isErr(undoResult)) {
- toast.failure('Failed to undo', senderEmail);
- } else {
- invalidateAllSoup();
- toast.success('Sender filter removed');
- }
+ [
+ {
+ label: 'Undo',
+ icon: ArrowCounterClockwise,
+ onClick: async () => {
+ const undoResult = await emailClient.deleteEmailFilter({
+ id: filterId,
+ });
+ if (isErr(undoResult)) {
+ toast.failure('Failed to undo', senderEmail);
+ } else {
+ invalidateAllSoup();
+ toast.success('Sender filter removed');
+ }
+ },
},
- }
+ ]
);
}