1
0
Fork 0

feat(awards): brass-emboss ribbon devices, swap arrow for valor V

This commit is contained in:
Jason Fraley 2026-10-27 01:47:10 -04:00
parent 7430251adf
commit 245e70f3f2
4 changed files with 42 additions and 10 deletions

View file

@ -14,6 +14,7 @@
* - `computeDeviceSlots(...)` lays the devices out as one centered cluster on
* the ribbon face, evenly spaced and shrunk to fit narrow ribbons.
*/
import type { ReactNode } from "react";
import { RIBBON_CONSTANTS, DEFAULT_RIBBON } from "./constants";
import type { DeviceType, RibbonDesign } from "./types";
@ -88,22 +89,53 @@ export function computeDeviceSlots(
const DEVICE_SHAPES: Record<DeviceType, string> = {
star: "M50 2 L60.6 35.4 L95.7 35.2 L67.1 55.6 L78.2 88.8 L50 68 L21.8 88.8 L32.9 55.6 L4.3 35.2 L39.4 35.4 Z",
oakLeaf:
"M50 94 C36 84 28 70 28 54 C28 40 34 26 50 6 C66 26 72 40 72 54 C72 70 64 84 50 94 Z M50 18 L50 84",
arrowUp: "M50 4 L88 44 L66 44 L66 96 L34 96 L34 44 L12 44 Z",
"M50 88 Q68 90 80 80 Q72 74 64 72 Q86 70 92 52 Q78 50 66 50 Q84 40 80 22 Q70 26 60 30 Q56 18 50 4 Q44 18 40 30 Q30 26 20 22 Q16 40 34 50 Q22 50 8 52 Q14 70 32 72 Q24 74 20 80 Q32 90 50 88 Z",
valor: "M10 12 L30 12 L50 66 L70 12 L90 12 L56 92 L44 92 Z",
campaignClasp: "M12 32 L88 32 L88 68 L12 68 Z",
};
const BRASS_OUTLINE = "#3b2208";
/**
* Brass device body shared by every device type. Built for legibility at
* ribbon scale (~24px): a brass gradient with a dark outline carries the
* silhouette. Offset highlight/shadow layers blur together when small, so the
* emboss is expressed through the gradient and outline instead. The gradient
* id is static: every instance defines the identical gradient, so duplicates
* are harmless, and RibbonArt stays hook-free for server components.
*/
function BrassShape({ d, children }: { d: string; children?: ReactNode }) {
return (
<g transform="translate(-50 -50)">
<defs>
<linearGradient id="ptf-brass" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stopColor="#f7dc8f" />
<stop offset="55%" stopColor="#c8913a" />
<stop offset="100%" stopColor="#8a5a1c" />
</linearGradient>
</defs>
<path d={d} fill="url(#ptf-brass)" stroke={BRASS_OUTLINE} strokeWidth={5} strokeLinejoin="round" />
{children}
</g>
);
}
function DeviceShape({ type }: { type: DeviceType }) {
const d = DEVICE_SHAPES[type];
const d = DEVICE_SHAPES[type] ?? DEVICE_SHAPES.star;
if (type === "oakLeaf") {
// Filled silhouette plus a central vein stroke for readability.
// Leaf rotated and given an engraved midrib plus a brass stem at the
// bottom right, so it reads as a sprig rather than a flat blob.
return (
<g transform="translate(-50 -50)">
<path d={d} fill="currentColor" stroke="currentColor" strokeWidth={6} strokeLinecap="round" />
<g transform="rotate(-35)">
<BrassShape d={d}>
<path d="M50 86 L50 94" fill="none" stroke={BRASS_OUTLINE} strokeWidth={11} strokeLinecap="round" />
<path d="M50 86 L50 94" fill="none" stroke="#c8913a" strokeWidth={5} strokeLinecap="round" />
<path d="M50 84 L50 16" fill="none" stroke={BRASS_OUTLINE} strokeWidth={4} strokeLinecap="round" />
</BrassShape>
</g>
);
}
return <path d={d} fill="currentColor" transform="translate(-50 -50)" />;
return <BrassShape d={d} />;
}
/**

View file

@ -40,7 +40,7 @@ export const MILITARY_COLORS: { name: string; hex: string }[] = [
export const RIBBON_DEVICE_INFO: Record<DeviceType, { label: string; symbol: string }> = {
star: { label: "Star", symbol: "\u2605" },
oakLeaf: { label: "Oak Leaf", symbol: "\u{1F333}" },
arrowUp: { label: "Arrow", symbol: "\u2191" },
valor: { label: "Valor (V)", symbol: "V" },
campaignClasp: { label: "Clasp", symbol: "\u2015" },
};

View file

@ -1,6 +1,6 @@
// ─── Types ──────────────────────────────────────────────────────────
export type DeviceType = "star" | "oakLeaf" | "arrowUp" | "campaignClasp";
export type DeviceType = "star" | "oakLeaf" | "valor" | "campaignClasp";
export type Device = {
id: string;

View file

@ -43,7 +43,7 @@ export function validateRibbonDesign(design: unknown): RibbonValidationResult {
return { ok: false, error: "Must have at most 6 devices" };
}
const validDeviceTypes = ["star", "oakLeaf", "arrowUp", "campaignClasp"];
const validDeviceTypes = ["star", "oakLeaf", "valor", "campaignClasp"];
for (let i = 0; i < devices.length; i++) {
const device = devices[i];
if (!device || typeof device !== "object") {