Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore(web): polish the memo card and editor styles

boojack98d8322f145b
diff --git a/web/src/components/ClampedSection.tsx b/web/src/components/ClampedSection.tsx
index dd5351e06..6a44c91e3 100644
--- a/web/src/components/ClampedSection.tsx
+++ b/web/src/components/ClampedSection.tsx
@@ -1,5 +1,6 @@
-import { ChevronDown, ChevronUp } from "lucide-react";
+import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
import { type ReactNode, useEffect, useRef, useState } from "react";
+import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { useTranslate } from "@/utils/i18n";
@@ -57,14 +58,14 @@ const ClampedSection = ({ enabled, children }: ClampedSectionProps) => {
)}
</div>
{clamped && (
- <button
- type="button"
- className="inline-flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
- onClick={() => setExpanded((prev) => !prev)}
- >
- <span>{t(collapsed ? "memo.show-more" : "memo.show-less")}</span>
- {collapsed ? <ChevronDown className="w-3 h-3" /> : <ChevronUp className="w-3 h-3" />}
- </button>
+ <Button variant="quiet" size="sm" onClick={() => setExpanded((prev) => !prev)}>
+ {t(collapsed ? "memo.show-more" : "memo.show-less")}
+ {collapsed ? (
+ <ChevronDownIcon className="size-3.5" strokeWidth={1.8} />
+ ) : (
+ <ChevronUpIcon className="size-3.5" strokeWidth={1.8} />
+ )}
+ </Button>
)}
</>
);
diff --git a/web/src/components/MemoActionMenu/MemoActionMenu.tsx b/web/src/components/MemoActionMenu/MemoActionMenu.tsx
index 96a2cff7a..d770d2dea 100644
--- a/web/src/components/MemoActionMenu/MemoActionMenu.tsx
+++ b/web/src/components/MemoActionMenu/MemoActionMenu.tsx
@@ -71,18 +71,18 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
<DropdownMenuTrigger render={<Button variant="quiet" size="icon-sm" aria-label={t("common.more")} />}>
<MoreVerticalIcon className="size-4" strokeWidth={1.8} />
</DropdownMenuTrigger>
- <DropdownMenuContent align="end" sideOffset={2}>
+ <DropdownMenuContent align="end" sideOffset={2} size="sm">
{/* Edit actions (non-readonly, non-archived) */}
{!readonly && !isArchived && (
<>
{!isComment && (
<DropdownMenuItem onClick={handleTogglePinMemoBtnClick}>
- {memo.pinned ? <BookmarkMinusIcon className="w-4 h-auto" /> : <BookmarkPlusIcon className="w-4 h-auto" />}
+ {memo.pinned ? <BookmarkMinusIcon /> : <BookmarkPlusIcon />}
{memo.pinned ? t("common.unpin") : t("common.pin")}
</DropdownMenuItem>
)}
<DropdownMenuItem onClick={handleEditMemoClick}>
- <Edit3Icon className="w-4 h-auto" />
+ <Edit3Icon />
{t("common.edit")}
</DropdownMenuItem>
</>
@@ -92,16 +92,16 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
{!isArchived && (
<DropdownMenuSub>
<DropdownMenuSubTrigger>
- <CopyIcon className="w-4 h-auto" />
+ <CopyIcon />
{t("common.copy")}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem onClick={handleCopyLink}>
- <LinkIcon className="w-4 h-auto" />
+ <LinkIcon />
{t("memo.copy-link")}
</DropdownMenuItem>
<DropdownMenuItem onClick={handleCopyContent}>
- <FileTextIcon className="w-4 h-auto" />
+ <FileTextIcon />
{t("memo.copy-content")}
</DropdownMenuItem>
</DropdownMenuSubContent>
@@ -112,16 +112,16 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
{canMutateTasks && (
<DropdownMenuSub>
<DropdownMenuSubTrigger>
- <ListChecksIcon className="w-4 h-auto" />
+ <ListChecksIcon />
{t("memo.task-actions.title")}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem disabled={!hasOpenTasks} onClick={handleCheckAllTaskListItemsClick}>
- <CheckCheckIcon className="w-4 h-auto" />
+ <CheckCheckIcon />
{t("memo.task-actions.check-all")}
</DropdownMenuItem>
<DropdownMenuItem onClick={handleUncheckAllTaskListItemsClick}>
- <ListRestartIcon className="w-4 h-auto" />
+ <ListRestartIcon />
{t("memo.task-actions.uncheck-all")}
</DropdownMenuItem>
</DropdownMenuSubContent>
@@ -130,7 +130,7 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
{!readonly && !isComment && (
<DropdownMenuItem onClick={handleToggleMemoStatusClick}>
- {isArchived ? <ArchiveRestoreIcon className="w-4 h-auto" /> : <ArchiveIcon className="w-4 h-auto" />}
+ {isArchived ? <ArchiveRestoreIcon /> : <ArchiveIcon />}
{isArchived ? t("common.restore") : t("common.archive")}
</DropdownMenuItem>
)}
@@ -138,19 +138,19 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
{(canMove || !readonly) && (
<DropdownMenuSub>
<DropdownMenuSubTrigger>
- <MoreHorizontalIcon className="size-4" />
+ <MoreHorizontalIcon />
{t("common.more")}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
{canMove && (
<DropdownMenuItem onClick={() => setMoveDialogOpen(true)}>
- <FolderInputIcon className="size-4" />
+ <FolderInputIcon />
{t("memo.move.title")}
</DropdownMenuItem>
)}
{!readonly && (
<DropdownMenuItem onClick={handleDeleteMemoClick}>
- <TrashIcon className="size-4" />
+ <TrashIcon />
{t("common.delete")}
</DropdownMenuItem>
)}
diff --git a/web/src/components/MemoEditor/Editor/editor.css b/web/src/components/MemoEditor/Editor/editor.css
index 27de1845b..4129d3882 100644
--- a/web/src/components/MemoEditor/Editor/editor.css
+++ b/web/src/components/MemoEditor/Editor/editor.css
@@ -101,21 +101,28 @@
}
/* Tag autocomplete popover — app surface, not CodeMirror defaults. */
+ /* Sized like the kit's small dropdown: 13px rows, 28px tall, 2px inset. */
& .cm-tooltip.cm-tooltip-autocomplete {
background: var(--popover);
color: var(--popover-foreground);
border: 1px solid var(--border);
- border-radius: 0.5rem;
- box-shadow: var(--shadow-md);
+ border-radius: calc(var(--radius) - 4px);
+ box-shadow: var(--shadow-sm);
overflow: hidden;
+ padding: 0.125rem;
font-family: inherit;
- font-size: 0.9rem;
+ font-size: 0.8125rem;
+ line-height: 1.125rem;
}
& .cm-tooltip-autocomplete > ul {
font-family: inherit;
}
& .cm-tooltip-autocomplete > ul > li {
+ min-height: 1.75rem;
+ display: flex;
+ align-items: center;
padding: 0.25rem 0.5rem;
+ border-radius: calc(var(--radius) - 6px);
}
& .cm-tooltip-autocomplete > ul > li[aria-selected] {
background: var(--accent);
diff --git a/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx b/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx
index 5281977c4..d91af936c 100644
--- a/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx
+++ b/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx
@@ -20,7 +20,7 @@ import VisibilitySelector from "./VisibilitySelector";
const ShortcutChip: FC<{ busy: boolean }> = ({ busy }) => (
<kbd
aria-hidden
- className="grid place-items-center rounded-[4px] bg-primary-foreground/20 px-1 py-0.5 font-sans text-[11px] leading-none font-medium pointer-coarse:hidden"
+ className="grid place-items-center rounded-[4px] bg-primary-foreground/20 px-1 py-0.5 font-sans text-2xs leading-none font-medium pointer-coarse:hidden"
>
<span className={cn("col-start-1 row-start-1 inline-flex items-center gap-px", busy && "invisible")}>
{primaryModifierGlyph()}
@@ -76,20 +76,21 @@ export const EditorToolbar: FC<EditorToolbarProps> = ({
};
const commitButton = justSaved ? (
- <Button disabled>
+ <Button size="sm" disabled>
{t("editor.saved")}
<CheckIcon className="size-3.5" strokeWidth={2.5} />
</Button>
) : (
- <Button onClick={onSave} disabled={isSaving || !valid}>
+ <Button size="sm" onClick={onSave} disabled={isSaving || !valid}>
{commitLabel}
<ShortcutChip busy={isSaving} />
</Button>
);
return (
- <div className="w-full flex flex-row justify-between items-center mb-2">
- <div className="flex flex-row justify-start items-center gap-1">
+ // Every control on this rail is 28px, the same box as the sidebar's compose control and nav pills.
+ <div className="flex w-full flex-row items-center justify-between">
+ <div className="flex flex-row items-center justify-start gap-1">
<InsertMenu
isUploading={isUploading}
isSaving={committing}
@@ -103,9 +104,9 @@ export const EditorToolbar: FC<EditorToolbarProps> = ({
<VisibilitySelector value={visibility} space={space} onChange={handleVisibilityChange} />
</div>
- <div className="flex flex-row justify-end items-center gap-2">
+ <div className="flex flex-row items-center justify-end gap-1">
{onCancel && (
- <Button variant="ghost" onClick={onCancel} disabled={committing}>
+ <Button variant="quiet" size="sm" onClick={onCancel} disabled={committing}>
{t("common.cancel")}
</Button>
)}
diff --git a/web/src/components/MemoEditor/Toolbar/FormattingToolbar.tsx b/web/src/components/MemoEditor/Toolbar/FormattingToolbar.tsx
index 56886cd88..aee4932e7 100644
--- a/web/src/components/MemoEditor/Toolbar/FormattingToolbar.tsx
+++ b/web/src/components/MemoEditor/Toolbar/FormattingToolbar.tsx
@@ -49,17 +49,6 @@ interface ToolbarButton {
onClick: () => void;
}
-// Button styling: quiet ghost controls that sit directly on the editor surface
-// (no filled track or border — that container read as a heavy slab). The active
-// verb is the only filled element, so the toolbar recedes and the current state
-// carries the weight. Kept as raw buttons (not the Button kit) because the idle
-// hover + active treatment don't map to a single kit variant, and per policy a
-// custom look is raw HTML rather than className overrides on the kit.
-const SEGMENT_BASE =
- "inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded-md text-sm transition-colors outline-none touch-manipulation focus-visible:ring-2 focus-visible:ring-ring";
-const SEGMENT_IDLE = "text-muted-foreground hover:text-foreground hover:bg-foreground/5";
-const SEGMENT_ACTIVE = "bg-accent text-accent-foreground";
-
// Command buttons must not take focus on mousedown — that blurs the editor and
// drops the selection the command targets. The click still fires and applies the
// format to the live selection.
@@ -115,7 +104,7 @@ export function FormattingToolbar({ controllerRef, exit, className }: Formatting
>
<DropdownMenu>
<DropdownMenuTrigger render={<SegmentButton Icon={HeadingGlyph} label={t("editor.format.heading")} />} />
- <DropdownMenuContent align="start" finalFocus={returnFocusToEditor}>
+ <DropdownMenuContent align="start" size="sm" finalFocus={returnFocusToEditor}>
{HEADING_COMMANDS.map((command) => (
<DropdownMenuItem key={command.id} onClick={() => run(command.id)}>
{t(command.labelKey)}
@@ -135,7 +124,7 @@ export function FormattingToolbar({ controllerRef, exit, className }: Formatting
{compact ? (
<DropdownMenu>
<DropdownMenuTrigger render={<SegmentButton Icon={MoreHorizontalIcon} label={t("editor.format.more")} />} />
- <DropdownMenuContent align="start" finalFocus={returnFocusToEditor}>
+ <DropdownMenuContent align="start" size="sm" finalFocus={returnFocusToEditor}>
{blockButtons.map((button) => (
<DropdownMenuItem key={button.label} onClick={button.onClick}>
{button.label}
@@ -150,8 +139,8 @@ export function FormattingToolbar({ controllerRef, exit, className }: Formatting
{exit && (
<>
<div className="flex-1" />
- <Button variant="ghost" size="icon" aria-label={exitLabel} title={exitLabel} onClick={exit.onExit}>
- <ExitIcon className="w-4 h-4" />
+ <Button variant="quiet" size="icon-compact" aria-label={exitLabel} title={exitLabel} onClick={exit.onExit}>
+ <ExitIcon className="size-4" strokeWidth={1.8} />
</Button>
</>
)}
@@ -161,7 +150,7 @@ export function FormattingToolbar({ controllerRef, exit, className }: Formatting
// Thin vertical rule between command groups (heading · marks · blocks).
function Divider() {
- return <span aria-hidden="true" className="w-px h-5 bg-border mx-1.5 shrink-0" />;
+ return <span aria-hidden="true" className="mx-1 h-4 w-px shrink-0 bg-border/70" />;
}
interface SegmentButtonProps extends ComponentPropsWithoutRef<"button"> {
@@ -171,20 +160,13 @@ interface SegmentButtonProps extends ComponentPropsWithoutRef<"button"> {
active?: boolean;
}
-// The one segment element, shared by command toggles and dropdown triggers.
-// Forwards ref + rest props so it also works as a Base UI `render` trigger.
-// (which injects its own onClick/aria attributes).
-const SegmentButton = forwardRef<HTMLButtonElement, SegmentButtonProps>(({ Icon, label, active, className, ...rest }, ref) => (
- <button
- ref={ref}
- type="button"
- aria-label={label}
- aria-pressed={active}
- title={label}
- className={cn(SEGMENT_BASE, active ? SEGMENT_ACTIVE : SEGMENT_IDLE, className)}
- {...rest}
- >
- {Icon && <Icon className="w-4 h-4" />}
- </button>
+// The one segment element, shared by command toggles and dropdown triggers: the kit's
+// quiet 28px square, so the toolbar container stays transparent and only the verb that
+// is on carries the accent fill. Forwards ref + rest props so it also works as a Base UI
+// `render` trigger (which injects its own onClick/aria attributes).
+const SegmentButton = forwardRef<HTMLButtonElement, SegmentButtonProps>(({ Icon, label, active, ...rest }, ref) => (
+ <Button ref={ref} variant="quiet" size="icon-compact" aria-label={label} aria-pressed={active} title={label} {...rest}>
+ {Icon && <Icon className="size-4" strokeWidth={1.8} />}
+ </Button>
));
SegmentButton.displayName = "SegmentButton";
diff --git a/web/src/components/MemoEditor/Toolbar/InsertMenu.tsx b/web/src/components/MemoEditor/Toolbar/InsertMenu.tsx
index 01ce4692c..93c84c54d 100644
--- a/web/src/components/MemoEditor/Toolbar/InsertMenu.tsx
+++ b/web/src/components/MemoEditor/Toolbar/InsertMenu.tsx
@@ -152,13 +152,19 @@ const InsertMenu = (props: InsertMenuProps) => {
return (
<>
<DropdownMenu>
- <DropdownMenuTrigger render={<Button variant="secondary" size="icon" disabled={insertionDisabled} aria-label={t("common.add")} />}>
- {isUploading ? <LoaderIcon className="size-4 animate-spin" /> : <PlusIcon className="size-4" />}
+ <DropdownMenuTrigger
+ render={<Button variant="outline" size="icon-compact" disabled={insertionDisabled} aria-label={t("common.add")} />}
+ >
+ {isUploading ? (
+ <LoaderIcon className="size-4 animate-spin" strokeWidth={1.8} />
+ ) : (
+ <PlusIcon className="size-4" strokeWidth={1.8} />
+ )}
</DropdownMenuTrigger>
- <DropdownMenuContent align="start">
+ <DropdownMenuContent align="start" size="sm">
{insertItems.map((item) => (
<DropdownMenuItem key={item.key} onClick={item.onClick} disabled={props.isSaving}>
- <item.icon className="w-4 h-4" />
+ <item.icon />
{item.label}
</DropdownMenuItem>
))}
@@ -168,13 +174,13 @@ const InsertMenu = (props: InsertMenuProps) => {
<>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={viewToggles.onToggleFocusMode}>
- <Maximize2Icon className="w-4 h-4" />
+ <Maximize2Icon />
{t("editor.focus-mode")}
</DropdownMenuItem>
<DropdownMenuItem onClick={viewToggles.onToggleFormattingToolbar}>
- <TypeIcon className="w-4 h-4" />
+ <TypeIcon />
{t("editor.formatting-toolbar")}
- {viewToggles.isFormattingToolbarVisible && <CheckIcon className="w-4 h-4 ml-auto" />}
+ {viewToggles.isFormattingToolbarVisible && <CheckIcon className="ms-auto size-3.5" />}
</DropdownMenuItem>
</>
)}
diff --git a/web/src/components/MemoEditor/Toolbar/VisibilitySelector.tsx b/web/src/components/MemoEditor/Toolbar/VisibilitySelector.tsx
index 09bcd8368..24725a5b5 100644
--- a/web/src/components/MemoEditor/Toolbar/VisibilitySelector.tsx
+++ b/web/src/components/MemoEditor/Toolbar/VisibilitySelector.tsx
@@ -1,4 +1,5 @@
import { CheckIcon, ChevronDownIcon } from "lucide-react";
+import { Button } from "@/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import VisibilityIcon from "@/components/VisibilityIcon";
import { cn } from "@/lib/utils";
@@ -6,9 +7,13 @@ import { useTranslate } from "@/utils/i18n";
import { getAssignableVisibilityOptions, getVisibilityOption } from "@/utils/memo";
import type { VisibilitySelectorProps } from "../types";
+/**
+ * The visibility control is a quiet 28px chip built like the sidebar's scope pill: a
+ * 16px glyph at 75%, a 13px label and a 12px chevron at 55%. It fills only while its
+ * menu is open.
+ */
const VisibilitySelector = (props: VisibilitySelectorProps) => {
const { value, onChange } = props;
- const compact = props.size === "compact";
const t = useTranslate();
const visibilityOptions = getAssignableVisibilityOptions({ hasSpacePlacement: Boolean(props.space), current: value });
@@ -18,29 +23,20 @@ const VisibilitySelector = (props: VisibilitySelectorProps) => {
return (
<DropdownMenu onOpenChange={props.onOpenChange}>
- <DropdownMenuTrigger
- render={
- <button
- className={cn(
- "inline-flex items-center rounded-md hover:bg-accent transition-colors",
- compact ? "px-1.5 py-[3px] text-[13px] leading-5 text-foreground/85" : "h-8 px-2 text-sm text-muted-foreground",
- )}
- />
- }
- >
- <VisibilityIcon visibility={value} className={cn("opacity-60 mr-1.5", compact && "w-[13px]")} />
+ <DropdownMenuTrigger render={<Button variant="quiet" size="sm" />}>
+ <VisibilityIcon visibility={value} className="text-current opacity-75" />
<span className="truncate">{currentOption ? t(currentOption.labelKey) : ""}</span>
- <ChevronDownIcon className={cn("ml-0.5 opacity-60", compact ? "size-3.5 text-muted-foreground/70" : "w-4 h-4")} />
+ <ChevronDownIcon className="size-3 opacity-55" strokeWidth={1.8} />
</DropdownMenuTrigger>
- <DropdownMenuContent align="start">
+ <DropdownMenuContent align="start" size="sm">
{visibilityOptions.map((option) => (
<DropdownMenuItem key={option.value} onClick={() => onChange(option.value)}>
- <VisibilityIcon visibility={option.value} />
+ <VisibilityIcon visibility={option.value} className="size-3.5" />
<div className="flex flex-col">
<span>{t(option.labelKey)}</span>
- <span className="text-xs text-muted-foreground">{t(option.descriptionKey)}</span>
+ <span className="text-2xs text-muted-foreground">{t(option.descriptionKey)}</span>
</div>
- {value === option.value && <CheckIcon className="ml-auto w-4 h-4 text-primary" />}
+ <CheckIcon className={cn("ms-auto size-3.5 text-primary", value !== option.value && "invisible")} />
</DropdownMenuItem>
))}
</DropdownMenuContent>
diff --git a/web/src/components/MemoEditor/components/EditorMetadata.tsx b/web/src/components/MemoEditor/components/EditorMetadata.tsx
index 65cb43d34..83e1e439a 100644
--- a/web/src/components/MemoEditor/components/EditorMetadata.tsx
+++ b/web/src/components/MemoEditor/components/EditorMetadata.tsx
@@ -1,5 +1,6 @@
import type { FC } from "react";
import { AttachmentListEditor, LocationDisplayEditor, RelationListEditor } from "@/components/MemoMetadata";
+import { METADATA_ROW_LIST_CLASSES } from "@/components/MemoMetadata/MetadataSection";
import { extractManagedAttachmentUIDs } from "@/utils/managed-attachment";
import { useEditorContext, useEditorSelector } from "../state";
import type { EditorMetadataProps } from "../types";
@@ -37,7 +38,11 @@ export const EditorMetadata: FC<EditorMetadataProps> = ({ memoName, uploadingLoc
memoName={memoName}
/>
- {location && <LocationDisplayEditor location={location} onRemove={() => dispatch(actions.setMetadata({ location: undefined }))} />}
+ {location && (
+ <div className={METADATA_ROW_LIST_CLASSES}>
+ <LocationDisplayEditor location={location} onRemove={() => dispatch(actions.setMetadata({ location: undefined }))} />
+ </div>
+ )}
</div>
);
};
diff --git a/web/src/components/MemoEditor/components/TimestampPopover.tsx b/web/src/components/MemoEditor/components/TimestampPopover.tsx
index 1b5420c3e..6e7eff2e4 100644
--- a/web/src/components/MemoEditor/components/TimestampPopover.tsx
+++ b/web/src/components/MemoEditor/components/TimestampPopover.tsx
@@ -1,4 +1,5 @@
import { type FC, useId, useRef, useState } from "react";
+import { MEMO_TIME_CONTROL_CLASSES } from "@/components/MemoView/constants";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { useTranslate } from "@/utils/i18n";
import { useEditorContext, useEditorSelector } from "../state";
@@ -72,16 +73,7 @@ export const TimestampPopover: FC = () => {
return (
<Popover>
- <PopoverTrigger
- render={
- <button
- type="button"
- className="w-auto text-sm text-muted-foreground text-left hover:text-foreground transition-colors cursor-pointer"
- />
- }
- >
- {formatDate(createTime)}
- </PopoverTrigger>
+ <PopoverTrigger render={<button type="button" className={MEMO_TIME_CONTROL_CLASSES} />}>{formatDate(createTime)}</PopoverTrigger>
<PopoverContent align="start" className="w-auto p-2 pt-1 space-y-1">
<TimestampInput
label={t("common.created-at")}
diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx
index 97efda2e6..0fd3b4d02 100644
--- a/web/src/components/MemoEditor/index.tsx
+++ b/web/src/components/MemoEditor/index.tsx
@@ -342,7 +342,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
<div
ref={editorContainerRef}
className={cn(
- "group relative w-full flex flex-col justify-between items-start bg-card px-4 pt-3 pb-1 rounded-lg border border-border gap-2",
+ "group relative w-full flex flex-col justify-between items-start bg-card px-4 py-3 rounded-lg border border-border/70 gap-2",
FOCUS_MODE_STYLES.transition,
isFocusMode && cn(FOCUS_MODE_STYLES.container.base, FOCUS_MODE_STYLES.container.spacing),
!isFocusMode && className,
@@ -360,7 +360,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
)}
{(memoName || (!memo && hasTimestamp)) && (
- <div className="w-full -mb-1">
+ <div className="flex h-6 w-full items-center">
<TimestampPopover />
</div>
)}
diff --git a/web/src/components/MemoEditor/types/components.ts b/web/src/components/MemoEditor/types/components.ts
index 6d5734ed3..8dba2eda8 100644
--- a/web/src/components/MemoEditor/types/components.ts
+++ b/web/src/components/MemoEditor/types/components.ts
@@ -122,6 +122,4 @@ export interface VisibilitySelectorProps {
/** The memo's actual placement; independent of the ambient collection scope. */
space?: string;
onOpenChange?: (open: boolean) => void;
- /** "compact" renders a 13px trigger that blends into dense surfaces like the memo detail rail. */
- size?: "default" | "compact";
}
diff --git a/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx b/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx
index 6de5eed63..e0c4f296c 100644
--- a/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx
+++ b/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx
@@ -1,18 +1,15 @@
-import {
- ChevronDownIcon,
- ChevronUpIcon,
- FileAudioIcon,
- FileIcon,
- ImagePlusIcon,
- PaperclipIcon,
- PauseIcon,
- PlayIcon,
- XIcon,
-} from "lucide-react";
+import { ChevronDownIcon, ChevronUpIcon, FileAudioIcon, FileIcon, ImagePlusIcon, PauseIcon, PlayIcon, XIcon } from "lucide-react";
import { type FC, type MouseEvent, useMemo, useRef, useState } from "react";
import type { AttachmentItem, LocalFile } from "@/components/MemoEditor/types/attachment";
import { getAudioRecordingTimeLabel, toAttachmentItems } from "@/components/MemoEditor/types/attachment";
-import MetadataSection from "@/components/MemoMetadata/MetadataSection";
+import MetadataSection, {
+ METADATA_ROW_BOX_CLASSES,
+ METADATA_ROW_CONTROLS_CLASSES,
+ METADATA_ROW_SLOT_BUTTON_CLASSES,
+ METADATA_ROW_SLOT_CLASSES,
+ METADATA_ROW_TEXT_CLASSES,
+ MetadataRowDetail,
+} from "@/components/MemoMetadata/MetadataSection";
import PreviewImageDialog from "@/components/PreviewImageDialog";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
@@ -39,6 +36,7 @@ interface AttachmentListEditorProps {
uploadingLocalFileURLs?: ReadonlySet<string>;
}
+/** Trailing controls of an attachment row: quiet 24px squares that show once the row is engaged. */
const AttachmentItemActions: FC<{
placementAction?: { label: string; onClick: () => void; disabled?: boolean };
onRemove?: () => void;
@@ -52,25 +50,24 @@ const AttachmentItemActions: FC<{
};
return (
- <div className="shrink-0 flex items-center gap-0.5">
+ <div className={METADATA_ROW_CONTROLS_CLASSES}>
{placementAction && (
<Button
- variant="ghost"
+ variant="quiet"
size="sm"
onClick={(event) => {
stopPropagation(event);
placementAction.onClick();
}}
- className="h-6 gap-1 px-1.5 text-[10px] text-muted-foreground"
disabled={placementAction.disabled}
>
- <ImagePlusIcon className="size-3" />
+ <ImagePlusIcon className="size-3.5" strokeWidth={1.8} />
{placementAction.label}
</Button>
)}
{onMoveUp && (
<Button
- variant="ghost"
+ variant="quiet"
size="icon-sm"
onClick={(event) => {
stopPropagation(event);
@@ -80,13 +77,13 @@ const AttachmentItemActions: FC<{
title="Move up"
aria-label="Move attachment up"
>
- <ChevronUpIcon className="h-3 w-3 text-muted-foreground" />
+ <ChevronUpIcon className="size-3.5" strokeWidth={1.8} />
</Button>
)}
{onMoveDown && (
<Button
- variant="ghost"
+ variant="quiet"
size="icon-sm"
onClick={(event) => {
stopPropagation(event);
@@ -96,13 +93,13 @@ const AttachmentItemActions: FC<{
title="Move down"
aria-label="Move attachment down"
>
- <ChevronDownIcon className="h-3 w-3 text-muted-foreground" />
+ <ChevronDownIcon className="size-3.5" strokeWidth={1.8} />
</Button>
)}
{onRemove && (
<Button
- variant="ghost"
+ variant="quiet"
size="icon-sm"
onClick={(event) => {
stopPropagation(event);
@@ -111,7 +108,7 @@ const AttachmentItemActions: FC<{
title="Remove"
aria-label="Remove attachment"
>
- <XIcon className="h-3 w-3 text-muted-foreground hover:text-destructive" />
+ <XIcon className="size-3.5" strokeWidth={1.8} />
</Button>
)}
</div>
@@ -147,7 +144,7 @@ const AttachmentItemCard: FC<{
audioMeta?.durationSeconds ? formatAudioTime(audioMeta.durationSeconds) : undefined,
fileTypeLabel,
size ? formatFileSize(size) : undefined,
- ].filter(Boolean);
+ ];
const handleAudioToggle = async (event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
@@ -161,90 +158,81 @@ const AttachmentItemCard: FC<{
};
return (
- <div
- className="relative rounded border border-transparent px-1.5 py-1 transition-all hover:border-border hover:bg-accent/20"
- aria-busy={isUploadingInline || undefined}
- >
- <div className="flex items-center gap-1.5">
- <div className="relative flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded bg-muted/40">
- {(category === "image" || category === "motion") && thumbnailUrl ? (
- <div
- onClick={(event) => {
- event.stopPropagation();
- onPreview?.();
- }}
- className={cn("h-full w-full overflow-hidden", isPreviewable ? "cursor-pointer" : "cursor-default")}
- aria-label={`Preview ${filename}`}
- >
- <img src={thumbnailUrl} alt="" className="h-full w-full object-cover" loading="lazy" decoding="async" />
- </div>
- ) : isVoiceNote ? (
- <>
- <button
- type="button"
- onClick={handleAudioToggle}
- className="flex size-full items-center justify-center rounded bg-muted/40 text-muted-foreground hover:bg-accent hover:text-foreground"
- aria-label={isPlaying ? t("editor.audio-recorder.pause-recording") : t("editor.audio-recorder.play-recording")}
- >
- {isPlaying ? <PauseIcon className="h-3.5 w-3.5" /> : <PlayIcon className="h-3.5 w-3.5 translate-x-[0.5px]" />}
- </button>
- <audio
- ref={audioRef}
- preload="none"
- className="hidden"
- onPlay={() => setIsPlaying(true)}
- onPause={() => setIsPlaying(false)}
- onEnded={() => setIsPlaying(false)}
- />
- </>
- ) : category === "video" ? (
+ <div className={METADATA_ROW_BOX_CLASSES} aria-busy={isUploadingInline || undefined}>
+ <div className={cn(METADATA_ROW_SLOT_CLASSES, "relative overflow-hidden rounded-[5px] bg-muted/40")}>
+ {(category === "image" || category === "motion") && thumbnailUrl ? (
+ <div
+ onClick={(event) => {
+ event.stopPropagation();
+ onPreview?.();
+ }}
+ className={cn("size-full overflow-hidden", isPreviewable ? "cursor-pointer" : "cursor-default")}
+ aria-label={`Preview ${filename}`}
+ >
+ <img src={thumbnailUrl} alt="" className="size-full object-cover" loading="lazy" decoding="async" />
+ </div>
+ ) : isVoiceNote ? (
+ <>
<button
type="button"
- onClick={(event) => {
- event.stopPropagation();
- onPreview?.();
- }}
- className="flex size-full items-center justify-center rounded bg-muted/40 text-muted-foreground hover:bg-accent hover:text-foreground"
- aria-label={`Preview ${filename}`}
+ onClick={handleAudioToggle}
+ className={METADATA_ROW_SLOT_BUTTON_CLASSES}
+ aria-pressed={isPlaying}
+ aria-label={isPlaying ? t("editor.audio-recorder.pause-recording") : t("editor.audio-recorder.play-recording")}
>
- <PlayIcon className="h-3.5 w-3.5 translate-x-[0.5px]" />
+ {isPlaying ? (
+ <PauseIcon className="size-3.5" strokeWidth={1.8} />
+ ) : (
+ <PlayIcon className="size-3.5 translate-x-[0.5px]" strokeWidth={1.8} />
+ )}
</button>
- ) : category === "audio" ? (
- <FileAudioIcon className="h-3.5 w-3.5 text-muted-foreground" />
- ) : (
- <FileIcon className="h-3.5 w-3.5 text-muted-foreground" />
- )}
- {category === "motion" && (
- <span className="absolute inset-x-0 bottom-0 bg-black/70 text-center text-[7px] font-semibold uppercase tracking-wide text-white">
- Live
- </span>
- )}
- </div>
-
- <div className="min-w-0 flex-1 flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:gap-1.5">
- <span className="truncate text-xs" title={filename}>
- {titleLabel}
+ <audio
+ ref={audioRef}
+ preload="none"
+ className="hidden"
+ onPlay={() => setIsPlaying(true)}
+ onPause={() => setIsPlaying(false)}
+ onEnded={() => setIsPlaying(false)}
+ />
+ </>
+ ) : category === "video" ? (
+ <button
+ type="button"
+ onClick={(event) => {
+ event.stopPropagation();
+ onPreview?.();
+ }}
+ className={METADATA_ROW_SLOT_BUTTON_CLASSES}
+ aria-label={`Preview ${filename}`}
+ >
+ <PlayIcon className="size-3.5 translate-x-[0.5px]" strokeWidth={1.8} />
+ </button>
+ ) : category === "audio" ? (
+ <FileAudioIcon className="size-3.5 text-muted-foreground" strokeWidth={1.8} />
+ ) : (
+ <FileIcon className="size-3.5 text-muted-foreground" strokeWidth={1.8} />
+ )}
+ {category === "motion" && (
+ <span className="absolute inset-x-0 bottom-0 bg-black/70 text-center text-[7px] font-semibold uppercase tracking-wide text-white">
+ Live
</span>
-
- <div className="flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground">
- {detailParts.map((part, index) => (
- <span key={`${item.id}-${part}`}>
- {index > 0 && <span className="hidden text-muted-foreground/50 sm:inline"> • </span>}
- <span>{part}</span>
- </span>
- ))}
- </div>
- </div>
-
- <AttachmentItemActions
- placementAction={placementAction}
- onRemove={onRemove}
- onMoveUp={onMoveUp}
- onMoveDown={onMoveDown}
- canMoveUp={canMoveUp}
- canMoveDown={canMoveDown}
- />
+ )}
</div>
+
+ <span className={METADATA_ROW_TEXT_CLASSES} title={filename}>
+ {titleLabel}
+ </span>
+
+ <MetadataRowDetail parts={detailParts} />
+
+ <AttachmentItemActions
+ placementAction={placementAction}
+ onRemove={onRemove}
+ onMoveUp={onMoveUp}
+ onMoveDown={onMoveDown}
+ canMoveUp={canMoveUp}
+ canMoveDown={canMoveDown}
+ />
</div>
);
};
@@ -390,7 +378,7 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
return (
<>
- <MetadataSection icon={PaperclipIcon} title="Attachments" count={items.length} contentClassName="flex flex-col gap-1 p-1 sm:p-1.5">
+ <MetadataSection title={t("common.attachments")}>
{items.map((item) => {
const itemList = item.isLocal ? localItems : attachmentItems;
const itemIndex = itemList.findIndex((entry) => entry.id === item.id);
diff --git a/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx b/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx
index 97bbd187b..5a6881055 100644
--- a/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx
+++ b/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx
@@ -1,7 +1,6 @@
-import { DownloadIcon, FileIcon, PaperclipIcon, PlayIcon } from "lucide-react";
+import { DownloadIcon, FileIcon, PlayIcon } from "lucide-react";
import type { PropsWithChildren } from "react";
import { useMemo } from "react";
-import MetadataSection from "@/components/MemoMetadata/MetadataSection";
import MotionPhotoPreview from "@/components/MotionPhotoPreview";
import VideoPoster from "@/components/VideoPoster";
import { cn } from "@/lib/utils";
@@ -9,8 +8,15 @@ import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
import { getAttachmentUrl } from "@/utils/attachment";
import type { AttachmentVisualItem, PreviewMediaItem } from "@/utils/media-item";
import { buildAttachmentVisualItems } from "@/utils/media-item";
+import {
+ METADATA_ROW_CLASSES,
+ METADATA_ROW_HINT_CLASSES,
+ METADATA_ROW_TEXT_CLASSES,
+ MetadataRowDetail,
+ MetadataRowIconSlot,
+} from "../MetadataSection";
import AudioAttachmentItem from "./AudioAttachmentItem";
-import { getAttachmentMetadata, isAudioAttachment, separateAttachments } from "./attachmentHelpers";
+import { getAttachmentMetadata } from "./attachmentHelpers";
import {
COLLAGE_VIDEO_PLAY_BADGE_CLASS,
COVER_MEDIA_CLASS,
@@ -24,48 +30,8 @@ import {
} from "./attachmentVisualClasses";
import { resolveVisualGalleryLayout } from "./visualGalleryLayout";
-interface AttachmentListViewProps {
- attachments: Attachment[];
- onImagePreview?: (items: PreviewMediaItem[], index: number) => void;
-}
-
type VisualItem = AttachmentVisualItem;
-const AttachmentMeta = ({ attachment }: { attachment: Attachment }) => {
- const { fileTypeLabel, fileSizeLabel } = getAttachmentMetadata(attachment);
-
- return (
- <div className="mt-1 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground">
- <span>{fileTypeLabel}</span>
- {fileSizeLabel && (
- <>
- <span className="text-muted-foreground/40">•</span>
- <span>{fileSizeLabel}</span>
- </>
- )}
- </div>
- );
-};
-
-const DocumentItem = ({ attachment }: { attachment: Attachment }) => {
- return (
- <div className="group flex items-center justify-between gap-3 rounded-xl border border-border/70 bg-background/65 px-3 py-2.5 transition-colors hover:bg-accent/20">
- <div className="flex min-w-0 items-center gap-3">
- <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-muted/50 text-muted-foreground">
- <FileIcon className="h-4 w-4" />
- </div>
- <div className="min-w-0">
- <div className="truncate text-sm font-medium leading-tight text-foreground" title={attachment.filename}>
- {attachment.filename}
- </div>
- <AttachmentMeta attachment={attachment} />
- </div>
- </div>
- <DownloadIcon className="h-4 w-4 shrink-0 text-muted-foreground/60 transition-colors group-hover:text-foreground/70" />
- </div>
- );
-};
-
const getMotionPreviewProps = (item: VisualItem) => ({
motionUrl: item.previewItem.kind === "motion" ? item.previewItem.motionUrl : item.sourceUrl,
presentationTimestampUs: item.previewItem.kind === "motion" ? item.previewItem.presentationTimestampUs : undefined,
@@ -89,29 +55,28 @@ const VisualTile = ({
};
const VideoPlayBadge = ({ className, children }: PropsWithChildren<{ className?: string }>) => (
- <span
+ <div
className={cn(
- "pointer-events-none absolute inline-flex items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm backdrop-blur-sm",
+ "pointer-events-none absolute flex items-center justify-center rounded-full bg-background/80 text-foreground/70 shadow-sm backdrop-blur-sm",
className,
)}
>
{children}
- </span>
+ </div>
);
const CollageVisualItem = ({
item,
- onPreview,
className,
overlayLabel,
+ onPreview,
}: {
item: VisualItem;
- onPreview?: () => void;
className?: string;
overlayLabel?: string;
+ onPreview?: () => void;
}) => {
const motionPreviewProps = item.kind === "motion" ? getMotionPreviewProps(item) : undefined;
-
return (
<VisualTile className={cn("block h-full w-full", className)} onPreview={onPreview} overlayLabel={overlayLabel}>
{item.kind === "video" ? (
@@ -130,8 +95,8 @@ const CollageVisualItem = ({
alt={item.filename}
presentationTimestampUs={motionPreviewProps.presentationTimestampUs}
containerClassName="h-full w-full"
- badgeClassName="left-2 top-2 px-2 py-0.5 text-[10px]"
- mediaClassName={COVER_MEDIA_CLASS}
+ posterClassName={COVER_MEDIA_CLASS}
+ videoClassName={COVER_MEDIA_CLASS}
/>
) : (
<img src={item.posterUrl} alt={item.filename} className={COVER_MEDIA_CLASS} loading="lazy" decoding="async" />
@@ -181,98 +146,80 @@ const SingleVisualItem = ({ item, onPreview }: { item: VisualItem; onPreview?: (
);
};
-const VisualGallery = ({ items, onPreview }: { items: VisualItem[]; onPreview?: (itemId: string) => void }) => {
- const layout = resolveVisualGalleryLayout(items);
+interface AttachmentGalleryProps {
+ visual: Attachment[];
+ onImagePreview?: (items: PreviewMediaItem[], index: number) => void;
+}
+
+/** The memo's images, motion photos and videos as the bare gallery, flush with the content. */
+export const AttachmentGallery = ({ visual, onImagePreview }: AttachmentGalleryProps) => {
+ const visualItems = useMemo(() => buildAttachmentVisualItems(visual), [visual]);
+ const layout = resolveVisualGalleryLayout(visualItems);
if (!layout) {
return null;
}
+ const handlePreview = (itemId: string) => {
+ const previewItems = visualItems.map((item) => item.previewItem);
+ const index = previewItems.findIndex((item) => item.id === itemId);
+ onImagePreview?.(previewItems, index >= 0 ? index : 0);
+ };
+
if (layout.mode === "single") {
return (
<div className="w-full">
- <SingleVisualItem item={layout.item} onPreview={() => onPreview?.(layout.item.id)} />
+ <SingleVisualItem item={layout.item} onPreview={() => handlePreview(layout.item.id)} />
</div>
);
}
return (
- <div className={layout.containerClassName}>
+ <div className={cn("w-full", layout.containerClassName)}>
{layout.cells.map(({ item, className, overlayLabel }) => (
<CollageVisualItem
key={item.id}
item={item}
className={className}
overlayLabel={overlayLabel}
- onPreview={() => onPreview?.(item.id)}
+ onPreview={() => handlePreview(item.id)}
/>
))}
</div>
);
};
-const AudioList = ({ attachments, compact = false }: { attachments: Attachment[]; compact?: boolean }) => (
- <div className={cn("gap-2", compact ? "grid grid-cols-1 sm:grid-cols-2" : "flex flex-col")}>
- {attachments.map((attachment) => (
+/**
+ * A document is a row: file glyph in the slot, name, type and size on the detail rail.
+ * The whole row downloads; its arrow only appears over the detail rail once the row is
+ * engaged, so the rail stays on the same edge as every other row's at rest.
+ */
+const DocumentRow = ({ attachment }: { attachment: Attachment }) => {
+ const { fileTypeLabel, fileSizeLabel } = getAttachmentMetadata(attachment);
+ return (
+ <a href={getAttachmentUrl(attachment)} download title={`Download ${attachment.filename}`} className={METADATA_ROW_CLASSES}>
+ <MetadataRowIconSlot icon={FileIcon} />
+ <span className={METADATA_ROW_TEXT_CLASSES}>{attachment.filename}</span>
+ <MetadataRowDetail parts={[fileTypeLabel, fileSizeLabel]} />
+ <DownloadIcon aria-hidden="true" className={METADATA_ROW_HINT_CLASSES} strokeWidth={1.8} />
+ </a>
+ );
+};
+
+/** Audio and file attachments as metadata rows, for a host that owns the row list. */
+export const AttachmentRows = ({ audio, docs }: { audio: Attachment[]; docs: Attachment[] }) => (
+ <>
+ {audio.map((attachment) => (
<AudioAttachmentItem
key={attachment.name}
filename={attachment.filename}
sourceUrl={getAttachmentUrl(attachment)}
mimeType={attachment.type}
size={Number(attachment.size)}
- compact={compact}
/>
))}
- </div>
-);
-
-const DocsList = ({ attachments }: { attachments: Attachment[] }) => (
- <div className="flex flex-col gap-2">
- {attachments.map((attachment) => (
- <a key={attachment.name} href={getAttachmentUrl(attachment)} download title={`Download ${attachment.filename}`}>
- <DocumentItem attachment={attachment} />
- </a>
+ {docs.map((attachment) => (
+ <DocumentRow key={attachment.name} attachment={attachment} />
))}
- </div>
+ </>
);
-
-const Divider = () => <div className="border-t border-border/70 opacity-80" />;
-
-const AttachmentListView = ({ attachments, onImagePreview }: AttachmentListViewProps) => {
- const { visual, audio, docs } = useMemo(() => separateAttachments(attachments), [attachments]);
- const visualItems = useMemo(() => buildAttachmentVisualItems(visual), [visual]);
- const previewItems = useMemo(() => visualItems.map((item) => item.previewItem), [visualItems]);
- const hasVisual = visualItems.length > 0;
- const hasAudio = audio.length > 0;
- const hasDocs = docs.length > 0;
- const hasMedia = hasVisual || hasAudio;
-
- if (attachments.length === 0) {
- return null;
- }
-
- const handlePreview = (itemId: string) => {
- const index = previewItems.findIndex((item) => item.id === itemId);
- onImagePreview?.(previewItems, index >= 0 ? index : 0);
- };
-
- return (
- <MetadataSection
- icon={PaperclipIcon}
- title="Attachments"
- count={visualItems.length + audio.length + docs.length}
- contentClassName="flex flex-col gap-2 p-2"
- >
- {hasMedia && (
- <div className="flex flex-col gap-2">
- {hasVisual && <VisualGallery items={visualItems} onPreview={handlePreview} />}
- {hasAudio && <AudioList attachments={audio.filter(isAudioAttachment)} compact />}
- </div>
- )}
- {hasMedia && hasDocs && <Divider />}
- {hasDocs && <DocsList attachments={docs} />}
- </MetadataSection>
- );
-};
-
-export default AttachmentListView;
diff --git a/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx b/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx
index d96862e69..b21e6440a 100644
--- a/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx
+++ b/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx
@@ -1,12 +1,25 @@
-import { PauseIcon, PlayIcon } from "lucide-react";
+import { DownloadIcon, Maximize2Icon, PauseIcon, PlayIcon, RotateCcwIcon, RotateCwIcon } from "lucide-react";
import { useEffect, useRef, useState } from "react";
-import { Button } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { cn } from "@/lib/utils";
import { formatFileSize, getFileTypeLabel } from "@/utils/format";
+import {
+ METADATA_ROW_BOX_CLASSES,
+ METADATA_ROW_HINT_CLASSES,
+ METADATA_ROW_ICON_CLASSES,
+ METADATA_ROW_LABEL_CLASSES,
+ METADATA_ROW_SLOT_BUTTON_CLASSES,
+ METADATA_ROW_TEXT_CLASSES,
+ MetadataRowDetail,
+} from "../MetadataSection";
import { formatAudioTime, toggleAudioPlayback } from "./attachmentHelpers";
const AUDIO_PLAYBACK_RATES = [0.5, 0.75, 1, 1.5, 2] as const;
const UNKNOWN_DURATION_LABEL = "--:--";
+const SKIP_SECONDS = 10;
+const OPEN_PLAYER_CLASSES = cn(METADATA_ROW_LABEL_CLASSES, "cursor-pointer");
+const DOWNLOAD_CLASSES = buttonVariants({ variant: "quiet", size: "icon" });
const getDurationLabel = (duration: number): string => (duration > 0 ? formatAudioTime(duration) : UNKNOWN_DURATION_LABEL);
@@ -19,16 +32,15 @@ interface AudioProgressBarProps {
filename: string;
currentTime: number;
duration: number;
- progressPercent: number;
onSeek: (value: number) => void;
- className?: string;
}
-const AudioProgressBar = ({ filename, currentTime, duration, progressPercent, onSeek, className }: AudioProgressBarProps) => (
- <div className={`flex items-center gap-2 ${className ?? ""}`}>
- <div className="relative flex h-3.5 min-w-0 flex-1 items-center">
- <div className="absolute inset-x-0 h-1 rounded-full bg-muted/75" />
- <div className="absolute start-0 h-1 rounded-full bg-foreground/20" style={{ width: `${Math.min(progressPercent, 100)}%` }} />
+const AudioProgressBar = ({ filename, currentTime, duration, onSeek }: AudioProgressBarProps) => {
+ const progressPercent = duration > 0 ? (currentTime / duration) * 100 : 0;
+ return (
+ <div className="relative flex h-4 w-full items-center">
+ <div className="absolute inset-x-0 h-1 rounded-full bg-muted" />
+ <div className="absolute start-0 h-1 rounded-full bg-primary/60" style={{ width: `${Math.min(progressPercent, 100)}%` }} />
<input
type="range"
min={0}
@@ -37,44 +49,46 @@ const AudioProgressBar = ({ filename, currentTime, duration, progressPercent, on
value={Math.min(currentTime, duration || 0)}
onChange={(e) => onSeek(Number(e.target.value))}
aria-label={`Seek ${filename}`}
- className="relative z-10 h-3.5 w-full cursor-pointer appearance-none bg-transparent outline-none disabled:cursor-default
+ className="relative z-10 h-4 w-full cursor-pointer appearance-none bg-transparent outline-none disabled:cursor-default
[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:rounded-full
[&::-webkit-slider-runnable-track]:bg-transparent
- [&::-webkit-slider-thumb]:mt-[-2.5px] [&::-webkit-slider-thumb]:size-2 [&::-webkit-slider-thumb]:appearance-none
- [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border [&::-webkit-slider-thumb]:border-border/50
- [&::-webkit-slider-thumb]:bg-background/95
+ [&::-webkit-slider-thumb]:mt-[-4px] [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none
+ [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border [&::-webkit-slider-thumb]:border-border
+ [&::-webkit-slider-thumb]:bg-background [&::-webkit-slider-thumb]:shadow-xs
[&::-moz-range-track]:h-1 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-transparent
- [&::-moz-range-thumb]:size-2 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border
- [&::-moz-range-thumb]:border-border/50 [&::-moz-range-thumb]:bg-background/95"
+ [&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border
+ [&::-moz-range-thumb]:border-border [&::-moz-range-thumb]:bg-background"
disabled={duration === 0}
/>
</div>
- </div>
-);
+ );
+};
interface AudioAttachmentItemProps {
filename: string;
sourceUrl: string;
mimeType: string;
size?: number;
- title?: string;
- compact?: boolean;
- className?: string;
}
-const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compact = false, className }: AudioAttachmentItemProps) => {
+/**
+ * An audio attachment is a metadata row like a document. The play control in the leading
+ * slot starts and pauses playback in place; the name opens a small player with the
+ * scrubber, skip, speed and download. The audio element lives here, not in the dialog, so
+ * playback carries on when the dialog closes and the row's glyph always reflects it.
+ */
+const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size }: AudioAttachmentItemProps) => {
const audioRef = useRef<HTMLAudioElement>(null);
const [isPlaying, setIsPlaying] = useState(false);
- const [currentTime, setCurrentTime] = useState(0);
const [duration, setDuration] = useState(0);
const [playbackRate, setPlaybackRate] = useState<(typeof AUDIO_PLAYBACK_RATES)[number]>(1);
- const displayTitle = title ?? filename;
+ const [playerOpen, setPlayerOpen] = useState(false);
+ // Only the open player reads the playhead, so the row does not re-render on every timeupdate while it plays.
+ const [currentTime, setCurrentTime] = useState(0);
const fileTypeLabel = getFileTypeLabel(mimeType);
const fileSizeLabel = size ? formatFileSize(size) : undefined;
- const progressPercent = duration > 0 ? (currentTime / duration) * 100 : 0;
- const currentTimeLabel = formatAudioTime(currentTime);
- const durationLabel = getDurationLabel(duration);
- const timeLabel = `${currentTimeLabel} / ${durationLabel}`;
+ const PlaybackIcon = isPlaying ? PauseIcon : PlayIcon;
+ const playbackLabel = isPlaying ? `Pause ${filename}` : `Play ${filename}`;
useEffect(() => {
if (!audioRef.current) {
@@ -105,6 +119,18 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
setCurrentTime(nextTime);
};
+ const skip = (seconds: number) => {
+ const audio = audioRef.current;
+ if (!audio) return;
+ const limit = duration > 0 ? duration : Number.POSITIVE_INFINITY;
+ handleSeek(Math.min(Math.max(audio.currentTime + seconds, 0), limit));
+ };
+
+ const handlePlayerOpenChange = (open: boolean) => {
+ if (open) setCurrentTime(audioRef.current?.currentTime ?? 0);
+ setPlayerOpen(open);
+ };
+
const handlePlaybackRateChange = () => {
setPlaybackRate((currentRate) => getNextPlaybackRate(currentRate));
};
@@ -114,50 +140,23 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
};
return (
- <div className={cn("rounded-xl border border-border/40 bg-background/75", compact ? "px-3 py-2.5" : "px-2 py-1.5", className)}>
- <div className="flex items-start justify-between gap-2">
- <div className={cn("min-w-0 flex flex-1", compact ? "flex-col gap-0.5" : "items-baseline gap-1")}>
- <div className="truncate text-sm font-medium leading-5 text-foreground" title={filename}>
- {displayTitle}
- </div>
- <div className="truncate text-[11px] leading-4 text-muted-foreground">
- {fileTypeLabel}
- {fileSizeLabel ? ` · ${fileSizeLabel}` : ""}
- </div>
- </div>
-
- <Button
- variant="outline"
- size="icon-sm"
+ <>
+ <div className={METADATA_ROW_BOX_CLASSES}>
+ <button
+ type="button"
+ className={METADATA_ROW_SLOT_BUTTON_CLASSES}
onClick={togglePlayback}
- aria-label={isPlaying ? `Pause ${displayTitle}` : `Play ${displayTitle}`}
+ aria-pressed={isPlaying}
+ aria-label={playbackLabel}
>
- {isPlaying ? <PauseIcon className="size-2.5" /> : <PlayIcon className="size-2.5 translate-x-[0.5px]" />}
- </Button>
- </div>
-
- <div className={cn("mt-1", compact ? "space-y-1.5" : "flex items-center gap-1")}>
- <AudioProgressBar
- filename={filename}
- currentTime={currentTime}
- duration={duration}
- progressPercent={progressPercent}
- onSeek={handleSeek}
- className="min-w-0 flex-1"
- />
-
- <div className={cn("flex items-center", compact ? "justify-between gap-2" : "shrink-0 gap-1")}>
- <div className="shrink-0 text-[10px] tabular-nums text-muted-foreground">{timeLabel}</div>
-
- <Button
- variant="ghost"
- size="sm"
- onClick={handlePlaybackRateChange}
- aria-label={`Playback speed ${playbackRate}x for ${displayTitle}`}
- >
- {playbackRate}x
- </Button>
- </div>
+ <PlaybackIcon className={METADATA_ROW_ICON_CLASSES} strokeWidth={1.8} />
+ </button>
+ {/* The name opens the player; an open glyph takes the detail rail's place once the row is engaged. */}
+ <button type="button" className={OPEN_PLAYER_CLASSES} onClick={() => handlePlayerOpenChange(true)} title={filename}>
+ <span className={METADATA_ROW_TEXT_CLASSES}>{filename}</span>
+ <MetadataRowDetail parts={[duration > 0 ? getDurationLabel(duration) : undefined, fileTypeLabel, fileSizeLabel]} />
+ <Maximize2Icon aria-hidden="true" className={METADATA_ROW_HINT_CLASSES} strokeWidth={1.8} />
+ </button>
</div>
<audio
@@ -166,7 +165,7 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
className="hidden"
onLoadedMetadata={(e) => handleDuration(e.currentTarget.duration)}
onDurationChange={(e) => handleDuration(e.currentTarget.duration)}
- onTimeUpdate={(e) => setCurrentTime(e.currentTarget.currentTime)}
+ onTimeUpdate={playerOpen ? (e) => setCurrentTime(e.currentTarget.currentTime) : undefined}
onPlay={() => setIsPlaying(true)}
onPause={() => setIsPlaying(false)}
onEnded={() => {
@@ -174,7 +173,49 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
setCurrentTime(0);
}}
/>
- </div>
+
+ <Dialog open={playerOpen} onOpenChange={handlePlayerOpenChange}>
+ <DialogContent size="sm">
+ <DialogHeader>
+ <DialogTitle>{filename}</DialogTitle>
+ <DialogDescription>{[fileTypeLabel, fileSizeLabel].filter(Boolean).join(" · ")}</DialogDescription>
+ </DialogHeader>
+
+ <div className="flex flex-col gap-1">
+ <AudioProgressBar filename={filename} currentTime={currentTime} duration={duration} onSeek={handleSeek} />
+ <div className="flex items-center justify-between text-2xs tabular-nums text-muted-foreground/60">
+ <span>{formatAudioTime(currentTime)}</span>
+ <span>{getDurationLabel(duration)}</span>
+ </div>
+ </div>
+
+ {/* One 32px rail: download at the start, transport in the middle, speed at the end. */}
+ <div className="grid grid-cols-[1fr_auto_1fr] items-center">
+ <div className="flex justify-start">
+ <a href={sourceUrl} download className={DOWNLOAD_CLASSES} aria-label={`Download ${filename}`}>
+ <DownloadIcon className="size-4" strokeWidth={1.8} />
+ </a>
+ </div>
+ <div className="flex items-center gap-1">
+ <Button variant="quiet" size="icon" onClick={() => skip(-SKIP_SECONDS)} aria-label={`Back ${SKIP_SECONDS} seconds`}>
+ <RotateCcwIcon className="size-4" strokeWidth={1.8} />
+ </Button>
+ <Button size="icon" onClick={togglePlayback} aria-label={playbackLabel}>
+ <PlaybackIcon className="size-4" strokeWidth={2} />
+ </Button>
+ <Button variant="quiet" size="icon" onClick={() => skip(SKIP_SECONDS)} aria-label={`Forward ${SKIP_SECONDS} seconds`}>
+ <RotateCwIcon className="size-4" strokeWidth={1.8} />
+ </Button>
+ </div>
+ <div className="flex justify-end">
+ <Button variant="quiet" size="sm" onClick={handlePlaybackRateChange} aria-label={`Playback speed ${playbackRate}x`}>
+ {playbackRate}x
+ </Button>
+ </div>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </>
);
};
diff --git a/web/src/components/MemoMetadata/Attachment/attachmentVisualClasses.ts b/web/src/components/MemoMetadata/Attachment/attachmentVisualClasses.ts
index e8a920a4b..c3feb0cfb 100644
--- a/web/src/components/MemoMetadata/Attachment/attachmentVisualClasses.ts
+++ b/web/src/components/MemoMetadata/Attachment/attachmentVisualClasses.ts
@@ -1,10 +1,15 @@
+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
+import { cn } from "@/lib/utils";
+
/**
* Tailwind class bundles for attachment visual tiles (`VisualTile`, collage, single image/video).
* Hover uses `group/media` on {@link MEDIA_HOVER_SURFACE_CLASS} so scale/gradient track the media surface, not the outer button chrome.
*/
-export const VISUAL_TILE_BUTTON_CLASS =
- "relative block overflow-hidden rounded-xl border border-border/70 bg-muted/30 p-0 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50";
+export const VISUAL_TILE_BUTTON_CLASS = cn(
+ "relative block overflow-hidden rounded-md border border-border/70 bg-muted/30 p-0 text-left outline-none transition-colors",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+);
export const MEDIA_HOVER_SURFACE_CLASS = "group/media relative h-full min-h-0 w-full overflow-hidden";
diff --git a/web/src/components/MemoMetadata/Attachment/index.ts b/web/src/components/MemoMetadata/Attachment/index.ts
index 3da447284..08b2e0e7b 100644
--- a/web/src/components/MemoMetadata/Attachment/index.ts
+++ b/web/src/components/MemoMetadata/Attachment/index.ts
@@ -1,4 +1,4 @@
export { default as AttachmentCard } from "./AttachmentCard";
export { default as AttachmentListEditor } from "./AttachmentListEditor";
-export { default as AttachmentListView } from "./AttachmentListView";
+export { AttachmentGallery, AttachmentRows } from "./AttachmentListView";
export { default as AudioAttachmentItem } from "./AudioAttachmentItem";
diff --git a/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx b/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx
index 1e1979b47..150c7e6d2 100644
--- a/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx
+++ b/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx
@@ -1,40 +1,32 @@
-import { MapPinIcon, XIcon } from "lucide-react";
+import { MapPinIcon } from "lucide-react";
import type { FC } from "react";
-import { Button } from "@/components/ui/button";
-import { cn } from "@/lib/utils";
+import {
+ METADATA_ROW_BOX_CLASSES,
+ METADATA_ROW_TEXT_CLASSES,
+ MetadataRowDetail,
+ MetadataRowIconSlot,
+ MetadataRowRemoveControl,
+} from "@/components/MemoMetadata/MetadataSection";
import type { Location } from "@/types/proto/api/v1/memo_service_pb";
import { getLocationCoordinatesText, getLocationDisplayText } from "./locationHelpers";
interface LocationDisplayEditorProps {
location: Location;
onRemove?: () => void;
- className?: string;
}
-const LocationDisplayEditor: FC<LocationDisplayEditorProps> = ({ location, onRemove, className }) => {
+/** The draft's location as one metadata row; the remove control shows once the row is engaged. */
+const LocationDisplayEditor: FC<LocationDisplayEditorProps> = ({ location, onRemove }) => {
const displayText = getLocationDisplayText(location);
return (
- <div
- className={cn(
- "relative flex items-center gap-1.5 px-1.5 py-1 rounded border border-border bg-muted/20 hover:bg-accent/20 transition-all w-full",
- className,
- )}
- >
- <MapPinIcon className="w-3.5 h-3.5 shrink-0 text-muted-foreground" />
-
- <div className="flex items-center gap-1.5 min-w-0 flex-1">
- <span className="text-xs truncate" title={displayText}>
- {displayText}
- </span>
- <span className="text-[11px] text-muted-foreground shrink-0 hidden sm:inline">{getLocationCoordinatesText(location)}</span>
- </div>
-
- {onRemove && (
- <Button variant="ghost" size="icon-sm" onClick={onRemove} title="Remove" aria-label="Remove location">
- <XIcon className="w-3 h-3 text-muted-foreground hover:text-destructive" />
- </Button>
- )}
+ <div className={METADATA_ROW_BOX_CLASSES}>
+ <MetadataRowIconSlot icon={MapPinIcon} />
+ <span className={METADATA_ROW_TEXT_CLASSES} title={displayText}>
+ {displayText}
+ </span>
+ <MetadataRowDetail parts={[getLocationCoordinatesText(location)]} />
+ {onRemove && <MetadataRowRemoveControl label="Remove location" onClick={onRemove} />}
</div>
);
};
diff --git a/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx b/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx
index 0626f311c..d39c4bf2b 100644
--- a/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx
+++ b/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx
@@ -1,9 +1,8 @@
import { MapPinIcon } from "lucide-react";
import { useState } from "react";
+import { METADATA_ROW_CLASSES, METADATA_ROW_TEXT_CLASSES, MetadataRowIconSlot } from "@/components/MemoMetadata/MetadataSection";
import { LazyLocationPicker } from "@/components/map/LazyLocationPicker";
-import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
-import { cn } from "@/lib/utils";
import type { Location } from "@/types/proto/api/v1/memo_service_pb";
import { getLocationCoordinatesText, getLocationDisplayText } from "./locationHelpers";
@@ -11,6 +10,7 @@ interface LocationDisplayViewProps {
location?: Location;
}
+/** The memo's location as a metadata row; the row fills while its map is open. */
const LocationDisplayView = ({ location }: LocationDisplayViewProps) => {
const [popoverOpen, setPopoverOpen] = useState<boolean>(false);
@@ -22,20 +22,9 @@ const LocationDisplayView = ({ location }: LocationDisplayViewProps) => {
return (
<Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
- <PopoverTrigger
- render={
- <button
- type="button"
- title={displayText}
- className={cn(
- "inline-flex min-h-7 max-w-full min-w-0 items-center gap-1.5 rounded-sm text-xs text-muted-foreground transition-colors hover:text-foreground data-popup-open:text-foreground",
- FOCUS_VISIBLE_OUTLINE_CLASSES,
- )}
- />
- }
- >
- <MapPinIcon className="size-3.5 shrink-0" aria-hidden="true" />
- <span className="min-w-0 truncate">{displayText}</span>
+ <PopoverTrigger render={<button type="button" title={displayText} className={METADATA_ROW_CLASSES} />}>
+ <MetadataRowIconSlot icon={MapPinIcon} />
+ <span className={METADATA_ROW_TEXT_CLASSES}>{displayText}</span>
</PopoverTrigger>
<PopoverContent align="start" className="w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-xl p-0">
{popoverOpen && (
@@ -47,7 +36,7 @@ const LocationDisplayView = ({ location }: LocationDisplayViewProps) => {
)}
<div className="space-y-1 px-3 py-2.5">
{location.placeholder.trim() && <p className="wrap-anywhere text-sm font-medium">{displayText}</p>}
- <p className="text-xs tabular-nums text-muted-foreground">{getLocationCoordinatesText(location, 6)}</p>
+ <p className="text-2xs tabular-nums text-muted-foreground">{getLocationCoordinatesText(location, 6)}</p>
</div>
</PopoverContent>
</Popover>
diff --git a/web/src/components/MemoMetadata/MemoMetadataRows.tsx b/web/src/components/MemoMetadata/MemoMetadataRows.tsx
new file mode 100644
index 000000000..2380e214a
--- /dev/null
+++ b/web/src/components/MemoMetadata/MemoMetadataRows.tsx
@@ -0,0 +1,41 @@
+import { useMemo } from "react";
+import { useNearViewport } from "@/hooks/useNearViewport";
+import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
+import type { Location, MemoRelation } from "@/types/proto/api/v1/memo_service_pb";
+import { AttachmentRows } from "./Attachment/AttachmentListView";
+import LocationDisplayView from "./Location/LocationDisplayView";
+import { METADATA_ROW_LIST_CLASSES } from "./MetadataSection";
+import RelationRows, { getRelationRowItems } from "./Relation/RelationRows";
+
+interface MemoMetadataRowsProps {
+ audio: Attachment[];
+ docs: Attachment[];
+ relations: MemoRelation[];
+ currentMemoName: string;
+ parentPage?: string;
+ location?: Location;
+}
+
+/**
+ * Everything attached to a memo that is not its content or media, as one list of 28px
+ * rows 2px apart: audio, files, related memos, and the location. Renders nothing when
+ * the memo has none of them, so the body never carries an empty list.
+ */
+const MemoMetadataRows = ({ audio, docs, relations, currentMemoName, parentPage, location }: MemoMetadataRowsProps) => {
+ const { ref: viewportRef, isNearViewport } = useNearViewport<HTMLDivElement>();
+ const relationItems = useMemo(() => getRelationRowItems(relations, currentMemoName), [relations, currentMemoName]);
+
+ if (audio.length === 0 && docs.length === 0 && relationItems.length === 0 && !location) {
+ return null;
+ }
+
+ return (
+ <div ref={viewportRef} className={METADATA_ROW_LIST_CLASSES}>
+ <AttachmentRows audio={audio} docs={docs} />
+ {relationItems.length > 0 && <RelationRows items={relationItems} parentPage={parentPage} enabled={isNearViewport} />}
+ {location && <LocationDisplayView location={location} />}
+ </div>
+ );
+};
+
+export default MemoMetadataRows;
diff --git a/web/src/components/MemoMetadata/MetadataSection.tsx b/web/src/components/MemoMetadata/MetadataSection.tsx
index 5ddfc3ee7..fb462e21d 100644
--- a/web/src/components/MemoMetadata/MetadataSection.tsx
+++ b/web/src/components/MemoMetadata/MetadataSection.tsx
@@ -1,25 +1,121 @@
-import type { LucideIcon } from "lucide-react";
-import type { PropsWithChildren, Ref } from "react";
+import { type LucideIcon, XIcon } from "lucide-react";
+import type { PropsWithChildren, ReactNode } from "react";
+import { Button } from "@/components/ui/button";
+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
import { cn } from "@/lib/utils";
-import SectionHeader, { type SectionHeaderTab } from "./SectionHeader";
+
+/**
+ * The metadata lists under a memo (attachments, relations, location, comments) share one
+ * row grammar with the sidebar rail: a 28px row, a 20px leading slot on the artwork rail,
+ * a 13px label and a tabular detail rail. Only the hover wash differs, because these rows
+ * sit on a card rather than the sidebar surface.
+ */
+export const METADATA_ROW_BOX_CLASSES =
+ "group/row relative flex h-7 w-full min-w-0 items-center gap-1 rounded-md px-2 text-start text-ui text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground";
+/** A row that is itself the control: the box, the focus outline, and the quiet "on" fill while pressed or holding a popup open. */
+export const METADATA_ROW_CLASSES = cn(
+ METADATA_ROW_BOX_CLASSES,
+ "aria-pressed:bg-accent aria-pressed:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+);
+/** The focusable body of a split row; its gap must equal the box's `gap-1`. */
+export const METADATA_ROW_LABEL_CLASSES = `flex h-full min-w-0 flex-1 items-center gap-1 text-start ${FOCUS_VISIBLE_OUTLINE_CLASSES}`;
+export const METADATA_ROW_SLOT_CLASSES = "flex size-5 shrink-0 items-center justify-center";
+export const METADATA_ROW_ICON_CLASSES = "me-auto size-4 shrink-0 opacity-75";
+/** The row's text column: foreground ink, truncating. */
+export const METADATA_ROW_TEXT_CLASSES = "min-w-0 flex-1 truncate text-foreground";
+export const METADATA_ROW_DETAIL_CLASSES = "shrink-0 text-2xs tabular-nums text-muted-foreground/60";
+/**
+ * A slot that is itself a control (play, disclosure): the same box and glyph as any other
+ * slot, so it reads like its siblings at rest. The glyph darkens under the pointer and
+ * takes the accent ink while it is on; no chip, so the row keeps one surface.
+ */
+export const METADATA_ROW_SLOT_BUTTON_CLASSES = cn(
+ METADATA_ROW_SLOT_CLASSES,
+ "relative cursor-pointer rounded transition-colors hover:text-foreground hover:[&>svg]:opacity-100 aria-pressed:text-primary aria-pressed:[&>svg]:opacity-100 after:absolute after:-inset-0.5 after:content-['']",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+);
+
+/** A row is engaged by pointer or keyboard; everything that reveals or yields keys off this pair. */
+const whenEngaged = (value: string) => `md:group-hover/row:${value} md:group-focus-within/row:${value}`;
+
+/**
+ * Trailing controls of an editable row. On desktop they overlay the row's end and stay
+ * hidden until the row is engaged, so they never take width from the detail rail at
+ * rest; on touch layouts they sit inline and always show.
+ */
+export const METADATA_ROW_CONTROLS_CLASSES = cn(
+ "flex shrink-0 items-center gap-0.5 transition-opacity md:absolute md:inset-y-0 md:end-1 md:opacity-0",
+ whenEngaged("opacity-100"),
+);
+/** A glyph hinting at what engaging the row does (download, open), overlaid where the detail rail was. */
+export const METADATA_ROW_HINT_CLASSES = cn("absolute end-2 size-4 opacity-0 transition-opacity", whenEngaged("opacity-75"));
+/** The detail rail gives way to whatever overlays it. */
+export const METADATA_ROW_DETAIL_YIELD_CLASSES = cn("transition-opacity", whenEngaged("opacity-0"));
+
+/**
+ * Rows carry 8px of horizontal padding for their hover wash. A list of them pulls out by
+ * that much so leading glyphs land on the memo's text edge, and spaces rows 2px apart.
+ */
+export const METADATA_ROW_LIST_CLASSES = "-mx-2 flex w-[calc(100%+1rem)] flex-col gap-0.5";
+
+/** The standard glyph-in-slot pairing, so every row draws its glyph identically. */
+export const MetadataRowIconSlot = ({ icon: Icon }: { icon: LucideIcon }) => (
+ <span className={METADATA_ROW_SLOT_CLASSES} aria-hidden="true">
+ <Icon className={METADATA_ROW_ICON_CLASSES} strokeWidth={1.8} />
+ </span>
+);
+
+const DETAIL_RAIL_CLASSES = cn(METADATA_ROW_DETAIL_CLASSES, METADATA_ROW_DETAIL_YIELD_CLASSES, "hidden items-center gap-1 sm:flex");
+
+/** The detail rail: short facts separated by quiet dots, hidden on narrow screens where the label needs the room. */
+export const MetadataRowDetail = ({ parts }: { parts: Array<string | undefined> }) => {
+ const shown = parts.filter((part): part is string => Boolean(part));
+ if (shown.length === 0) return null;
+ return (
+ <span className={DETAIL_RAIL_CLASSES}>
+ {shown.map((part, index) => (
+ <span key={part} className="flex items-center gap-1">
+ {index > 0 && <span className="text-muted-foreground/40">·</span>}
+ <span>{part}</span>
+ </span>
+ ))}
+ </span>
+ );
+};
+
+/** An editable row's remove control, in the trailing overlay. */
+export const MetadataRowRemoveControl = ({ label, onClick }: { label: string; onClick: () => void }) => (
+ <div className={METADATA_ROW_CONTROLS_CLASSES}>
+ <Button variant="quiet" size="icon-sm" onClick={onClick} title="Remove" aria-label={label}>
+ <XIcon className="size-3.5" strokeWidth={1.8} />
+ </Button>
+ </div>
+);
interface MetadataSectionProps extends PropsWithChildren {
- icon: LucideIcon;
title: string;
- count: number;
- tabs?: SectionHeaderTab[];
- className?: string;
- contentClassName?: string;
- rootRef?: Ref<HTMLDivElement>;
+ count?: number;
+ /** A control on the header's trailing end; it pulls out by its own padding to end on the text edge. */
+ action?: ReactNode;
}
-const MetadataSection = ({ icon, title, count, tabs, className, contentClassName, rootRef, children }: MetadataSectionProps) => {
- return (
- <div ref={rootRef} className={cn("w-full overflow-hidden rounded-lg border border-border bg-muted/20", className)}>
- <SectionHeader icon={icon} title={title} count={count} tabs={tabs} />
- <div className={contentClassName}>{children}</div>
+/**
+ * A quiet titled list: a 24px header with an uppercase title on the text edge, then
+ * rows whose leading glyph lands on that same edge. No box or band, so the list recedes
+ * behind the memo's own content.
+ */
+const MetadataSection = ({ title, count, action, children }: MetadataSectionProps) => (
+ <section className="w-full" aria-label={title}>
+ <div className="mb-0.5 flex h-6 min-w-0 items-center justify-between gap-2">
+ <h3 className="flex min-w-0 items-center gap-1.5 text-2xs font-normal uppercase tracking-wide text-muted-foreground/55 select-none">
+ <span className="truncate">{title}</span>
+ {count != null && <span className="tabular-nums text-muted-foreground/60">{count}</span>}
+ </h3>
+ {action && <div className="-me-2 shrink-0">{action}</div>}
</div>
- );
-};
+ <div className={METADATA_ROW_LIST_CLASSES}>{children}</div>
+ </section>
+);
export default MetadataSection;
diff --git a/web/src/components/MemoMetadata/Relation/RelationCard.tsx b/web/src/components/MemoMetadata/Relation/RelationCard.tsx
deleted file mode 100644
index 4cfeba9f9..000000000
--- a/web/src/components/MemoMetadata/Relation/RelationCard.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import MemoSnippetLink from "@/components/MemoView/components/MemoSnippetLink";
-import { createMemoNavigationState } from "@/components/MemoView/navigation";
-import type { MemoRelation_Memo } from "@/types/proto/api/v1/memo_service_pb";
-
-interface RelationCardProps {
- memo: MemoRelation_Memo;
- parentPage?: string;
- className?: string;
-}
-
-const RelationCard = ({ memo, parentPage, className }: RelationCardProps) => {
- return (
- <MemoSnippetLink
- name={memo.name}
- snippet={memo.snippet}
- to={`/${memo.name}`}
- state={parentPage ? createMemoNavigationState(parentPage) : undefined}
- className={className}
- />
- );
-};
-
-export default RelationCard;
diff --git a/web/src/components/MemoMetadata/Relation/RelationListEditor.tsx b/web/src/components/MemoMetadata/Relation/RelationListEditor.tsx
index a137736fa..c375b58ba 100644
--- a/web/src/components/MemoMetadata/Relation/RelationListEditor.tsx
+++ b/web/src/components/MemoMetadata/Relation/RelationListEditor.tsx
@@ -1,9 +1,9 @@
-import { LinkIcon, XIcon } from "lucide-react";
import type { FC } from "react";
import { useMemo } from "react";
-import MetadataSection from "@/components/MemoMetadata/MetadataSection";
+import MetadataSection, { METADATA_ROW_BOX_CLASSES, MetadataRowRemoveControl } from "@/components/MemoMetadata/MetadataSection";
import type { MemoRelation } from "@/types/proto/api/v1/memo_service_pb";
-import RelationCard from "./RelationCard";
+import { useTranslate } from "@/utils/i18n";
+import RelationRow from "./RelationRow";
import { getEditorReferenceRelations } from "./relationHelpers";
import { useResolvedRelationMemos } from "./useResolvedRelationMemos";
@@ -14,31 +14,8 @@ interface RelationListEditorProps {
memoName?: string;
}
-const RelationItemCard: FC<{
- memo: MemoRelation["relatedMemo"];
- onRemove?: () => void;
- parentPage?: string;
-}> = ({ memo, onRemove, parentPage }) => {
- return (
- <div className="group relative flex items-center justify-between w-full rounded hover:bg-accent/20 transition-colors">
- <RelationCard memo={memo!} parentPage={parentPage} className="flex-1 hover:bg-transparent" />
-
- {onRemove && (
- <button
- type="button"
- onClick={onRemove}
- className="p-1 mr-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-destructive/10 active:bg-destructive/10 transition-all touch-manipulation"
- title="Remove"
- aria-label="Remove relation"
- >
- <XIcon className="w-3 h-3 text-muted-foreground hover:text-destructive" />
- </button>
- )}
- </div>
- );
-};
-
const RelationListEditor: FC<RelationListEditorProps> = ({ relations, onRelationsChange, parentPage, memoName }) => {
+ const t = useTranslate();
const referenceRelations = useMemo(() => getEditorReferenceRelations(relations, memoName), [relations, memoName]);
const relatedMemoNames = useMemo(
() => referenceRelations.flatMap((relation) => (relation.relatedMemo?.name ? [relation.relatedMemo.name] : [])),
@@ -57,17 +34,18 @@ const RelationListEditor: FC<RelationListEditorProps> = ({ relations, onRelation
}
return (
- <MetadataSection
- icon={LinkIcon}
- title="Relations"
- count={referenceRelations.length}
- contentClassName="flex flex-col gap-0.5 p-1 sm:p-1.5"
- >
+ <MetadataSection title={t("common.relations")}>
{referenceRelations.map((relation) => {
const relatedMemo = relation.relatedMemo!;
if (resolvedMemos[relatedMemo.name] === null) return null;
const memo = relatedMemo.snippet ? relatedMemo : resolvedMemos[relatedMemo.name] || relatedMemo;
- return <RelationItemCard key={memo.name} memo={memo} onRemove={() => handleDeleteRelation(memo.name)} parentPage={parentPage} />;
+ // A split row: the link is the focusable body, and the remove control overlays the trailing end once the row is engaged.
+ return (
+ <div key={memo.name} className={METADATA_ROW_BOX_CLASSES}>
+ <RelationRow memo={memo} parentPage={parentPage} variant="label" />
+ <MetadataRowRemoveControl label="Remove relation" onClick={() => handleDeleteRelation(memo.name)} />
+ </div>
+ );
})}
</MetadataSection>
);
diff --git a/web/src/components/MemoMetadata/Relation/RelationListView.tsx b/web/src/components/MemoMetadata/Relation/RelationListView.tsx
deleted file mode 100644
index 83ed19de6..000000000
--- a/web/src/components/MemoMetadata/Relation/RelationListView.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { LinkIcon, MilestoneIcon } from "lucide-react";
-import { useMemo, useState } from "react";
-import MetadataSection from "@/components/MemoMetadata/MetadataSection";
-import { useNearViewport } from "@/hooks/useNearViewport";
-import type { MemoRelation } from "@/types/proto/api/v1/memo_service_pb";
-import { useTranslate } from "@/utils/i18n";
-import RelationCard from "./RelationCard";
-import { getRelationBuckets, getRelationMemo, getRelationMemoName, type RelationDirection } from "./relationHelpers";
-import { useResolvedRelationMemos } from "./useResolvedRelationMemos";
-
-interface RelationListViewProps {
- relations: MemoRelation[];
- currentMemoName?: string;
- parentPage?: string;
- className?: string;
-}
-
-function RelationListView({ relations, currentMemoName, parentPage, className }: RelationListViewProps) {
- const t = useTranslate();
- const [activeTab, setActiveTab] = useState<"referencing" | "referenced">("referencing");
- const { ref: viewportRef, isNearViewport } = useNearViewport<HTMLDivElement>();
-
- const { referencing: referencingRelations, referenced: referencedRelations } = useMemo(
- () => getRelationBuckets(relations, currentMemoName),
- [relations, currentMemoName],
- );
-
- const hasBothTabs = referencingRelations.length > 0 && referencedRelations.length > 0;
- const direction: RelationDirection = hasBothTabs ? activeTab : referencingRelations.length > 0 ? "referencing" : "referenced";
- const isReferencing = direction === "referencing";
- const icon = isReferencing ? LinkIcon : MilestoneIcon;
- const activeRelations = isReferencing ? referencingRelations : referencedRelations;
- const activeMemoNames = useMemo(
- () =>
- activeRelations.flatMap((relation) => {
- const memo = getRelationMemo(relation, direction);
- return memo?.name ? [memo.name] : [];
- }),
- [activeRelations, direction],
- );
- const resolvedMemos = useResolvedRelationMemos(activeMemoNames, { enabled: isNearViewport });
-
- if (referencingRelations.length === 0 && referencedRelations.length === 0) {
- return null;
- }
-
- return (
- <MetadataSection
- rootRef={viewportRef}
- className={className}
- icon={icon}
- title={isReferencing ? t("common.referencing") : t("common.referenced-by")}
- count={activeRelations.length}
- tabs={
- hasBothTabs
- ? [
- {
- id: "referencing",
- label: t("common.referencing"),
- count: referencingRelations.length,
- active: isReferencing,
- onClick: () => setActiveTab("referencing"),
- },
- {
- id: "referenced",
- label: t("common.referenced-by"),
- count: referencedRelations.length,
- active: !isReferencing,
- onClick: () => setActiveTab("referenced"),
- },
- ]
- : undefined
- }
- contentClassName="flex flex-col gap-0 p-1.5"
- >
- {activeRelations.map((relation) => {
- const memo = getRelationMemo(relation, direction);
- if (!memo || resolvedMemos[memo.name] === null) {
- return null;
- }
- return (
- <RelationCard key={getRelationMemoName(relation, direction)} memo={resolvedMemos[memo.name] ?? memo} parentPage={parentPage} />
- );
- })}
- </MetadataSection>
- );
-}
-
-export default RelationListView;
diff --git a/web/src/components/MemoMetadata/Relation/RelationRow.tsx b/web/src/components/MemoMetadata/Relation/RelationRow.tsx
new file mode 100644
index 000000000..02fa41acf
--- /dev/null
+++ b/web/src/components/MemoMetadata/Relation/RelationRow.tsx
@@ -0,0 +1,35 @@
+import { LinkIcon, type LucideIcon } from "lucide-react";
+import type { ReactNode } from "react";
+import { Link } from "react-router-dom";
+import { createMemoNavigationState } from "@/components/MemoView/navigation";
+import type { MemoRelation_Memo } from "@/types/proto/api/v1/memo_service_pb";
+import { METADATA_ROW_CLASSES, METADATA_ROW_LABEL_CLASSES, METADATA_ROW_TEXT_CLASSES, MetadataRowIconSlot } from "../MetadataSection";
+
+interface RelationRowProps {
+ memo: MemoRelation_Memo;
+ parentPage?: string;
+ icon?: LucideIcon;
+ /**
+ * "row" is a complete row that is its own focus target; "label" is the focusable body
+ * of a row whose box is a wrapper carrying other controls (the editor's remove button).
+ */
+ variant?: "row" | "label";
+ /** Detail on the trailing rail, such as the relation's direction. */
+ trailing?: ReactNode;
+}
+
+/** One related memo as a metadata row: a glyph in the leading slot and the snippet. */
+const RelationRow = ({ memo, parentPage, icon = LinkIcon, variant = "row", trailing }: RelationRowProps) => (
+ <Link
+ className={variant === "row" ? METADATA_ROW_CLASSES : METADATA_ROW_LABEL_CLASSES}
+ to={`/${memo.name}`}
+ state={parentPage ? createMemoNavigationState(parentPage) : undefined}
+ viewTransition
+ >
+ <MetadataRowIconSlot icon={icon} />
+ <span className={METADATA_ROW_TEXT_CLASSES}>{memo.snippet || <span className="italic text-muted-foreground/60">No content</span>}</span>
+ {trailing}
+ </Link>
+);
+
+export default RelationRow;
diff --git a/web/src/components/MemoMetadata/Relation/RelationRows.tsx b/web/src/components/MemoMetadata/Relation/RelationRows.tsx
new file mode 100644
index 000000000..abfd33c13
--- /dev/null
+++ b/web/src/components/MemoMetadata/Relation/RelationRows.tsx
@@ -0,0 +1,75 @@
+import { LinkIcon, MilestoneIcon } from "lucide-react";
+import { useMemo } from "react";
+import type { MemoRelation } from "@/types/proto/api/v1/memo_service_pb";
+import { useTranslate } from "@/utils/i18n";
+import { METADATA_ROW_DETAIL_CLASSES } from "../MetadataSection";
+import RelationRow from "./RelationRow";
+import { getRelationBuckets, getRelationMemo, getRelationMemoName, type RelationDirection } from "./relationHelpers";
+import { useResolvedRelationMemos } from "./useResolvedRelationMemos";
+
+export interface RelationRowItem {
+ relation: MemoRelation;
+ direction: RelationDirection;
+}
+
+/** Every reference to or from the memo, referencing first, as rows in one list. */
+export const getRelationRowItems = (relations: MemoRelation[], currentMemoName?: string): RelationRowItem[] => {
+ const { referencing, referenced } = getRelationBuckets(relations, currentMemoName);
+ return [
+ ...referencing.map((relation) => ({ relation, direction: "referencing" as const })),
+ ...referenced.map((relation) => ({ relation, direction: "referenced" as const })),
+ ];
+};
+
+const DIRECTION_ICONS = { referencing: LinkIcon, referenced: MilestoneIcon } as const;
+
+interface RelationRowsProps {
+ items: RelationRowItem[];
+ parentPage?: string;
+ /** Resolve fresh snippets only once the rows are near the viewport. */
+ enabled: boolean;
+}
+
+/**
+ * Related memos are rows like the memo's files: a direction glyph in the slot, the
+ * snippet, and the direction spelled out on the detail rail. No header or tabs, so the
+ * list reads as part of the memo rather than a panel attached to it.
+ */
+const RelationRows = ({ items, parentPage, enabled }: RelationRowsProps) => {
+ const t = useTranslate();
+ const memoNames = useMemo(
+ () =>
+ items.flatMap(({ relation, direction }) => {
+ const memo = getRelationMemo(relation, direction);
+ return memo?.name ? [memo.name] : [];
+ }),
+ [items],
+ );
+ const resolvedMemos = useResolvedRelationMemos(memoNames, { enabled });
+ const directionLabels: Record<RelationDirection, string> = {
+ referencing: t("common.referencing"),
+ referenced: t("common.referenced-by"),
+ };
+
+ return (
+ <>
+ {items.map(({ relation, direction }) => {
+ const memo = getRelationMemo(relation, direction);
+ if (!memo || resolvedMemos[memo.name] === null) {
+ return null;
+ }
+ return (
+ <RelationRow
+ key={getRelationMemoName(relation, direction)}
+ memo={resolvedMemos[memo.name] ?? memo}
+ parentPage={parentPage}
+ icon={DIRECTION_ICONS[direction]}
+ trailing={<span className={METADATA_ROW_DETAIL_CLASSES}>{directionLabels[direction]}</span>}
+ />
+ );
+ })}
+ </>
+ );
+};
+
+export default RelationRows;
diff --git a/web/src/components/MemoMetadata/Relation/index.ts b/web/src/components/MemoMetadata/Relation/index.ts
index b46fac0c0..8a61e2b78 100644
--- a/web/src/components/MemoMetadata/Relation/index.ts
+++ b/web/src/components/MemoMetadata/Relation/index.ts
@@ -1,4 +1,4 @@
export { LinkMemoDialog } from "./LinkMemoDialog";
-export { default as RelationCard } from "./RelationCard";
export { default as RelationListEditor } from "./RelationListEditor";
-export { default as RelationListView } from "./RelationListView";
+export { default as RelationRow } from "./RelationRow";
+export { default as RelationRows } from "./RelationRows";
diff --git a/web/src/components/MemoMetadata/SectionHeader.tsx b/web/src/components/MemoMetadata/SectionHeader.tsx
deleted file mode 100644
index b41891702..000000000
--- a/web/src/components/MemoMetadata/SectionHeader.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import type { LucideIcon } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { cn } from "@/lib/utils";
-
-export interface SectionHeaderTab {
- id: string;
- label: string;
- count: number;
- active: boolean;
- onClick: () => void;
-}
-
-interface SectionHeaderProps {
- icon: LucideIcon;
- title: string;
- count: number;
- tabs?: SectionHeaderTab[];
-}
-
-const SectionHeader = ({ icon: Icon, title, count, tabs }: SectionHeaderProps) => {
- return (
- <div className="flex items-center gap-1.5 px-2 py-1 border-b border-border bg-muted/30">
- <Icon className="w-3.5 h-3.5 text-muted-foreground" />
-
- {tabs && tabs.length > 1 ? (
- <div className="flex items-center gap-0.5">
- {tabs.map((tab, idx) => (
- <div key={tab.id} className="flex items-center gap-0.5">
- <Button
- variant="ghost"
- size="sm"
- onClick={tab.onClick}
- className={cn(
- "h-auto text-xs px-0 py-0 hover:bg-transparent",
- tab.active ? "text-muted-foreground" : "text-muted-foreground/60 hover:text-muted-foreground",
- )}
- >
- {tab.label} ({tab.count})
- </Button>
- {idx < tabs.length - 1 && <span className="text-muted-foreground/40 font-mono text-xs">/</span>}
- </div>
- ))}
- </div>
- ) : (
- <span className="text-xs text-muted-foreground">
- {title} ({count})
- </span>
- )}
- </div>
- );
-};
-
-export default SectionHeader;
diff --git a/web/src/components/MemoMetadata/index.ts b/web/src/components/MemoMetadata/index.ts
index 596cb1d7f..d3e586934 100644
--- a/web/src/components/MemoMetadata/index.ts
+++ b/web/src/components/MemoMetadata/index.ts
@@ -1,7 +1,7 @@
// Consolidated memo metadata components for attachments, locations, and relations.
-export { AttachmentCard, AttachmentListEditor, AttachmentListView } from "./Attachment";
+export { AttachmentCard, AttachmentGallery, AttachmentListEditor, AttachmentRows } from "./Attachment";
export { LocationDialog, LocationDisplayEditor, LocationDisplayView } from "./Location";
+export { default as MemoMetadataRows } from "./MemoMetadataRows";
export { default as MetadataSection } from "./MetadataSection";
-export { LinkMemoDialog, RelationCard, RelationListEditor, RelationListView } from "./Relation";
-export { default as SectionHeader } from "./SectionHeader";
+export { LinkMemoDialog, RelationListEditor, RelationRow, RelationRows } from "./Relation";
diff --git a/web/src/components/MemoPreview/MemoPreview.tsx b/web/src/components/MemoPreview/MemoPreview.tsx
index 2663071ea..4b1697bc3 100644
--- a/web/src/components/MemoPreview/MemoPreview.tsx
+++ b/web/src/components/MemoPreview/MemoPreview.tsx
@@ -67,8 +67,8 @@ const AttachmentThumbnails = ({ attachments }: { attachments: Attachment[] }) =>
</div>
))}
{others.map((item) => (
- <div key={item.id} className="flex items-center gap-1 text-[10px] text-muted-foreground">
- <FileIcon className="w-3 h-3 shrink-0" />
+ <div key={item.id} className="flex items-center gap-1 text-2xs text-muted-foreground">
+ <FileIcon className="size-3 shrink-0" strokeWidth={1.8} />
<span className="truncate max-w-[80px]">{item.filename}</span>
</div>
))}
@@ -95,11 +95,9 @@ const PreviewMeta = ({
}
return (
- <div className="flex items-center gap-1.5 text-xs text-muted-foreground leading-none shrink-0">
- {showMemoId && memoId && (
- <span className="text-[8px] font-mono px-1 py-0.5 rounded border border-border bg-muted/40 shrink-0">{memoId}</span>
- )}
- {showCreator && creatorName && <span className="font-medium text-foreground/80 truncate">{creatorName}</span>}
+ <div className="flex shrink-0 items-center gap-1.5 text-ui leading-none text-muted-foreground">
+ {showMemoId && memoId && <span className="shrink-0 font-mono text-2xs text-muted-foreground/60">{memoId}</span>}
+ {showCreator && creatorName && <span className="truncate font-medium text-foreground">{creatorName}</span>}
</div>
);
};
@@ -127,9 +125,9 @@ const MemoPreview = ({
const meta = <PreviewMeta creator={creator} showCreator={showCreator} memoName={name} showMemoId={showMemoId} />;
const contentNode = truncate ? (
hasContent ? (
- <div className="text-sm text-muted-foreground truncate min-w-0">{content}</div>
+ <div className="min-w-0 truncate text-ui text-muted-foreground">{content}</div>
) : hasAttachments ? null : (
- <div className="text-sm text-muted-foreground truncate min-w-0">No content</div>
+ <div className="min-w-0 truncate text-ui text-muted-foreground">No content</div>
)
) : (
// Previews are inert (pointer-events-none), so a static CSS bound replaces the
@@ -155,9 +153,9 @@ const MemoPreview = ({
{contentNode}
{hasAttachments &&
(truncate ? (
- <div className="shrink-0 text-muted-foreground/70 inline-flex justify-center items-center gap-0.5">
- <FileIcon className="w-3 h-3 inline-block" />
- <span className="text-xs">{countLogicalAttachmentItems(attachmentOnlyItems)}</span>
+ <div className="inline-flex shrink-0 items-center justify-center gap-0.5 text-muted-foreground/60">
+ <FileIcon className="inline-block size-3" strokeWidth={1.8} />
+ <span className="text-2xs tabular-nums">{countLogicalAttachmentItems(attachmentOnlyItems)}</span>
</div>
) : (
<AttachmentThumbnails attachments={attachmentOnlyItems} />
diff --git a/web/src/components/MemoReactionListView/MemoReactionListView.tsx b/web/src/components/MemoReactionListView/MemoReactionListView.tsx
index afe362a25..6e5cf7312 100644
--- a/web/src/components/MemoReactionListView/MemoReactionListView.tsx
+++ b/web/src/components/MemoReactionListView/MemoReactionListView.tsx
@@ -22,7 +22,8 @@ const MemoReactionListView = (props: Props) => {
}
return (
- <div className="w-full flex flex-row justify-start items-start flex-wrap gap-1 select-none">
+ // Chips are filled surfaces, so their box edge, not their padding, sits on the text edge.
+ <div className="flex w-full flex-row flex-wrap items-center justify-start gap-1 select-none">
{Array.from(reactionGroup).map(([reactionType, users]) => (
<ReactionView key={`${reactionType.toString()} ${users.length}`} memo={memoData} reactionType={reactionType} users={users} />
))}
diff --git a/web/src/components/MemoReactionListView/ReactionSelector.tsx b/web/src/components/MemoReactionListView/ReactionSelector.tsx
index 50c727cf9..9dced1098 100644
--- a/web/src/components/MemoReactionListView/ReactionSelector.tsx
+++ b/web/src/components/MemoReactionListView/ReactionSelector.tsx
@@ -1,51 +1,41 @@
import { SmilePlusIcon } from "lucide-react";
-import { useState } from "react";
-import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
+import { type ReactElement, useState } from "react";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { useInstance } from "@/contexts/InstanceContext";
import { cn } from "@/lib/utils";
import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
import { useTranslate } from "@/utils/i18n";
import { useReactionActions } from "./hooks";
+import { REACTION_ADD_CLASSES } from "./ReactionView";
interface Props {
memo: Memo;
- className?: string;
- onOpenChange?: (open: boolean) => void;
+ /**
+ * The element that opens the picker. Defaults to the round add control that closes a
+ * strip of reaction pills; a host with its own action grammar (the memo header) passes
+ * the control that belongs there.
+ */
+ trigger?: ReactElement;
}
-const ReactionSelector = (props: Props) => {
- const { memo, className, onOpenChange } = props;
+/** The emoji picker. It owns only the popover and the grid; the trigger is the host's. */
+const ReactionSelector = ({ memo, trigger }: Props) => {
const t = useTranslate();
const [open, setOpen] = useState(false);
const { memoRelatedSetting } = useInstance();
- const handleOpenChange = (newOpen: boolean) => {
- setOpen(newOpen);
- onOpenChange?.(newOpen);
- };
-
const { hasReacted, handleReactionClick } = useReactionActions({
memo,
- onComplete: () => handleOpenChange(false),
+ onComplete: () => setOpen(false),
});
return (
- <Popover open={open} onOpenChange={handleOpenChange}>
+ <Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger
- render={
- <button
- type="button"
- aria-label={t("setting.memo.add-reaction")}
- className={cn(
- "flex size-7 cursor-pointer items-center justify-center rounded-full border text-muted-foreground transition-all hover:opacity-80",
- FOCUS_VISIBLE_OUTLINE_CLASSES,
- className,
- )}
- />
- }
+ aria-label={t("setting.memo.add-reaction")}
+ render={trigger ?? <button type="button" className={REACTION_ADD_CLASSES} />}
>
- <SmilePlusIcon className="mx-auto size-4" />
+ <SmilePlusIcon className="size-4" strokeWidth={1.8} />
</PopoverTrigger>
<PopoverContent align="center" className="max-w-[90vw] sm:max-w-md">
<div className="grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-1 max-h-64 overflow-y-auto">
diff --git a/web/src/components/MemoReactionListView/ReactionView.tsx b/web/src/components/MemoReactionListView/ReactionView.tsx
index ee8b96114..7a9904d61 100644
--- a/web/src/components/MemoReactionListView/ReactionView.tsx
+++ b/web/src/components/MemoReactionListView/ReactionView.tsx
@@ -1,3 +1,4 @@
+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCurrentUser from "@/hooks/useCurrentUser";
import { cn } from "@/lib/utils";
@@ -6,6 +7,21 @@ import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
import type { User } from "@/types/proto/api/v1/user_service_pb";
import { formatReactionTooltip, useReactionActions } from "./hooks";
+/**
+ * A reaction is a token attached to the memo, not a control, so it takes the pill shape
+ * the space and New badges use rather than the rounded box of a button. Everything else
+ * is the quiet grammar: 28px, 13px, muted ink under a light wash, and the accent fill for
+ * the one that is on — your own reaction, or the add control while its picker is open.
+ */
+export const REACTION_PILL_CLASSES = "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-ui text-muted-foreground/70";
+const REACTION_PILL_INTERACTIVE_CLASSES = cn(
+ REACTION_PILL_CLASSES,
+ "cursor-pointer transition-colors hover:bg-muted/60 hover:text-foreground aria-pressed:bg-accent aria-pressed:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+);
+/** The strip's add control: a round quiet face of the pills' height, so the strip reads as one row. */
+export const REACTION_ADD_CLASSES = cn(REACTION_PILL_INTERACTIVE_CLASSES, "size-7 justify-center px-0");
+
interface Props {
memo: Memo;
reactionType: string;
@@ -20,34 +36,32 @@ const ReactionView = (props: Props) => {
const { handleReactionClick } = useReactionActions({ memo });
- const handleClick = () => {
- if (!currentUser || readonly) return;
- handleReactionClick(reactionType);
- };
-
- const isClickable = currentUser && !readonly;
+ const isClickable = Boolean(currentUser) && !readonly;
+ const label = (
+ <>
+ <span className="text-sm leading-none">{reactionType}</span>
+ <span className="text-2xs tabular-nums text-muted-foreground/60">{users.length}</span>
+ </>
+ );
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger
render={
- <button
- type="button"
- className={cn(
- "h-7 border px-2 py-0.5 rounded-full flex flex-row justify-center items-center gap-1",
- "text-sm text-muted-foreground",
- isClickable && "cursor-pointer",
- !isClickable && "cursor-default",
- hasReaction && "bg-accent border-border",
- )}
- onClick={handleClick}
- disabled={!isClickable}
- />
+ isClickable ? (
+ <button
+ type="button"
+ className={REACTION_PILL_INTERACTIVE_CLASSES}
+ aria-pressed={hasReaction}
+ onClick={() => handleReactionClick(reactionType)}
+ />
+ ) : (
+ <span className={REACTION_PILL_CLASSES} />
+ )
}
>
- <span>{reactionType}</span>
- <span className="opacity-60">{users.length}</span>
+ {label}
</TooltipTrigger>
<TooltipContent>
<p>{formatReactionTooltip(users, reactionType)}</p>
diff --git a/web/src/components/MemoView/components/MemoBody.tsx b/web/src/components/MemoView/components/MemoBody.tsx
index ccd05fe28..901d500b9 100644
--- a/web/src/components/MemoView/components/MemoBody.tsx
+++ b/web/src/components/MemoView/components/MemoBody.tsx
@@ -1,7 +1,8 @@
import { EyeIcon } from "lucide-react";
import { useMemo } from "react";
import ClampedSection from "@/components/ClampedSection";
-import { AttachmentListView, LocationDisplayView, RelationListView } from "@/components/MemoMetadata";
+import { AttachmentGallery, MemoMetadataRows } from "@/components/MemoMetadata";
+import { separateAttachments } from "@/components/MemoMetadata/Attachment/attachmentHelpers";
import { isReferenceRelation } from "@/components/MemoMetadata/Relation/relationHelpers";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
@@ -17,14 +18,8 @@ const BlurOverlay: React.FC<{ onClick?: () => void }> = ({ onClick }) => {
const t = useTranslate();
return (
<div className="absolute inset-0 z-10 flex items-center justify-center pt-4">
- <Button
- type="button"
- variant="outline"
- size="sm"
- className="cursor-pointer rounded-lg bg-card px-3 text-xs text-foreground shadow-sm hover:-translate-y-0.5 hover:border-ring/40 hover:bg-accent hover:text-accent-foreground hover:shadow-md active:translate-y-0 active:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
- onClick={onClick}
- >
- <EyeIcon className="h-3.5 w-3.5" />
+ <Button type="button" variant="outline" size="sm" onClick={onClick}>
+ <EyeIcon className="size-3.5" strokeWidth={1.8} />
{t("memo.click-to-show-sensitive-content")}
</Button>
</div>
@@ -42,6 +37,7 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact }) => {
() => filterInlineManagedAttachments(memo.content, memo.attachments),
[memo.content, memo.attachments],
);
+ const { visual, audio, docs } = useMemo(() => separateAttachments(attachmentOnlyItems), [attachmentOnlyItems]);
return (
<>
@@ -63,9 +59,15 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact }) => {
onDoubleClick={handleMemoContentDoubleClick}
compact={Boolean(compact)}
/>
- <AttachmentListView attachments={attachmentOnlyItems} onImagePreview={openPreview} />
- <RelationListView relations={referencedMemos} currentMemoName={memo.name} parentPage={parentPage} />
- {memo.location && <LocationDisplayView location={memo.location} />}
+ <AttachmentGallery visual={visual} onImagePreview={openPreview} />
+ <MemoMetadataRows
+ audio={audio}
+ docs={docs}
+ relations={referencedMemos}
+ currentMemoName={memo.name}
+ parentPage={parentPage}
+ location={memo.location}
+ />
</ClampedSection>
<MemoReactionListView memo={memo} reactions={memo.reactions} />
</div>
diff --git a/web/src/components/MemoView/components/MemoCommentListView.tsx b/web/src/components/MemoView/components/MemoCommentListView.tsx
index 0e6f900b7..533defe42 100644
--- a/web/src/components/MemoView/components/MemoCommentListView.tsx
+++ b/web/src/components/MemoView/components/MemoCommentListView.tsx
@@ -1,15 +1,26 @@
import { ArrowUpRightIcon } from "lucide-react";
import { Link } from "react-router-dom";
+import MetadataSection, { METADATA_ROW_CLASSES, METADATA_ROW_SLOT_CLASSES } from "@/components/MemoMetadata/MetadataSection";
import { MemoPreview } from "@/components/MemoPreview";
+import { buttonVariants } from "@/components/ui/button";
import { useMemoComments } from "@/hooks/useMemoQueries";
import { useNearViewport } from "@/hooks/useNearViewport";
import { useUsersByNames } from "@/hooks/useUserQueries";
import { MEMO_COMMENTS_ANCHOR_ID } from "@/lib/memo-comments";
import { extractMemoIdFromName } from "@/lib/resource-names";
+import { useTranslate } from "@/utils/i18n";
+import UserAvatar from "../../UserAvatar";
import { useMemoViewContext, useMemoViewDerived } from "../MemoViewContext";
import { createMemoNavigationState } from "../navigation";
+const VIEW_ALL_CLASSES = buttonVariants({ variant: "quiet", size: "sm" });
+
+/**
+ * The comment strip hangs off the card's bottom edge: a titled list of up to three
+ * comments, each a row whose avatar sits in the leading slot on the card's text edge.
+ */
const MemoCommentListView: React.FC = () => {
+ const t = useTranslate();
const { memo, parentPage } = useMemoViewContext();
const { isInMemoDetailPage, commentAmount } = useMemoViewDerived();
const { ref: viewportRef, isNearViewport } = useNearViewport<HTMLDivElement>();
@@ -27,39 +38,43 @@ const MemoCommentListView: React.FC = () => {
}
return (
- <div ref={viewportRef} className="border border-t-0 border-border rounded-b-lg px-4 pt-2 pb-3 flex flex-col gap-1">
- <div className="flex items-center justify-between mb-1">
- <span className="text-xs text-muted-foreground">Comments{commentAmount > 1 ? ` (${commentAmount})` : ""}</span>
- <Link
- to={`/${memo.name}#${MEMO_COMMENTS_ANCHOR_ID}`}
- state={createMemoNavigationState(parentPage)}
- className="flex items-center gap-0.5 text-xs text-muted-foreground/80 hover:underline underline-offset-2 transition-colors"
- >
- View all
- <ArrowUpRightIcon className="w-3 h-3" />
- </Link>
- </div>
- {displayedComments.map((comment) => {
- const uid = extractMemoIdFromName(comment.name);
- const creator = commentCreators?.get(comment.creator);
- return (
- <Link
- key={comment.name}
- to={`/${memo.name}#${uid}`}
- state={createMemoNavigationState(parentPage)}
- viewTransition
- className="rounded-md bg-muted/40 px-2 py-1 transition-colors hover:bg-muted/60"
- >
- <MemoPreview
- content={comment.snippet || comment.content}
- attachments={comment.attachments}
- creator={creator}
- showCreator
- truncate
- />
+ <div ref={viewportRef} className="rounded-b-lg border border-t-0 border-border/70 px-4 pb-2 pt-1.5">
+ <MetadataSection
+ title={t("memo.comment.self")}
+ count={commentAmount}
+ action={
+ <Link to={`/${memo.name}#${MEMO_COMMENTS_ANCHOR_ID}`} state={createMemoNavigationState(parentPage)} className={VIEW_ALL_CLASSES}>
+ {t("common.view-all")}
+ <ArrowUpRightIcon className="size-3" strokeWidth={1.8} />
</Link>
- );
- })}
+ }
+ >
+ {displayedComments.map((comment) => {
+ const uid = extractMemoIdFromName(comment.name);
+ const creator = commentCreators?.get(comment.creator);
+ return (
+ <Link
+ key={comment.name}
+ to={`/${memo.name}#${uid}`}
+ state={createMemoNavigationState(parentPage)}
+ viewTransition
+ className={METADATA_ROW_CLASSES}
+ >
+ <span className={METADATA_ROW_SLOT_CLASSES} aria-hidden="true">
+ <UserAvatar className="size-4 rounded-[4px]" avatarUrl={creator?.avatarUrl} />
+ </span>
+ <MemoPreview
+ className="min-w-0 flex-1"
+ content={comment.snippet || comment.content}
+ attachments={comment.attachments}
+ creator={creator}
+ showCreator
+ truncate
+ />
+ </Link>
+ );
+ })}
+ </MetadataSection>
</div>
);
};
diff --git a/web/src/components/MemoView/components/MemoHeader.tsx b/web/src/components/MemoView/components/MemoHeader.tsx
index 7cbf3f295..946c3fcfb 100644
--- a/web/src/components/MemoView/components/MemoHeader.tsx
+++ b/web/src/components/MemoView/components/MemoHeader.tsx
@@ -1,8 +1,9 @@
import { BookmarkIcon } from "lucide-react";
-import { useCallback, useState } from "react";
+import { useCallback } from "react";
import { Link } from "react-router-dom";
import RelativeTime from "@/components/RelativeTime";
-import { buttonVariants } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { useNewMemo } from "@/contexts/NewMemoContext";
import useNavigateTo from "@/hooks/useNavigateTo";
@@ -16,6 +17,7 @@ import MemoActionMenu from "../../MemoActionMenu";
import { ReactionSelector } from "../../MemoReactionListView";
import UserAvatar from "../../UserAvatar";
import VisibilityIcon from "../../VisibilityIcon";
+import { MEMO_TIME_CONTROL_CLASSES } from "../constants";
import { useMemoActions } from "../hooks";
import { useMemoViewContext, useMemoViewDerived } from "../MemoViewContext";
import { createMemoNavigationState } from "../navigation";
@@ -27,7 +29,6 @@ const MEMO_HEADER_ACTION_CLASSES = cn(buttonVariants({ variant: "quiet", size: "
const MemoHeader: React.FC<MemoHeaderProps> = ({ timeDisplay = "relative", showCreator, showVisibility, showPinned, showSpace }) => {
const t = useTranslate();
- const [reactionSelectorOpen, setReactionSelectorOpen] = useState(false);
const { memo, creator, currentUser, parentPage, isArchived, readonly, openEditor } = useMemoViewContext();
const { createTime, updateTime, displayTime: memoDisplayTime, isDisplayingUpdatedTime, relativeTimeFormat } = useMemoViewDerived();
@@ -65,24 +66,17 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ timeDisplay = "relative", showC
const spaceMetadata = showSpace && memo.space ? <MemoSpaceBadge spaceName={memo.space} /> : null;
return (
- <div className="flex w-full items-center justify-between gap-2">
+ // A fixed 24px row, the height of its action squares, so the card's top edge never
+ // moves with what the header happens to show.
+ <div className="flex h-6 w-full items-center justify-between gap-2">
<div className="flex min-w-0 flex-1 items-center gap-2">
- {showCreator && creator ? (
- <CreatorDisplay
- creator={creator}
- displayTime={displayTime}
- timeTooltip={timeTooltip}
- trailingMetadata={spaceMetadata}
- onGotoDetail={handleGotoMemoDetailPage}
- />
- ) : (
- <div data-slot="memo-header-meta" className="flex min-w-0 items-center gap-1.5">
- <TimeDisplay displayTime={displayTime} timeTooltip={timeTooltip} onGotoDetail={handleGotoMemoDetailPage} />
- {spaceMetadata}
- </div>
- )}
+ <div data-slot="memo-header-meta" className="flex min-w-0 items-center gap-1.5">
+ {showCreator && creator && <CreatorDisplay creator={creator} />}
+ <TimeDisplay displayTime={displayTime} timeTooltip={timeTooltip} onGotoDetail={handleGotoMemoDetailPage} />
+ {spaceMetadata}
+ </div>
{memo.name === newMemoName && (
- <span className="ml-2 shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs font-medium leading-none text-primary">
+ <span className="shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-2xs font-medium leading-none text-primary">
{t("memo.new-badge")}
</span>
)}
@@ -90,17 +84,10 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ timeDisplay = "relative", showC
<div data-slot="memo-header-actions" className="flex shrink-0 select-none flex-row items-center justify-end gap-1">
{currentUser && !isArchived && (
- <ReactionSelector
- className={cn(
- MEMO_HEADER_ACTION_CLASSES,
- // The chip's own round bordered look gives way to the header's quiet square.
- "border-none hover:opacity-100",
- reactionSelectorOpen && "sm:flex!",
- "flex sm:hidden sm:group-hover:flex sm:group-focus-within:flex",
- )}
- memo={memo}
- onOpenChange={setReactionSelectorOpen}
- />
+ // On desktop the picker's trigger shows only while the card is engaged or the picker is open.
+ <span className="flex sm:hidden sm:group-hover:flex sm:group-focus-within:flex sm:has-[[data-popup-open]]:flex">
+ <ReactionSelector memo={memo} trigger={<Button variant="quiet" size="icon-sm" />} />
+ </span>
)}
{showVisibility && memo.visibility !== Visibility.PRIVATE && (
@@ -136,41 +123,30 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ timeDisplay = "relative", showC
);
};
-interface CreatorDisplayProps {
- creator: User;
- displayTime: React.ReactNode;
- timeTooltip: TimeTooltipContent;
- trailingMetadata?: React.ReactNode;
- onGotoDetail: () => void;
-}
-
-const CreatorDisplay: React.FC<CreatorDisplayProps> = ({ creator, displayTime, timeTooltip, trailingMetadata, onGotoDetail }) => (
- <div className="flex min-w-0 items-center">
- <Link className="w-auto hover:opacity-80 rounded-md transition-colors" to={`/u/${encodeURIComponent(creator.username)}`} viewTransition>
- <UserAvatar className="mr-2 shrink-0" avatarUrl={creator.avatarUrl} />
+/**
+ * The author on one line with the time: a 20px avatar in a 20px slot, then the name in
+ * medium 13px foreground ink. It is the identity, so it carries the weight; the time after
+ * it is muted.
+ */
+const CreatorDisplay: React.FC<{ creator: User }> = ({ creator }) => (
+ <>
+ <Link
+ className={cn(
+ "flex min-w-0 items-center gap-1.5 rounded-sm text-ui font-medium text-foreground transition-colors hover:text-foreground/80",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+ )}
+ to={`/u/${encodeURIComponent(creator.username)}`}
+ viewTransition
+ >
+ <span className="flex size-5 shrink-0 items-center justify-center">
+ <UserAvatar className="size-5 rounded-[5px]" avatarUrl={creator.avatarUrl} />
+ </span>
+ <span className="truncate">{creator.displayName || creator.username}</span>
</Link>
- <div className="flex min-w-0 flex-col items-start justify-center">
- <Link
- className="block leading-tight hover:opacity-80 rounded-md transition-colors truncate text-muted-foreground"
- to={`/u/${encodeURIComponent(creator.username)}`}
- viewTransition
- >
- {creator.displayName || creator.username}
- </Link>
- <div data-slot="memo-header-meta" className="flex min-w-0 items-center gap-1.5">
- <TimeTooltip content={timeTooltip}>
- <button
- type="button"
- className="w-auto -mt-0.5 border-0 bg-transparent p-0 text-xs leading-tight text-muted-foreground select-none cursor-pointer hover:opacity-80 transition-colors text-left"
- onClick={onGotoDetail}
- >
- {displayTime}
- </button>
- </TimeTooltip>
- {trailingMetadata}
- </div>
- </div>
- </div>
+ <span aria-hidden="true" className="text-muted-foreground/40">
+ ·
+ </span>
+ </>
);
interface TimeTooltipContent {
@@ -196,11 +172,7 @@ interface TimeDisplayProps {
const TimeDisplay: React.FC<TimeDisplayProps> = ({ displayTime, timeTooltip, onGotoDetail }) => (
<TimeTooltip content={timeTooltip}>
- <button
- type="button"
- className="w-auto border-0 bg-transparent p-0 text-sm leading-tight text-muted-foreground select-none cursor-pointer hover:text-foreground transition-colors text-left"
- onClick={onGotoDetail}
- >
+ <button type="button" className={MEMO_TIME_CONTROL_CLASSES} onClick={onGotoDetail}>
{displayTime}
</button>
</TimeTooltip>
diff --git a/web/src/components/MemoView/components/MemoSnippetLink.tsx b/web/src/components/MemoView/components/MemoSnippetLink.tsx
deleted file mode 100644
index e1002a017..000000000
--- a/web/src/components/MemoView/components/MemoSnippetLink.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Link } from "react-router-dom";
-import { extractMemoIdFromName } from "@/lib/resource-names";
-import { cn } from "@/lib/utils";
-
-interface MemoSnippetLinkProps {
- name: string;
- snippet: string;
- to: string;
- state?: object;
- className?: string;
-}
-
-const MemoSnippetLink = ({ name, snippet, to, state, className }: MemoSnippetLinkProps) => {
- const memoId = extractMemoIdFromName(name);
-
- return (
- <Link
- className={cn(
- "flex items-center gap-1 px-1 py-1 rounded text-xs text-muted-foreground hover:text-foreground hover:bg-accent/20 transition-colors group",
- className,
- )}
- to={to}
- viewTransition
- state={state}
- >
- <span className="text-[8px] font-mono px-1 py-0.5 rounded border border-border bg-muted/40 group-hover:bg-accent/30 transition-colors shrink-0">
- {memoId.slice(0, 6)}
- </span>
- <span className="truncate">{snippet || <span className="italic opacity-60">No content</span>}</span>
- </Link>
- );
-};
-
-export default MemoSnippetLink;
diff --git a/web/src/components/MemoView/constants.ts b/web/src/components/MemoView/constants.ts
index b16cce5f7..797fe506e 100644
--- a/web/src/components/MemoView/constants.ts
+++ b/web/src/components/MemoView/constants.ts
@@ -1,4 +1,16 @@
+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
+import { cn } from "@/lib/utils";
+
export const MEMO_CARD_BASE_CLASSES =
- "relative group flex flex-col justify-start items-start bg-card w-full px-4 py-3 mb-2 gap-2 text-card-foreground rounded-lg border border-border transition-colors";
+ "relative group flex flex-col justify-start items-start bg-card w-full px-4 py-3 mb-2 gap-2 text-card-foreground rounded-lg border border-border/70 transition-colors";
+
+/**
+ * A memo's timestamp as a control, on the card header and in the editor: one line of muted
+ * 13px text with no box, darkening on hover like every quiet label.
+ */
+export const MEMO_TIME_CONTROL_CLASSES = cn(
+ "min-w-0 truncate rounded-sm text-start text-ui text-muted-foreground transition-colors select-none hover:text-foreground",
+ FOCUS_VISIBLE_OUTLINE_CLASSES,
+);
export const RELATIVE_TIME_THRESHOLD_MS = 1000 * 60 * 60 * 24;
diff --git a/web/src/components/VisibilityIcon.tsx b/web/src/components/VisibilityIcon.tsx
index b9910cd2c..aa387ef9a 100644
--- a/web/src/components/VisibilityIcon.tsx
+++ b/web/src/components/VisibilityIcon.tsx
@@ -15,7 +15,7 @@ const VisibilityIcon = (props: Props) => {
return null;
}
- return <VIcon className={cn("w-4 h-auto text-muted-foreground", className)} />;
+ return <VIcon className={cn("size-4 text-muted-foreground", className)} strokeWidth={1.8} />;
};
export default VisibilityIcon;
diff --git a/web/src/locales/az.json b/web/src/locales/az.json
index 22530c2ce..7cac6b920 100644
--- a/web/src/locales/az.json
+++ b/web/src/locales/az.json
@@ -255,6 +255,7 @@
"username": "İstifadəçi adı",
"version": "Versiya",
"visibility": "Görünürlük",
+ "view-all": "Hamısına bax",
"views": "Görünüşlər",
"yourself": "Özünüz"
},
diff --git a/web/src/locales/en.json b/web/src/locales/en.json
index 36eb95ac0..aa2d1ec95 100644
--- a/web/src/locales/en.json
+++ b/web/src/locales/en.json
@@ -255,6 +255,7 @@
"username": "Username",
"version": "Version",
"visibility": "Visibility",
+ "view-all": "View all",
"views": "Views",
"yourself": "Yourself"
},
diff --git a/web/tests/location-display-view.test.tsx b/web/tests/location-display-view.test.tsx
index d932f621f..816c94c3e 100644
--- a/web/tests/location-display-view.test.tsx
+++ b/web/tests/location-display-view.test.tsx
@@ -39,7 +39,7 @@ describe("LocationDisplayView", () => {
const trigger = screen.getByRole("button", { name: new RegExp(placeholder) });
const visibleAddress = screen.getByText(placeholder);
expect(trigger).toHaveAttribute("title", placeholder);
- expect(trigger).toHaveClass("max-w-full", "min-w-0");
+ expect(trigger).toHaveClass("w-full", "min-w-0");
expect(visibleAddress).toHaveClass("min-w-0", "truncate");
});
});
diff --git a/web/tests/memo-body-compact.test.tsx b/web/tests/memo-body-compact.test.tsx
index 76ef28c8e..6c75ff7d4 100644
--- a/web/tests/memo-body-compact.test.tsx
+++ b/web/tests/memo-body-compact.test.tsx
@@ -29,9 +29,8 @@ vi.mock("@/components/MemoContent/MemoMarkdownRenderer", () => ({
}));
vi.mock("@/components/MemoMetadata", () => ({
- AttachmentListView: () => null,
- LocationDisplayView: () => null,
- RelationListView: () => null,
+ AttachmentGallery: () => null,
+ MemoMetadataRows: () => null,
}));
vi.mock("@/components/MemoReactionListView", () => ({
@@ -111,7 +110,7 @@ describe("<MemoBody /> compact body clamp", () => {
render(<MemoBody compact={false} />);
const revealButton = screen.getByRole("button", { name: "memo.click-to-show-sensitive-content" });
- expect(revealButton).toHaveClass("cursor-pointer");
+ expect(revealButton.className).not.toMatch(/ring-/);
fireEvent.click(revealButton);
expect(mockState.toggleBlurVisibility).toHaveBeenCalledOnce();
diff --git a/web/tests/memo-header-navigation.test.tsx b/web/tests/memo-header-navigation.test.tsx
index e0b83f00c..3f37985ae 100644
--- a/web/tests/memo-header-navigation.test.tsx
+++ b/web/tests/memo-header-navigation.test.tsx
@@ -1,4 +1,5 @@
import { fireEvent, render, screen } from "@testing-library/react";
+import React from "react";
import { MemoryRouter, useLocation } from "react-router-dom";
import { beforeEach, describe, expect, it, vi } from "vitest";
import MemoHeader from "@/components/MemoView/components/MemoHeader";
@@ -22,11 +23,9 @@ vi.mock("@/components/MemoActionMenu", () => ({
}));
vi.mock("@/components/MemoReactionListView", () => ({
- ReactionSelector: ({ className }: { className?: string }) => (
- <button type="button" aria-label="add-reaction" className={className}>
- Add reaction
- </button>
- ),
+ // The header supplies the picker's trigger; the mock renders it with the picker's label.
+ ReactionSelector: ({ trigger }: { trigger: React.ReactElement<{ "aria-label"?: string }> }) =>
+ React.cloneElement(trigger, { "aria-label": "add-reaction" }, "Add reaction"),
}));
vi.mock("@/components/UserAvatar", () => ({
@@ -108,20 +107,11 @@ describe("MemoHeader navigation", () => {
const actionRail = actions.closest('[data-slot="memo-header-actions"]');
expect(actionRail).toHaveClass("items-center", "gap-1");
- expect(reaction).toHaveClass("sm:group-focus-within:flex");
- // The reaction chip gives up its round bordered look for the header's quiet square.
- expect(reaction).toHaveClass(
- "size-6",
- "rounded-md",
- "border-none",
- "text-muted-foreground/70",
- "hover:bg-muted/60",
- "hover:text-foreground",
- "focus-visible:outline-2",
- "data-popup-open:bg-accent",
- );
- expect(reaction).not.toHaveClass("rounded-full");
- expect(reaction.className).not.toMatch(/ring-/);
+ // The header shows the picker only while the card is engaged or the picker is open, and its
+ // trigger is the same 24px quiet square as the other header actions.
+ expect(reaction.parentElement).toHaveClass("sm:group-focus-within:flex", "sm:has-[[data-popup-open]]:flex");
+ expect(reaction).toHaveClass("size-6", "rounded-md", "text-muted-foreground/70");
+ expect(reaction.className).not.toMatch(/border-none|rounded-full|ring-/);
});
it.each([false, true])("uses a keyboard-operable timestamp and preserves origin when showCreator=%s", (showCreator) => {
diff --git a/web/tests/reaction-selector.test.tsx b/web/tests/reaction-selector.test.tsx
index d6b116332..8251f4c37 100644
--- a/web/tests/reaction-selector.test.tsx
+++ b/web/tests/reaction-selector.test.tsx
@@ -25,6 +25,7 @@ describe("ReactionSelector", () => {
render(<ReactionSelector memo={memo} />);
const trigger = screen.getByRole("button", { name: "setting.memo.add-reaction" });
+ // The default trigger is a round quiet 28px face, closing the strip of reaction pills it follows.
expect(trigger).toHaveClass("size-7", "rounded-full", "focus-visible:outline-2");
expect(trigger.className).not.toMatch(/ring-/);
expect(trigger).toHaveAttribute("aria-expanded", "false");