Show on-device HTML UI mocks as firmware card previews.
Prefer media/preview.html over raster covers so catalog cards mirror each LVGL screen. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,48 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { Film, FileText, ImageIcon } from "lucide-react";
|
||||
import { FileText, LayoutTemplate } from "lucide-react";
|
||||
import type { FirmwareInfo } from "@/lib/firmware";
|
||||
import { formatBytes, cn } from "@/lib/utils";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
function MediaSlot({ fw, active }: { fw: FirmwareInfo; active: boolean }) {
|
||||
const src = fw.media.animation || fw.media.cover;
|
||||
if (src) {
|
||||
return (
|
||||
// Dynamic firmware media URLs — next/image needs remotePatterns per host
|
||||
// eslint-disable-next-line @next/next/no-img-element -- local API / arbitrary media
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
className="h-full w-full object-cover transition-transform duration-500 group-hover:scale-[1.03]"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const initials = fw.name
|
||||
.replace(/[^A-Za-z0-9\u4e00-\u9fff]+/g, " ")
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.slice(0, 2)
|
||||
.map((w) => w[0]?.toUpperCase() ?? "")
|
||||
.join("");
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-full w-full flex-col items-center justify-center gap-2 bg-[radial-gradient(ellipse_at_30%_20%,rgba(240,197,10,0.18),transparent_55%),linear-gradient(160deg,#1a1610,#0e0c09)]",
|
||||
active && "from-[rgba(240,197,10,0.22)]"
|
||||
)}
|
||||
>
|
||||
<span className="font-[family-name:var(--font-display)] text-3xl font-extrabold tracking-tight text-[var(--accent-hot)]/80">
|
||||
{initials || "FW"}
|
||||
</span>
|
||||
<span className="text-[0.65rem] uppercase tracking-[0.14em] text-[var(--muted)]">
|
||||
preview soon
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
import { FirmwarePreview } from "@/components/firmware-preview";
|
||||
|
||||
export function FirmwareCard({
|
||||
fw,
|
||||
@@ -53,9 +15,8 @@ export function FirmwareCard({
|
||||
active: boolean;
|
||||
onSelect: () => void;
|
||||
}) {
|
||||
const hasVideo = Boolean(fw.media.video);
|
||||
const hasPreview = Boolean(fw.media.preview);
|
||||
const hasDocs = Boolean(fw.media.docs);
|
||||
const hasCover = Boolean(fw.media.cover || fw.media.animation);
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -71,16 +32,11 @@ export function FirmwareCard({
|
||||
)}
|
||||
>
|
||||
<div className="relative aspect-[16/10] w-full overflow-hidden border-b border-[var(--line)]">
|
||||
<MediaSlot fw={fw} active={active} />
|
||||
<div className="absolute bottom-2 left-2 flex gap-1">
|
||||
{hasCover && (
|
||||
<FirmwarePreview fw={fw} />
|
||||
<div className="pointer-events-none absolute bottom-2 left-2 flex gap-1">
|
||||
{hasPreview && (
|
||||
<span className="rounded bg-black/55 p-1 text-[var(--ink)] backdrop-blur-sm">
|
||||
<ImageIcon className="size-3" aria-hidden />
|
||||
</span>
|
||||
)}
|
||||
{hasVideo && (
|
||||
<span className="rounded bg-black/55 p-1 text-[var(--ink)] backdrop-blur-sm">
|
||||
<Film className="size-3" aria-hidden />
|
||||
<LayoutTemplate className="size-3" aria-hidden />
|
||||
</span>
|
||||
)}
|
||||
{hasDocs && (
|
||||
@@ -91,7 +47,7 @@ export function FirmwareCard({
|
||||
</div>
|
||||
<Badge
|
||||
variant="muted"
|
||||
className="absolute bottom-2 right-2 bg-black/55 text-[0.65rem] backdrop-blur-sm"
|
||||
className="pointer-events-none absolute bottom-2 right-2 bg-black/55 text-[0.65rem] backdrop-blur-sm"
|
||||
>
|
||||
{formatBytes(fw.size)}
|
||||
</Badge>
|
||||
|
||||
Reference in New Issue
Block a user