import { html, css, cssManager } from '@design.estate/dees-element'; import type { DeesDashboardgrid } from './dees-dashboardgrid.js'; import '@design.estate/dees-wcctools/demotools'; export const demoFunc = () => { return html` { const grid = elementArg.querySelector('#dashboardGrid') as DeesDashboardgrid; // Set initial widgets grid.widgets = [ { id: 'metrics1', x: 0, y: 0, w: 3, h: 2, title: 'Revenue', icon: 'lucide:dollarSign', content: html`
$124,563
↑ 12.5% from last month
` }, { id: 'metrics2', x: 3, y: 0, w: 3, h: 2, title: 'Users', icon: 'lucide:users', content: html`
8,234
↑ 5.2% from last week
` }, { id: 'chart1', x: 6, y: 0, w: 6, h: 4, title: 'Analytics', icon: 'lucide:lineChart', content: html`
Chart visualization area
` } ]; // Configure grid grid.cellHeight = 80; grid.margin = { top: 10, right: 10, bottom: 10, left: 10 }; grid.enableAnimation = true; grid.showGridLines = false; let widgetCounter = 4; // Control buttons const buttons = elementArg.querySelectorAll('dees-button'); buttons.forEach(button => { const text = button.textContent?.trim(); if (text === 'Toggle Animation') { button.addEventListener('click', () => { grid.enableAnimation = !grid.enableAnimation; }); } else if (text === 'Toggle Grid Lines') { button.addEventListener('click', () => { grid.showGridLines = !grid.showGridLines; }); } else if (text === 'Add Widget') { button.addEventListener('click', () => { const newWidget = { id: `widget${widgetCounter++}`, x: 0, y: 0, w: 3, h: 2, autoPosition: true, title: `Widget ${widgetCounter - 1}`, icon: 'lucide:package', content: html`
New widget content
${Math.floor(Math.random() * 1000)}
` }; grid.addWidget(newWidget, true); }); } else if (text === 'Compact Grid') { button.addEventListener('click', () => { grid.compact(); }); } else if (text === 'Toggle Edit Mode') { button.addEventListener('click', () => { grid.editable = !grid.editable; button.textContent = grid.editable ? 'Lock Grid' : 'Unlock Grid'; }); } }); // Listen to grid events grid.addEventListener('widget-move', (e: CustomEvent) => { console.log('Widget moved:', e.detail.widget); }); grid.addEventListener('widget-resize', (e: CustomEvent) => { console.log('Widget resized:', e.detail.widget); }); }}>
Toggle Animation Toggle Grid Lines Add Widget Compact Grid Toggle Edit Mode
Drag widgets to reposition • Resize from edges and corners • Add widgets with auto-positioning
`; };