TomatitoToho commited on
Commit
29b1060
·
verified ·
1 Parent(s): eb642e7

Upload src/components/ui/Hotbar.tsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/components/ui/Hotbar.tsx +53 -0
src/components/ui/Hotbar.tsx ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client'
2
+
3
+ import { useUIStore } from '@/stores/uiStore'
4
+ import { usePlayerStore } from '@/stores/playerStore'
5
+ import { BLOCK_DEFS } from '@/engine/constants'
6
+
7
+ export function Hotbar() {
8
+ const { hotbarSlot, setHotbarSlot } = useUIStore()
9
+ const { player } = usePlayerStore()
10
+ const items = player?.inventory.hotbar || Array(9).fill(null)
11
+
12
+ return (
13
+ <div className="flex gap-0.5 p-0.5 bg-black/70 rounded-lg backdrop-blur-sm">
14
+ {items.map((item, i) => {
15
+ const def = item ? BLOCK_DEFS[item.id] : null
16
+ const isSelected = i === hotbarSlot
17
+
18
+ return (
19
+ <div
20
+ key={i}
21
+ className={`
22
+ w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center rounded cursor-pointer
23
+ transition-all duration-75 relative
24
+ ${isSelected
25
+ ? 'bg-white/25 border-2 border-white/80'
26
+ : 'bg-gray-800/50 border border-gray-600/40 hover:bg-gray-700/50'
27
+ }
28
+ `}
29
+ onClick={() => setHotbarSlot(i)}
30
+ >
31
+ {def && (
32
+ <>
33
+ <div
34
+ className="w-5 h-5 sm:w-7 sm:h-7 rounded-sm border border-black/20"
35
+ style={{ backgroundColor: def.color }}
36
+ />
37
+ {item!.count > 1 && (
38
+ <span className="absolute bottom-0 right-0.5 text-[8px] sm:text-[10px] text-white font-bold"
39
+ style={{ textShadow: '1px 1px 1px rgba(0,0,0,0.9)' }}>
40
+ {item!.count}
41
+ </span>
42
+ )}
43
+ </>
44
+ )}
45
+ <span className="absolute -bottom-3.5 text-[7px] sm:text-[9px] text-gray-500">
46
+ {i + 1}
47
+ </span>
48
+ </div>
49
+ )
50
+ })}
51
+ </div>
52
+ )
53
+ }