feat(dashboard): implement column-aware widget sizing for optimal mobile/desktop layouts
PROBLEM:
- Mobile (2-col): userInfo defaulted to 2x1 (full width), pushed mood to row 2
- After mobile CSS fixes, 1x1 widgets display perfectly
- Want userInfo 1x1 + mood 1x1 side-by-side in top row on mobile
- Desktop (3-4 col): userInfo should still expand to 2x1 for better space usage
SOLUTION:
- gridEngine: Support maxAutoSize as function (receives column count)
- userInfoWidget:
- Changed defaultSize from 2x1 to 1x1 (starts compact)
- Changed maxAutoSize to column-aware function:
* 2 columns (mobile): maxAutoSize 1x1 (stays compact)
* 3-4 columns (desktop): maxAutoSize 2x1 (can expand)
BEHAVIOR:
- Auto-layout resets widgets to defaultSize (1x1)
- Expansion pass grows widgets up to maxAutoSize based on available space
- Mobile: userInfo stays 1x1, mood can fit beside it (row 0: [userInfo][mood])
- Desktop: userInfo can expand to 2x1 if space available
AFFECTED:
- gridEngine.js: getWidgetMaxSize() now calls maxAutoSize(columns) if function
- userInfoWidget.js: Column-aware maxAutoSize, compact 1x1 defaultSize
This commit is contained in:
@@ -599,6 +599,11 @@ export class GridEngine {
|
|||||||
if (this.registry && widget.type) {
|
if (this.registry && widget.type) {
|
||||||
const definition = this.registry.get(widget.type);
|
const definition = this.registry.get(widget.type);
|
||||||
if (definition && definition.maxAutoSize) {
|
if (definition && definition.maxAutoSize) {
|
||||||
|
// Support maxAutoSize as function (column-aware sizing)
|
||||||
|
if (typeof definition.maxAutoSize === 'function') {
|
||||||
|
return definition.maxAutoSize(this.columns);
|
||||||
|
}
|
||||||
|
// Static maxAutoSize object
|
||||||
return definition.maxAutoSize;
|
return definition.maxAutoSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ export function registerUserInfoWidget(registry, dependencies) {
|
|||||||
description: 'User avatar, name, and level display',
|
description: 'User avatar, name, and level display',
|
||||||
category: 'user',
|
category: 'user',
|
||||||
minSize: { w: 1, h: 1 },
|
minSize: { w: 1, h: 1 },
|
||||||
defaultSize: { w: 2, h: 1 },
|
defaultSize: { w: 1, h: 1 }, // Start compact (1x1), expansion will grow it based on columns
|
||||||
maxAutoSize: { w: 2, h: 1 }, // Max size for auto-arrange expansion
|
// Column-aware max size: mobile (2-col) stays 1x1, desktop (3-4 col) can expand to 2x1
|
||||||
|
maxAutoSize: (columns) => {
|
||||||
|
if (columns <= 2) {
|
||||||
|
return { w: 1, h: 1 }; // Mobile: stay compact to allow mood widget beside it
|
||||||
|
}
|
||||||
|
return { w: 2, h: 1 }; // Desktop: can span 2 columns
|
||||||
|
},
|
||||||
requiresSchema: false,
|
requiresSchema: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user