From 7430251adf757196313455a296e625c572d454cb Mon Sep 17 00:00:00 2001
From: Z8MB1E
Date: Mon, 26 Oct 2026 22:21:10 -0400
Subject: [PATCH] feat(awards): render ribbon devices as vectors with
tier-driven auto-layout
Introduce RibbonArt, a single shared SVG renderer used by both the production viewer and admin/studio preview so they can no longer diverge. Devices are now vector glyphs (star/oak leaf/campaign clasp/arrow up) instead of Unicode text, laid out as one centered cluster that shrinks to fit. Device count derives from advancement tier using the service-star convention (tier N shows N-1, cap 6; bare ribbon at tier 1 or for non-tiered awards). Legacy per-device x/y positions are stored but ignored, so no schema change. Designers add/remove/reorder device types and preview tiers.
---
.../admin/awards/RibbonDesigner.tsx | 2 +-
.../awards/ribbonDesign/RibbonArt.tsx | 211 ++++++++++++++++++
src/components/awards/ribbonDesign/parts.tsx | 184 +++++++--------
src/components/frontend/account/AwardCard.tsx | 1 +
.../frontend/account/AwardListingCard.tsx | 1 +
.../frontend/account/AwardPickerDialog.tsx | 6 +-
.../frontend/account/RibbonRack.tsx | 2 +-
.../frontend/account/RibbonViewer.tsx | 77 ++-----
.../frontend/awards/RibbonStudio.tsx | 2 +-
tests/int/ribbon-devices.int.spec.ts | 147 ++++++++++++
10 files changed, 485 insertions(+), 148 deletions(-)
create mode 100644 src/components/awards/ribbonDesign/RibbonArt.tsx
create mode 100644 tests/int/ribbon-devices.int.spec.ts
diff --git a/src/components/admin/awards/RibbonDesigner.tsx b/src/components/admin/awards/RibbonDesigner.tsx
index 86bac4ff..d44c101e 100644
--- a/src/components/admin/awards/RibbonDesigner.tsx
+++ b/src/components/admin/awards/RibbonDesigner.tsx
@@ -52,7 +52,7 @@ export default function RibbonDesigner() {
Configure the ribbon colors, stripes, and device attachments for this award.
-
+
))}
@@ -133,6 +131,12 @@ export function StripeEditor({
// ─── Device Editor ──────────────────────────────────────────────────
+/**
+ * Devices are added/removed as an ordered set; their placement on the ribbon
+ * is computed automatically (centered cluster, tier-driven count when the
+ * award belongs to an advancement series). The legacy per-device X/Y sliders
+ * are gone because layout is derived, and stored positions are ignored.
+ */
export function DeviceEditor({
devices,
onChange,
@@ -143,12 +147,21 @@ export function DeviceEditor({
const addDevice = (type: DeviceType) =>
onChange([...devices, { id: crypto.randomUUID(), type, position: 50, positionY: 50 }]);
const removeDevice = (id: string) => onChange(devices.filter((d) => d.id !== id));
- const updateDevice = (id: string, patch: Partial) =>
- onChange(devices.map((d) => (d.id === id ? { ...d, ...patch } : d)));
+ const moveDevice = (idx: number, delta: number) => {
+ const next = [...devices];
+ const target = idx + delta;
+ if (target < 0 || target >= next.length) return;
+ [next[idx], next[target]] = [next[target], next[idx]];
+ onChange(next);
+ };
return (
Devices
+
+ Devices arrange themselves centered on the ribbon. For awards in an
+ advancement series, the tier sets how many show (tier N displays N - 1).
+