feat(dees-statsgrid): add cpuCores tile type with column spanning, rendering, demo and docs

This commit is contained in:
2026-01-12 18:00:16 +00:00
parent b478ae3071
commit e981ddf2d6
8 changed files with 2083 additions and 156 deletions

View File

@@ -1,7 +1,16 @@
import { html, css, cssManager } from '@design.estate/dees-element';
import '@design.estate/dees-wcctools/demotools';
import '../dees-panel/dees-panel.js';
import type { IStatsTile } from '../dees-statsgrid/dees-statsgrid.js';
import type { IStatsTile, ICpuCore } from '../dees-statsgrid/dees-statsgrid.js';
// Helper function to generate random CPU core data
const generateCpuCores = (count: number): ICpuCore[] => {
return Array.from({ length: count }, (_, i) => ({
id: i,
usage: Math.round(Math.random() * 100),
label: `${i}`,
}));
};
export const demoFunc = () => {
return html`
@@ -334,7 +343,96 @@ export const demoFunc = () => {
></dees-statsgrid>
</dees-panel>
<dees-panel .title=${'4. Interactive Features'} .subtitle=${'Tiles with actions and real-time updates'}>
<dees-panel .title=${'4. CPU Cores Visualization'} .subtitle=${'Vertical bar visualization for multi-core CPU usage with column spanning'}>
<dees-statsgrid
id="cpu-cores-grid"
.tiles=${[
{
id: 'cpu-cores-8',
title: 'CPU Cores (8-core)',
value: 0,
type: 'cpuCores',
icon: 'lucide:cpu',
columnSpan: 2,
coresData: generateCpuCores(8),
description: 'Intel i7 - 8 cores'
},
{
id: 'memory',
title: 'Memory Usage',
value: 68,
type: 'percentage',
icon: 'lucide:database',
description: '13.6 GB of 20 GB'
},
{
id: 'cpu-cores-16',
title: 'CPU Cores (16-core)',
value: 0,
type: 'cpuCores',
icon: 'lucide:cpu',
columnSpan: 2,
coresData: generateCpuCores(16),
description: 'AMD Ryzen 9 - 16 cores'
},
{
id: 'network',
title: 'Network I/O',
value: 245,
unit: 'MB/s',
type: 'trend',
icon: 'lucide:network',
trendData: [200, 220, 235, 240, 238, 245],
description: 'throughput'
},
{
id: 'cpu-cores-32',
title: 'Server CPU (32-core)',
value: 0,
type: 'cpuCores',
icon: 'lucide:server',
columnSpan: 3,
coresData: generateCpuCores(32),
description: 'AMD EPYC - 32 cores'
},
{
id: 'disk',
title: 'Disk Usage',
value: 42,
type: 'percentage',
icon: 'lucide:hard-drive',
description: '420 GB of 1 TB'
}
]}
.gridActions=${[
{
name: 'Randomize',
iconName: 'lucide:shuffle',
action: async () => {
const grid = document.querySelector('#cpu-cores-grid') as any;
if (!grid) return;
const tiles = grid.tiles.map((tile: any) => {
if (tile.type === 'cpuCores' && tile.coresData) {
return {
...tile,
coresData: tile.coresData.map((core: any) => ({
...core,
usage: Math.round(Math.random() * 100)
}))
};
}
return tile;
});
grid.tiles = tiles;
}
}
]}
.minTileWidth=${250}
.gap=${16}
></dees-statsgrid>
</dees-panel>
<dees-panel .title=${'5. Interactive Features'} .subtitle=${'Tiles with actions and real-time updates'}>
<dees-statsgrid
id="interactive-grid"
.tiles=${[
@@ -448,7 +546,7 @@ export const demoFunc = () => {
></dees-statsgrid>
</dees-panel>
<dees-panel .title=${'5. Code Example'} .subtitle=${'How to implement a stats grid with TypeScript'}>
<dees-panel .title=${'6. Code Example'} .subtitle=${'How to implement a stats grid with TypeScript'}>
<div class="code-block">${`const tiles: IStatsTile[] = [
{
id: 'revenue',