Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(web): simplify mobile forum tag editor

Gusa2a477fd4c73
diff --git a/src/web/src/components/community/channels/post-tag-dialog.test.ts b/src/web/src/components/community/channels/post-tag-dialog.test.ts
index c18c4cced..823420c2d 100644
--- a/src/web/src/components/community/channels/post-tag-dialog.test.ts
+++ b/src/web/src/components/community/channels/post-tag-dialog.test.ts
@@ -191,7 +191,7 @@ describe("PostTagDialog responsive session", () => {
expect(onSave).not.toHaveBeenCalled()
})
- it.each(["implicit", "close", "cancel"])("discards a changed mobile session via %s dismissal", (dismissal) => {
+ it.each(["implicit", "close"])("discards a changed mobile session via %s dismissal", (dismissal) => {
mocks.breakpoint = "mobile"
const onSave = vi.fn()
const { renderer } = renderDialog({ current: ["existing"], onSave })
@@ -199,10 +199,8 @@ describe("PostTagDialog responsive session", () => {
act(() => tagButton(renderer.root, FORUM_ARCHIVE_TAG).props.onClick())
if (dismissal === "implicit") setOpen(renderer.root, false)
- else if (dismissal === "close") {
+ else {
act(() => renderer.root.findByProps({ "aria-label": "Close" }).props.onClick())
- } else {
- act(() => byTestId(renderer.root, tid.forumTagDialogCancel).props.onClick())
}
expect(onSave).not.toHaveBeenCalled()
@@ -355,28 +353,47 @@ describe("PostTagDialog responsive session", () => {
expect(button.findByType("span").props.className).toContain("truncate")
})
- it("uses compact mobile actions while preserving the desktop popover sizing", () => {
+ it("uses a lightweight mobile editor with touch-safe header actions", () => {
mocks.breakpoint = "mobile"
const rendered = renderDialog({ allTags: ["compact"] })
setOpen(rendered.renderer.root, true)
+ const surface = byTestId(rendered.renderer.root, tid.forumTagDialog)
+ expect(String(surface.props.className)).toContain("w-[calc(100%-2rem)]")
+ expect(surface.findByType("h2").children).toEqual(["Tags"])
+ expect(surface.findAllByType("span").some((node) => node.children.includes("Add"))).toBe(true)
+
+ const tagField = surface.findAllByType("div").find((node) => (
+ String(node.props.className).includes("flex-wrap")
+ ))
+ expect(String(tagField?.props.className)).not.toContain("border")
+ expect(String(tagField?.props.className)).not.toContain("ring")
+
const mobileChipClass = String(tagButton(rendered.renderer.root, "compact").props.className)
expect(mobileChipClass).not.toContain("min-h-11")
expect(mobileChipClass).not.toContain("min-w-11")
+ expect(mobileChipClass).toContain("focus-visible:ring-2")
+ expect(mobileChipClass).toContain("active:translate-y-px")
const close = rendered.renderer.root.findByProps({ "aria-label": "Close" })
- expect(close.props.size).toBe("icon-sm")
- expect(String(close.props.className)).not.toContain("size-11")
- for (const testid of [tid.forumTagDialogCancel, tid.forumTagDialogSave]) {
- const actionClass = String(byTestId(rendered.renderer.root, testid).props.className)
- expect(actionClass).toContain("px-4")
- expect(actionClass).not.toContain("h-11")
- }
- expect(String(input(rendered.renderer.root).props.className)).toContain("h-11")
+ expect(close.props.size).toBe("icon")
+ expect(close.props["data-testid"]).toBe(tid.forumTagDialogCancel)
+ expect(String(close.props.className)).toContain("size-11")
+ const save = byTestId(rendered.renderer.root, tid.forumTagDialogSave)
+ expect(save.props.variant).toBe("ghost")
+ expect(String(save.props.className)).toContain("h-11")
+ expect(String(save.props.className)).toContain("px-2")
+
+ const mobileInput = input(rendered.renderer.root)
+ expect(mobileInput.props["aria-label"]).toBe("Add a tag")
+ expect(mobileInput.props.autoFocus).toBe(true)
+ expect(String(mobileInput.props.className)).toContain("h-11")
+ expect(String(mobileInput.props.className)).toContain("border-0")
switchBreakpoint(rendered, "desktop")
const popover = rendered.renderer.root.findByType("section")
expect(popover.props.className).toBe("w-64 space-y-3 p-3")
expect(String(input(rendered.renderer.root).props.className)).toContain("h-8")
+ expect(input(rendered.renderer.root).props["aria-label"]).toBe("Add a tag")
expect(String(tagButton(rendered.renderer.root, "compact").props.className))
.not.toContain("min-h-11")
})
diff --git a/src/web/src/components/community/channels/post-tag-dialog.tsx b/src/web/src/components/community/channels/post-tag-dialog.tsx
index 954d6a276..80f776c97 100644
--- a/src/web/src/components/community/channels/post-tag-dialog.tsx
+++ b/src/web/src/components/community/channels/post-tag-dialog.tsx
@@ -1,5 +1,11 @@
"use client"
+/* Hallmark · component: tag editor · genre: modern-minimal · theme: DESIGN.md
+ * states: default · hover · focus · active · disabled · loading · error-retain · success-close
+ * contrast: pass (40–41) · responsive: pass (320 / 375 / 414 / 768)
+ * pre-emit critique: P5 H5 E4 S5 R5 V4
+ */
+
import {
useEffect,
useLayoutEffect,
@@ -52,19 +58,23 @@ function PostTagEditorBody({
onToggle,
onAddDraft,
}: TagEditorBodyProps) {
+ const atTagLimit = ordinaryTagCount >= MAX_FORUM_TAGS_PER_POST
+
return (
<div
data-testid={tid.forumTagDialogBody}
className={cn(
"space-y-3",
- mobile && "min-h-0 flex-1 overflow-y-auto thin-scrollbar px-4 py-3",
+ mobile && "min-h-0 flex-1 overflow-y-auto thin-scrollbar px-3 pt-1 pb-3",
)}
>
{!mobile && (
<p className="text-[11px] font-medium tracking-[0.12em] text-muted-foreground">TAGS</p>
)}
- <div className="flex flex-wrap items-center gap-1.5">
+ <div
+ className="flex flex-wrap items-center gap-1.5"
+ >
{chips.length === 0 ? (
<p className="text-xs text-muted-foreground">No tags yet</p>
) : chips.map((tag) => {
@@ -83,7 +93,7 @@ function PostTagEditorBody({
title={`#${tag}`}
style={tagColorStyle(tag)}
className={cn(
- "inline-flex max-w-full min-w-0 items-center rounded-lg px-2 py-1 text-xs transition-opacity disabled:cursor-not-allowed disabled:opacity-40",
+ "inline-flex max-w-full min-w-0 items-center rounded-lg px-2 py-1 text-xs outline-none transition-opacity active:translate-y-px focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-40",
tagColorClassName,
active ? "opacity-100 ring-1 ring-current/20" : "opacity-55 hover:opacity-80",
)}
@@ -94,23 +104,49 @@ function PostTagEditorBody({
</button>
)
})}
+
+ {mobile && (
+ <div className="relative min-w-0 basis-full">
+ <Input
+ ref={inputRef}
+ autoFocus
+ aria-label="Add a tag"
+ data-testid={tid.forumTagDialogInput}
+ value={draft}
+ onChange={(event) => onDraftChange(event.target.value.slice(0, MAX_FORUM_TAG_LENGTH))}
+ onKeyDown={onEnterSubmit(onAddDraft)}
+ maxLength={MAX_FORUM_TAG_LENGTH}
+ placeholder="Add a tag…"
+ className="h-11 border-0 bg-transparent px-1 pr-16 text-sm shadow-none focus-visible:border-transparent focus-visible:ring-0 disabled:bg-transparent dark:bg-transparent dark:disabled:bg-transparent"
+ disabled={busy || atTagLimit}
+ />
+ <span className="pointer-events-none absolute inset-y-0 right-1 flex items-center text-[11px] text-muted-foreground">
+ {busy ? "Saving…" : atTagLimit ? `${MAX_FORUM_TAGS_PER_POST} tags max` : "Add"}
+ </span>
+ </div>
+ )}
</div>
- <Input
- ref={inputRef}
- data-testid={tid.forumTagDialogInput}
- value={draft}
- onChange={(event) => onDraftChange(event.target.value.slice(0, MAX_FORUM_TAG_LENGTH))}
- onKeyDown={onEnterSubmit(onAddDraft)}
- maxLength={MAX_FORUM_TAG_LENGTH}
- placeholder="Add a tag…"
- className={cn("text-sm", mobile ? "h-11" : "h-8")}
- disabled={busy || ordinaryTagCount >= MAX_FORUM_TAGS_PER_POST}
- />
+ {!mobile && (
+ <>
+ <Input
+ ref={inputRef}
+ aria-label="Add a tag"
+ data-testid={tid.forumTagDialogInput}
+ value={draft}
+ onChange={(event) => onDraftChange(event.target.value.slice(0, MAX_FORUM_TAG_LENGTH))}
+ onKeyDown={onEnterSubmit(onAddDraft)}
+ maxLength={MAX_FORUM_TAG_LENGTH}
+ placeholder="Add a tag…"
+ className="h-8 text-sm"
+ disabled={busy || atTagLimit}
+ />
- <p className="text-right text-[11px] text-muted-foreground">
- {busy ? "Saving…" : mobile ? "↵ to add" : "↵ to add · saves on close"}
- </p>
+ <p className="text-right text-[11px] text-muted-foreground">
+ {busy ? "Saving…" : "↵ to add · saves on close"}
+ </p>
+ </>
+ )}
</div>
)
}
@@ -296,41 +332,29 @@ export function PostTagDialog({
showCloseButton={false}
data-testid={tid.forumTagDialog}
aria-label={`Edit tags for ${postName}`}
- className="flex max-h-[calc(100dvh-2rem-env(safe-area-inset-top)-env(safe-area-inset-bottom))] w-full flex-col gap-0 p-0"
+ className="flex max-h-[calc(100dvh-2rem-env(safe-area-inset-top)-env(safe-area-inset-bottom))] w-[calc(100%-2rem)] max-w-sm flex-col gap-0 rounded-2xl p-0"
onClick={(event) => event.stopPropagation()}
>
- <div className="flex min-w-0 shrink-0 items-center gap-2 border-b border-border/50 py-3 pr-2 pl-4">
- <DialogTitle className="min-w-0 flex-1 truncate text-sm font-semibold">
- Edit tags for {postName}
- </DialogTitle>
+ <div className="flex min-w-0 shrink-0 items-center gap-1 px-2 py-2">
<Button
type="button"
variant="ghost"
- size="icon-sm"
+ size="icon"
+ className="-my-2 size-11 transition-colors"
aria-label="Close"
- disabled={busy}
- onClick={discard}
- >
- <X aria-hidden="true" />
- </Button>
- </div>
-
- {body(true)}
-
- <div className="flex shrink-0 justify-end gap-2 border-t border-border/50 p-4">
- <Button
- type="button"
- variant="outline"
- className="px-4"
data-testid={tid.forumTagDialogCancel}
disabled={busy}
onClick={discard}
>
- Cancel
+ <X aria-hidden="true" />
</Button>
+ <DialogTitle className="min-w-0 flex-1 truncate text-sm font-medium">
+ Tags
+ </DialogTitle>
<Button
type="button"
- className="px-4"
+ variant="ghost"
+ className="-my-2 h-11 px-2 font-semibold transition-colors"
data-testid={tid.forumTagDialogSave}
disabled={busy}
onClick={() => void saveMobile()}
@@ -338,6 +362,8 @@ export function PostTagDialog({
{busy ? "Saving…" : "Save"}
</Button>
</div>
+
+ {body(true)}
</DialogContent>
</Dialog>
)