diff --git a/web/src/components/Placeholder/Placeholder.css b/web/src/components/Placeholder/Placeholder.css deleted file mode 100644 index 4b55c39b..00000000 --- a/web/src/components/Placeholder/Placeholder.css +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Animations for piece components. - * - * Keyframes are wrapped in a prefers-reduced-motion guard so users who opt - * out of motion see static ASCII art. - */ - -@media (prefers-reduced-motion: no-preference) { - .placeholder-perched-finch-bob { - animation: placeholder-gentle-bob 3.4s ease-in-out infinite; - } - - .placeholder-nesting-sparrow-breathe { - animation: placeholder-soft-breathe 4s ease-in-out infinite; - } - - .placeholder-hovering-swift-flutter { - animation: placeholder-quick-flutter 0.75s ease-in-out infinite; - } - - .placeholder-busy-hummingbird-hover { - animation: placeholder-humming-hover 0.55s ease-in-out infinite; - } - - .placeholder-searching-owl-look { - animation: placeholder-watchful-look 4.2s ease-in-out infinite; - } - - .placeholder-curious-crow-tilt { - animation: placeholder-curious-tilt 3.8s ease-in-out infinite; - } - - .placeholder-wayward-gull-drift { - animation: placeholder-slow-drift 3.2s ease-in-out infinite; - } - - .placeholder-vanished-perch-sway { - animation: placeholder-light-sway 4.6s ease-in-out infinite; - } -} - -@keyframes placeholder-gentle-bob { - 0%, - 100% { - transform: translateY(0); - } - 50% { - transform: translateY(-4px); - } -} - -@keyframes placeholder-soft-breathe { - 0%, - 100% { - transform: scale(1); - } - 50% { - transform: scale(1.02); - } -} - -@keyframes placeholder-quick-flutter { - 0%, - 100% { - transform: translate(0, 0); - } - 50% { - transform: translate(2px, -1px); - } -} - -@keyframes placeholder-humming-hover { - 0%, - 100% { - transform: translate(0, 0); - } - 50% { - transform: translate(-1px, -2px); - } -} - -@keyframes placeholder-watchful-look { - 0%, - 100% { - transform: translateX(0); - } - 50% { - transform: translateX(2px); - } -} - -@keyframes placeholder-curious-tilt { - 0%, - 100% { - transform: rotate(0deg); - } - 50% { - transform: rotate(-1deg); - } -} - -@keyframes placeholder-slow-drift { - 0%, - 100% { - transform: translateX(0); - } - 50% { - transform: translateX(4px); - } -} - -@keyframes placeholder-light-sway { - 0%, - 100% { - transform: translateX(0); - } - 50% { - transform: translateX(-2px); - } -} diff --git a/web/src/components/Placeholder/ascii-pool.ts b/web/src/components/Placeholder/ascii-pool.ts deleted file mode 100644 index 032c2481..00000000 --- a/web/src/components/Placeholder/ascii-pool.ts +++ /dev/null @@ -1,77 +0,0 @@ -import type { ComponentType } from "react"; -import BusyHummingbird from "./pieces/BusyHummingbird"; -import CuriousCrow from "./pieces/CuriousCrow"; -import HoveringSwift from "./pieces/HoveringSwift"; -import NestingSparrow from "./pieces/NestingSparrow"; -import PerchedFinch from "./pieces/PerchedFinch"; -import SearchingOwl from "./pieces/SearchingOwl"; -import VanishedPerch from "./pieces/VanishedPerch"; -import WaywardGull from "./pieces/WaywardGull"; - -export type PlaceholderVariant = "empty" | "loading" | "noResults" | "notFound"; - -export interface AsciiPiece { - id: string; - variant: PlaceholderVariant; - credit: string; - Component: ComponentType; -} - -export const ASCII_POOL: AsciiPiece[] = [ - { - id: "memos-perched-finch", - variant: "empty", - credit: "Memos original ASCII art", - Component: PerchedFinch, - }, - { - id: "memos-nesting-sparrow", - variant: "empty", - credit: "Memos original ASCII art", - Component: NestingSparrow, - }, - { - id: "memos-hovering-swift", - variant: "loading", - credit: "Memos original ASCII art", - Component: HoveringSwift, - }, - { - id: "memos-busy-hummingbird", - variant: "loading", - credit: "Memos original ASCII art", - Component: BusyHummingbird, - }, - { - id: "memos-searching-owl", - variant: "noResults", - credit: "Memos original ASCII art", - Component: SearchingOwl, - }, - { - id: "memos-curious-crow", - variant: "noResults", - credit: "Memos original ASCII art", - Component: CuriousCrow, - }, - { - id: "memos-wayward-gull", - variant: "notFound", - credit: "Memos original ASCII art", - Component: WaywardGull, - }, - { - id: "memos-vanished-perch", - variant: "notFound", - credit: "Memos original ASCII art", - Component: VanishedPerch, - }, -]; - -export function pickPiece(variant: PlaceholderVariant): AsciiPiece { - const matches = ASCII_POOL.filter((p) => p.variant === variant); - if (matches.length === 0) { - throw new Error(`No ASCII piece registered for variant "${variant}"`); - } - return matches[Math.floor(Math.random() * matches.length)]; -} diff --git a/web/src/components/Placeholder/index.tsx b/web/src/components/Placeholder/index.tsx index 2f0a2f5f..5c11483e 100644 --- a/web/src/components/Placeholder/index.tsx +++ b/web/src/components/Placeholder/index.tsx @@ -1,8 +1,7 @@ -import { type ReactNode, useMemo } from "react"; +import { type ReactNode, useState } from "react"; import { cn } from "@/lib/utils"; -import { type PlaceholderVariant, pickPiece } from "./ascii-pool"; -import { DEFAULT_MESSAGES } from "./messages"; -import "./Placeholder.css"; +import { DEFAULT_MESSAGES, type PlaceholderVariant } from "./messages"; +import { pickTileSprite } from "./tileSprites"; interface PlaceholderProps { variant: PlaceholderVariant; @@ -11,11 +10,17 @@ interface PlaceholderProps { className?: string; } +const TILE_SIZE = 32; +const DISPLAY_SCALE = 2; +const DISPLAY_SIZE = TILE_SIZE * DISPLAY_SCALE; + const Placeholder = ({ variant, message, children, className }: PlaceholderProps) => { - const piece = useMemo(() => pickPiece(variant), [variant]); - const PieceComponent = piece.Component; + const [sprite] = useState(pickTileSprite); const resolvedMessage = message ?? DEFAULT_MESSAGES[variant]; const isLoading = variant === "loading"; + const stripWidth = sprite.frameWidth * sprite.frames; + const displayStripWidth = stripWidth * DISPLAY_SCALE; + const displayStripHeight = sprite.frameHeight * DISPLAY_SCALE; return (
- + +

{resolvedMessage}

{children &&
{children}
}
diff --git a/web/src/components/Placeholder/messages.ts b/web/src/components/Placeholder/messages.ts index 7c3d451f..46ccb6f1 100644 --- a/web/src/components/Placeholder/messages.ts +++ b/web/src/components/Placeholder/messages.ts @@ -1,10 +1,10 @@ -import type { PlaceholderVariant } from "./ascii-pool"; - // Future i18n: swap these for `t("placeholder.")` lookups via // react-i18next without touching the component. -export const DEFAULT_MESSAGES: Record = { +export const DEFAULT_MESSAGES = { empty: "No memos yet", loading: "Loading…", noResults: "Nothing matches that search", notFound: "This page flew the coop", -}; +} as const; + +export type PlaceholderVariant = keyof typeof DEFAULT_MESSAGES; diff --git a/web/src/components/Placeholder/pieces/BusyHummingbird.tsx b/web/src/components/Placeholder/pieces/BusyHummingbird.tsx deleted file mode 100644 index 7ff75479..00000000 --- a/web/src/components/Placeholder/pieces/BusyHummingbird.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const BusyHummingbird = () => ( - -); - -export default BusyHummingbird; diff --git a/web/src/components/Placeholder/pieces/CuriousCrow.tsx b/web/src/components/Placeholder/pieces/CuriousCrow.tsx deleted file mode 100644 index fa171e94..00000000 --- a/web/src/components/Placeholder/pieces/CuriousCrow.tsx +++ /dev/null @@ -1,15 +0,0 @@ -const CuriousCrow = () => ( - -); - -export default CuriousCrow; diff --git a/web/src/components/Placeholder/pieces/DESIGN.md b/web/src/components/Placeholder/pieces/DESIGN.md new file mode 100644 index 00000000..42b49f77 --- /dev/null +++ b/web/src/components/Placeholder/pieces/DESIGN.md @@ -0,0 +1,48 @@ +# Placeholder Bird Tilemaps + +These SVGs are pixel-art tile strips for the placeholder component. They should read as small game sprites first, not as decorative illustrations. + +## Canvas + +- Each frame is 32 by 32 pixels. +- A strip width is `32 * frameCount`; the height stays 32. +- The bird should occupy most of the frame. Use the full height when the animal shape supports it. +- Keep a transparent background. +- Use `shape-rendering="crispEdges"` and integer pixel coordinates. + +## Naming + +- Start with the animal name, for example `Owl` or `Falcon`. +- Add the animation name when needed, for example `OwlBlink` or `FalconIdle`. +- Do not name assets after UI states or empty-state scenarios. + +## Frame Count + +Frame count is not fixed. Choose it from the animal and animation: + +- short blink: usually 3-5 frames +- quiet idle: usually 4-6 frames +- hop or walk: usually 4-8 frames +- flying, diving, or large body motion: usually 6-10 frames + +Avoid padding an animation with duplicate frames just to hit a standard count. A frame should change the pose, expression, feather shape, or weight. + +## Shared Style + +- Use a strong readable silhouette at 1x. +- Prefer chunky pixel clusters over isolated noisy pixels. +- Use a limited palette with one dark outline, one or two body colors, one highlight color, and one accent. +- Keep eyes readable. At this scale, a 2 by 2 eye or a 1 pixel highlight is often better than a single dark pixel. +- Match visual weight between animals. Different species can have different proportions, but the on-screen size should feel comparable. + +## Animation + +- Make idle motion local: breathing, wing settling, ear feather movement, tail flicks, head turns, and blinking. +- Avoid moving the entire sprite unless the action is hop, fly, recoil, or collapse. +- Preserve the animal identity in every frame. A blink frame should still clearly read as the same bird. +- Keep the first frame a stable readable pose because it is what appears in reduced-motion rendering. + +## Current Assets + +- `OwlBlink.svg`: five-frame blink/idle strip with breathing wings, blink, and ear-feather settle. +- `FalconIdle.svg`: four-frame idle strip with breathing, blink, alert head shift, and tail flick. diff --git a/web/src/components/Placeholder/pieces/FalconIdle.svg b/web/src/components/Placeholder/pieces/FalconIdle.svg new file mode 100644 index 00000000..b10f015d --- /dev/null +++ b/web/src/components/Placeholder/pieces/FalconIdle.svg @@ -0,0 +1,122 @@ + + Falcon idle pixel tileset + A four-frame 32 by 32 pixel falcon idle animation strip. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/components/Placeholder/pieces/HoveringSwift.tsx b/web/src/components/Placeholder/pieces/HoveringSwift.tsx deleted file mode 100644 index cc03d79a..00000000 --- a/web/src/components/Placeholder/pieces/HoveringSwift.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const HoveringSwift = () => ( - -); - -export default HoveringSwift; diff --git a/web/src/components/Placeholder/pieces/NestingSparrow.tsx b/web/src/components/Placeholder/pieces/NestingSparrow.tsx deleted file mode 100644 index 161ea505..00000000 --- a/web/src/components/Placeholder/pieces/NestingSparrow.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const NestingSparrow = () => ( - -); - -export default NestingSparrow; diff --git a/web/src/components/Placeholder/pieces/OwlBlink.svg b/web/src/components/Placeholder/pieces/OwlBlink.svg new file mode 100644 index 00000000..9633f07a --- /dev/null +++ b/web/src/components/Placeholder/pieces/OwlBlink.svg @@ -0,0 +1,84 @@ + + Owl blink pixel tileset + A five-frame 32 by 32 pixel owl idle and blink animation strip. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/components/Placeholder/pieces/PerchedFinch.tsx b/web/src/components/Placeholder/pieces/PerchedFinch.tsx deleted file mode 100644 index f84984a1..00000000 --- a/web/src/components/Placeholder/pieces/PerchedFinch.tsx +++ /dev/null @@ -1,15 +0,0 @@ -const PerchedFinch = () => ( - -); - -export default PerchedFinch; diff --git a/web/src/components/Placeholder/pieces/SearchingOwl.tsx b/web/src/components/Placeholder/pieces/SearchingOwl.tsx deleted file mode 100644 index 0876593b..00000000 --- a/web/src/components/Placeholder/pieces/SearchingOwl.tsx +++ /dev/null @@ -1,15 +0,0 @@ -const SearchingOwl = () => ( - -); - -export default SearchingOwl; diff --git a/web/src/components/Placeholder/pieces/VanishedPerch.tsx b/web/src/components/Placeholder/pieces/VanishedPerch.tsx deleted file mode 100644 index 2b7d80a6..00000000 --- a/web/src/components/Placeholder/pieces/VanishedPerch.tsx +++ /dev/null @@ -1,16 +0,0 @@ -const VanishedPerch = () => ( - -); - -export default VanishedPerch; diff --git a/web/src/components/Placeholder/pieces/WaywardGull.tsx b/web/src/components/Placeholder/pieces/WaywardGull.tsx deleted file mode 100644 index d39f7571..00000000 --- a/web/src/components/Placeholder/pieces/WaywardGull.tsx +++ /dev/null @@ -1,15 +0,0 @@ -const WaywardGull = () => ( - -); - -export default WaywardGull; diff --git a/web/src/components/Placeholder/tileSprites.ts b/web/src/components/Placeholder/tileSprites.ts new file mode 100644 index 00000000..8cce29fe --- /dev/null +++ b/web/src/components/Placeholder/tileSprites.ts @@ -0,0 +1,34 @@ +import FalconIdle from "./pieces/FalconIdle.svg?url"; +import OwlBlink from "./pieces/OwlBlink.svg?url"; + +export interface TileSprite { + name: string; + src: string; + frameWidth: number; + frameHeight: number; + frames: number; + duration: number; +} + +export const TILE_SPRITES: TileSprite[] = [ + { + name: "OwlBlink", + src: OwlBlink, + frameWidth: 32, + frameHeight: 32, + frames: 5, + duration: 1500, + }, + { + name: "FalconIdle", + src: FalconIdle, + frameWidth: 32, + frameHeight: 32, + frames: 4, + duration: 960, + }, +]; + +export function pickTileSprite(): TileSprite { + return TILE_SPRITES[Math.floor(Math.random() * TILE_SPRITES.length)]; +} diff --git a/web/tests/paged-memo-list.test.tsx b/web/tests/paged-memo-list.test.tsx new file mode 100644 index 00000000..d1e604e0 --- /dev/null +++ b/web/tests/paged-memo-list.test.tsx @@ -0,0 +1,49 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import PagedMemoList from "@/components/PagedMemoList"; + +vi.mock("@/hooks/useMemoQueries", () => ({ + useInfiniteMemos: () => ({ + data: { pages: [{ memos: [], nextPageToken: "" }] }, + fetchNextPage: vi.fn(async () => undefined), + hasNextPage: false, + isFetchingNextPage: false, + isLoading: false, + }), +})); + +vi.mock("@/contexts/MemoFilterContext", () => ({ + useMemoFilterContext: () => ({ filters: [] }), +})); + +vi.mock("@/utils/i18n", () => ({ + useTranslate: () => (key: string) => (key === "message.no-data" ? "No data found." : key), +})); + +vi.mock("@/components/MemoContent/MentionResolutionContext", () => ({ + MentionResolutionProvider: ({ children }: { children: React.ReactNode }) => <>{children}, +})); + +vi.mock("@/components/MemoFilters", () => ({ + default: () =>
, +})); + +vi.mock("@/components/MemoEditor", () => ({ + default: () =>
, +})); + +describe("", () => { + it("uses the tile sprite Placeholder for the empty state", () => { + const queryClient = new QueryClient(); + + render( + +
} /> + , + ); + + expect(screen.getByText("No data found.")).toBeInTheDocument(); + expect(screen.getByTestId("placeholder-sprite")).toBeInTheDocument(); + }); +}); diff --git a/web/tests/placeholder-component.test.tsx b/web/tests/placeholder-component.test.tsx index 2aa07d17..f7ecdb19 100644 --- a/web/tests/placeholder-component.test.tsx +++ b/web/tests/placeholder-component.test.tsx @@ -30,12 +30,27 @@ describe("", () => { expect(screen.queryByText(DEFAULT_MESSAGES.empty)).not.toBeInTheDocument(); }); - it("renders the ASCII art inside a
 with aria-hidden", () => {
+  it("renders a 32px sprite tileset at a crisp 2x display scale", () => {
     const { container } = render();
-    const pre = container.querySelector("pre");
-    expect(pre).not.toBeNull();
-    expect(pre).toHaveAttribute("aria-hidden", "true");
-    expect(pre!.textContent!.length).toBeGreaterThan(0);
+    const viewport = screen.getByTestId("placeholder-sprite");
+    const strip = viewport.firstElementChild;
+
+    expect(viewport).toHaveAttribute("aria-hidden", "true");
+    expect(viewport).toHaveStyle({
+      width: "64px",
+      height: "64px",
+      overflow: "hidden",
+    });
+    expect(strip).toHaveAttribute("src", expect.stringMatching(/(\.svg|data:image\/svg\+xml)/));
+    expect(strip).toHaveAttribute("width", expect.stringMatching(/^(128|160|192)$/));
+    expect(strip).toHaveAttribute("height", "32");
+    expect(["256px", "320px", "384px"]).toContain((strip as HTMLElement).style.width);
+    expect(["steps(4)", "steps(5)", "steps(6)"]).toContain((strip as HTMLElement).style.animationTimingFunction);
+    expect(strip).toHaveStyle({
+      height: "64px",
+      imageRendering: "pixelated",
+    });
+    expect(container.firstChild).toHaveClass("max-w-md");
   });
 
   it("does not render registry credit strings in the UI", () => {
diff --git a/web/tests/placeholder-pool.test.ts b/web/tests/placeholder-pool.test.ts
index ff2d9ab8..9944ce98 100644
--- a/web/tests/placeholder-pool.test.ts
+++ b/web/tests/placeholder-pool.test.ts
@@ -1,64 +1,33 @@
-import { render } from "@testing-library/react";
-import { createElement } from "react";
 import { describe, expect, it } from "vitest";
-import { ASCII_POOL, pickPiece, type PlaceholderVariant } from "@/components/Placeholder/ascii-pool";
-import { DEFAULT_MESSAGES } from "@/components/Placeholder/messages";
+import { TILE_SPRITES, pickTileSprite } from "@/components/Placeholder/tileSprites";
+import { DEFAULT_MESSAGES, type PlaceholderVariant } from "@/components/Placeholder/messages";
 
-const VARIANTS: PlaceholderVariant[] = ["empty", "loading", "noResults", "notFound"];
+describe("TILE_SPRITES integrity", () => {
+  it("registers 32px by 32px sprite strips with animation-specific frame counts", () => {
+    expect(TILE_SPRITES.map((sprite) => sprite.name)).toEqual(["OwlBlink", "FalconIdle"]);
+    expect(TILE_SPRITES.map((sprite) => [sprite.name, sprite.frames])).toEqual([
+      ["OwlBlink", 5],
+      ["FalconIdle", 4],
+    ]);
 
-describe("ASCII_POOL integrity", () => {
-  it("contains at least two pieces per variant", () => {
-    for (const variant of VARIANTS) {
-      const matches = ASCII_POOL.filter((p) => p.variant === variant);
-      expect(matches.length, `variant=${variant}`).toBeGreaterThanOrEqual(2);
+    for (const sprite of TILE_SPRITES) {
+      expect(sprite.name).toMatch(/^[A-Z][A-Za-z]+(Idle|Hop|Blink|Drift|Flutter|Hover)$/);
+      expect(sprite.frameWidth).toBe(32);
+      expect(sprite.frameHeight).toBe(32);
+      expect(sprite.frames).toBeGreaterThanOrEqual(2);
+      expect(sprite.src).toMatch(/(\.svg|data:image\/svg\+xml)/);
     }
   });
 
-  it("uses unique ids", () => {
-    const ids = ASCII_POOL.map((p) => p.id);
-    expect(new Set(ids).size).toBe(ids.length);
-  });
-
-  it("uses non-empty credits for every piece", () => {
-    for (const piece of ASCII_POOL) {
-      expect(piece.credit.trim().length, `piece=${piece.id}`).toBeGreaterThan(0);
-    }
-  });
-
-  it("uses original Memos credits for bundled pieces", () => {
-    for (const piece of ASCII_POOL) {
-      expect(piece.credit, `piece=${piece.id}`).toContain("Memos");
-      expect(piece.credit, `piece=${piece.id}`).not.toMatch(/jgs|Joan Stark/i);
-    }
-  });
-
-  it("registers renderable piece components", () => {
-    for (const piece of ASCII_POOL) {
-      const PieceComponent = piece.Component;
-      const { container, unmount } = render(createElement(PieceComponent));
-      const pre = container.querySelector("pre");
-
-      expect(pre, `piece=${piece.id}`).not.toBeNull();
-      expect(pre, `piece=${piece.id}`).toHaveAttribute("aria-hidden", "true");
-      expect(pre?.textContent?.trim().length, `piece=${piece.id}`).toBeGreaterThan(0);
-
-      unmount();
-    }
-  });
-});
-
-describe("pickPiece", () => {
-  it("returns a piece matching the requested variant", () => {
-    for (const variant of VARIANTS) {
-      const piece = pickPiece(variant);
-      expect(piece.variant).toBe(variant);
-    }
+  it("returns a registered tile sprite from the pool", () => {
+    const sprite = pickTileSprite();
+    expect(TILE_SPRITES).toContain(sprite);
   });
 });
 
 describe("DEFAULT_MESSAGES", () => {
   it("provides a non-empty message for every variant", () => {
-    for (const variant of VARIANTS) {
+    for (const variant of Object.keys(DEFAULT_MESSAGES) as PlaceholderVariant[]) {
       expect(DEFAULT_MESSAGES[variant], `variant=${variant}`).toBeTruthy();
       expect(DEFAULT_MESSAGES[variant].trim().length).toBeGreaterThan(0);
     }