fix(ui): render computed source badge in pinned modifier panel
This commit is contained in:
parent
92dae32f31
commit
0987adbff3
1 changed files with 33 additions and 14 deletions
|
|
@ -69,20 +69,39 @@ export function ModifierPinnedPanel({ pieceId, engine, onClose }: Props) {
|
||||||
<div className="px-4 py-3">
|
<div className="px-4 py-3">
|
||||||
{modifierRows.length > 0 ? (
|
{modifierRows.length > 0 ? (
|
||||||
<ul className="space-y-0">
|
<ul className="space-y-0">
|
||||||
{modifierRows.map((row) => (
|
{modifierRows.map((row) => {
|
||||||
<li
|
const sourceBadge =
|
||||||
key={row.id}
|
row.source.kind === "per-instance"
|
||||||
data-testid="pinned-modifier-row"
|
? { text: `per-instance: ${row.source.square}`, cls: "text-cyan-700 bg-cyan-50" }
|
||||||
className="flex items-center justify-between gap-3 py-1.5 border-b border-neutral-100 last:border-0"
|
: row.source.kind === "per-type"
|
||||||
>
|
? {
|
||||||
<span className="text-xs text-neutral-500 shrink-0">
|
text: `per-type: all ${row.source.color} ${row.source.pieceType}s`,
|
||||||
{row.label}
|
cls: "text-purple-700 bg-purple-50",
|
||||||
</span>
|
}
|
||||||
<span className="text-xs font-semibold text-neutral-800 text-right">
|
: row.source.kind === "preset"
|
||||||
{row.description}
|
? { text: `from ${row.source.presetName}`, cls: "text-emerald-700 bg-emerald-50" }
|
||||||
</span>
|
: { text: "default", cls: "text-neutral-500 bg-neutral-50" };
|
||||||
</li>
|
return (
|
||||||
))}
|
<li
|
||||||
|
key={row.id}
|
||||||
|
data-testid="pinned-modifier-row"
|
||||||
|
className="flex flex-col gap-1 py-1.5 border-b border-neutral-100 last:border-0"
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-between gap-3">
|
||||||
|
<span className="text-xs text-neutral-500 shrink-0">{row.label}</span>
|
||||||
|
<span className="text-xs font-semibold text-neutral-800 text-right">
|
||||||
|
{row.description}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
data-testid={`source-badge-${row.id}`}
|
||||||
|
className={`text-[10px] px-1.5 py-0.5 rounded self-end ${sourceBadge.cls}`}
|
||||||
|
>
|
||||||
|
{sourceBadge.text}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-xs text-neutral-400 italic">No active modifiers</p>
|
<p className="text-xs text-neutral-400 italic">No active modifiers</p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue