mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
feat: new stats renderer
This commit is contained in:
1 parent
a0290bb59f
commit
94481e81bb
14 files changed
+333
-126
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { Stat } from '../index.js';
|
||||
import GenericStatsRow from './GenericStatsRow.js';
|
||||
|
||||
export default function GenericStatsColumn(stats: Stat[]) {
|
||||
return `
|
||||
<style>
|
||||
.generic-stats-column {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="generic-stats-column">
|
||||
${stats.map((stat) => GenericStatsRow(stat)).join('\n')}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Stat } from '../index.js';
|
||||
|
||||
export default function GenericStatsRow(stat: Stat) {
|
||||
return `
|
||||
<style>
|
||||
.generic-stats-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.generic-stats-label {
|
||||
color: #A0A0A0;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.generic-stats-value {
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="generic-stats-row">
|
||||
<span class="generic-stats-label">${stat[0]}</span>
|
||||
<span class="generic-stats-value">${stat[1]}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -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>
|
||||
`;
|
||||
}
|
||||
Reference in new issue
Block a user