Upload src/components/ui/Hotbar.tsx with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253'use client'
import { useUIStore } from '@/stores/uiStore'import { usePlayerStore } from '@/stores/playerStore'import { BLOCK_DEFS } from '@/engine/constants'
export function Hotbar() { const { hotbarSlot, setHotbarSlot } = useUIStore() const { player } = usePlayerStore() const items = player?.inventory.hotbar || Array(9).fill(null)
return ( <div className="flex gap-0.5 p-0.5 bg-black/70 rounded-lg backdrop-blur-sm"> {items.map((item, i) => { const def = item ? BLOCK_DEFS[item.id] : null const isSelected = i === hotbarSlot
return ( <div key={i} className={` w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center rounded cursor-pointer transition-all duration-75 relative ${isSelected ? 'bg-white/25 border-2 border-white/80' : 'bg-gray-800/50 border border-gray-600/40 hover:bg-gray-700/50' } `} onClick={() => setHotbarSlot(i)} > {def && ( <> <div className="w-5 h-5 sm:w-7 sm:h-7 rounded-sm border border-black/20" style={{ backgroundColor: def.color }} /> {item!.count > 1 && ( <span className="absolute bottom-0 right-0.5 text-[8px] sm:text-[10px] text-white font-bold" style={{ textShadow: '1px 1px 1px rgba(0,0,0,0.9)' }}> {item!.count} </span> )} </> )} <span className="absolute -bottom-3.5 text-[7px] sm:text-[9px] text-gray-500"> {i + 1} </span> </div> ) })} </div> )}src/components/ui/Hotbar.tsxAdded+53