Move Unit Composition into the main table

This commit is contained in:
NilsUeter
2026-06-07 11:27:57 +02:00
parent 2ea21b1b60
commit 50fd17d41b
+61 -24
View File
@@ -83,11 +83,11 @@ const Force = ({ force, onePerPage, colorUserChoice }) => {
> >
{unitOrder.map((unit, index) => ( {unitOrder.map((unit, index) => (
<div key={unit.name + index} className="relative"> <div key={unit.name + index} className="relative">
<div className="flex items-center justify-start gap-1 absolute text-[13px] -top-2.5 z-10 print-display-none"> <div className="print-display-none absolute -top-2.5 z-10 flex items-center justify-start gap-1 text-[13px]">
<button <button
disabled={index === 0} disabled={index === 0}
type="button" type="button"
className="py-0.5 px-1.5 pl-1" className="px-1.5 py-0.5 pl-1"
onClick={() => onClick={() =>
// move unit up in the order // move unit up in the order
setUnitOrder((prevOrder) => { setUnitOrder((prevOrder) => {
@@ -118,7 +118,7 @@ const Force = ({ force, onePerPage, colorUserChoice }) => {
<button <button
disabled={index === unitOrder.length - 1} disabled={index === unitOrder.length - 1}
type="button" type="button"
className="py-0.5 px-1.5 pl-1" className="px-1.5 py-0.5 pl-1"
onClick={() => onClick={() =>
// move unit down in the order // move unit down in the order
setUnitOrder((prevOrder) => { setUnitOrder((prevOrder) => {
@@ -310,7 +310,7 @@ const Unit = ({ unit, catalog, onePerPage, forceRules, colorUserChoice }) => {
type="checkbox" type="checkbox"
onChange={(e) => setHideModelCount(e.target.checked)} onChange={(e) => setHideModelCount(e.target.checked)}
/> />
<span className="print-display-none">Hide model selection</span> <span className="print-display-none">Hide Unit Composition</span>
</label> </label>
<label <label
className="print-display-none" className="print-display-none"
@@ -428,21 +428,6 @@ const Unit = ({ unit, catalog, onePerPage, forceRules, colorUserChoice }) => {
/> />
))} ))}
</div> </div>
{!hideModelCount && modelStats?.[0] && (
<div
className={`pointer-events-none mt-[17px] ${
modelStats.length > 1 ? "" : "self-center"
}`}
style={{
fontSize: "0.7em",
zIndex: 101,
}}
>
{modelList.map((model, index) => (
<div key={model}>{model}</div>
))}
</div>
)}
</div> </div>
</div> </div>
<div <div
@@ -584,6 +569,11 @@ const Unit = ({ unit, catalog, onePerPage, forceRules, colorUserChoice }) => {
forceRules={forceRules} forceRules={forceRules}
/> />
<OtherAbilities abilities={abilities} /> <OtherAbilities abilities={abilities} />
<UnitComposition
hideModelCount={hideModelCount}
modelStats={modelStats}
modelList={modelList}
/>
</table> </table>
<div style={{ flex: "1" }} /> <div style={{ flex: "1" }} />
<table <table
@@ -648,6 +638,45 @@ const Unit = ({ unit, catalog, onePerPage, forceRules, colorUserChoice }) => {
); );
}; };
const UnitComposition = ({ hideModelCount, modelStats, modelList }) => {
return (
<>
{!hideModelCount && modelStats?.[0] && (
<>
<thead>
<tr
style={{
backgroundColor: "var(--primary-color)",
color: "#fff",
}}
>
<th></th>
<th className="text-left uppercase">Unit Composition</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody style={{
fontSize: "0.7em",
}}>
{modelList.map((model, index) => (
<tr key={model}>
<td></td>
<td style={{ textAlign: "left" }} colSpan={7} key={model}>{model}</td>
</tr>
))}
</tbody>
</>
)}
</>
);
};
const backgrounds = { const backgrounds = {
"Imperium - Adeptus Astartes - Dark Angels": imperiumBackground, "Imperium - Adeptus Astartes - Dark Angels": imperiumBackground,
"Imperium - Adeptus Astartes - Space Wolves": imperiumBackground, "Imperium - Adeptus Astartes - Space Wolves": imperiumBackground,
@@ -1034,11 +1063,13 @@ const removeKeywordsSet = new Set([
"Melee Weapon", "Melee Weapon",
"Ranged Weapon", "Ranged Weapon",
"Attacks Dx Weapon", "Attacks Dx Weapon",
"Extra Attacks Weapon" "Extra Attacks Weapon",
]); ]);
const Keywords = ({ keywords }) => { const Keywords = ({ keywords }) => {
const joinedKeywords = [...keywords].filter(key => !removeKeywordsSet.has(key)).join("; ") const joinedKeywords = [...keywords]
.filter((key) => !removeKeywordsSet.has(key))
.join("; ");
return ( return (
<div <div
style={{ style={{
@@ -1058,8 +1089,11 @@ const Keywords = ({ keywords }) => {
gap: 3, gap: 3,
}} }}
> >
<span className="font-normal" style={{ fontSize: "1em" }}>KEYWORDS:</span> <span className="font-normal" style={{ fontSize: "1em" }}>
<span className="uppercase" KEYWORDS:
</span>
<span
className="uppercase"
style={{ style={{
fontSize: joinedKeywords.length > 70 ? ".8em" : "1em", fontSize: joinedKeywords.length > 70 ? ".8em" : "1em",
fontWeight: 800, fontWeight: 800,
@@ -1092,7 +1126,10 @@ const Factions = ({ factions }) => {
minHeight: 54, minHeight: 54,
}} }}
> >
<span className="font-normal" style={{ fontSize: ".9em", lineHeight: 1.3 }}> <span
className="font-normal"
style={{ fontSize: ".9em", lineHeight: 1.3 }}
>
FACTION KEYWORDS: FACTION KEYWORDS:
</span> </span>
<span className="uppercase" style={{ fontSize: ".9em", fontWeight: 600 }}> <span className="uppercase" style={{ fontSize: ".9em", fontWeight: 600 }}>