Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ logs/

# Local scratch (assistant-generated; not part of the project)
TODOS.md

# Claude Code local session artifacts
.claude/scheduled_tasks.*
.claude/settings.local.json
3 changes: 3 additions & 0 deletions apps/web/bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Process Tailwind CSS when the dev server bundles static assets.
[serve.static]
plugins = ["bun-plugin-tailwind"]
20 changes: 19 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,23 @@
"version": "0.1.0",
"private": true,
"type": "module",
"module": "src/index.ts"
"module": "src/index.ts",
"scripts": {
"dev": "bun run --watch src/index.ts",
"start": "bun run src/index.ts"
},
"dependencies": {
"@floating-ui/react": "^0.27.19",
"@tanstack/react-router": "^1.170.16",
"lucide-react": "^1.21.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"zustand": "^5.0.14"
},
"devDependencies": {
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"bun-plugin-tailwind": "^0.1.2",
"tailwindcss": "^4.3.1"
}
}
18 changes: 18 additions & 0 deletions apps/web/src/assets.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Importing an image asset yields its served URL (Bun's bundler resolves it to
* a content-addressed path).
*/
declare module "*.gif" {
const src: string;
export default src;
}

declare module "*.png" {
const src: string;
export default src;
}

declare module "*.svg" {
const src: string;
export default src;
}
Binary file added apps/web/src/assets/counters/0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/6.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/7.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/8.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/src/assets/counters/9.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions apps/web/src/components/counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import d0 from "../assets/counters/0.gif";
import d1 from "../assets/counters/1.gif";
import d2 from "../assets/counters/2.gif";
import d3 from "../assets/counters/3.gif";
import d4 from "../assets/counters/4.gif";
import d5 from "../assets/counters/5.gif";
import d6 from "../assets/counters/6.gif";
import d7 from "../assets/counters/7.gif";
import d8 from "../assets/counters/8.gif";
import d9 from "../assets/counters/9.gif";

/** Digit glyph GIFs indexed 0-9. */
const DIGITS = [d0, d1, d2, d3, d4, d5, d6, d7, d8, d9] as const;

/**
* Odometer-style counter: renders each digit of `value` as its moe-counter GIF.
* Non-digit characters are rendered as plain text. `digitClass` controls the
* glyph height (default `h-12`).
*/
export function Counter({
value,
className,
digitClass = "h-12",
}: {
value: string;
className?: string;
digitClass?: string;
}) {
return (
<span
role="img"
aria-label={value}
className={`inline-flex items-end gap-px ${className ?? ""}`}
>
{[...value].map((ch, i) => {
const digit = DIGITS[ch.charCodeAt(0) - 48];
return digit ? (
<img key={i} src={digit} alt="" aria-hidden className={`${digitClass} w-auto`} />
) : (
<span key={i} aria-hidden>
{ch}
</span>
);
})}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
</span>
);
}
72 changes: 72 additions & 0 deletions apps/web/src/components/menu/dropdown-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { type ReactNode, useState } from "react";

import {
FloatingFocusManager,
FloatingPortal,
type Placement,
autoUpdate,
flip,
offset,
shift,
useClick,
useDismiss,
useFloating,
useInteractions,
} from "@floating-ui/react";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
import { ChevronDown } from "lucide-react";

/**
* Click-toggled dropdown menu (Danbooru-style "Size" / "Options" menus).
* The trigger is a labelled button; the panel renders `children`.
*/
export function DropdownMenu({
label,
children,
placement = "bottom-end",
}: {
label: ReactNode;
children: ReactNode;
placement?: Placement;
}) {
const [open, setOpen] = useState(false);

const { refs, floatingStyles, context } = useFloating({
open,
onOpenChange: setOpen,
placement,
middleware: [offset(4), flip({ padding: 8 }), shift({ padding: 8 })],
whileElementsMounted: autoUpdate,
});

const click = useClick(context);
const dismiss = useDismiss(context);
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);

return (
<>
<button
ref={refs.setReference}
{...getReferenceProps()}
type="button"
className="flex items-center gap-0.5 rounded px-1 hover:text-link"
>
{label}
<ChevronDown className="h-3 w-3" />
</button>
{open && (
<FloatingPortal>
<FloatingFocusManager context={context} modal={false}>
<div
ref={refs.setFloating}
style={floatingStyles}
{...getFloatingProps()}
className="z-50 min-w-40 rounded-md border border-line bg-surface p-2 text-[12px] shadow-lg"
>
{children}
</div>
</FloatingFocusManager>
</FloatingPortal>
)}
</>
);
}
90 changes: 90 additions & 0 deletions apps/web/src/components/popover/hover-popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { type ReactNode, useState } from "react";

import {
FloatingPortal,
type Placement,
autoUpdate,
flip,
offset,
safePolygon,
shift,
useDismiss,
useFloating,
useFocus,
useHover,
useInteractions,
useRole,
} from "@floating-ui/react";

interface HoverPopoverProps {
/** Trigger content (wrapped in an element that carries the floating ref). */
children: ReactNode;
/** Renders the floating content; only called while open. */
render: () => ReactNode;
/**
* Interactive popovers (clickable content) keep open while the cursor travels
* toward them (safePolygon) and use a dialog role. Default true.
*/
interactive?: boolean;
placement?: Placement;
/** Class for the trigger wrapper (e.g. to make it a grid cell). */
className?: string;
}

/**
* Generic hover/focus popover built on Floating UI. Opens on pointer hover and
* keyboard focus, flips/shifts to stay in view, and dismisses on Escape or
* outside interaction. Content-agnostic — see docs/POPOVER.md.
*/
export function HoverPopover({
children,
render,
interactive = true,
placement = "top",
className,
}: HoverPopoverProps) {
const [open, setOpen] = useState(false);

const { refs, floatingStyles, context } = useFloating({
open,
onOpenChange: setOpen,
placement,
middleware: [offset(8), flip({ padding: 8 }), shift({ padding: 8 })],
whileElementsMounted: autoUpdate,
});

const hover = useHover(context, {
delay: { open: 150, close: 0 },
handleClose: interactive ? safePolygon() : null,
});
const focus = useFocus(context);
const dismiss = useDismiss(context);
const role = useRole(context, { role: interactive ? "dialog" : "tooltip" });

const { getReferenceProps, getFloatingProps } = useInteractions([
hover,
focus,
dismiss,
role,
]);

return (
<>
<span ref={refs.setReference} className={className} {...getReferenceProps()}>
{children}
</span>
{open && (
<FloatingPortal>
<div
ref={refs.setFloating}
style={floatingStyles}
className="z-50"
{...getFloatingProps()}
>
{render()}
</div>
</FloatingPortal>
)}
</>
);
}
27 changes: 27 additions & 0 deletions apps/web/src/components/popover/post-tags-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { CATEGORY_ORDER, TAG_TEXT_CLASS, groupByCategory } from "../../lib/tags";

/**
* Gallery-tile popover content: a post's tags grouped by category. Shown when
* hovering a thumbnail. Phase 0 takes the tags directly; Phase 1 fetches the
* post DTO via `usePostPreview(id)`.
*/
export function PostTagsCard({ postId, tags }: { postId: number; tags: string[] }) {
const grouped = groupByCategory(tags);

return (
<div className="w-60 rounded-md border border-line bg-surface p-3 text-[13px] shadow-lg">
<div className="mb-2 border-b border-line pb-1 font-bold">post #{postId}</div>
<div className="space-y-1.5">
{CATEGORY_ORDER.filter((c) => grouped.has(c)).map((category) => (
<ul key={category} className="flex flex-wrap gap-x-3 gap-y-0.5">
{grouped.get(category)?.map((name) => (
<li key={name}>
<span className={TAG_TEXT_CLASS[category]}>{name}</span>
</li>
))}
</ul>
))}
</div>
</div>
);
}
Loading