diff --git a/pwa/src/components/game/LocationView.css b/pwa/src/components/game/LocationView.css index dd0712e..689a251 100644 --- a/pwa/src/components/game/LocationView.css +++ b/pwa/src/components/game/LocationView.css @@ -1,7 +1,7 @@ /* Grid View Styles */ .entity-list.grid-view { display: grid; - grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem; align-items: start; } @@ -22,7 +22,9 @@ cursor: pointer; position: relative; overflow: hidden; - height: 100%; + height: auto; + min-width: 0; + width: 100%; } .entity-card.grid-card:hover { diff --git a/pwa/src/components/game/LocationView.tsx b/pwa/src/components/game/LocationView.tsx index 6a66bf1..62d6b07 100644 --- a/pwa/src/components/game/LocationView.tsx +++ b/pwa/src/components/game/LocationView.tsx @@ -92,22 +92,10 @@ function LocationView({ const { t } = useTranslation() const { playSfx } = useAudio() - // View Mode State - const [viewMode, setViewMode] = useState<'list' | 'grid'>(() => { - return (localStorage.getItem('locationViewMode') as 'list' | 'grid') || 'list' - }) - // Dropdown State const [activeDropdown, setActiveDropdown] = useState(null) const [dropdownPos, setDropdownPos] = useState({ x: 0, y: 0 }) - const toggleViewMode = () => { - const newMode = viewMode === 'list' ? 'grid' : 'list' - setViewMode(newMode) - localStorage.setItem('locationViewMode', newMode) - playSfx('/audio/sfx/click.wav') - } - // Handle dropdown toggle const handleDropdownClick = (e: React.MouseEvent, id: string) => { e.stopPropagation() @@ -115,9 +103,10 @@ function LocationView({ setActiveDropdown(null) } else { const rect = e.currentTarget.getBoundingClientRect() + // Fix: GameDropdown uses fixed positioning, so we don't add scroll offsets setDropdownPos({ - x: rect.left + window.scrollX, - y: rect.bottom + window.scrollY + 5 + x: rect.left, + y: rect.bottom + 5 }) setActiveDropdown(id) } @@ -147,15 +136,6 @@ function LocationView({ )} - { e.stopPropagation(); toggleViewMode(); }} - className="view-toggle-btn" - style={{ marginLeft: 'auto' }} - > - {viewMode === 'list' ? '📋' : '🔲'} - {location.tags && location.tags.length > 0 && ( @@ -235,12 +215,12 @@ function LocationView({ {location.npcs.filter((npc: any) => npc.type === 'enemy').length > 0 && (

{t('location.enemies')}

-
+
{location.npcs.filter((npc: any) => npc.type === 'enemy').map((enemy: any, i: number) => { const id = `enemy-${enemy.id || i}`; return ( -
handleDropdownClick(e, id) : undefined}> +
handleDropdownClick(e, id)}> {enemy.id && (
)} - {viewMode === 'list' && ( - <> -
-
{getTranslatedText(enemy.name)}
- {enemy.level &&
{t('location.level')} {enemy.level}
} -
- onInitiateCombat(enemy.id)} - > - {t('common.fight')} - - - )} - - {viewMode === 'grid' && ( - -
{getTranslatedText(enemy.name)}
-
{t('location.level')} {enemy.level}
-
Click for actions
-
- }> -
- - )} + +
{getTranslatedText(enemy.name)}
+
{t('location.level')} {enemy.level}
+
Click for actions
+
+ }> +
+ {/* Dropdown for Grid View */} - {viewMode === 'grid' && activeDropdown === id && ( + {activeDropdown === id && ( setActiveDropdown(null)} @@ -314,46 +275,25 @@ function LocationView({ {location.corpses && location.corpses.length > 0 && (

{t('location.corpses')}

-
+
{location.corpses.map((corpse: any) => (
-
handleDropdownClick(e, `corpse-${corpse.id}`) : undefined} +
handleDropdownClick(e, `corpse-${corpse.id}`)} > - {viewMode === 'list' ? ( - <> -
-
{corpse.emoji} {getTranslatedText(corpse.name)}
-
{corpse.loot_count} {t('location.items')}
-
- { - playSfx('/audio/sfx/interact.wav') - onLootCorpse(String(corpse.id)) - }} - disabled={corpse.loot_count === 0} - > - 🔍 {t('common.examine')} - - - ) : ( - -
{corpse.emoji} {getTranslatedText(corpse.name)}
-
{corpse.loot_count} {t('location.items')}
-
- }> -
-
{corpse.emoji}
-
{corpse.loot_count} items
-
- - )} + +
{corpse.emoji} {getTranslatedText(corpse.name)}
+
{corpse.loot_count} {t('location.items')}
+
+ }> +
+
{corpse.emoji}
+
{corpse.loot_count} items
+
+ - {viewMode === 'grid' && activeDropdown === `corpse-${corpse.id}` && ( + {activeDropdown === `corpse-${corpse.id}` && ( setActiveDropdown(null)} @@ -437,33 +377,23 @@ function LocationView({ {location.npcs.filter((npc: any) => npc.type !== 'enemy').length > 0 && (

{t('location.npcs')}

-
+
{location.npcs.filter((npc: any) => npc.type !== 'enemy').map((npc: any, i: number) => ( -
handleDropdownClick(e, `npc-${i}`) : undefined} +
handleDropdownClick(e, `npc-${i}`)} > - 🧑 + 🧑 - {viewMode === 'list' ? ( - <> -
-
{getTranslatedText(npc.name)}
- {npc.level &&
{t('location.level')} {npc.level}
} -
- {t('common.talk')} - - ) : ( - -
{getTranslatedText(npc.name)}
-
{t('location.level')} {npc.level}
-
- }> -
- - )} + +
{getTranslatedText(npc.name)}
+
{t('location.level')} {npc.level}
+
+ }> +
+ - {viewMode === 'grid' && activeDropdown === `npc-${i}` && ( + {activeDropdown === `npc-${i}` && ( setActiveDropdown(null)} @@ -485,14 +415,14 @@ function LocationView({ {location.items.length > 0 && (

{t('location.itemsOnGround')}

-
+
{location.items.map((item: any, i: number) => { // Use loose equality to handle potential string/number mismatches const isShaking = failedActionItemId == item.id; const itemId = `item-${item.id}-${i}`; return ( -
handleDropdownClick(e, itemId) : undefined} +
handleDropdownClick(e, itemId)} > @@ -528,13 +458,13 @@ function LocationView({ )}
}> -
+
{item.image_path ? ( {getTranslatedText(item.name)} { (e.target as HTMLImageElement).style.display = 'none'; const icon = (e.target as HTMLImageElement).nextElementSibling; @@ -542,71 +472,15 @@ function LocationView({ }} /> ) : null} - {item.emoji || '📦'} + {item.emoji || '📦'} - {viewMode === 'list' && ( -
-
- {getTranslatedText(item.name) || 'Unknown Item'} -
- {item.quantity > 1 &&
×{item.quantity}
} -
- )} - {viewMode === 'grid' && item.quantity > 1 && ( + {item.quantity > 1 && (
x{item.quantity}
)}
- {viewMode === 'list' && ( -
- {item.quantity === 1 ? ( - { - // Sound handled in useGameEngine - onPickup(item.id, 1) - }} - > - {t('common.pickUp')} - - ) : ( -
- { - onPickup(item.id, 1) - }}> - x1 - - - {item.quantity >= 5 && ( - { - onPickup(item.id, 5) - }}> - x5 - - )} - - {item.quantity >= 10 && ( - { - onPickup(item.id, 10) - }}> - x10 - - )} - - { - onPickup(item.id, item.quantity) - }}> - {t('common.all') || 'All'} - -
- )} -
- )} - - {viewMode === 'grid' && activeDropdown === itemId && ( + {activeDropdown === itemId && ( setActiveDropdown(null)}