diff --git a/src/index.css b/src/index.css index 33a8804..c1fbf4c 100644 --- a/src/index.css +++ b/src/index.css @@ -10,3 +10,19 @@ body { min-height: 100dvh; background-color: #020617; /* slate-950 */ } + +/* Custom Scrollbar for action columns */ +.overflow-x-auto::-webkit-scrollbar { + height: 6px; +} +.overflow-x-auto::-webkit-scrollbar-track { + background: rgba(15, 23, 42, 0.3); + border-radius: 9999px; +} +.overflow-x-auto::-webkit-scrollbar-thumb { + background: rgba(100, 116, 139, 0.4); + border-radius: 9999px; +} +.overflow-x-auto::-webkit-scrollbar-thumb:hover { + background: rgba(245, 158, 11, 0.5); +} diff --git a/src/ui/ActionCard.tsx b/src/ui/ActionCard.tsx index bf00255..9b5ef1e 100644 --- a/src/ui/ActionCard.tsx +++ b/src/ui/ActionCard.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { gameRuntime } from '../state/runtime'; import { useGameStore } from '../state/store'; import type { ActionView } from '../state/viewModel'; @@ -11,7 +11,21 @@ export function ActionCard({ action }: ActionCardProps) { const activeActionId = useGameStore((s) => s.activeActionId); const actionProgress = useGameStore((s) => s.actionProgress); const prefs = useGameStore((s) => s.prefs); - const [isOpen, setIsOpen] = useState(false); + const [openInfoId, setOpenInfoId] = useState(null); + const containerRef = useRef(null); + + useEffect(() => { + function handleClickOutside(event: MouseEvent) { + if (containerRef.current && !containerRef.current.contains(event.target as Node)) { + setOpenInfoId(null); + } + } + + document.addEventListener('click', handleClickOutside); + return () => { + document.removeEventListener('click', handleClickOutside); + }; + }, []); const isActive = action.id === activeActionId; const isDisabled = !action.available && !isActive; @@ -36,14 +50,17 @@ export function ActionCard({ action }: ActionCardProps) { } } + const tooltipId = `tooltip-${action.id}`; + return ( -
+
- {isOpen ? ( + {openInfoId === action.id ? (