Table layout to work with any number of data cols

This commit is contained in:
Kalle
2022-10-23 11:18:57 +03:00
parent cca225c780
commit 3fe59c1a88
2 changed files with 13 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import { WeaponCombobox } from "~/components/Combobox";
import { Image } from "~/components/Image";
import { Main } from "~/components/Main";
import { DAMAGE_RECEIVERS, useObjectDamage } from "~/modules/analyzer";
import { useObjectDamage } from "~/modules/analyzer";
import {
type MainWeaponId,
BIG_BUBBLER_ID,
@@ -93,9 +93,11 @@ function DamageReceiversGrid({
return (
<div
className="object-damage__grid"
style={
{ "--columns-count": String(2 + damagesToReceivers.length) } as any
}
style={{
gridTemplateColumns: gridTemplateColumnsValue(
damagesToReceivers[0]?.damages.length ?? 0
),
}}
>
<div />
<div />
@@ -154,3 +156,10 @@ function DamageReceiversGrid({
</div>
);
}
function gridTemplateColumnsValue(dataColumnsCount: number) {
return `max-content max-content ${new Array(dataColumnsCount)
.fill(null)
.map(() => `1fr`)
.join(" ")}`;
}

View File

@@ -2,9 +2,6 @@
display: grid;
width: 100%;
column-gap: var(--s-6);
/* xxx: make dynamic */
grid-template-columns: max-content max-content 1fr 1fr 1fr 1fr 1fr;
place-items: center;
row-gap: var(--s-3);
}