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(email): restyle (#3301)

teo0bb1da36b34a
diff --git a/js/app/packages/block-email/component/AttachmentPill.tsx b/js/app/packages/block-email/component/AttachmentPill.tsx
index 24be40db25..d61877e46d 100644
--- a/js/app/packages/block-email/component/AttachmentPill.tsx
+++ b/js/app/packages/block-email/component/AttachmentPill.tsx
@@ -26,7 +26,7 @@ export function EmailAttachmentPill(props: EmailAttachmentPillProps) {
return (
<div
ref={parentDiv}
- class="items-center text-xs flex flex-row p-2 w-36 rounded border border-edge hover:bg-hover hover-transition-bg"
+ class="items-center text-xs flex flex-row p-2 w-36 rounded-lg border border-ink-muted/8 bg-ink-muted/[0.025] hover:bg-ink-muted/[0.06] cursor-pointer"
classList={{
'pl-2': props.removable,
}}
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 3a94f06da9..073018c6f2 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -1099,6 +1099,40 @@ export function BaseInput(props: {
displayPriority: 10,
});
+ registerHotkey({
+ hotkey: 'arrowup',
+ scopeId: composeHotkeyScope,
+ description: 'Select last message',
+ runWithInputFocused: true,
+ condition: () => {
+ const ed = editor();
+ if (!ed) return false;
+ const rootEl = ed.getRootElement();
+ if (!rootEl || !rootEl.contains(document.activeElement)) return false;
+ return ed.read(() => {
+ const text = $getRoot().getTextContent();
+ return text.trim().length === 0;
+ });
+ },
+ keyDownHandler: () => {
+ const messages = ctx.messages.list();
+ if (!messages?.length) return false;
+ const lastMsg = messages[messages.length - 1];
+ if (!lastMsg?.db_id) return false;
+ editor()?.blur();
+ ctx.messages.setFocused(lastMsg.db_id);
+ const msgEl = document.querySelector(
+ `[data-message-body-id="${lastMsg.db_id}"]`
+ ) as HTMLElement | null;
+ const focusable = msgEl?.closest(
+ '[tabindex="0"]'
+ ) as HTMLElement | null;
+ focusable?.focus();
+ return true;
+ },
+ hotkeyToken: TOKENS.email.previousMessage,
+ });
+
registerHotkey({
hotkey: 'escape',
scopeId: composeHotkeyScope,
@@ -1280,10 +1314,10 @@ export function BaseInput(props: {
ref={(el) => {
composeContainerRef = el;
}}
- class="relative flex flex-col flex-1 bg-surface border border-edge rounded-md max-w-full"
+ class="relative flex flex-col flex-1 bg-ink-muted/[0.025] border border-ink-muted/8 rounded-lg max-w-full"
>
{/* Top Bar */}
- <div class="relative flex items-start gap-2 p-2">
+ <div class="relative flex items-start gap-2 px-3 pt-1.5 pb-0.5">
<DropdownMenu>
<DropdownMenu.Trigger>
<div class="px-1">
@@ -1480,7 +1514,7 @@ export function BaseInput(props: {
</div>
<div class="size-full flex flex-col">
<Show when={showFormatRibbon()}>
- <div class="flex flex-row w-full gap-2 items-center p-2">
+ <div class="flex flex-row w-full gap-2 items-center px-3 py-1.5">
<FormatButtons
selectionState={() => formatState}
onInlineFormat={(format) => {
@@ -1501,7 +1535,7 @@ export function BaseInput(props: {
</div>
</Show>
<div
- class="max-h-80 overflow-y-scroll w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-3"
+ class="max-h-80 overflow-y-scroll w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1 [&_.text-ink-placeholder]:left-0 [&_.text-ink-placeholder>p]:my-0"
onclick={() => {
editor()?.focus();
}}
@@ -1628,7 +1662,7 @@ export function BaseInput(props: {
</For>
</div>
</div>
- <div class="flex flex-row w-full h-8 justify-between items-center p-2 mb-2 space-x-2">
+ <div class="flex flex-row w-full h-9 justify-between items-center px-3 pb-2 pt-0.5 space-x-2">
<div class="flex flex-row items-center gap-1">
<div class="relative">
<Button
@@ -1717,17 +1751,13 @@ export function BaseInput(props: {
!!form().sendTime()
}
onClick={() => sendEmail()}
- class="text-ink-muted hover:scale-115 transition ease-in-out flex-col items-center rounded-full p-[0.25lh] hover:bg-transparent disabled:opacity-30"
+ class="flex items-center justify-center rounded-full size-7 bg-accent hover:bg-accent/90 disabled:opacity-30 disabled:cursor-not-allowed"
>
<Show
when={!sendMutation.isPending}
- fallback={
- <Spinner class="size-6 animate-spin cursor-disabled" />
- }
+ fallback={<Spinner class="size-4 animate-spin text-surface" />}
>
- <div class="group hover:bg-accent transition ease-in-out size-6 border border-accent rounded-full flex items-center justify-center p-0">
- <ArrowUp class="group-hover:text-surface! group-hover:fill-surface! text-accent! fill-accent! size-4 transition ease-in-out" />
- </div>
+ <ArrowUp class="text-surface! fill-surface! size-4" />
</Show>
</button>
</Tooltip>
diff --git a/js/app/packages/block-email/component/BottomReplyButtons.tsx b/js/app/packages/block-email/component/BottomReplyButtons.tsx
index 2aed21b218..eff738a72e 100644
--- a/js/app/packages/block-email/component/BottomReplyButtons.tsx
+++ b/js/app/packages/block-email/component/BottomReplyButtons.tsx
@@ -5,12 +5,30 @@ import ArrowBendUpRight from '@icon/regular/arrow-bend-up-right.svg';
import type { ApiMessage } from '@service-email/generated/schemas';
import { createCallback } from '@solid-primitives/rootless';
import { Button } from '@ui';
-import { Show } from 'solid-js';
+import { type Component, Show } from 'solid-js';
import { isReplyAllEligible } from '../util/recipientConversion';
import type { ReplyType } from '../util/replyType';
import { useEmailContext } from './EmailContext';
import { getEmailFormRegistry } from './EmailFormContext';
+function ReplyActionButton(props: {
+ icon: Component<{ class?: string }>;
+ label: string;
+ onClick: () => void;
+}) {
+ return (
+ <Button
+ variant="base"
+ size="sm"
+ class="rounded-lg px-3 py-1.5 text-sm text-ink-muted hover:text-ink border border-ink-muted/8 bg-ink-muted/[0.025] hover:bg-ink-muted/[0.06]"
+ onClick={props.onClick}
+ >
+ <props.icon class="size-3.5" />
+ <span>{props.label}</span>
+ </Button>
+ );
+}
+
export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {
const ctx = useEmailContext();
const formRegistry = getEmailFormRegistry();
@@ -33,37 +51,25 @@ export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {
});
return (
- <div class="w-full border-t border-edge-muted pt-3 pb-2">
- <div class="flex flex-row items-center gap-2 pl-[calc(var(--user-icon-width)+2*var(--message-padding-x))]">
- <Button
- variant="base"
- size="md"
- class="rounded-full px-4 py-1"
+ <div class="w-full pt-2 pb-1">
+ <div class="flex flex-row items-center gap-2">
+ <ReplyActionButton
+ icon={ArrowBendUpLeft}
+ label="Reply"
onClick={open('reply')}
- >
- <ArrowBendUpLeft class="size-4" />
- <span>Reply</span>
- </Button>
+ />
<Show when={shouldShowReplyAll()}>
- <Button
- variant="base"
- size="md"
- class="rounded-full px-4 py-1"
+ <ReplyActionButton
+ icon={ArrowBendDoubleUpLeft}
+ label="Reply all"
onClick={open('reply-all')}
- >
- <ArrowBendDoubleUpLeft class="size-4" />
- <span>Reply all</span>
- </Button>
+ />
</Show>
- <Button
- variant="base"
- size="md"
- class="rounded-full px-4 py-1"
+ <ReplyActionButton
+ icon={ArrowBendUpRight}
+ label="Forward"
onClick={open('forward')}
- >
- <ArrowBendUpRight class="size-4" />
- <span>Forward</span>
- </Button>
+ />
</div>
</div>
);
diff --git a/js/app/packages/block-email/component/CollapsedMessage.tsx b/js/app/packages/block-email/component/CollapsedMessage.tsx
index 32f15b8612..7068a8a500 100644
--- a/js/app/packages/block-email/component/CollapsedMessage.tsx
+++ b/js/app/packages/block-email/component/CollapsedMessage.tsx
@@ -2,7 +2,7 @@ import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
import { useEmail } from '@core/context/user';
import type { ApiMessage } from '@service-email/generated/schemas';
import { cn } from '@ui/utils/classname';
-import { createMemo, createSignal } from 'solid-js';
+import { createMemo } from 'solid-js';
import { getSenderDisplayName, getSenderMacroId } from '../util/emailUser';
import { formatShortDate } from './EmailMessageTopBar';
import { EmailUserTooltip } from './EmailUserTooltip';
@@ -10,13 +10,10 @@ import { EmailUserTooltip } from './EmailUserTooltip';
interface CollapsedMessageProps {
message: ApiMessage;
isFocused: boolean;
- isFirstMessage: boolean;
onClick: () => void;
}
export function CollapsedMessage(props: CollapsedMessageProps) {
- const [hover, setHover] = createSignal(false);
- const [hasMouseLeft, setHasMouseLeft] = createSignal(false);
const currentUserEmail = useEmail();
const senderDisplay = createMemo(() =>
@@ -30,7 +27,6 @@ export function CollapsedMessage(props: CollapsedMessageProps) {
});
const snippet = createMemo(() => {
- // Prefer body_text for snippet, fall back to stripping HTML
if (props.message.body_text) {
return props.message.body_text.replace(/\s+/g, ' ').trim();
}
@@ -54,41 +50,24 @@ export function CollapsedMessage(props: CollapsedMessageProps) {
return (
<div class="shrink-0 flex justify-center w-full">
- {/* These pl/pr below are needed to align with expanded messages at mobile width. */}
- <div class="macro-message-width macro-message-margin w-full pl-2 pr-4 sm:px-0">
+ <div class="macro-message-width macro-message-padding w-full">
<div
- class={cn('relative flex flex-row items-center w-full pb-2', {
- 'bg-active': props.isFocused,
- 'bg-hover': hover(),
- 'pt-2': !props.isFirstMessage,
- 'opacity-80': hasMouseLeft() && !hover(),
- 'opacity-100': !hasMouseLeft() || hover(),
- })}
+ class={cn(
+ 'relative flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer min-w-0 ring-1 ring-inset',
+ props.isFocused
+ ? 'bg-active/60 ring-edge'
+ : 'bg-ink-muted/[0.025] ring-ink-muted/8 hover:bg-active/40 hover:ring-edge'
+ )}
data-message-body-id={props.message.db_id}
tabIndex={0}
onClick={props.onClick}
onKeyDown={handleKeyDown}
- onMouseEnter={() => setHover(true)}
- onMouseLeave={() => {
- setHover(false);
- setHasMouseLeft(true);
- }}
>
- {/* Rail line - behind avatar */}
<div
- class="absolute top-0 bottom-0 border-l border-rail z-0"
- style={{
- left: 'var(--left-of-connector)',
- }}
- />
- {/* Avatar - centered on the rail, in front of rail */}
- <div
- class="relative z-10 flex justify-center items-center shrink-0"
+ class="shrink-0 flex justify-center items-center"
style={{
width: 'var(--user-icon-width)',
height: 'var(--user-icon-width)',
- 'margin-left':
- 'calc(var(--left-of-connector) - var(--user-icon-width) / 2 + 1px)',
}}
>
<UserIcon
@@ -98,24 +77,17 @@ export function CollapsedMessage(props: CollapsedMessageProps) {
suppressClick={true}
/>
</div>
- {/* Sender + Snippet - aligned with expanded message content */}
- <div
- class="flex-1 flex items-center min-w-0"
- style={{
- 'padding-left': 'var(--message-padding-x)',
- }}
- >
- <span class="w-16 shrink-0">
- <EmailUserTooltip recipient={props.message.from}>
- <span class="text-ink font-semibold truncate text-sm cursor-default block">
- {senderDisplay()}
- </span>
- </EmailUserTooltip>
- </span>
- <span class="text-ink truncate">{snippet()}</span>
+ <div class="shrink-0 min-w-0 max-w-28">
+ <EmailUserTooltip recipient={props.message.from}>
+ <div class="text-sm font-medium text-ink truncate cursor-default">
+ {senderDisplay()}
+ </div>
+ </EmailUserTooltip>
+ </div>
+ <div class="flex-1 min-w-0 text-sm text-ink-muted/60 truncate">
+ {snippet()}
</div>
- {/* Date */}
- <div class="text-xs text-ink shrink-0 ml-4 pr-2">
+ <div class="shrink-0 text-xs text-ink-extra-muted tabular-nums">
{props.message.internal_date_ts &&
formatShortDate(props.message.internal_date_ts)}
</div>
diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsx
index f5762de4e0..0dba484fa4 100644
--- a/js/app/packages/block-email/component/Email.tsx
+++ b/js/app/packages/block-email/component/Email.tsx
@@ -32,6 +32,7 @@ import { registerEmailHotkeys } from '../util/emailHotkeys';
import { scrollToMessage } from '../util/scrollToMessage';
import { BottomReplyButtons } from './BottomReplyButtons';
import { EmailFormContextProvider } from './EmailFormContext';
+import { EmailParticipants } from './EmailParticipants';
import { MessageList } from './MessageList';
import { ModalsProvider } from './ModalsProvider';
import { TopBar } from './TopBar';
@@ -216,8 +217,7 @@ function EmailContent(props: EmailViewProps) {
);
context.messages.setFocused(lastUnreadMessageId_!);
} else {
- // No unread message, scroll to last message
- scrollToLastMessage('instant', true);
+ scrollToLastMessage('instant', false);
}
}
@@ -289,10 +289,22 @@ function EmailContent(props: EmailViewProps) {
});
const navigateMessage = createCallback((dir: 'prev' | 'next') => {
- const currentFocusedId = context.messages.focusedID();
const messages = context.messages.list();
const list = context.messagesListRef();
- if (!currentFocusedId || !messages || !list) return false;
+ if (!messages?.length || !list) return false;
+
+ const currentFocusedId = context.messages.focusedID();
+
+ if (!currentFocusedId) {
+ const target =
+ dir === 'prev' ? messages[messages.length - 1] : messages[0];
+ if (!target?.db_id) return false;
+ performScrollToMessage(target.db_id, {
+ behavior: 'smooth',
+ focus: true,
+ });
+ return true;
+ }
const currentIndex = messages.findIndex(
(m) => m.db_id === currentFocusedId
@@ -300,13 +312,18 @@ function EmailContent(props: EmailViewProps) {
if (currentIndex < 0) return false;
const delta = dir === 'prev' ? -1 : 1;
-
const targetIndex = currentIndex + delta;
- if (targetIndex < 0 || targetIndex >= messages.length) return false;
+ if (targetIndex < 0 || targetIndex >= messages.length) {
+ if (dir === 'next' && markdownDomRef) {
+ context.messages.setFocused(undefined);
+ markdownDomRef.focus();
+ return true;
+ }
+ return false;
+ }
const targetMsg = messages[targetIndex];
-
if (!targetMsg?.db_id) return false;
performScrollToMessage(targetMsg.db_id, {
@@ -502,13 +519,16 @@ function EmailContent(props: EmailViewProps) {
<div
class="macro-message-width macro-message-padding w-full border-b"
classList={{
- 'border-edge-muted': isScrolled(),
+ 'border-edge-muted/50': isScrolled(),
'border-transparent': !isScrolled(),
}}
>
- <h1 class="ph-no-capture text-3xl font-semibold text-ink pt-3 pb-2">
+ <h1 class="ph-no-capture text-2xl font-semibold text-ink pt-3 pb-1.5 tracking-tight text-balance">
{props.title}
</h1>
+ <div class="pb-2.5">
+ <EmailParticipants />
+ </div>
</div>
</div>
</Show>
@@ -530,7 +550,7 @@ function EmailContent(props: EmailViewProps) {
}
>
{(info) => (
- <div class="shrink-0 w-full pb-2">
+ <div class="shrink-0 w-full pb-4">
<div class="relative w-full flex flex-row justify-center bg-surface macro-message-width macro-message-padding mx-auto">
<FloatingInputLoader
isLoading={context.query.isFetching}
diff --git a/js/app/packages/block-email/component/EmailMessageBody.tsx b/js/app/packages/block-email/component/EmailMessageBody.tsx
index 54615f1bf6..118315efb5 100644
--- a/js/app/packages/block-email/component/EmailMessageBody.tsx
+++ b/js/app/packages/block-email/component/EmailMessageBody.tsx
@@ -295,7 +295,7 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {
return (
<div
- class="ph-no-capture flex flex-col pt-2"
+ class="ph-no-capture flex flex-col pt-1 max-sm:-ml-[calc(var(--user-icon-width)+var(--message-padding-x))]"
onPointerDown={() => {
if (!props.isBodyExpanded() && props.message.db_id) {
props.setExpandedMessageBody(props.message.db_id);
@@ -335,12 +335,13 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {
<Match when={true}>{host()}</Match>
</Switch>
<Show when={!showFullHTML() && hasHiddenReplyStructure()}>
- <div class="flex items-center gap-2 mt-2">
+ <div class="flex items-center mt-1.5">
<Button
variant="ghost"
size="icon-sm"
onClick={() => setShowFullHTML(true)}
class={cn(
+ 'rounded-md text-ink-extra-muted hover:text-ink-muted',
props.isFocused ? 'hover:bg-surface' : 'hover:bg-active'
)}
>
diff --git a/js/app/packages/block-email/component/EmailMessageTopBar.tsx b/js/app/packages/block-email/component/EmailMessageTopBar.tsx
index 3cc943d90e..57ecc5b43b 100644
--- a/js/app/packages/block-email/component/EmailMessageTopBar.tsx
+++ b/js/app/packages/block-email/component/EmailMessageTopBar.tsx
@@ -16,7 +16,6 @@ import {
import {
getRecipientDisplayName,
getSenderDisplayName,
- isMessageFromCurrentUser,
} from '../util/emailUser';
import { useEmailContext } from './EmailContext';
import { EmailUserTooltip } from './EmailUserTooltip';
@@ -69,80 +68,66 @@ export function formatShortDate(date: DateValue): string {
});
}
-function RecipientRow(props: {
+function RecipientChip(props: { recipient: Recipient }): JSX.Element {
+ return (
+ <EmailUserTooltip recipient={props.recipient}>
+ <span class="cursor-default whitespace-nowrap">
+ <span class="text-ink">
+ {props.recipient.name ?? props.recipient.email}
+ </span>
+ <Show when={props.recipient.name && props.recipient.email}>
+ <span class="text-ink-extra-muted ml-1.5">
+ {props.recipient.email}
+ </span>
+ </Show>
+ </span>
+ </EmailUserTooltip>
+ );
+}
+
+function DetailRow(props: {
label: string;
recipients: Recipient[];
- bold?: boolean;
}): JSX.Element {
return (
<Show when={props.recipients.length > 0}>
- <div class="flex flex-row gap-2">
- <span class="text-ink-extra-muted min-w-10">{props.label}</span>
- <span class="select-text cursor-text">
+ <div class="flex flex-row gap-3 text-sm">
+ <span class="text-ink-extra-muted shrink-0 w-10 text-sm pt-0.5">
+ {props.label}
+ </span>
+ <div class="flex flex-row flex-wrap gap-y-1 select-text cursor-text min-w-0">
<For each={props.recipients}>
{(r, index) => (
<>
- <EmailUserTooltip recipient={r}>
- <span
- classList={{
- 'font-semibold': props.bold,
- 'text-ink': true,
- 'cursor-default': true,
- }}
- >
- {r.name ?? r.email}
- <Show when={r.name && r.email}>
- <span class="text-ink-muted"> &lt;{r.email}&gt;</span>
- </Show>
- </span>
- </EmailUserTooltip>
+ <RecipientChip recipient={r} />
<Show when={index() < props.recipients.length - 1}>
- <span class="text-ink-muted">, </span>
+ <span class="text-ink-extra-muted mr-2">,</span>
</Show>
</>
)}
</For>
- </span>
+ </div>
</div>
</Show>
);
}
-function ExpandedHeader(props: {
- message: ApiMessage;
- onClose: () => void;
-}): JSX.Element {
+function ExpandedDetails(props: { message: ApiMessage }): JSX.Element {
+ const fromRecipients = createMemo(() =>
+ props.message.from ? [props.message.from] : []
+ );
+
return (
- <div class="flex flex-col gap-1 text-sm select-children cursor-text">
- <div class="flex flex-row gap-2">
- <span class="text-ink-extra-muted min-w-10">From</span>
- <span class="select-text cursor-text">
- <EmailUserTooltip recipient={props.message.from}>
- <span class="font-semibold text-ink cursor-default">
- {props.message.from?.name ?? props.message.from?.email}
- <Show
- when={props.message.from?.name && props.message.from?.email}
- >
- <span class="text-ink-muted">
- {' '}
- &lt;{props.message.from?.email}&gt;
- </span>
- </Show>
- </span>
- </EmailUserTooltip>
- </span>
- </div>
- <RecipientRow label="To" recipients={props.message.to} />
- <RecipientRow label="Cc" recipients={props.message.cc} bold />
- <RecipientRow label="Bcc" recipients={props.message.bcc} bold />
- <div class="flex flex-row items-center gap-2 text-ink-extra-muted">
- <Show when={props.message.internal_date_ts}>
- <span>{formatFullDate(props.message.internal_date_ts!)}</span>
- </Show>
- <Button variant="ghost" size="icon-sm" onClick={props.onClose}>
- <CaretUp />
- </Button>
- </div>
+ <div class="mt-2.5 py-3 border-y border-ink-muted/8 flex flex-col gap-1.5 text-sm">
+ <DetailRow label="From" recipients={fromRecipients()} />
+ <DetailRow label="To" recipients={props.message.to} />
+ <DetailRow label="Cc" recipients={props.message.cc} />
+ <DetailRow label="Bcc" recipients={props.message.bcc} />
+ <Show when={props.message.internal_date_ts}>
+ <div class="text-xs text-ink-extra-muted tabular-nums mt-1.5 select-text cursor-text">
+ {formatFullDate(props.message.internal_date_ts!)}
+ </div>
+ </Show>
</div>
);
}
@@ -173,10 +158,11 @@ function CollapsedRecipientList(props: {
);
}
-function CollapsedHeader(props: {
+function HeaderTopRow(props: {
senderName: string;
isHovering: boolean;
- onExpand: () => void;
+ isExpanded: boolean;
+ onToggle: () => void;
message: ApiMessage;
focused: boolean;
setShowReply: Setter<boolean>;
@@ -191,39 +177,48 @@ function CollapsedHeader(props: {
return (
<div class="flex flex-row w-full items-center justify-between">
- <div class="flex flex-row items-center gap-1 text-sm min-w-0">
- <span class="text-ink font-semibold truncate">
- <EmailUserTooltip recipient={props.message.from}>
- <span class="cursor-default">{props.senderName}</span>
- </EmailUserTooltip>
- <span style={{ padding: '0 0.275em' }}>to</span>
+ <div class="flex flex-row items-center gap-1.5 text-sm min-w-0">
+ <EmailUserTooltip recipient={props.message.from}>
+ <span class="text-ink font-medium cursor-default">
+ {props.senderName}
+ </span>
+ </EmailUserTooltip>
+ <span class="text-ink-extra-muted text-sm truncate">
+ to{' '}
<CollapsedRecipientList
recipients={allRecipients()}
currentUserEmail={props.currentUserEmail}
/>
</span>
<div
- class="transition-opacity"
classList={{
- 'opacity-0': !props.isHovering,
- 'opacity-100': props.isHovering,
+ 'opacity-0': !props.isHovering && !props.isExpanded,
+ 'opacity-100': props.isHovering || props.isExpanded,
}}
>
- <Tooltip label="Expand Message Header">
+ <Tooltip
+ label={
+ props.isExpanded
+ ? 'Collapse Message Header'
+ : 'Expand Message Header'
+ }
+ >
<Button
variant="ghost"
size="icon-sm"
onClick={(e) => {
e.stopPropagation();
- props.onExpand();
+ props.onToggle();
}}
>
- <CaretDown />
+ <Show when={props.isExpanded} fallback={<CaretDown />}>
+ <CaretUp />
+ </Show>
</Button>
</Tooltip>
</div>
</div>
- <div class="flex flex-row gap-4 items-center shrink-0">
+ <div class="flex flex-row gap-3 items-center shrink-0">
<MessageActions
message={props.message}
showActions={props.focused}
@@ -232,9 +227,11 @@ function CollapsedHeader(props: {
hiddenActions={props.hiddenActions}
/>
<Show when={props.message.internal_date_ts}>
- <div class="text-xs text-ink">
- {formatShortDate(props.message.internal_date_ts!)}
- </div>
+ <Tooltip label={formatFullDate(props.message.internal_date_ts!)}>
+ <div class="text-xs text-ink-extra-muted tabular-nums cursor-default">
+ {formatShortDate(props.message.internal_date_ts!)}
+ </div>
+ </Tooltip>
</Show>
</div>
</div>
@@ -265,10 +262,6 @@ export function EmailMessageTopBar(props: EmailMessageTopBarProps) {
});
};
- const _isFromCurrentUser = createMemo(() =>
- isMessageFromCurrentUser(props.message, userEmail())
- );
-
const senderName = createMemo(() =>
getSenderDisplayName(props.message, userEmail())
);
@@ -289,26 +282,22 @@ export function EmailMessageTopBar(props: EmailMessageTopBarProps) {
return (
<div
- class="ph-no-capture pr-2 flex items-center -mt-1 sm:mt-0"
+ class="ph-no-capture pr-1.5 flex flex-col w-full"
style={{ 'min-height': 'var(--user-icon-width)' }}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
onClick={handleClick}
>
<Show when={props.isBodyExpanded()}>
- <Show
- when={!props.expandedHeader()}
- fallback={
- <ExpandedHeader
- message={props.message}
- onClose={() => toggleExpandedHeader(false)}
- />
- }
+ <div
+ class="flex items-center"
+ style={{ 'min-height': 'var(--user-icon-width)' }}
>
- <CollapsedHeader
+ <HeaderTopRow
senderName={senderName()}
isHovering={isHovering()}
- onExpand={() => toggleExpandedHeader(true)}
+ isExpanded={props.expandedHeader()}
+ onToggle={() => toggleExpandedHeader(!props.expandedHeader())}
message={props.message}
focused={props.focused}
setShowReply={props.setShowReply}
@@ -316,6 +305,9 @@ export function EmailMessageTopBar(props: EmailMessageTopBarProps) {
hiddenActions={props.hiddenActions}
currentUserEmail={userEmail()}
/>
+ </div>
+ <Show when={props.expandedHeader()}>
+ <ExpandedDetails message={props.message} />
</Show>
</Show>
</div>
diff --git a/js/app/packages/block-email/component/EmailParticipants.tsx b/js/app/packages/block-email/component/EmailParticipants.tsx
new file mode 100644
index 0000000000..7418873885
--- /dev/null
+++ b/js/app/packages/block-email/component/EmailParticipants.tsx
@@ -0,0 +1,106 @@
+import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
+import { useEmail } from '@core/context/user';
+import { emailToMacroId } from '@core/user';
+import { createMemo, createSignal, For, Show } from 'solid-js';
+import { useEmailContext } from './EmailContext';
+import { EmailUserTooltip } from './EmailUserTooltip';
+
+interface Participant {
+ email: string;
+ name?: string;
+}
+
+const DEFAULT_VISIBLE_COUNT = 5;
+
+export function EmailParticipants() {
+ const context = useEmailContext();
+ const currentUserEmail = useEmail();
+ const [expanded, setExpanded] = createSignal(false);
+
+ const participants = createMemo(() => {
+ const messages = context.messages.unfiltered();
+ const seen = new Map<string, Participant>();
+
+ for (const m of messages) {
+ if (m.from?.email) {
+ const existing = seen.get(m.from.email);
+ if (!existing || (!existing.name && m.from.name)) {
+ seen.set(m.from.email, {
+ email: m.from.email,
+ name: m.from.name ?? undefined,
+ });
+ }
+ }
+ for (const r of [...m.to, ...m.cc]) {
+ if (!r.email) continue;
+ const existing = seen.get(r.email);
+ if (!existing || (!existing.name && r.name)) {
+ seen.set(r.email, {
+ email: r.email,
+ name: r.name ?? undefined,
+ });
+ }
+ }
+ }
+
+ return Array.from(seen.values());
+ });
+
+ const visibleParticipants = createMemo(() => {
+ const all = participants();
+ if (expanded() || all.length <= DEFAULT_VISIBLE_COUNT) return all;
+ return all.slice(0, DEFAULT_VISIBLE_COUNT);
+ });
+
+ const hiddenCount = createMemo(() =>
+ Math.max(0, participants().length - DEFAULT_VISIBLE_COUNT)
+ );
+
+ const getDisplayName = (p: Participant) => {
+ if (p.email === currentUserEmail()) return 'Me';
+ if (p.name) return p.name.split(' ')[0];
+ return p.email.split('@')[0];
+ };
+
+ const getIconProps = (p: Participant): UserIconProps => {
+ const macroId = emailToMacroId(p.email);
+ if (macroId) return { id: macroId };
+ return { email: p.email };
+ };
+
+ return (
+ <div class="flex flex-wrap gap-1.5" role="list">
+ <For each={visibleParticipants()}>
+ {(participant) => (
+ <EmailUserTooltip
+ recipient={{ email: participant.email, name: participant.name }}
+ >
+ <div
+ role="listitem"
+ class="inline-flex items-center gap-1.5 rounded-full border border-ink-muted/8 bg-ink-muted/[0.025] py-1 pr-2.5 pl-1.5 text-sm text-ink hover:bg-ink-muted/[0.06] cursor-default"
+ >
+ <UserIcon
+ {...getIconProps(participant)}
+ isDeleted={false}
+ size="sm"
+ suppressClick
+ />
+ <span class="truncate max-w-32">
+ {getDisplayName(participant)}
+ </span>
+ </div>
+ </EmailUserTooltip>
+ )}
+ </For>
+ <Show when={hiddenCount() > 0}>
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ class="inline-flex items-center rounded-full border border-ink-muted/8 bg-ink-muted/[0.025] px-3 py-1 text-sm text-ink-muted hover:text-ink hover:bg-ink-muted/[0.06] tabular-nums"
+ >
+ {expanded() ? 'Show less' : `+${hiddenCount()} more`}
+ </button>
+ </Show>
+ </div>
+ );
+}
diff --git a/js/app/packages/block-email/component/MessageActions.tsx b/js/app/packages/block-email/component/MessageActions.tsx
index abb1ef31a8..2a1471834d 100644
--- a/js/app/packages/block-email/component/MessageActions.tsx
+++ b/js/app/packages/block-email/component/MessageActions.tsx
@@ -49,7 +49,7 @@ export function MessageActions(props: {
return (
<div
- class="flex flex-row items-center gap-1 transition-opacity"
+ class="flex flex-row items-center gap-0.5"
classList={{
'opacity-0 pointer-events-none': !canShowActions(),
'opacity-100': canShowActions(),
@@ -57,11 +57,11 @@ export function MessageActions(props: {
>
<Show when={!props.hiddenActions?.includes('reply')}>
<Button
- class="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"
+ class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/[0.08]"
onClick={onChangeReplyType('reply')}
tooltip="Reply"
>
- <ArrowBendUpLeft class="size-5" />
+ <ArrowBendUpLeft class="size-3.5" />
</Button>
</Show>
<Show
@@ -70,20 +70,20 @@ export function MessageActions(props: {
}
>
<Button
- class="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"
+ class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/[0.08]"
onClick={onChangeReplyType('reply-all')}
tooltip="Reply all"
>
- <ArrowBendDoubleUpLeft class="size-5" />
+ <ArrowBendDoubleUpLeft class="size-3.5" />
</Button>
</Show>
<Show when={!props.hiddenActions?.includes('forward')}>
<Button
- class="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"
+ class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/[0.08]"
onClick={onChangeReplyType('forward')}
tooltip="Forward"
>
- <ArrowBendUpRight class="size-5" />
+ <ArrowBendUpRight class="size-3.5" />
</Button>
</Show>
</div>
diff --git a/js/app/packages/block-email/component/MessageContainer.tsx b/js/app/packages/block-email/component/MessageContainer.tsx
index 8ebdc9e743..216ec76856 100644
--- a/js/app/packages/block-email/component/MessageContainer.tsx
+++ b/js/app/packages/block-email/component/MessageContainer.tsx
@@ -6,14 +6,11 @@ import { EmailInput } from '@block-email/component/EmailInput';
import { EmailMessageBody } from '@block-email/component/EmailMessageBody';
import { EmailMessageTopBar } from '@block-email/component/EmailMessageTopBar';
import { getSenderMacroId } from '@block-email/util/emailUser';
-import { ThreadReplyInputConnector } from '@channel/Thread/ThreadReplyInputConnector';
import { ImageGalleryPreview } from '@core/component/ImageGalleryPreview';
import { Message } from '@core/component/Message';
import { toast } from '@core/component/Toast/Toast';
import { VideoPreview } from '@core/component/VideoPreview';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
-import { useUserId } from '@core/context/user';
-import { tryMacroId, useDisplayName } from '@core/user';
import { isErr } from '@core/util/maybeResult';
import { logger } from '@observability';
import { refetchSoupEntity } from '@queries/soup/cache';
@@ -22,7 +19,6 @@ import type { ApiMessage, Attachment } from '@service-email/generated/schemas';
import { storageServiceClient } from '@service-storage/client';
import type { FileType } from '@service-storage/generated/schemas/fileType';
import { createMemo, createSignal, For, Show } from 'solid-js';
-import { Portal } from 'solid-js/web';
interface MessageContainerProps {
message: ApiMessage;
@@ -43,9 +39,6 @@ export function MessageContainer(props: MessageContainerProps) {
});
const [expandedHeader, setExpandedHeader] = createSignal<boolean>(false);
- const [threadAppendMountTarget, setThreadAppendMountTarget] = createSignal<
- HTMLElement | undefined
- >();
const [showReplyInternal, setShowReplyInternal] =
createSignal<boolean>(false);
@@ -70,8 +63,6 @@ export function MessageContainer(props: MessageContainerProps) {
}
};
- const userId = useUserId();
- const [currentUserName] = useDisplayName(tryMacroId(userId() ?? ''));
const senderMacroId = createMemo(() => getSenderMacroId(props.message));
const isBodyExpanded = createMemo(() => {
@@ -201,7 +192,6 @@ export function MessageContainer(props: MessageContainerProps) {
<CollapsedMessage
message={props.message}
isFocused={props.isFocused}
- isFirstMessage={props.isFirstMessage}
onClick={handleExpand}
/>
}
@@ -209,152 +199,143 @@ export function MessageContainer(props: MessageContainerProps) {
{/* Expanded message view */}
<div class="shrink-0 flex justify-center w-full">
<div class="macro-message-width macro-message-padding w-full">
- <Message
- id={props.message.db_id ?? undefined}
- focused={props.isFocused}
- isFirstMessage={props.isFirstMessage}
- isLastMessage={props.isLastMessage}
- senderId={senderMacroId()}
- isNewMessage={isNewMessage()}
- isTarget={props.isTarget}
- hasReplyInputBelow={true}
- hasThreadChildren={
- !props.isLastMessage && (showReply() || !!draftChild())
- }
+ <div
+ class="relative rounded-lg overflow-hidden pl-1 pr-1.5 py-2 ring-1 ring-inset [&>div]:bg-transparent!"
+ classList={{
+ 'bg-active/60 ring-edge': props.isFocused,
+ 'bg-ink-muted/[0.025] ring-ink-muted/8': !props.isFocused,
+ }}
>
- <Message.TopBar>
- <EmailMessageTopBar
- message={props.message}
- focused={props.isFocused}
- setExpandedBodyId={context.messages.setExpandedBodyId}
- isBodyExpanded={isBodyExpanded}
- expandedHeader={expandedHeader}
- setExpandedHeader={setExpandedHeader}
- setFocusedMessageId={context.messages.setFocused}
- setShowReply={setShowReply}
- isLastMessage={props.isLastMessage}
- hiddenActions={
- !context.permissions().isOwner
- ? ['reply', 'reply-all', 'forward']
- : undefined
- }
- />
- </Message.TopBar>
- <Message.Body>
- <EmailMessageBody
- message={props.message}
- isBodyExpanded={isBodyExpanded}
- setExpandedMessageBody={(id) =>
- context.messages.setExpandedBodyId(id, true)
- }
- setFocusedMessageId={context.messages.setFocused}
- isFirstMessageInThread={props.isFirstMessage}
- isFocused={props.isFocused}
- />
- </Message.Body>
- {/* Image attachments */}
- <Show when={imageAttachmentsWithSfs().length > 0}>
- <div class="flex flex-wrap gap-2 mt-2">
- <ImageGalleryPreview
- images={imageAttachmentsWithSfs().map((a) => ({
- id: a.sfs_id!,
- }))}
- variant="small"
- attachmentIds={imageAttachmentsWithSfs().map((a) => a.db_id!)}
+ <Message
+ id={props.message.db_id ?? undefined}
+ focused={false}
+ isFirstMessage={true}
+ isLastMessage={props.isLastMessage}
+ senderId={senderMacroId()}
+ isNewMessage={isNewMessage()}
+ isTarget={props.isTarget}
+ hasReplyInputBelow={true}
+ hideConnectors
+ hasThreadChildren={
+ !props.isLastMessage && (showReply() || !!draftChild())
+ }
+ >
+ <Message.TopBar>
+ <EmailMessageTopBar
+ message={props.message}
+ focused={props.isFocused}
+ setExpandedBodyId={context.messages.setExpandedBodyId}
+ isBodyExpanded={isBodyExpanded}
+ expandedHeader={expandedHeader}
+ setExpandedHeader={setExpandedHeader}
+ setFocusedMessageId={context.messages.setFocused}
+ setShowReply={setShowReply}
+ isLastMessage={props.isLastMessage}
+ hiddenActions={
+ !context.permissions().isOwner
+ ? ['reply', 'reply-all', 'forward']
+ : undefined
+ }
/>
- </div>
- </Show>
-
- {/* Video attachments */}
- <Show when={videoAttachmentsWithSfs().length > 0}>
- <For each={videoAttachmentsWithSfs()}>
- {(attachment) => (
- <VideoPreview id={attachment.sfs_id!} variant="dynamic" />
- )}
- </For>
- </Show>
+ </Message.TopBar>
+ <Message.Body>
+ <EmailMessageBody
+ message={props.message}
+ isBodyExpanded={isBodyExpanded}
+ setExpandedMessageBody={(id) =>
+ context.messages.setExpandedBodyId(id, true)
+ }
+ setFocusedMessageId={context.messages.setFocused}
+ isFirstMessageInThread={props.isFirstMessage}
+ isFocused={props.isFocused}
+ />
+ </Message.Body>
+ {/* Image attachments */}
+ <Show when={imageAttachmentsWithSfs().length > 0}>
+ <div class="flex flex-wrap gap-2 mt-2">
+ <ImageGalleryPreview
+ images={imageAttachmentsWithSfs().map((a) => ({
+ id: a.sfs_id!,
+ }))}
+ variant="small"
+ attachmentIds={imageAttachmentsWithSfs().map(
+ (a) => a.db_id!
+ )}
+ />
+ </div>
+ </Show>
- {/* Other attachments (non-media or without sfs_id) */}
- <Show when={otherAttachments().length > 0}>
- <div class="flex flex-row overflow-x-scroll mt-2 gap-2">
- <For each={otherAttachments()}>
+ {/* Video attachments */}
+ <Show when={videoAttachmentsWithSfs().length > 0}>
+ <For each={videoAttachmentsWithSfs()}>
{(attachment) => (
- <EmailAttachmentPill
- attachment={{
- fileName: attachment.filename ?? '',
- mimeType: attachment.mime_type ?? undefined,
- }}
- onClick={(fileType) =>
- onClickAttachment(attachment, fileType)
- }
- />
+ <VideoPreview id={attachment.sfs_id!} variant="dynamic" />
)}
</For>
- </div>
- </Show>
+ </Show>
- {/* Draft attachments. Needed to display attachments of sent messages before they actually get sent (undo window). */}
- <Show
- when={
- draftAttachments().length > 0 ||
- forwardedAttachments().length > 0
- }
- >
- <div class="flex flex-row overflow-x-scroll mt-2 gap-2">
- <For each={draftAttachments()}>
- {(attachment) => (
- <EmailAttachmentPill
- attachment={{
- fileName: attachment.file_name,
- mimeType: attachment.content_type,
- }}
- />
- )}
- </For>
- <For each={forwardedAttachments()}>
- {(attachment) => (
- <EmailAttachmentPill
- attachment={{
- fileName: attachment.filename ?? '',
- mimeType: attachment.mime_type ?? undefined,
- }}
- />
- )}
- </For>
- </div>
- </Show>
- </Message>
- <Show when={(showReply() || draftChild()) && !props.isLastMessage}>
- <Message
- focused={false}
- unfocusable
- senderId={userId()}
- isFirstMessage={false}
- isLastMessage={false}
- threadDepth={1}
- isFirstInThread
- isLastInThread
- shouldShowThreadAppendInput
- setThreadAppendMountTarget={(el) =>
- setThreadAppendMountTarget(el)
- }
- >
- <Message.TopBar name={currentUserName()} />
- <div class="h-4" />
+ {/* Other attachments (non-media or without sfs_id) */}
+ <Show when={otherAttachments().length > 0}>
+ <div class="flex flex-row overflow-x-scroll mt-2 gap-2">
+ <For each={otherAttachments()}>
+ {(attachment) => (
+ <EmailAttachmentPill
+ attachment={{
+ fileName: attachment.filename ?? '',
+ mimeType: attachment.mime_type ?? undefined,
+ }}
+ onClick={(fileType) =>
+ onClickAttachment(attachment, fileType)
+ }
+ />
+ )}
+ </For>
+ </div>
+ </Show>
+
+ {/* Draft attachments */}
+ <Show
+ when={
+ draftAttachments().length > 0 ||
+ forwardedAttachments().length > 0
+ }
+ >
+ <div class="flex flex-row overflow-x-scroll mt-2 gap-2">
+ <For each={draftAttachments()}>
+ {(attachment) => (
+ <EmailAttachmentPill
+ attachment={{
+ fileName: attachment.file_name,
+ mimeType: attachment.content_type,
+ }}
+ />
+ )}
+ </For>
+ <For each={forwardedAttachments()}>
+ {(attachment) => (
+ <EmailAttachmentPill
+ attachment={{
+ fileName: attachment.filename ?? '',
+ mimeType: attachment.mime_type ?? undefined,
+ }}
+ />
+ )}
+ </For>
+ </div>
+ </Show>
</Message>
- <Show when={context.permissions().isOwner}>
- <Portal mount={threadAppendMountTarget()}>
- <div class="relative isolate">
- <ThreadReplyInputConnector />
+ <Show when={(showReply() || draftChild()) && !props.isLastMessage}>
+ <Show when={context.permissions().isOwner}>
+ <div class="border-t border-ink-muted/8 -mx-1.5 px-1.5 pt-2 pb-1 [&>*>div]:border-0! [&>*>div]:bg-transparent! [&>*>div]:rounded-none!">
<EmailInput
replyingTo={() => props.message}
setShowReply={setShowReply}
draft={draftChild()}
/>
</div>
- </Portal>
+ </Show>
</Show>
- </Show>
+ </div>
</div>
</div>
</Show>
diff --git a/js/app/packages/block-email/component/MessageList.tsx b/js/app/packages/block-email/component/MessageList.tsx
index 1ec8b53a10..2602a7faad 100644
--- a/js/app/packages/block-email/component/MessageList.tsx
+++ b/js/app/packages/block-email/component/MessageList.tsx
@@ -25,7 +25,7 @@ export function MessageList(props: MessageListProps) {
return (
<div
- class="pt-2 pb-6 w-full flex flex-col-reverse items-center overflow-y-scroll overflow-x-hidden hide-scrollbar text-sm"
+ class="pt-1 pb-6 w-full flex flex-col-reverse items-center overflow-y-scroll overflow-x-hidden hide-scrollbar text-sm gap-1.5"
ref={context.registerMessagesList}
onscroll={(e) => {
// Since the list is reversed, calculate scroll from visual top
@@ -114,7 +114,7 @@ export function MessageList(props: MessageListProps) {
<Show when={isMobile() && props.title}>
<div class="shrink-0 w-full flex justify-center pb-3">
<div class="macro-message-width macro-message-padding w-full">
- <h1 class="text-2xl font-semibold text-ink pt-1 pb-0">
+ <h1 class="text-xl font-semibold text-ink pt-1 pb-0 tracking-tight text-balance">
{props.title}
</h1>
</div>