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(md/core): update doc card/preview and add item/preview ui prims (#6398)

Seamus2538cbc59302
diff --git a/apps/web/src/components/ui/components/Card.docs.tsx b/apps/web/src/components/ui/components/Card.docs.tsx
new file mode 100644
index 0000000000..38e509dbfd
--- /dev/null
+++ b/apps/web/src/components/ui/components/Card.docs.tsx
@@ -0,0 +1,260 @@
+import { defineDoc } from '@app/features/ui-gallery/types';
+import FileText from '@phosphor/file-text.svg';
+import Terminal from '@phosphor/terminal.svg';
+import { createSignal, For, Show } from 'solid-js';
+import { Button } from './Button';
+import { Card } from './Card';
+import { Item } from './Item';
+
+// #region demo:canonical
+function CanonicalDemo() {
+ const [expanded, setExpanded] = createSignal(false);
+ return (
+ <Card class="w-full max-w-md">
+ <Card.Header>
+ <Item class="items-start gap-2 border-0 p-0">
+ <Card.Icon aria-hidden="true">
+ <FileText />
+ </Card.Icon>
+ <Item.Content>
+ <Card.Title>Making room for good work</Card.Title>
+ <Card.Description>
+ A working note on focus, rhythm, and collaboration.
+ </Card.Description>
+ <Card.Metadata class="gap-x-1.5 pt-1">
+ <span>Alex Morgan</span>
+ <span aria-hidden="true">·</span>
+ <span>Edited 2h ago</span>
+ </Card.Metadata>
+ </Item.Content>
+ </Item>
+ </Card.Header>
+ <Card.Body class="pt-2">
+ <p>
+ Protect a little time for thinking. Share the rough draft early, and
+ leave enough context for someone else to pick up the thread.
+ </p>
+ <Show when={expanded()}>
+ <p class="mt-3">
+ Start with one clear question. Gather a few references, record the
+ decisions, and finish with a next step that someone can own.
+ </p>
+ </Show>
+ </Card.Body>
+ <Card.Footer>
+ <Card.Metadata>4 min read</Card.Metadata>
+ <Button
+ size="sm"
+ variant="ghost"
+ aria-expanded={expanded()}
+ onClick={() => setExpanded(!expanded())}
+ >
+ {expanded() ? 'Show less' : 'Read more'}
+ </Button>
+ </Card.Footer>
+ </Card>
+ );
+}
+// #endregion
+
+// #region demo:setup
+function SetupDemo() {
+ const [expanded, setExpanded] = createSignal(false);
+ return (
+ <Card class="w-full max-w-md">
+ <Card.Header>
+ <Item class="items-start gap-2 border-0 p-0">
+ <Card.Icon aria-hidden="true">
+ <Terminal />
+ </Card.Icon>
+ <Item.Content>
+ <Card.Title>Connect your editor</Card.Title>
+ <Card.Description>Add Macro as a context source.</Card.Description>
+ <Card.Metadata>Setup guide · Example configuration</Card.Metadata>
+ </Item.Content>
+ </Item>
+ </Card.Header>
+ <Show when={expanded()}>
+ <Card.Body class="pt-0">
+ <Card variant="filled" offset={1}>
+ <Card.Body>
+ <pre class="whitespace-pre-wrap break-all text-xs">
+ <code>
+ {
+ '{\n "mcpServers": {\n "example": { "url": "https://example.com/mcp" }\n }\n}'
+ }
+ </code>
+ </pre>
+ </Card.Body>
+ </Card>
+ </Card.Body>
+ </Show>
+ <Card.Footer>
+ <Card.Metadata>No connection is made in this demo.</Card.Metadata>
+ <Button
+ size="sm"
+ variant="ghost"
+ aria-expanded={expanded()}
+ onClick={() => setExpanded(!expanded())}
+ >
+ {expanded() ? 'Hide configuration' : 'Show configuration'}
+ </Button>
+ </Card.Footer>
+ </Card>
+ );
+}
+// #endregion
+
+// #region demo:tool-result
+function ToolResultDemo() {
+ const [expanded, setExpanded] = createSignal(false);
+ return (
+ <Card class="w-full max-w-md">
+ <Card.Header>
+ <Item class="items-start gap-2 border-0 p-0">
+ <Card.Icon aria-hidden="true">
+ <Terminal />
+ </Card.Icon>
+ <Item.Content>
+ <Card.Title>Search complete</Card.Title>
+ <Card.Description>
+ Found references to the reading room project.
+ </Card.Description>
+ <Card.Metadata>3 results · 0.8 seconds</Card.Metadata>
+ </Item.Content>
+ </Item>
+ </Card.Header>
+ <Show when={expanded()}>
+ <Card.Body class="pt-0">
+ <Card variant="filled" offset={1}>
+ <Card.Body class="p-1">
+ <For
+ each={[
+ 'Reading room brief',
+ 'Material references',
+ 'First proposal',
+ ]}
+ >
+ {(name) => (
+ <Item size="sm" class="gap-2">
+ <Item.Icon aria-hidden="true">
+ <FileText />
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>{name}</Item.Title>
+ <Item.Metadata>Document · Design</Item.Metadata>
+ </Item.Content>
+ </Item>
+ )}
+ </For>
+ </Card.Body>
+ </Card>
+ </Card.Body>
+ </Show>
+ <Card.Footer>
+ <Card.Metadata>Read-only result</Card.Metadata>
+ <Button
+ size="sm"
+ variant="ghost"
+ aria-expanded={expanded()}
+ onClick={() => setExpanded(!expanded())}
+ >
+ {expanded() ? 'Hide results' : 'Show results'}
+ </Button>
+ </Card.Footer>
+ </Card>
+ );
+}
+// #endregion
+
+// #region demo:attachments
+function AttachmentsDemo() {
+ const [showAll, setShowAll] = createSignal(false);
+ const files = [
+ { name: 'Reading room brief.pdf', detail: 'Alex Morgan · 2.4 MB' },
+ {
+ name: 'Material and finish specifications.pdf',
+ detail: 'Seamus · 6.1 MB',
+ },
+ { name: 'Installation notes.pdf', detail: 'Alex Morgan · 840 KB' },
+ ];
+ return (
+ <Card class="w-full max-w-md">
+ <Card.Header>
+ <Card.Title>Shared in Design</Card.Title>
+ <Card.Description>
+ Files from the project conversation.
+ </Card.Description>
+ </Card.Header>
+ <Card.Body class="pt-0">
+ <div class="divide-y divide-edge-muted">
+ <For each={showAll() ? files : files.slice(0, 2)}>
+ {(file) => (
+ <Item size="sm" class="items-start gap-2 px-0">
+ <Item.Icon aria-hidden="true">
+ <FileText />
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>{file.name}</Item.Title>
+ <Item.Metadata>{file.detail}</Item.Metadata>
+ </Item.Content>
+ </Item>
+ )}
+ </For>
+ </div>
+ </Card.Body>
+ <Card.Footer>
+ <Card.Metadata>3 attachments</Card.Metadata>
+ <Button
+ size="sm"
+ variant="ghost"
+ aria-expanded={showAll()}
+ onClick={() => setShowAll(!showAll())}
+ >
+ {showAll() ? 'Show fewer' : 'Show all'}
+ </Button>
+ </Card.Footer>
+ </Card>
+ );
+}
+// #endregion
+
+export default defineDoc({
+ name: 'Card',
+ category: 'Data Display',
+ status: 'beta',
+ exports: ['Card'],
+ import: "import { Card, Item } from '@ui';",
+ description:
+ 'A canonical rich-content card: identity in Header, readable content in Body, and supporting details and actions in Footer. Title, Description, Metadata, and Icon share Item primitives: semibold text-sm titles, regular text-sm descriptions, and medium-weight text-xs details. Cards default to outlined; use filled for a surface background or ghost for no frame. Depth and offset inherit the Layer model.',
+ demos: [
+ {
+ id: 'canonical',
+ title: 'Card',
+ description:
+ 'Compose only the slots you need. This example uses a plain first-line icon, a clear title/description/details hierarchy, body content, and an expandable reading action.',
+ render: CanonicalDemo,
+ },
+ {
+ id: 'setup',
+ title: 'Integration setup',
+ description:
+ 'Inspired by McpSetupCards: a setup summary, expandable configuration, and a separate action footer. Sample data only.',
+ render: SetupDemo,
+ },
+ {
+ id: 'tool-result',
+ title: 'Tool result',
+ description:
+ 'Inspired by ToolCard: a result summary with optional output. The feature still owns streaming status and disclosure behavior.',
+ render: ToolResultDemo,
+ },
+ {
+ id: 'attachments',
+ title: 'Conversation attachments',
+ description:
+ 'Inspired by AttachmentEntityRow: a Card groups compact Item rows. A production migration would retain Entity navigation and permissions.',
+ render: AttachmentsDemo,
+ },
+ ],
+});
diff --git a/apps/web/src/components/ui/components/Card.tsx b/apps/web/src/components/ui/components/Card.tsx
new file mode 100644
index 0000000000..e7534eee21
--- /dev/null
+++ b/apps/web/src/components/ui/components/Card.tsx
@@ -0,0 +1,111 @@
+import { type ComponentProps, splitProps } from 'solid-js';
+import { cn } from '../utils/classname';
+import { Item } from './Item';
+import { Layer } from './Layer';
+
+export type CardProps = ComponentProps<'div'> & {
+ depth?: 0 | 1 | 2 | 3 | 4;
+ offset?: number;
+ variant?: 'ghost' | 'outlined' | 'filled';
+};
+
+function CardRoot(props: CardProps) {
+ const [local, rest] = splitProps(props, [
+ 'class',
+ 'depth',
+ 'offset',
+ 'variant',
+ 'children',
+ ]);
+ const variant = () => local.variant ?? 'outlined';
+ return (
+ <Layer depth={local.depth} offset={local.offset}>
+ <div
+ data-slot="card"
+ data-variant={variant()}
+ class={cn(
+ 'relative flex min-w-0 flex-col rounded-xl border border-transparent text-ink',
+ variant() === 'outlined' && 'border-edge-muted',
+ variant() === 'filled' ? 'border-edge bg-surface' : 'bg-transparent',
+ local.class
+ )}
+ {...rest}
+ >
+ {local.children}
+ </div>
+ </Layer>
+ );
+}
+
+function CardHeader(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="card-header"
+ class={cn('flex min-w-0 flex-col gap-1 p-3', local.class)}
+ {...rest}
+ />
+ );
+}
+
+function CardBody(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="card-body"
+ class={cn('min-w-0 p-3 text-sm leading-6', local.class)}
+ {...rest}
+ />
+ );
+}
+
+function CardMedia(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="card-media"
+ class={cn(
+ 'relative min-w-0 overflow-hidden bg-hover first:rounded-t-[inherit] last:rounded-b-[inherit] [&>img]:w-full [&>img]:object-cover',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function CardFooter(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="card-footer"
+ class={cn(
+ 'flex min-w-0 flex-wrap items-center justify-between gap-2 border-t border-edge-muted p-3',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+/** An intrinsic-height frame for rich content, composed with Item identity rows.
+ * @do Compose Header, Media, Body, and Footer in the order the content needs.
+ * @do Use Item inside Header; Card shares Item's Title, Description, Metadata, and Actions.
+ * @do Give media an explicit height or aspect ratio at the call site.
+ * @do Keep loading, selection, navigation, and data fetching with the feature.
+ * @do Use ghost for no frame, outlined (default) for a muted edge, and filled for bg-surface with border-edge.
+ * @do Set depth to choose a Layer surface depth; omit it to inherit the parent layer.
+ * @do Use offset={1} to sit one depth above the parent; Layer clamps depths to 0–4.
+ * @dont Wrap a card with nested actions in a button or link. Link its title instead.
+ * @dont Add empty slots for spacing; omitted slots take no space.
+ */
+export const Card = Object.assign(CardRoot, {
+ Header: CardHeader,
+ Media: CardMedia,
+ Body: CardBody,
+ Footer: CardFooter,
+ Title: Item.Title,
+ Icon: Item.Icon,
+ Description: Item.Description,
+ Metadata: Item.Metadata,
+ Actions: Item.Actions,
+});
diff --git a/apps/web/src/components/ui/components/Item.docs.tsx b/apps/web/src/components/ui/components/Item.docs.tsx
new file mode 100644
index 0000000000..b4389094bd
--- /dev/null
+++ b/apps/web/src/components/ui/components/Item.docs.tsx
@@ -0,0 +1,376 @@
+import { defineDoc } from '@app/features/ui-gallery/types';
+import CheckCircle from '@phosphor/check-circle.svg';
+import Circle from '@phosphor/circle.svg';
+import FilePdf from '@phosphor/file-pdf.svg';
+import FileText from '@phosphor/file-text.svg';
+import Heart from '@phosphor/heart.svg';
+import { createSignal, For, Show } from 'solid-js';
+import { Badge } from './Badge';
+import { Button } from './Button';
+import { Card } from './Card';
+import { Item } from './Item';
+
+// #region demo:reference
+function ReferenceDemo() {
+ const [saved, setSaved] = createSignal(false);
+ return (
+ <Item variant="outlined" class="w-full max-w-sm">
+ <Item.Media>
+ <FilePdf aria-hidden="true" />
+ </Item.Media>
+ <Item.Content>
+ <Item.Title>Design tokens</Item.Title>
+ <Item.Description>Updated 2 hours ago</Item.Description>
+ </Item.Content>
+ <Item.Actions>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ aria-label="Favorite Design tokens"
+ aria-pressed={saved()}
+ onClick={() => setSaved(!saved())}
+ >
+ <Heart class={saved() ? 'fill-current text-accent' : ''} />
+ </Button>
+ </Item.Actions>
+ </Item>
+ );
+}
+// #endregion
+
+// #region demo:inline-icon
+function InlineIconDemo() {
+ return (
+ <Item variant="outlined" class="w-full max-w-sm items-start gap-2">
+ <Item.Icon aria-hidden="true">
+ <FileText />
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>
+ A longer document title that wraps onto another line
+ </Item.Title>
+ <Item.Description>Alex Morgan - Updated today</Item.Description>
+ </Item.Content>
+ </Item>
+ );
+}
+// #endregion
+
+// #region demo:rows
+function RowsDemo() {
+ const [saved, setSaved] = createSignal(false);
+ return (
+ <div class="w-full max-w-md divide-y divide-edge-muted">
+ <Item>
+ <Item.Media>
+ <FileText aria-hidden="true" />
+ </Item.Media>
+ <Item.Content>
+ <Item.Title>Notes for the next chapter</Item.Title>
+ <Item.Description>
+ A shared place for ideas that deserve a second look.
+ </Item.Description>
+ <Item.Metadata>
+ <span>Document</span>
+ <span>Updated today</span>
+ </Item.Metadata>
+ </Item.Content>
+ <Item.Actions>
+ <Button
+ size="sm"
+ variant="ghost"
+ aria-pressed={saved()}
+ onClick={() => setSaved(!saved())}
+ >
+ {saved() ? 'Saved' : 'Save'}
+ </Button>
+ </Item.Actions>
+ </Item>
+ <Item>
+ <Item.Media>
+ <span
+ class="flex size-8 items-center justify-center rounded-full bg-accent/10 text-xs font-medium text-accent"
+ aria-hidden="true"
+ >
+ AM
+ </span>
+ </Item.Media>
+ <Item.Content>
+ <Item.Title>Alex Morgan</Item.Title>
+ <Item.Description>Product designer</Item.Description>
+ </Item.Content>
+ <Item.Actions>
+ <Badge size="sm" variant="outline">
+ Member
+ </Badge>
+ </Item.Actions>
+ </Item>
+ </div>
+ );
+}
+// #endregion
+
+// #region demo:compact
+function CompactDemo() {
+ return (
+ <Card class="w-full max-w-sm">
+ <Card.Header>
+ <Card.Title>Related reading</Card.Title>
+ <Card.Description>The same row works inside a card.</Card.Description>
+ </Card.Header>
+ <Card.Body class="p-1">
+ <Item size="sm">
+ <Item.Media>
+ <FileText aria-hidden="true" />
+ </Item.Media>
+ <Item.Content>
+ <Item.Title>
+ <a
+ class="rounded-sm underline decoration-edge underline-offset-4 focus-visible:outline-2 focus-visible:outline-accent"
+ href="#reading-note"
+ >
+ A longer title stays readable even when space is limited
+ </a>
+ </Item.Title>
+ <Item.Metadata>5 min read</Item.Metadata>
+ </Item.Content>
+ </Item>
+ </Card.Body>
+ <Card.Footer id="reading-note">
+ <Card.Description>
+ Use a real link for navigation. Adjacent actions remain independent.
+ </Card.Description>
+ </Card.Footer>
+ </Card>
+ );
+}
+// #endregion
+
+// #region demo:variants
+function VariantsDemo() {
+ return (
+ <div class="flex w-full max-w-md flex-col gap-3">
+ <For each={['ghost', 'outlined', 'filled'] as const}>
+ {(variant) => (
+ <Item variant={variant} depth={2}>
+ <Item.Media>
+ <FileText aria-hidden="true" />
+ </Item.Media>
+ <Item.Content>
+ <Item.Title>{variant}</Item.Title>
+ <Item.Description>
+ Depth 2 · the same content in every variant
+ </Item.Description>
+ </Item.Content>
+ </Item>
+ )}
+ </For>
+ </div>
+ );
+}
+// #endregion
+
+// #region demo:wrapping
+function WrappingDemo() {
+ return (
+ <div class="grid w-full gap-3 sm:grid-cols-2">
+ <For
+ each={[
+ 'Design tokens',
+ 'Design tokens for a quieter workspace, from the first draft to the final details',
+ ]}
+ >
+ {(title) => (
+ <Item variant="outlined" class="items-start gap-2">
+ <Item.Icon aria-hidden="true">
+ <FileText />
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>{title}</Item.Title>
+ <Item.Description>Alex Morgan - Edited 2h ago</Item.Description>
+ </Item.Content>
+ </Item>
+ )}
+ </For>
+ </div>
+ );
+}
+// #endregion
+
+// #region demo:task
+function TaskDemo() {
+ const [completed, setCompleted] = createSignal(false);
+ return (
+ <Item variant="outlined" class="w-full max-w-md items-start gap-2">
+ <Item.Icon>
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ class="shrink-0 rounded-full text-task"
+ aria-label="Complete review task"
+ aria-pressed={completed()}
+ onClick={() => setCompleted(!completed())}
+ >
+ <Show when={completed()} fallback={<Circle class="size-4" />}>
+ <CheckCircle class="size-4" />
+ </Show>
+ </Button>
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>Review the reading room proposal</Item.Title>
+ <Item.Description>Seamus - Today</Item.Description>
+ <Item.Metadata class="pt-2" aria-live="polite">
+ <Badge size="sm" variant="outline">
+ {completed() ? 'Completed' : 'Not started'}
+ </Badge>
+ <Badge size="sm" variant="outline">
+ Medium priority
+ </Badge>
+ <span>Alex + 2 others</span>
+ </Item.Metadata>
+ </Item.Content>
+ </Item>
+ );
+}
+// #endregion
+
+// #region demo:text-only
+function TextOnlyDemo() {
+ const [following, setFollowing] = createSignal(false);
+ return (
+ <Item variant="filled" depth={2} class="w-full max-w-md items-start">
+ <Item.Content>
+ <Item.Title>Design updates</Item.Title>
+ <Item.Description>
+ Decisions, drafts, and progress from the team.
+ </Item.Description>
+ <Item.Metadata class="gap-x-1.5 pt-1">
+ <span>12 members</span>
+ <span aria-hidden="true">·</span>
+ <span>3 unread</span>
+ </Item.Metadata>
+ </Item.Content>
+ <Item.Actions class="h-5">
+ <Button
+ size="sm"
+ variant="outline"
+ aria-pressed={following()}
+ onClick={() => setFollowing(!following())}
+ >
+ {following() ? 'Following' : 'Follow'}
+ </Button>
+ </Item.Actions>
+ </Item>
+ );
+}
+// #endregion
+
+// #region demo:attachments
+function AttachmentsDemo() {
+ return (
+ <div class="w-full max-w-md divide-y divide-edge-muted">
+ <For
+ each={[
+ { title: 'Reading room brief.pdf', detail: 'PDF · 8 pages · 2.4 MB' },
+ {
+ title: 'Material and finish specifications.pdf',
+ detail: 'PDF · 24 pages · 6.1 MB',
+ },
+ ]}
+ >
+ {(file) => (
+ <Item size="sm" class="items-start gap-2">
+ <Item.Icon aria-hidden="true">
+ <FilePdf />
+ </Item.Icon>
+ <Item.Content>
+ <Item.Title>{file.title}</Item.Title>
+ <Item.Description>{file.detail}</Item.Description>
+ </Item.Content>
+ <Item.Actions class="h-5">
+ <Badge size="sm" variant="outline">
+ PDF
+ </Badge>
+ </Item.Actions>
+ </Item>
+ )}
+ </For>
+ </div>
+ );
+}
+// #endregion
+
+export default defineDoc({
+ name: 'Item',
+ category: 'Data Display',
+ status: 'beta',
+ exports: ['Item'],
+ import: "import { Item } from '@ui';",
+ description:
+ 'An identity row for rich cards and lists. Titles and descriptions use text-sm with 20px leading: semibold titles and regular descriptions in ink-muted. Metadata uses medium text-xs with 16px leading in ink-subtle. Content keeps a 4px gap even when titles wrap. Icon is a plain inline-flex slot aligned with the first title line; Media is a larger tile.',
+ demos: [
+ {
+ id: 'wrapping',
+ title: 'Short and wrapped titles',
+ description:
+ 'Compare the same first-line alignment and byline gap across different title lengths.',
+ render: WrappingDemo,
+ },
+ {
+ id: 'task',
+ title: 'Interactive task status',
+ description:
+ 'The Icon slot can contain a real button. Toggle completion to try it; metadata stays aligned with the title.',
+ render: TaskDemo,
+ },
+ {
+ id: 'text-only',
+ title: 'Text-only with an action',
+ description:
+ 'Icons and media are optional. A follow button and metadata make a useful row on their own.',
+ render: TextOnlyDemo,
+ },
+ {
+ id: 'attachments',
+ title: 'Compact attachments',
+ description:
+ 'Small rows with plain file icons, wrapping filenames, and file facts.',
+ render: AttachmentsDemo,
+ },
+ {
+ id: 'inline-icon',
+ title: 'First-line icon',
+ description:
+ 'Item.Icon stays aligned with the first title line, independently of wrapping and secondary content.',
+ render: InlineIconDemo,
+ },
+ {
+ id: 'reference',
+ title: 'Document reference',
+ description:
+ 'A top-aligned media tile, two-line identity, and an independent favorite action. Use self-center on Media when centered alignment is preferred.',
+ render: ReferenceDemo,
+ },
+ {
+ id: 'variants',
+ title: 'Variants and depth',
+ description:
+ 'Items default to ghost. Outlined adds an edge; filled paints bg-surface using the selected depth. Omit depth to inherit the parent Layer.',
+ render: VariantsDemo,
+ },
+ {
+ id: 'rows',
+ title: 'Rich rows',
+ description:
+ 'Icons, avatars, metadata, badges, and stateful actions compose in the same slots.',
+ render: RowsDemo,
+ },
+ {
+ id: 'compact',
+ title: 'Compact and nested',
+ description:
+ 'Use small spacing for compact lists, or remove padding inside a Card.Header. Titles wrap instead of silently losing their label.',
+ render: CompactDemo,
+ },
+ ],
+});
diff --git a/apps/web/src/components/ui/components/Item.tsx b/apps/web/src/components/ui/components/Item.tsx
new file mode 100644
index 0000000000..192e628ead
--- /dev/null
+++ b/apps/web/src/components/ui/components/Item.tsx
@@ -0,0 +1,154 @@
+import { type ComponentProps, splitProps } from 'solid-js';
+import { cn } from '../utils/classname';
+import { Layer } from './Layer';
+
+export type ItemProps = ComponentProps<'div'> & {
+ size?: 'sm' | 'md';
+ depth?: 0 | 1 | 2 | 3 | 4;
+ offset?: number;
+ variant?: 'ghost' | 'outlined' | 'filled';
+};
+
+function ItemRoot(props: ItemProps) {
+ const [local, rest] = splitProps(props, [
+ 'class',
+ 'size',
+ 'depth',
+ 'offset',
+ 'variant',
+ 'children',
+ ]);
+ const variant = () => local.variant ?? 'ghost';
+ return (
+ <Layer depth={local.depth} offset={local.offset}>
+ <div
+ data-slot="item"
+ data-variant={variant()}
+ class={cn(
+ 'flex min-w-0 items-center gap-3 rounded-xl border border-transparent text-sm text-ink',
+ variant() === 'outlined' && 'border-edge-muted',
+ variant() === 'filled' ? 'border-edge bg-surface' : 'bg-transparent',
+ local.size === 'sm' ? 'p-2' : 'p-3',
+ local.class
+ )}
+ {...rest}
+ >
+ {local.children}
+ </div>
+ </Layer>
+ );
+}
+
+function ItemIcon(props: ComponentProps<'span'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <span
+ data-slot="item-icon"
+ class={cn(
+ 'inline-flex h-5 w-4 shrink-0 self-start items-center justify-center [&>svg]:size-4',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function ItemMedia(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-media"
+ class={cn(
+ 'flex size-10 shrink-0 self-start items-center justify-center overflow-hidden rounded-lg bg-hover text-ink-muted [&>svg]:size-5 [&>img]:size-full [&>img]:object-cover',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function ItemContent(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-content"
+ class={cn('flex min-w-0 flex-1 flex-col gap-1', local.class)}
+ {...rest}
+ />
+ );
+}
+
+function ItemTitle(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-title"
+ class={cn(
+ 'min-w-0 text-sm font-semibold leading-5 wrap-break-word',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function ItemDescription(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-description"
+ class={cn(
+ 'text-sm font-normal leading-5 text-ink-muted wrap-break-word',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function ItemMetadata(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-metadata"
+ class={cn(
+ 'flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs font-medium leading-4 text-ink-subtle',
+ local.class
+ )}
+ {...rest}
+ />
+ );
+}
+
+function ItemActions(props: ComponentProps<'div'>) {
+ const [local, rest] = splitProps(props, ['class']);
+ return (
+ <div
+ data-slot="item-actions"
+ class={cn('flex shrink-0 items-center gap-1', local.class)}
+ {...rest}
+ />
+ );
+}
+
+/** A content row shared by lists and rich cards.
+ * @do Compose Media, Content, and Actions in reading order; all slots are optional.
+ * @do Use Icon for a plain 1rem icon aligned with the first title line; Media is a larger top-aligned tile. Use self-center to opt into centered media.
+ * @do Use Title, Description, and Metadata inside Content for a consistent hierarchy.
+ * @do Put native links or Buttons inside slots for keyboard-accessible actions.
+ * @do Use size="sm" for compact rows, and class="p-0" inside a padded Card slot.
+ * @do Use ghost (default) for no frame, outlined for a muted edge, and filled for bg-surface with border-edge.
+ * @do Set depth to choose a Layer surface depth; omit it to inherit the parent layer.
+ * @do Use offset={1} to sit one depth above the parent; Layer clamps depths to 0–4.
+ * @dont Turn the root into a click target containing other interactive controls.
+ * @dont Truncate labels without a Tooltip; titles wrap by default.
+ */
+export const Item = Object.assign(ItemRoot, {
+ Icon: ItemIcon,
+ Media: ItemMedia,
+ Content: ItemContent,
+ Title: ItemTitle,
+ Description: ItemDescription,
+ Metadata: ItemMetadata,
+ Actions: ItemActions,
+});
diff --git a/apps/web/src/components/ui/index.ts b/apps/web/src/components/ui/index.ts
index e1c1b24d34..0e8174ebeb 100644
--- a/apps/web/src/components/ui/index.ts
+++ b/apps/web/src/components/ui/index.ts
@@ -37,6 +37,7 @@ export {
CalendarMonthMenu,
formatCalendarMonth,
} from './components/Calendar';
+export { Card, type CardProps } from './components/Card';
export type { ChatInputProps, ChatInputRows } from './components/ChatInput';
export type { CheckboxProps } from './components/Checkbox';
export {
@@ -114,6 +115,7 @@ export type {
InputGroupVariantProps,
} from './components/InputGroup';
export { InputGroup, inputGroupVariants } from './components/InputGroup';
+export { Item, type ItemProps } from './components/Item';
export { Layer } from './components/Layer';
export { LogoProgress } from './components/LogoProgress';
export type { NavRowProps } from './components/NavRow';
diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsx
index fda59ed0b4..904bc995e8 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx
@@ -17,18 +17,18 @@ import {
useMaybeBlockName,
} from '@core/block';
import { EntityIcon } from '@core/component/EntityIcon';
+import { useHoldParentHoverCardOpen } from '@core/component/HoverCard';
import { isBlockNameWithLocation } from '@core/component/LexicalMarkdown/component/core/BlockLink';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { channelTheme } from '@core/component/LexicalMarkdown/theme';
import { toast } from '@core/component/Toast/Toast';
-import { UserIcon as UserIconComponent } from '@core/component/UserIcon';
import { itemToBlockName, resolveBlockAlias } from '@core/constant/allBlocks';
import { getDisplayName, tryMacroId } from '@core/user';
import { copyBranchNameToClipboard } from '@core/util/branchName';
import { matches } from '@core/util/match';
+import DotsThree from '@icon/dots-three-large.svg';
import MacroEmbed from '@icon/macro-embed.svg';
import CollapseInlinePreview from '@phosphor/arrows-in-line-horizontal.svg';
-import OpenIcon from '@phosphor/arrows-out.svg';
import ExpandInlinePreview from '@phosphor/arrows-out-line-horizontal.svg';
import MessageIcon from '@phosphor/chat-circle.svg';
import ThreadIcon from '@phosphor/chats-circle.svg';
@@ -54,7 +54,7 @@ import { blockNameToItemType } from '@service-storage/client';
import { fetchBinary } from '@service-storage/util/fetchBinary';
import { createCallback } from '@solid-primitives/rootless';
import { useNavigate } from '@solidjs/router';
-import { cn, Surface, Tooltip } from '@ui';
+import { Card, cn, Dropdown, Item } from '@ui';
import type { Component, JSX } from 'solid-js';
import {
createEffect,
@@ -71,7 +71,10 @@ import { formatDate } from '../util/date';
import NotFound from './AccessErrorViews/NotFound';
import Unauthorized from './AccessErrorViews/Unauthorized';
import { useItemPreviewData } from './ItemPreview';
-import { TaskPropertiesPreview } from './TaskPropertiesPreview';
+import {
+ TaskPropertiesPreview,
+ TaskPropertiesPreviewProvider,
+} from './TaskPropertiesPreview';
/**
* Container for displaying mentions with optional collapsing
@@ -212,40 +215,6 @@ export const mentionsAccessories = (
}
};
-function PopupIcon(props: {
- icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>>;
-}) {
- return (
- <Dynamic
- component={props.icon}
- class="relative size-4 inline-flex items-center mx-1"
- />
- );
-}
-
-function PopupIconButton(props: {
- tooltip: string;
- onClick: () => void;
- icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>>;
-}) {
- return (
- <Tooltip label={props.tooltip}>
- <button
- aria-label={props.tooltip}
- onClick={(e) => {
- e.stopPropagation();
- props.onClick();
- }}
- class="rounded-md py-1 hover:bg-hover transition flex items-center gap-1.5"
- >
- <div class="w-fit flex justify-end items-center m-0.5 text-xs font-normal text-current/90">
- <PopupIcon icon={props.icon} />
- </div>
- </button>
- </Tooltip>
- );
-}
-
/**
* Metadata info component with icon and text
*/
@@ -273,26 +242,6 @@ function MetadataInfo(props: {
);
}
-/**
- * User info with icon and display name
- */
-function UserInfo(props: { userId: string }) {
- const displayName = () => getDisplayName(tryMacroId(props.userId));
- return (
- <div class="justify-start mt-2 w-fit max-w-[66%] text-ink-muted truncate flex items-center gap-1.5">
- <UserIconComponent
- id={props.userId}
- size="sm"
- suppressClick
- showTooltip={false}
- />
- <span class="relative text-[0.8em] text-ink-muted max-w-full">
- {displayName()}
- </span>
- </div>
- );
-}
-
/**
* Popup preview component for document references
*/
@@ -491,8 +440,8 @@ export type DocumentPreviewContentProps = {
/**
* The inner preview body shared by every document/task preview: the header
* (icon + filename + action buttons), the task body
- * ({@link TaskPropertiesPreview}), the image cover strip, the owner/updated
- * footer, and the loading / no_access / does_not_exist states.
+ * ({@link TaskPropertiesPreview}), the inset image preview, the author/update
+ * byline, and the loading / no_access / does_not_exist states.
*
* It renders NO floating/highlighted chrome — no colored highlight border, no
* shadow, no rounded floating shell. Wrap it in your own container to control
@@ -519,6 +468,9 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
const { item, ItemEntityIcon, documentProperties } =
useItemPreviewData(itemPreviewEntity);
+ const [menuOpen, setMenuOpen] = createSignal(false);
+ useHoldParentHoverCardOpen(menuOpen);
+
// Resolve the caller-provided type against the item's actual subType so
// that e.g. a markdown doc with `subType: { type: 'task' }` routes to the
// 'task' block alias instead of raw 'md'. Mirrors BlockLink/EntityMention.
@@ -719,118 +671,99 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
await handle?.goToLocationFromParams(props.documentInfo.params);
});
- /**
- * Renders the action buttons for the preview
- */
- const renderActionButtons = () => {
- const buttons = [];
-
- // Preview toggle button
- if (props.previewInfo?.showPreview) {
- buttons.push(
- <Show when={props.previewInfo.showPreview}>
- <PopupIconButton
- tooltip={
- props.previewInfo.isPreviewable
- ? 'Convert to Embed'
- : 'Convert to Card View'
- }
- onClick={props.previewInfo.handlePreviewToggle}
- icon={MacroEmbed}
- />
- </Show>
- );
- }
+ const PreviewTitle = (local: { name: string }) => (
+ <Item.Title>
+ <Show
+ when={props.documentInfo.isOpenable}
+ fallback={<span class="wrap-anywhere">{local.name}</span>}
+ >
+ <button
+ type="button"
+ class="min-w-0 text-left wrap-anywhere rounded-sm hover:underline focus-visible:outline-2 focus-visible:outline-accent"
+ onClick={(event) => {
+ event.stopPropagation();
+ void openDocument();
+ }}
+ >
+ {local.name}
+ </button>
+ </Show>
+ </Item.Title>
+ );
- // Collapse/expand button
- if (props.collapseInfo?.isCollapsable) {
- buttons.push(
- <>
- <Show
- when={props.collapseInfo?.isCollapsed}
- fallback={
- <PopupIconButton
- tooltip="Collapse Reference"
- onClick={handleToggleCollapse}
- icon={CollapseInlinePreview}
- />
- }
- >
- <PopupIconButton
- tooltip="Expand Reference"
- onClick={handleToggleCollapse}
- icon={ExpandInlinePreview}
- />
+ const renderActionButtons = () => (
+ <Item.Actions
+ class="col-start-3 row-start-1 h-5"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <Dropdown open={menuOpen()} onOpenChange={setMenuOpen}>
+ <Dropdown.Trigger
+ size="icon-sm"
+ variant="ghost"
+ aria-label="Reference actions"
+ >
+ <DotsThree />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="z-nested-action-menu">
+ <Dropdown.Group>
+ <Show when={props.previewInfo?.showPreview}>
+ <Dropdown.Item
+ onSelect={() => props.previewInfo?.handlePreviewToggle()}
+ >
+ <MacroEmbed class="size-4" />
+ {props.previewInfo?.isPreviewable
+ ? 'Convert to Embed'
+ : 'Convert to Card View'}
+ </Dropdown.Item>
+ </Show>
+ <Show when={props.collapseInfo?.isCollapsable}>
+ <Dropdown.Item onSelect={handleToggleCollapse}>
+ <Show
+ when={props.collapseInfo?.isCollapsed}
+ fallback={<CollapseInlinePreview class="size-4" />}
+ >
+ <ExpandInlinePreview class="size-4" />
+ </Show>
+ {props.collapseInfo?.isCollapsed
+ ? 'Expand Reference'
+ : 'Collapse Reference'}
+ </Dropdown.Item>
+ </Show>
+ <Show when={canOpenInChat()}>
+ <Dropdown.Item onSelect={handleOpenInChat}>
+ <SparkleIcon class="size-4" />
+ Open Document in AI Chat
+ </Dropdown.Item>
+ </Show>
+ <Dropdown.Item onSelect={handleCopy}>
+ <Link class="size-4" />
+ Copy Link
+ </Dropdown.Item>
+ <Show when={props.documentInfo.type === 'task'}>
+ <Dropdown.Item onSelect={handleCopyBranchName}>
+ <GitBranchIcon class="size-4" />
+ Copy Branch Name
+ </Dropdown.Item>
+ </Show>
+ <Show when={props.documentInfo.isOpenable && !isSplitAlreadyOpen()}>
+ <Dropdown.Item onSelect={() => void openInNewSplit()}>
+ <ColumnsPlusRight class="size-4" />
+ Open in New Split
+ </Dropdown.Item>
+ </Show>
+ </Dropdown.Group>
+ <Show when={props.delete}>
+ <Dropdown.Group>
+ <Dropdown.Item onSelect={() => props.delete?.()}>
+ <TrashSimple class="size-4" />
+ Delete
+ </Dropdown.Item>
+ </Dropdown.Group>
</Show>
- <div class="w-px mx-1 h-6 bg-edge" />
- </>
- );
- }
-
- // Open in AI chat button
- if (canOpenInChat()) {
- buttons.push(
- <PopupIconButton
- tooltip="Open Document in AI Chat"
- onClick={handleOpenInChat}
- icon={SparkleIcon}
- />
- );
- }
-
- buttons.push(
- <PopupIconButton tooltip="Copy Link" onClick={handleCopy} icon={Link} />
- );
-
- if (props.documentInfo.type === 'task') {
- buttons.push(
- <PopupIconButton
- tooltip="Copy Branch Name"
- onClick={handleCopyBranchName}
- icon={GitBranchIcon}
- />
- );
- }
-
- if (props.documentInfo.isOpenable) {
- buttons.push(
- <PopupIconButton
- tooltip="Open Fullscreen"
- onClick={openDocument}
- icon={OpenIcon}
- />
- );
-
- if (!isSplitAlreadyOpen()) {
- buttons.push(
- <PopupIconButton
- tooltip="Open in New Split"
- onClick={openInNewSplit}
- icon={ColumnsPlusRight}
- />
- );
- }
- }
-
- if (props.delete) {
- buttons.push(
- <PopupIconButton
- tooltip="Delete"
- onClick={props.delete}
- icon={TrashSimple}
- />
- );
- }
-
- // Add dividers between buttons
- return buttons.map((button, _index, _array) => (
- <>
- {button}
- {/* Divider */}
- {/* {index < array.length - 1 && <div class="w-px mx-1 h-6 bg-edge" />} */}
- </>
- ));
- };
+ </Dropdown.Content>
+ </Dropdown>
+ </Item.Actions>
+ );
return (
<Switch>
@@ -855,132 +788,167 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
};
return (
- <div class="w-full flex flex-col">
- {/* Header: icon + filename + action buttons */}
- <div class="flex items-center justify-between gap-2 p-2">
- <div class="flex items-center gap-2 min-w-0">
- <ItemEntityIcon size="sm" />
- <div class="text-sm font-semibold select-text min-w-0">
- <Show when={accessories()}>
- {(acc) => (
- <div class="text-[0.8em] text-ink-muted mt-1 select-none">
- {`${acc().note} `}
- {getMentionsIcon(acc().icon)}
- </div>
- )}
- </Show>
- </div>
- </div>
- <div class="flex shrink-0">{renderActionButtons()}</div>
- </div>
-
- <div class="line-clamp-2 wrap-break-word px-2 mb-2">
- {props.documentInfo.name || accessibleItem().name}
- </div>
-
- {/* Task properties: status, priority, assignees */}
- <Show when={props.documentInfo.type === 'task'}>
- <Suspense fallback={<div class="w-full bg-active h-4 m-2" />}>
- <TaskPropertiesPreview
- taskId={props.documentInfo.id}
- taskName={accessibleItem().name}
- previewProperties={documentProperties()}
- />
- </Suspense>
- </Show>
-
- {/* Calendar event schedule, location, and people */}
- <Show when={matches(item(), isCalendarEventPreviewItem)}>
- {(calendarItem) => (
- <CalendarEventPreviewDetails event={calendarItem().event} />
- )}
- </Show>
-
- {/* Visual preview for images */}
- <Show when={props.documentInfo.type === 'image'}>
- <ImageCoverStrip
- documentId={accessibleItem().id}
- fileType={accessibleItem().fileType}
- class="shrink-0 h-32"
- />
- </Show>
-
- {/* Footer: message context + owner/timestamp */}
- <Show
- when={
- messageContext() ||
- accessibleItem().owner ||
- accessibleItem().updatedAt ||
- props.snapshotInfo
- }
- >
- <div class="p-2 border-t border-edge-muted">
- <Show when={messageContext()}>
- {(context) => (
- <div class="mb-2 text-sm text-ink-muted border-l-2 border-edge pl-3 py-1">
- <div class="line-clamp-3 wrap-break-word">
- <StaticMarkdown
- markdown={context().content}
- theme={channelTheme}
- target="internal"
+ <TaskPropertiesPreviewProvider
+ taskId={
+ targetBlockType() === 'task' ? props.documentInfo.id : undefined
+ }
+ previewProperties={documentProperties()}
+ >
+ <div class="w-full flex flex-col">
+ <Card.Header class="py-2.5">
+ <Item class="grid grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 border-0 p-0">
+ <Item.Icon class="col-start-1 row-start-1">
+ <Show
+ when={targetBlockType() === 'task'}
+ fallback={<ItemEntityIcon size="xs" />}
+ >
+ <Suspense
+ fallback={
+ <LoadingSpinner class="size-4 animate-spin text-ink-muted" />
+ }
+ >
+ <TaskPropertiesPreview
+ taskId={props.documentInfo.id}
+ taskName={accessibleItem().name}
+ previewProperties={documentProperties()}
+ mode="status"
/>
- </div>
- </div>
- )}
- </Show>
-
- <div class="flex justify-between items-center text-sm font-medium">
- <Show
- when={messageContext()}
- fallback={
- <Show when={accessibleItem().owner}>
- {(owner) => <UserInfo userId={owner()} />}
- </Show>
- }
+ </Suspense>
+ </Show>
+ </Item.Icon>
+ <Item.Content class="col-start-2 row-start-1">
+ <PreviewTitle
+ name={props.documentInfo.name || accessibleItem().name}
+ />
+ <Show
+ when={
+ messageContext()?.sender_id ||
+ accessibleItem().owner ||
+ messageContext()?.created_at ||
+ accessibleItem().updatedAt
+ }
+ >
+ <Item.Description class="text-left wrap-anywhere">
+ <Show
+ when={
+ messageContext()?.sender_id ||
+ accessibleItem().owner
+ }
+ >
+ {(owner) =>
+ getDisplayName(tryMacroId(owner())) ||
+ owner().replace('macro|', '')
+ }
+ </Show>
+ <Show
+ when={
+ (messageContext()?.sender_id ||
+ accessibleItem().owner) &&
+ (messageContext()?.created_at ||
+ accessibleItem().updatedAt)
+ }
+ >
+ {' - '}
+ </Show>
+ <Show
+ when={
+ messageContext()?.created_at ||
+ accessibleItem().updatedAt
+ }
+ >
+ {(time) => formatDate(time())}
+ </Show>
+ </Item.Description>
+ </Show>
+ <Show when={accessories()}>
+ {(acc) => (
+ <Item.Metadata>
+ {acc().note}
+ {getMentionsIcon(acc().icon)}
+ </Item.Metadata>
+ )}
+ </Show>
+ </Item.Content>
+ {renderActionButtons()}
+ </Item>
+ </Card.Header>
+
+ {/* Status lives in the header; remaining properties align with the title. */}
+ <Show when={targetBlockType() === 'task'}>
+ <Card.Body class="pt-2 pl-9 [&>div]:px-0 [&>div]:pb-0">
+ <Suspense
+ fallback={<div class="w-full bg-active h-4 m-2" />}
>
- {(context) => <UserInfo userId={context().sender_id} />}
- </Show>
-
- <Show
- when={messageContext()}
- fallback={
- <Show when={accessibleItem().updatedAt}>
- {(time) => (
- <MetadataInfo icon={ClockIcon} align="right">
- <span class="text-xxs font-mono uppercase">
- {formatDate(time())}
- </span>
- </MetadataInfo>
- )}
- </Show>
- }
+ <TaskPropertiesPreview
+ taskId={props.documentInfo.id}
+ taskName={accessibleItem().name}
+ previewProperties={documentProperties()}
+ mode="details"
+ />
+ </Suspense>
+ </Card.Body>
+ </Show>
+
+ {/* Calendar event schedule, location, and people */}
+ <Show when={matches(item(), isCalendarEventPreviewItem)}>
+ {(calendarItem) => (
+ <CalendarEventPreviewDetails event={calendarItem().event} />
+ )}
+ </Show>
+
+ {/* Visual preview for images */}
+ <Show when={props.documentInfo.type === 'image'}>
+ <Card.Body class="px-3 pt-2 pb-3">
+ <Card
+ variant="filled"
+ offset={1}
+ class="overflow-hidden rounded-lg"
>
+ <ImageCoverStrip
+ documentId={accessibleItem().id}
+ fileType={accessibleItem().fileType}
+ class="shrink-0 h-32"
+ />
+ </Card>
+ </Card.Body>
+ </Show>
+
+ {/* Message excerpt and snapshot details */}
+ <Show when={messageContext() || props.snapshotInfo}>
+ <Card.Body class="pt-2">
+ <Show when={messageContext()}>
{(context) => (
- <MetadataInfo icon={ClockIcon} align="right">
- {formatDate(context().created_at)}
- </MetadataInfo>
+ <div class="mb-2 text-sm text-ink-muted border-l-2 border-edge pl-3 py-1">
+ <div class="line-clamp-3 wrap-break-word">
+ <StaticMarkdown
+ markdown={context().content}
+ theme={channelTheme}
+ target="internal"
+ />
+ </div>
+ </div>
)}
</Show>
- </div>
- <Show when={props.snapshotInfo}>
- {(snapshot) => (
- <div class="mt-2 pt-2 border-t border-edge">
- <div class="flex items-center gap-1.5 text-ink-muted">
- <ClockIcon class="size-3" />
- <span class="text-xxs font-medium font-mono uppercase">
- Snapshot from{' '}
- {formatDate(new Date(snapshot().date), {
- showTime: true,
- })}
- </span>
+ <Show when={props.snapshotInfo}>
+ {(snapshot) => (
+ <div class="mt-2 pt-2 border-t border-edge">
+ <div class="flex items-center gap-1.5 text-ink-muted">
+ <ClockIcon class="size-3" />
+ <span class="text-xs font-medium font-mono uppercase">
+ Snapshot from{' '}
+ {formatDate(new Date(snapshot().date), {
+ showTime: true,
+ })}
+ </span>
+ </div>
</div>
- </div>
- )}
- </Show>
- </div>
- </Show>
- </div>
+ )}
+ </Show>
+ </Card.Body>
+ </Show>
+ </div>
+ </TaskPropertiesPreviewProvider>
);
}}
</Match>
@@ -1004,17 +972,17 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
</div>
}
>
- <div class="w-full flex flex-col">
- <div class="flex items-center justify-between gap-2 px-3 pt-3 pb-2">
- <div class="flex items-center gap-2 min-w-0">
- <EntityIcon targetType={props.documentInfo.type} size="sm" />
- </div>
- <div class="flex shrink-0">{renderActionButtons()}</div>
- </div>
- <div class="line-clamp-2 wrap-break-word px-2 mb-2">
- {props.documentInfo.name}
- </div>
- </div>
+ <Card.Header class="py-2.5">
+ <Item class="grid grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 border-0 p-0">
+ <Item.Icon class="col-start-1 row-start-1">
+ <EntityIcon targetType={props.documentInfo.type} size="xs" />
+ </Item.Icon>
+ <Item.Content class="col-start-2 row-start-1">
+ <PreviewTitle name={props.documentInfo.name ?? ''} />
+ </Item.Content>
+ {renderActionButtons()}
+ </Item>
+ </Card.Header>
</Show>
)}
</Match>
@@ -1025,7 +993,7 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
/**
* Floating hover-card preview for document references. This is the shell used by
* {@link import('./ItemPreview').ItemPreview} hover cards: a fixed-width,
- * floating, rounded surface with a highlighted (colored) border and drop
+ * floating, rounded filled card with a semantic border and drop
* shadow, plus mouse-enter/leave handling to keep the card alive while hovered.
*
* The reusable body lives in {@link DocumentPreviewContent}; this component only
@@ -1043,7 +1011,11 @@ export function PopupPreview(
onMouseEnter={props.mouseEnter}
onMouseLeave={props.mouseLeave}
>
- <Surface depth={3} class="rounded-xl shadow-lg shadow-drop-shadow">
+ <Card
+ variant="filled"
+ depth={2}
+ class="rounded-xl shadow-lg shadow-drop-shadow"
+ >
<DocumentPreviewContent
delete={props.delete}
collapseInfo={props.collapseInfo}
@@ -1052,7 +1024,7 @@ export function PopupPreview(
snapshotInfo={props.snapshotInfo}
useFallbackData={props.useFallbackData}
/>
- </Surface>
+ </Card>
</div>
);
}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
index 7b83344714..3cfb813426 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
@@ -10,7 +10,9 @@ import { resolveBlockAlias, verifyBlockName } from '@core/constant/allBlocks';
import { ENABLE_BLOCK_IN_BLOCK } from '@core/constant/featureFlags';
import { canNestBlock, createBlockInstance } from '@core/orchestrator';
import { blockElementSignal } from '@core/signal/blockElement';
+import { getDisplayName, tryMacroId } from '@core/user';
import { matches } from '@core/util/match';
+import DotsThree from '@icon/dots-three-large.svg';
import {
$convertCardToMention,
$getId,
@@ -24,18 +26,15 @@ import {
} from '@macro-inc/lexical-core';
import Minimize from '@phosphor/arrows-in.svg';
import Clipboard from '@phosphor/clipboard.svg';
-import ClockIcon from '@phosphor/clock.svg';
-import DotsThree from '@phosphor/list.svg';
import LoadingSpinner from '@phosphor/spinner.svg';
import TrashSimple from '@phosphor/trash-simple.svg';
-import UserIcon from '@phosphor/user.svg';
import {
type AccessiblePreviewItem,
isAccessiblePreviewItem,
} from '@queries/preview';
import { blockNameToItemType } from '@service-storage/client';
import { debounce } from '@solid-primitives/scheduled';
-import { cn, Dropdown, Layer } from '@ui';
+import { Card, cn, Dropdown, Item } from '@ui';
import {
$addUpdateTag,
$createNodeSelection,
@@ -58,7 +57,10 @@ import {
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { formatDate } from '../../../../util/date';
-import { TaskPropertiesPreview } from '../../../TaskPropertiesPreview';
+import {
+ TaskPropertiesPreview,
+ TaskPropertiesPreviewProvider,
+} from '../../../TaskPropertiesPreview';
import { LexicalWrapperContext } from '../../context/LexicalWrapperContext';
import { floatWithElement } from '../../directive/floatWithElement';
import { UPDATE_DOCUMENT_NAME_COMMAND } from '../../plugins';
@@ -350,128 +352,200 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {
const DocumentInfo = (props: {
item: AccessiblePreviewItem;
blockName: string;
+ blockParams: DocumentCardDecoratorProps['blockParams'];
}) => {
return (
- <div class="p-2">
- <div class="flex center gap-2 items-center">
- <div class="shrink-0">
- <ItemEntityIcon size="sm" />
- </div>
- <div class="text-sm font-semibold truncate grow">
- <BlockLink id={props.item.id} blockOrFileName={props.blockName}>
- <span class="hover:underline">{props.item.name}</span>
- </BlockLink>
- </div>
- <Dropdown open={dropdownOpen()} onOpenChange={setDropdownOpen}>
- <Dropdown.Trigger size="icon-sm" variant="ghost">
- <DotsThree />
- </Dropdown.Trigger>
- <Dropdown.Content mount={blockElementSignal.get()}>
- <Dropdown.Group>
- <Dropdown.Item onSelect={convertToMention}>
- <Minimize class="size-4 shrink-0" />
- <span class="flex-1 truncate">Convert to Inline Mention</span>
- </Dropdown.Item>
- <Dropdown.Item onSelect={handleCopy}>
- <Clipboard class="size-4 shrink-0" />
- <span class="flex-1 truncate">Copy Link</span>
- </Dropdown.Item>
- </Dropdown.Group>
- <Dropdown.Group>
- <Dropdown.Item onSelect={deleteCard}>
- <TrashSimple class="size-4 shrink-0" />
- <span class="flex-1 truncate">Delete</span>
- </Dropdown.Item>
- </Dropdown.Group>
- </Dropdown.Content>
- </Dropdown>
- </div>
- <div
- class={cn('flex items-center justify-between', {
- 'mt-2': Boolean(props.item.owner) || Boolean(props.item.updatedAt),
- })}
- >
- <Show when={props.item.owner}>
- {(owner) => (
- <div class="flex items-center text-xs text-ink-extra-muted">
- <UserIcon class="size-3 mr-1" />
- <span class="truncate">{owner().replace('macro|', '')}</span>
- </div>
- )}
- </Show>
- <Show when={props.item.updatedAt}>
- {(updatedAt) => (
- <div class="flex items-center text-xs text-ink-extra-muted pr-1">
- <ClockIcon class="size-3 mr-1" />
- <span>{formatDate(updatedAt())}</span>
- </div>
- )}
- </Show>
- </div>
- </div>
+ <Card.Header class="shrink-0 py-2.5">
+ <Item class="grid grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 border-0 p-0">
+ <Item.Icon class="col-start-1 row-start-1">
+ <Show
+ when={props.blockName === 'task'}
+ fallback={<ItemEntityIcon size="xs" />}
+ >
+ <Suspense
+ fallback={
+ <LoadingSpinner class="size-4 animate-spin text-ink-muted" />
+ }
+ >
+ <TaskPropertiesPreview
+ taskId={props.item.id}
+ taskName={props.item.name}
+ previewProperties={documentProperties()}
+ mode="status"
+ />
+ </Suspense>
+ </Show>
+ </Item.Icon>
+ <Item.Content class="col-start-2 row-start-1">
+ <Item.Title>
+ <BlockLink
+ id={props.item.id}
+ blockOrFileName={props.blockName}
+ params={props.blockParams}
+ >
+ <span
+ role="link"
+ tabIndex={0}
+ class="wrap-anywhere rounded-sm hover:underline focus-visible:outline-2 focus-visible:outline-accent"
+ onKeyDown={(event) => {
+ if (event.key !== 'Enter') return;
+ event.preventDefault();
+ event.stopPropagation();
+ event.currentTarget.click();
+ }}
+ >
+ {props.item.name}
+ </span>
+ </BlockLink>
+ </Item.Title>
+ <Show when={props.item.owner || props.item.updatedAt}>
+ <Item.Description class="text-left wrap-anywhere">
+ <Show when={props.item.owner}>
+ {(owner) =>
+ getDisplayName(tryMacroId(owner())) ||
+ owner().replace('macro|', '')
+ }
+ </Show>
+ <Show when={props.item.owner && props.item.updatedAt}>
+ {' - '}
+ </Show>
+ <Show when={props.item.updatedAt}>
+ {(updatedAt) => formatDate(updatedAt())}
+ </Show>
+ </Item.Description>
+ </Show>
+ </Item.Content>
+ <Item.Actions class="col-start-3 row-start-1 h-5">
+ <Dropdown open={dropdownOpen()} onOpenChange={setDropdownOpen}>
+ <Dropdown.Trigger
+ size="icon-sm"
+ variant="ghost"
+ aria-label="Document card actions"
+ >
+ <DotsThree />
+ </Dropdown.Trigger>
+ <Dropdown.Content mount={blockElementSignal.get()}>
+ <Dropdown.Group>
+ <Dropdown.Item onSelect={convertToMention}>
+ <Minimize class="size-4 shrink-0" />
+ <span class="flex-1 truncate">
+ Convert to Inline Mention
+ </span>
+ </Dropdown.Item>
+ <Dropdown.Item onSelect={handleCopy}>
+ <Clipboard class="size-4 shrink-0" />
+ <span class="flex-1 truncate">Copy Link</span>
+ </Dropdown.Item>
+ </Dropdown.Group>
+ <Dropdown.Group>
+ <Dropdown.Item onSelect={deleteCard}>
+ <TrashSimple class="size-4 shrink-0" />
+ <span class="flex-1 truncate">Delete</span>
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ </Item.Actions>
+ </Item>
+ </Card.Header>
);
};
return (
- <Layer depth={2}>
- <div
- ref={(el) => {
- setContainerRef(el);
- setPreviewBoxRef(el);
- }}
- contentEditable={false}
- class={cn(
- 'relative my-2 rounded border border-edge bg-surface no-select-children select-none overflow-hidden flex flex-col',
- isSelectedAsNode() &&
- !channelMessageId() &&
- 'bg-active outline-edge outline-4',
- isPreviewable() && 'resize-y shrink-0 min-h-25'
- )}
- style={{
- height: isPreviewable() ? previewBoxHeight : 'auto',
- }}
- onClick={(e) => {
- if (channelMessageId()) return;
- e.preventDefault();
- clickCardHandler();
- }}
- >
- <Switch>
- <Match when={item().loading}>
- <div class="flex items-center justify-center p-4 text-ink-muted">
- <LoadingSpinner class="size-6 animate-spin" />
- </div>
- </Match>
- <Match when={matches(item(), isAccessiblePreviewItem)}>
- {(item) => (
- <>
- {/*<div class="h-2"/>*/}
- <DocumentInfo item={item()} blockName={props.blockName} />
- <Show when={props.blockName === 'task'}>
+ <Card
+ variant="filled"
+ depth={2}
+ ref={(el) => {
+ setContainerRef(el);
+ setPreviewBoxRef(el);
+ }}
+ contentEditable={false}
+ class={cn(
+ 'my-2 rounded-xl no-select-children select-none overflow-hidden',
+ isSelectedAsNode() &&
+ !channelMessageId() &&
+ 'border-[color-mix(in_oklch,var(--color-edge)_80%,var(--color-ink))] ring-2 ring-edge-muted',
+ isPreviewable() && 'resize-y shrink-0 min-h-80'
+ )}
+ style={{
+ height: isPreviewable() ? previewBoxHeight : 'auto',
+ }}
+ onClick={(e) => {
+ if (channelMessageId()) return;
+ // Controls and embedded editors own their clicks and native defaults.
+ if (
+ e.target instanceof Element &&
+ e.target.closest(
+ 'a, button, input, textarea, select, [role="link"], [role="button"], [role="combobox"], [data-document-card-controls]'
+ )
+ )
+ return;
+ e.preventDefault();
+ clickCardHandler();
+ }}
+ >
+ <Switch>
+ <Match when={item().loading}>
+ <div class="flex items-center justify-center p-4 text-ink-muted">
+ <LoadingSpinner class="size-6 animate-spin" />
+ </div>
+ </Match>
+ <Match when={matches(item(), isAccessiblePreviewItem)}>
+ {(item) => (
+ <TaskPropertiesPreviewProvider
+ taskId={props.blockName === 'task' ? item().id : undefined}
+ previewProperties={documentProperties()}
+ >
+ <DocumentInfo
+ item={item()}
+ blockName={props.blockName}
+ blockParams={props.blockParams}
+ />
+ <Show when={props.blockName === 'task'}>
+ <Card.Body
+ class="shrink-0 pt-2 pl-9 [&>div]:px-0 [&>div]:pb-0"
+ data-document-card-controls
+ >
<Suspense fallback={<div class="w-full bg-active h-4 m-2" />}>
<TaskPropertiesPreview
taskId={item().id}
previewProperties={documentProperties()}
+ mode="details"
/>
</Suspense>
- </Show>
- <Show when={previewComponent()}>
- <Show
- when={isPreviewable()}
- fallback={
- <Dynamic component={previewComponent()} {...props} />
- }
+ </Card.Body>
+ </Show>
+ <Show when={previewComponent()}>
+ <Card.Body
+ class={cn(
+ 'mx-3 mt-2 mb-3 p-0',
+ isPreviewable() && 'flex min-h-0 flex-1'
+ )}
+ data-document-card-controls
+ >
+ <Card
+ variant="filled"
+ offset={1}
+ class={cn(
+ 'w-full overflow-hidden rounded-lg',
+ isPreviewable() && 'min-h-0 flex-1'
+ )}
>
- <div class="relative grow overflow-y-scroll">
+ <div
+ class={cn(
+ 'relative min-w-0',
+ isPreviewable() && 'min-h-0 flex-1 overflow-y-auto'
+ )}
+ >
<Dynamic component={previewComponent()} {...props} />
</div>
- </Show>
- </Show>
- </>
- )}
- </Match>
- </Switch>
- </div>
- </Layer>
+ </Card>
+ </Card.Body>
+ </Show>
+ </TaskPropertiesPreviewProvider>
+ )}
+ </Match>
+ </Switch>
+ </Card>
);
}
diff --git a/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx b/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
index 4e5d408679..559c4a4777 100644
--- a/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
+++ b/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
@@ -4,6 +4,30 @@ import { render } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { beforeEach, describe, expect, it, vi } from 'vitest';
+// Test preview composition/data ownership independently of the property editors.
+vi.mock('@property', () => ({
+ Property: {
+ Root: (props: {
+ canEdit: boolean;
+ children: import('solid-js').JSX.Element;
+ }) => (
+ <div data-status-editable={String(props.canEdit)}>{props.children}</div>
+ ),
+ Tooltip: (props: { children: import('solid-js').JSX.Element }) =>
+ props.children,
+ EditTrigger: (
+ props: import('solid-js').JSX.ButtonHTMLAttributes<HTMLButtonElement>
+ ) => <button {...props} />,
+ Icon: (props: { property: Property }) => (
+ <span>icon:{String(props.property.value)}</span>
+ ),
+ Text: (props: { property: Property }) => (
+ <span>{String(props.property.value)}</span>
+ ),
+ PopoverEditor: () => null,
+ },
+}));
+
const propertiesQuery = vi.hoisted(() => vi.fn());
const accessQuery = vi.hoisted(() => vi.fn());
vi.mock('@property/hooks', () => ({ useEntityProperties: propertiesQuery }));
@@ -43,7 +67,10 @@ vi.mock('@property/context/PropertiesContext', () => ({
import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import { InlineTaskProperties } from './InlineTaskProperties';
-import { TaskPropertiesPreview } from './TaskPropertiesPreview';
+import {
+ TaskPropertiesPreview,
+ TaskPropertiesPreviewProvider,
+} from './TaskPropertiesPreview';
beforeEach(() => {
vi.clearAllMocks();
@@ -65,6 +92,147 @@ const status = {
} as Property;
describe('task preview data ownership', () => {
+ it('shares one REST property and permission subscription across both slots', () => {
+ const [properties, setProperties] = createSignal<Property[]>([status]);
+ propertiesQuery.mockReturnValue({
+ properties,
+ isLoading: () => false,
+ refetch: vi.fn(),
+ });
+ const view = render(() => (
+ <TaskPropertiesPreviewProvider taskId="task">
+ <TaskPropertiesPreview taskId="task" mode="status" />
+ <TaskPropertiesPreview taskId="task" mode="details" />
+ </TaskPropertiesPreviewProvider>
+ ));
+ expect(propertiesQuery).toHaveBeenCalledTimes(1);
+ expect(accessQuery).toHaveBeenCalledTimes(1);
+ expect(
+ view.getByRole('button', { name: /Task status: status-1/ })
+ ).toBeTruthy();
+ setProperties([
+ { ...status, value: ['status-2'] } as Property,
+ {
+ ...status,
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PRIORITY,
+ displayName: 'Priority',
+ } as Property,
+ ]);
+ expect(
+ view.getByRole('button', { name: /Task status: status-2/ })
+ ).toBeTruthy();
+ expect(view.container.textContent).toContain('Priority');
+ expect(propertiesQuery).toHaveBeenCalledTimes(1);
+ expect(accessQuery).toHaveBeenCalledTimes(1);
+ view.unmount();
+ });
+
+ it('shares pending and loaded GraphQL data without mounting REST subscriptions', () => {
+ const [metadata, setMetadata] = createSignal<PreviewDocumentProperties>({
+ properties: undefined,
+ canEdit: false,
+ refetch: vi.fn(async () => {}),
+ });
+ const view = render(() => (
+ <TaskPropertiesPreviewProvider
+ taskId="task"
+ previewProperties={metadata()}
+ >
+ <TaskPropertiesPreview taskId="task" mode="status" />
+ <TaskPropertiesPreview taskId="task" mode="details" />
+ </TaskPropertiesPreviewProvider>
+ ));
+ expect(propertiesQuery).not.toHaveBeenCalled();
+ expect(accessQuery).not.toHaveBeenCalled();
+ setMetadata((old) => ({ ...old, properties: [status], canEdit: true }));
+ expect(
+ view
+ .getByRole('button', { name: /Task status: status-1/ })
+ .getAttribute('aria-disabled')
+ ).toBe('false');
+ setMetadata((old) => ({ ...old, canEdit: false }));
+ expect(
+ view
+ .getByRole('button', { name: /Task status: status-1/ })
+ .getAttribute('aria-disabled')
+ ).toBe('true');
+ expect(propertiesQuery).not.toHaveBeenCalled();
+ expect(accessQuery).not.toHaveBeenCalled();
+ view.unmount();
+ });
+
+ it('does not subscribe for non-task card content', () => {
+ const view = render(() => (
+ <TaskPropertiesPreviewProvider>
+ <span>Document</span>
+ </TaskPropertiesPreviewProvider>
+ ));
+ expect(view.container.textContent).toBe('Document');
+ expect(propertiesQuery).not.toHaveBeenCalled();
+ expect(accessQuery).not.toHaveBeenCalled();
+ view.unmount();
+ });
+
+ it('renders an icon-only status control that tracks values and permissions', () => {
+ const [metadata, setMetadata] = createSignal<PreviewDocumentProperties>({
+ properties: [status],
+ canEdit: true,
+ refetch: vi.fn(async () => {}),
+ });
+ const view = render(() => (
+ <TaskPropertiesPreview
+ taskId="task"
+ mode="status"
+ previewProperties={metadata()}
+ />
+ ));
+ expect(
+ view
+ .getByRole('button', { name: /Task status: status-1/ })
+ .getAttribute('aria-disabled')
+ ).toBe('false');
+ expect(view.container.textContent).toContain('icon:status-1');
+ setMetadata((old) => ({
+ ...old,
+ canEdit: false,
+ properties: [{ ...status, value: ['status-2'] } as Property],
+ }));
+ expect(
+ view
+ .getByRole('button', { name: /Task status: status-2/ })
+ .getAttribute('aria-disabled')
+ ).toBe('true');
+ expect(
+ view.container
+ .querySelector('[data-status-editable]')
+ ?.getAttribute('data-status-editable')
+ ).toBe('false');
+ expect(propertiesQuery).not.toHaveBeenCalled();
+ expect(accessQuery).not.toHaveBeenCalled();
+ view.unmount();
+ });
+
+ it('omits the duplicate status chip from card details', () => {
+ const priority = {
+ ...status,
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PRIORITY,
+ displayName: 'Priority',
+ } as Property;
+ const view = render(() => (
+ <TaskPropertiesPreview
+ taskId="task"
+ mode="details"
+ previewProperties={{
+ properties: [status, priority],
+ canEdit: true,
+ refetch: vi.fn(async () => {}),
+ }}
+ />
+ ));
+ expect(view.container.textContent).toBe('Priority');
+ view.unmount();
+ });
+
it('never mounts child queries for pending or loaded GraphQL edges', () => {
const [metadata, setMetadata] = createSignal<PreviewDocumentProperties>({
properties: undefined,
diff --git a/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx b/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
index a5ec33b5c3..6838f2fbbd 100644
--- a/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
+++ b/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
@@ -4,6 +4,8 @@ import {
hasPermissions,
Permissions,
} from '@core/component/SharePermissions';
+import CircleIcon from '@phosphor/circle.svg';
+import { Property as PropertyUI } from '@property';
import { Modals } from '@property/component/modal';
import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import {
@@ -12,10 +14,19 @@ import {
} from '@property/context/PropertiesContext';
import { useEntityProperties } from '@property/hooks';
import type { Property, PropertyApiValues } from '@property/types';
+import { hasValue } from '@property/utils/typeGuards';
import type { PreviewDocumentProperties } from '@queries/preview/types';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
import { useDocumentAccessLevelQuery } from '@queries/storage/document-metadata';
-import { type Accessor, createMemo, For, Show } from 'solid-js';
+import {
+ type Accessor,
+ createContext,
+ createMemo,
+ For,
+ type JSX,
+ Show,
+ useContext,
+} from 'solid-js';
const TASK_PREVIEW_PROPERTIES = [
SYSTEM_PROPERTY_IDS.STATUS,
@@ -23,34 +34,62 @@ const TASK_PREVIEW_PROPERTIES = [
SYSTEM_PROPERTY_IDS.ASSIGNEES,
];
-type TaskPreviewProps = { taskId: string; taskName?: string };
+type TaskPreviewProps = {
+ taskId: string;
+ taskName?: string;
+ mode?: 'all' | 'status' | 'details';
+};
-/** Status, priority, and assignee editors; GraphQL previews own their data. */
-export function TaskPropertiesPreview(
- props: TaskPreviewProps & {
- previewProperties?: PreviewDocumentProperties;
- }
-) {
+type TaskPreviewData = {
+ taskId: Accessor<string>;
+ properties: Accessor<Property[]>;
+ isLoading: Accessor<boolean>;
+ canEdit: Accessor<boolean>;
+ refetch: () => void;
+};
+
+const TaskPreviewDataContext = createContext<TaskPreviewData>();
+
+/** One data owner for status and details; non-task cards are a passthrough. */
+export function TaskPropertiesPreviewProvider(props: {
+ taskId?: string;
+ previewProperties?: PreviewDocumentProperties;
+ children: JSX.Element;
+}) {
return (
- <Show
- when={props.previewProperties}
- fallback={<RestTaskPropertiesPreview {...props} />}
- >
- {(metadata) => (
- <TaskPropertiesPreviewContent
- taskId={props.taskId}
- taskName={props.taskName}
- properties={() => metadata().properties ?? []}
- isLoading={metadata().properties === undefined}
- canEdit={metadata().canEdit}
- refetch={() => void metadata().refetch()}
- />
+ <Show when={props.taskId} keyed fallback={props.children}>
+ {(taskId) => (
+ <Show
+ when={props.previewProperties}
+ fallback={
+ <RestTaskPreviewProvider taskId={taskId}>
+ {props.children}
+ </RestTaskPreviewProvider>
+ }
+ >
+ {(metadata) => (
+ <TaskPreviewDataContext.Provider
+ value={{
+ taskId: () => taskId,
+ properties: () => metadata().properties ?? [],
+ isLoading: () => metadata().properties === undefined,
+ canEdit: () => metadata().canEdit,
+ refetch: () => void metadata().refetch(),
+ }}
+ >
+ {props.children}
+ </TaskPreviewDataContext.Provider>
+ )}
+ </Show>
)}
</Show>
);
}
-function RestTaskPropertiesPreview(props: TaskPreviewProps) {
+function RestTaskPreviewProvider(props: {
+ taskId: string;
+ children: JSX.Element;
+}) {
const { properties, isLoading, refetch } = useEntityProperties(
props.taskId,
'TASK',
@@ -58,16 +97,54 @@ function RestTaskPropertiesPreview(props: TaskPreviewProps) {
);
const accessQuery = useDocumentAccessLevelQuery(() => props.taskId);
return (
- <TaskPropertiesPreviewContent
- {...props}
- properties={() => (isLoading() ? [] : properties())}
- isLoading={isLoading()}
- canEdit={
- accessQuery.isSuccess &&
- hasPermissions(getPermissions(accessQuery.data), Permissions.CAN_EDIT)
+ <TaskPreviewDataContext.Provider
+ value={{
+ taskId: () => props.taskId,
+ properties: () => (isLoading() ? [] : properties()),
+ isLoading,
+ canEdit: () =>
+ accessQuery.isSuccess &&
+ hasPermissions(
+ getPermissions(accessQuery.data),
+ Permissions.CAN_EDIT
+ ),
+ refetch,
+ }}
+ >
+ {props.children}
+ </TaskPreviewDataContext.Provider>
+ );
+}
+
+/** Standalone use gets its own owner; sibling slots reuse the surrounding owner. */
+export function TaskPropertiesPreview(
+ props: TaskPreviewProps & {
+ previewProperties?: PreviewDocumentProperties;
+ }
+) {
+ const shared = useContext(TaskPreviewDataContext);
+ return (
+ <Show
+ when={shared?.taskId() === props.taskId ? shared : undefined}
+ fallback={
+ <TaskPropertiesPreviewProvider
+ taskId={props.taskId}
+ previewProperties={props.previewProperties}
+ >
+ <TaskPropertiesPreview {...props} />
+ </TaskPropertiesPreviewProvider>
}
- refetch={refetch}
- />
+ >
+ {(data) => (
+ <TaskPropertiesPreviewContent
+ {...props}
+ properties={() => data().properties()}
+ isLoading={data().isLoading()}
+ canEdit={data().canEdit()}
+ refetch={() => data().refetch()}
+ />
+ )}
+ </Show>
);
}
@@ -83,6 +160,10 @@ function TaskPropertiesPreviewContent(
const previewProperties = createMemo(() =>
TASK_PREVIEW_PROPERTIES.flatMap((id) => {
+ if (props.mode === 'status' && id !== SYSTEM_PROPERTY_IDS.STATUS)
+ return [];
+ if (props.mode === 'details' && id === SYSTEM_PROPERTY_IDS.STATUS)
+ return [];
const property = props
.properties()
.find((candidate) => candidate.propertyDefinitionId === id);
@@ -104,7 +185,22 @@ function TaskPropertiesPreviewContent(
};
return (
- <Show when={!props.isLoading && previewProperties().length > 0}>
+ <Show
+ when={!props.isLoading && previewProperties().length > 0}
+ fallback={
+ <Show when={props.mode === 'status'}>
+ <CircleIcon
+ class="size-4 text-ink-muted"
+ role="img"
+ aria-label={
+ props.isLoading
+ ? 'Loading task status'
+ : 'Task status unavailable'
+ }
+ />
+ </Show>
+ }
+ >
<PropertiesProvider
entityId={props.taskId}
entityType="TASK"
@@ -116,17 +212,60 @@ function TaskPropertiesPreviewContent(
onPropertyDeleted={props.refetch}
saveHandler={saveHandler}
>
- <div class="px-2 pb-2 flex flex-row flex-wrap gap-1 text-xs justify-start">
+ <Show
+ when={props.mode === 'status'}
+ fallback={
+ <div class="px-2 pb-2 flex flex-row flex-wrap gap-1 text-xs justify-start">
+ <For each={previewProperties()}>
+ {(property) => (
+ <InlinePropertyValue
+ property={property}
+ entityId={props.taskId}
+ class="bg-surface-2 border border-edge"
+ />
+ )}
+ </For>
+ </div>
+ }
+ >
<For each={previewProperties()}>
{(property) => (
- <InlinePropertyValue
+ <PropertyUI.Root
property={property}
- entityId={props.taskId}
- class="bg-surface-2 border border-edge"
- />
+ canEdit={props.canEdit}
+ onSave={saveHandler.saveProperty}
+ onRefresh={props.refetch}
+ >
+ <PropertyUI.Tooltip property={property}>
+ <PropertyUI.EditTrigger
+ class="inline-flex size-6 shrink-0 items-center justify-center rounded-full hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent"
+ aria-disabled={!props.canEdit || !!property.isMetadata}
+ >
+ <Show
+ when={hasValue(property)}
+ fallback={<CircleIcon class="size-4 text-ink-muted" />}
+ >
+ <PropertyUI.Icon property={property} class="size-4" />
+ </Show>
+ <span class="sr-only">
+ Task status:{' '}
+ <PropertyUI.Text
+ property={property}
+ fallback="Not started"
+ />
+ </span>
+ </PropertyUI.EditTrigger>
+ </PropertyUI.Tooltip>
+ <PropertyUI.PopoverEditor
+ entitySelfFilter={{
+ entityType: 'TASK',
+ blockId: props.taskId,
+ }}
+ />
+ </PropertyUI.Root>
)}
</For>
- </div>
+ </Show>
<Modals />
</PropertiesProvider>
</Show>
diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.md
index cb35788eac..213202c2e7 100644
--- a/docs/AGENT_GUIDE/documents.md
+++ b/docs/AGENT_GUIDE/documents.md
@@ -55,12 +55,50 @@ unavailable label. Mounted references refresh every 30 seconds while the tab is
active to update titles and check access.
Hover a document reference chip to open its preview without navigating. With
-`ENABLE_GRAPHQL_SOUP` enabled, the popup reuses the reference's live `ItemPreviews`
+the preview open, the compact header shows a tinted icon, title, and author/time
+byline. Click the title to open the document; the Reference actions ellipsis menu contains copy
+link, split, embed/collapse, AI, and delete actions when applicable. The preview
+stays open while this menu is active. Images use an inset frame and task chips
+appear below the header. Long titles wrap in place without a full-name tooltip.
+
+With `ENABLE_GRAPHQL_SOUP` enabled, the popup reuses the reference's live `ItemPreviews`
batch, including task properties and viewer permission, without another fetch.
Explicit refreshes may revalidate that batch, but requests must settle while the
pointer stays over the same reference; cache updates must not cause a continuous
fetch cascade.
+## Embedded document cards
+
+Document cards use a compact icon/title row and an actions menu. Full previews
+sit inside an inset surface; the author's display name and update time appear
+under the title as a byline. The plain 1rem icon sits in a column to the left
+of the title, aligned with its first line. Wrapped title lines, the byline,
+and task chips share the title's left edge. Full previews use the card's full
+content width with equal left and right insets. Title and byline share a text
+stack with a consistent 4px gap and 20px title leading, including when the title wraps.
+Titles and bylines use text-sm, differentiated by semibold and regular weight;
+smaller details use text-xs.
+Item.Icon provides the plain first-line-aligned icon slot. The small ellipsis button
+sits at the top right. Full embeds have a 320px minimum
+card height and a smaller rounded inset frame.
+The document-preview overlay uses the same plain icon, title/byline stack,
+small actions button, and task status control; image previews keep equal side insets.
+Metadata-only references omit the preview. Tasks replace the type icon with an
+icon-only status control; click it to change status when you have edit access.
+Priority and assignee chips remain below, without a duplicate status chip.
+Status and detail slots share one TaskPropertiesPreviewProvider per card:
+GraphQL preview data is reused, and REST fallback property/access queries are
+owned once, not separately by each slot. Non-task cards do not load task properties.
+Use the title to open the referenced document and the
+actions menu to copy its link, convert it to an inline mention, or delete the card.
+Title navigation preserves the reference's block parameters, including message,
+thread, annotation, and document locations.
+Click the card frame to select its editor node; controls and embedded content
+handle their own clicks. Full embeds remain vertically resizable and scroll
+inside the inset preview. When verifying, check a canvas embed, a metadata-only
+reference, and an editable task, including resize, menu actions, and keyboard
+access to the title and property controls.
+
## AI edit
1. Click `Edit with AI` (button directly under the editor body).