27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
/**
|
|
* Gemeinsames Raster für Dashboard-Kacheln (Mobile 2 / Desktop 4 Spalten).
|
|
* Optional Mobile 4: mobile auf 4 setzen + Klasse dashboard-tile-grid--mobile-4col.
|
|
*/
|
|
export const DASHBOARD_TILE_GRID_COLS = { mobile: 2, desktop: 4 }
|
|
|
|
/** @param {number} span @param {number} maxCols */
|
|
export function clampTileSpan(span, maxCols) {
|
|
const n = Number(span)
|
|
if (!Number.isFinite(n)) return 1
|
|
return Math.min(maxCols, Math.max(1, Math.round(n)))
|
|
}
|
|
|
|
/** @param {number} [mobileCols] 2 oder 4 */
|
|
export function dashboardTileGridClassName(mobileCols = DASHBOARD_TILE_GRID_COLS.mobile) {
|
|
let c = 'dashboard-tile-grid'
|
|
if (mobileCols === 4) c += ' dashboard-tile-grid--mobile-4col'
|
|
return c
|
|
}
|
|
|
|
/** KPI-Raster: dieselben Regeln wie `dashboard-tile-grid`, plus Legacy-Klasse `dashboard-stat-grid`. */
|
|
export function dashboardStatGridClassName(mobileCols = DASHBOARD_TILE_GRID_COLS.mobile) {
|
|
let c = 'dashboard-stat-grid dashboard-tile-grid'
|
|
if (mobileCols === 4) c += ' dashboard-stat-grid--mobile-4col dashboard-tile-grid--mobile-4col'
|
|
return c
|
|
}
|