feat(dashboard): implement column-aware defaultSize for optimal 3-4 col widget layout
PROBLEM:
- Reset/auto-layout placed userInfo at 1x1, mood at [1,0] blocking expansion
- Expansion pass couldn't grow userInfo to 2x1 because mood already occupied column 1
- Result: 1x1 userInfo, 1x1 mood, empty space at [2,0] in 3-col layout
ROOT CAUSE:
- Static defaultSize 1x1 → placement happens first
- Expansion happens second, but mood blocks userInfo horizontal growth
SOLUTION - Column-aware defaultSize:
1. userInfoWidget.js: defaultSize now function of columns
- Mobile (≤2 col): { w: 1, h: 1 } (compact, mood beside it)
- Desktop (3-4 col): { w: 2, h: 1 } (starts at target size)
2. dashboardManager.js: resetWidgetSizesToDefault() supports function defaultSize
- Calls defaultSize(columns) if function, otherwise uses static object
- Same pattern as maxAutoSize support
3. widgetRegistry.js: Updated validation to accept function defaultSize
- Skip validation for functions (can't validate until runtime)
4. dashboardManager.js: Reordered userWidgetOrder
- mood(2) before stats(3) so mood sits beside userInfo in top row
RESULT (3-4 columns):
- userInfo starts at 2x1, placed at [0,0]
- mood placed at [2,0] (beside 2-wide userInfo)
- stats placed at [0,1] and expands to 3x? (full width below)
- No expansion blocking, no wasted space
MOBILE FIXES (from previous commits):
- Stats widget: padding-bottom 0.5rem (was 0.3rem, prevent Arousal clipping)
- Refresh button: Show with Dashboard v2 (#rpg-dashboard-container selector)
- Mood text: 0.6rem font-size (improve readability)
AFFECTED:
- userInfoWidget.js: defaultSize + maxAutoSize column-aware functions
- dashboardManager.js: resetWidgetSizesToDefault, userWidgetOrder
- widgetRegistry.js: Validation allows function defaultSize
- userStatsWidget.js: maxAutoSize column-aware (previous commit)
- style.css: Stats padding fix 0.5rem
This commit is contained in:
@@ -804,9 +804,9 @@ export class DashboardManager {
|
||||
|
||||
// Specific widget type ordering within user category
|
||||
const userWidgetOrder = {
|
||||
'userInfo': 1, // Name/level at top
|
||||
'userStats': 2, // Health/energy bars
|
||||
'userMood': 3, // Mood
|
||||
'userInfo': 1, // Name/level at top-left
|
||||
'userMood': 2, // Mood at top-right (before stats so it sits beside userInfo)
|
||||
'userStats': 3, // Health/energy bars (after mood, goes below userInfo+mood)
|
||||
'userAttributes': 4 // STR/DEX/etc
|
||||
};
|
||||
|
||||
@@ -1231,8 +1231,17 @@ export class DashboardManager {
|
||||
const definition = this.registry.get(widget.type);
|
||||
if (definition && definition.defaultSize) {
|
||||
const oldSize = `${widget.w}x${widget.h}`;
|
||||
widget.w = definition.defaultSize.w;
|
||||
widget.h = definition.defaultSize.h;
|
||||
|
||||
// Support defaultSize as function (column-aware sizing)
|
||||
let defaultSize;
|
||||
if (typeof definition.defaultSize === 'function') {
|
||||
defaultSize = definition.defaultSize(this.gridEngine.columns);
|
||||
} else {
|
||||
defaultSize = definition.defaultSize;
|
||||
}
|
||||
|
||||
widget.w = defaultSize.w;
|
||||
widget.h = defaultSize.h;
|
||||
const newSize = `${widget.w}x${widget.h}`;
|
||||
if (oldSize !== newSize) {
|
||||
console.log(`[DashboardManager] Reset ${widget.type} from ${oldSize} to ${newSize}`);
|
||||
|
||||
Reference in New Issue
Block a user