rmnr
DocsTourSlicesBest PracticeAgentsInstall

Command Palette

Search for a command to run...

New

Slice · AI prompt

Preview — media quick-look

Quick-look viewer for image/video/audio/pdf: zoomable stage, transport players, editor handoff — backend optional.

Resource detail View source
Copy this prompt into Claude / Codex / Cursor
media-viewer.prompt.mdmarkdown
# Install `media-viewer` — Preview — media quick-look

> Quick-look viewer for image/video/audio/pdf: zoomable stage, transport players, editor handoff — backend optional.

📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail   : https://resource.rahmanef.com/slices/media-viewer
🧠 JSON catalog   : https://resource.rahmanef.com/api/knowledge?slice=media-viewer
🔗 Source         : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/media-viewer

## 1. Install

```bash
npx rahman-resources add media-viewer
# alias: npx rr add media-viewer
```

The CLI copies `frontend/slices/media-viewer/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.

## 2. What it ships

- npm: `lucide-react`
- shadcn primitives: `button`, `badge`, `separator`, `tooltip`, `slider`

## 3. Wire it up

Stack: Next 16 + React 19 + Tailwind 4 + shadcn/ui. A quick-look media viewer (image/video/audio/pdf/text). Fully client-side; no backend required.

STEP 1 — Install. `npx rr add media-viewer`. Ensure `@/features/media-viewer` resolves in tsconfig paths and Tailwind scans the slice folder.

STEP 2 — Deps. npm: `lucide-react`. shadcn: `npx shadcn@latest add button badge separator tooltip slider`.

STEP 3 — Mount. `<MediaViewer />` with no payload shows the offline sample gallery. Pass a file to view it:
```tsx
"use client";
import { MediaViewer } from "@/features/media-viewer";
export default function Page() {
  return <div className="h-dvh"><MediaViewer payload={{ path: "/media/clip.mp4", name: "clip.mp4", kind: "video" }} /></div>;
}
```
Or register the `mediaViewerApp` descriptor in an appshell manifest for windowed hosts.

STEP 4 — Remote files (optional). Paths resolve through `configureMediaSource({ rawUrl })` — identity by default, so public/absolute URLs already work. Point rawUrl at your fs endpoint for private files.

STEP 5 — Editor handoff (optional). `configureMediaOpener((appId, title, size, payload) => …)` routes the "Open in Image/Video Editor" actions to your shell (no-op until set). Wire it to openWindow when running inside appshell with image-editor / reel-editor installed.

## Rules of engagement

- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice

The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.