1
0
Fork 0

feat(frontend): make faction cards links with type-tag width and cover-image backgrounds

Each faction card in the Mission Details FACTIONS section is now an anchor
to /intelligence/factions/<id>. The type badge (Player/Major/Minor/
Corporation/Special) uses width:fit-content so its colored background only
spans the text instead of the full card, and a faction's coverImage (when
present) renders as a centered object-cover background at low opacity that
brightens on hover.
This commit is contained in:
Jason Fraley 2026-11-02 14:28:53 -05:00
parent e5f6d107b9
commit b6e8fa6f90

View file

@ -1,5 +1,5 @@
import { ShieldIcon } from "lucide-react";
import type { Faction } from "@/payload-types";
import type { Faction, Media } from "@/payload-types";
import { Item, ItemContent, ItemHeader, ItemTitle } from "@/components/ui/item";
interface FactionEntry {
@ -56,24 +56,44 @@ export function MissionFactions({ factionsInvolved }: MissionFactionsProps) {
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
{factionsInvolved.map((entry, index) => {
const faction = typeof entry.faction === "object" ? entry.faction : null;
const coverImage =
faction && typeof faction.coverImage === "object" && faction.coverImage !== null
? (faction.coverImage as Media)
: null;
const coverUrl = coverImage?.url ?? null;
const factionId = typeof entry.faction === "object" ? entry.faction.id : entry.faction;
return (
<Item key={index} variant="outline">
<ItemHeader>
<ItemTitle>{faction?.name ?? `Faction #${entry.faction}`}</ItemTitle>
<span
className={`text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${threatLevelColors[entry.threatLevel] ?? "bg-muted text-muted-foreground"}`}
>
{entry.threatLevel}
</span>
</ItemHeader>
{faction && (
<ItemContent>
<span className={`text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${FACTION_TYPE_COLORS[faction.type] ?? "bg-muted/50 text-muted-foreground"}`}>
{FACTION_TYPE_LABELS[faction.type] ?? faction.type}
<Item key={index} variant="outline" asChild>
<a
href={`/intelligence/factions/${factionId}`}
className="relative overflow-hidden hover:bg-accent/50"
>
{coverUrl && (
<img
src={coverUrl}
alt=""
className="absolute inset-0 z-0 h-full w-full object-cover object-center opacity-15 transition-opacity [a]:hover:opacity-30"
/>
)}
<ItemHeader>
<ItemTitle>{faction?.name ?? `Faction #${entry.faction}`}</ItemTitle>
<span
className={`w-fit self-start text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${threatLevelColors[entry.threatLevel] ?? "bg-muted text-muted-foreground"}`}
>
{entry.threatLevel}
</span>
</ItemContent>
)}
</ItemHeader>
{faction && (
<ItemContent>
<span
className={`w-fit self-start text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${FACTION_TYPE_COLORS[faction.type] ?? "bg-muted/50 text-muted-foreground"}`}
>
{FACTION_TYPE_LABELS[faction.type] ?? faction.type}
</span>
</ItemContent>
)}
</a>
</Item>
);
})}