fix: improve inventory and quests widget resizing at narrow widths
Resolved issues where inventory and quests widgets didn't properly adapt to narrow desktop widths (~296px, 2 columns): - Assets tab was cut off (1/3 off-screen) - Widgets shrank vertically instead of expanding - Sub-tabs overflowed horizontally Changes: 1. Widget onResize Handlers (inventoryWidget.js, questsWidget.js): - Strengthened inventory onResize to call render() for full re-layout - Added quests onResize handler with re-render + width-aware styling - Both apply responsive CSS classes at narrow widths 2. Increased maxAutoSize for 2-Column Layouts: - inventoryWidget.js: h: 6 → h: 8 (creates expansion headroom) - questsWidget.js: h: 5 → h: 7 (user requested height) - Previously: defaultSize = maxAutoSize → zero expansion possible - Now: defaultSize < maxAutoSize → widgets can expand vertically 3. Added Missing Quests Widget Container Styles (style.css): - Added .rpg-quests-widget and .rpg-quests-views flex container styles - Proper overflow handling (hidden on container, auto on content) - Prevents Assets tab horizontal cut-off 4. Implemented Compact Mode CSS (style.css): - .rpg-inventory-compact: reduced padding, icon-only sub-tabs - Applied when widget width < 6 grid units - Prevents 3 sub-tabs from overflowing 296px container - Icons remain visible, labels hidden for space savings 5. Grid Engine Boolean Return (gridEngine.js): - setContainerWidth now returns true/false for column changes - Allows DashboardManager to optimize resize handling Why This Works: - Auto-layout expansion requires defaultSize < maxAutoSize for headroom - Flex container styles prevent overflow with proper scroll handling - Compact mode makes sub-tabs fit within narrow containers - onResize handlers ensure internal layouts adapt to dimension changes Fixes: Assets tab cut-off, vertical shrinking, sub-tab overflow at ~296px
This commit is contained in:
@@ -65,8 +65,19 @@ export function registerInventoryWidget(registry, dependencies) {
|
||||
description: 'Full inventory system with On Person, Stored, and Assets',
|
||||
category: 'inventory',
|
||||
minSize: { w: 2, h: 4 },
|
||||
defaultSize: { w: 2, h: 6 },
|
||||
maxAutoSize: { w: 3, h: 8 }, // Max size for auto-arrange expansion (full tab)
|
||||
// Column-aware sizing: compact on mobile, spacious on desktop
|
||||
defaultSize: (columns) => {
|
||||
if (columns <= 2) {
|
||||
return { w: 2, h: 5 }; // Mobile: 2×5 (full width, compact)
|
||||
}
|
||||
return { w: 2, h: 6 }; // Desktop: 2×6 (default)
|
||||
},
|
||||
maxAutoSize: (columns) => {
|
||||
if (columns <= 2) {
|
||||
return { w: 2, h: 8 }; // Mobile: 2×8 max (increased for expansion headroom)
|
||||
}
|
||||
return { w: 3, h: 8 }; // Desktop: 3×8 max (can expand)
|
||||
},
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
@@ -113,14 +124,18 @@ export function registerInventoryWidget(registry, dependencies) {
|
||||
},
|
||||
|
||||
onResize(container, newW, newH) {
|
||||
// Adjust layout for narrow widgets
|
||||
const widget = container.querySelector('.rpg-inventory-widget');
|
||||
if (!widget) return;
|
||||
// Re-render widget to update internal layout for new dimensions
|
||||
// This ensures sub-tabs, item lists, and storage locations adapt correctly
|
||||
this.render(container, this.config || {});
|
||||
|
||||
if (newW < 6) {
|
||||
widget.classList.add('rpg-inventory-compact');
|
||||
} else {
|
||||
widget.classList.remove('rpg-inventory-compact');
|
||||
// Apply compact mode styling if needed
|
||||
const widget = container.querySelector('.rpg-inventory-widget');
|
||||
if (widget) {
|
||||
if (newW < 6) {
|
||||
widget.classList.add('rpg-inventory-compact');
|
||||
} else {
|
||||
widget.classList.remove('rpg-inventory-compact');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user