feat: new stats renderer

This commit is contained in:
TresAbhi committed 2023-05-24 02:01:22 +00:00
1 parent a0290bb59f
commit 94481e81bb
14 files changed
+333 -126

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import GenericStatsColumn from './components/GenericStatsColumn.js';
export type Stat = [string, string | number];
export default function GenericStats(stats: Stat[], columnCount = 2) {
const itemsPerRow = Math.ceil(stats.length / columnCount);
const columns: Stat[][] = [];
stats.forEach((stat, index) => {
const column = Math.floor(index / itemsPerRow);
if (!columns[column]) columns[column] = [];
columns[column].push(stat);
});
return `
<style>
.generic-stats {
display: flex;
gap: 32px;
}
</style>
<div class="generic-stats">
${columns.map((column) => GenericStatsColumn(column)).join('\n')}
</div>
`;
}