ui: hotbar

This commit is contained in:
cha0s 2024-06-13 21:54:32 -05:00
parent c1758ef3d6
commit 162a1f9b8a
4 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,6 @@
.dom { .dom {
display: flex;
flex-direction: column;
height: calc(100% / var(--scale)); height: calc(100% / var(--scale));
position: absolute; position: absolute;
top: 0; top: 0;

View File

@ -6,7 +6,7 @@ import Slot from './slot.jsx';
*/ */
export default function Hotbar({active, onActivate, slots}) { export default function Hotbar({active, onActivate, slots}) {
const Slots = slots.map((slot, i) => ( const Slots = slots.map((slot, i) => (
<div <button
className={ className={
[styles.slotWrapper, active === i && styles.active] [styles.slotWrapper, active === i && styles.active]
.filter(Boolean).join(' ') .filter(Boolean).join(' ')
@ -15,7 +15,7 @@ export default function Hotbar({active, onActivate, slots}) {
key={i} key={i}
> >
<Slot {...slot} /> <Slot {...slot} />
</div> </button>
)); ));
return ( return (
<div <div

View File

@ -1,22 +1,32 @@
.hotbar { .hotbar {
align-self: center;
--border: calc(var(--unit) * 3px); --border: calc(var(--unit) * 3px);
background-color: rgba(0, 0, 0, 0.2); background-color: rgba(0, 0, 0, 0.2);
border: var(--border) solid #444444; border: var(--border) solid #444444;
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
left: calc(var(--unit) * 225px);
line-height: 0; line-height: 0;
position: absolute; position: absolute;
top: calc(var(--unit) * 25px); top: calc(var(--unit) * 25px);
} }
.slotWrapper { .slotWrapper {
background-color: transparent;
border: var(--border) solid #999999; border: var(--border) solid #999999;
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
line-height: 0; line-height: 0;
padding: 0;
&.active + .slotWrapper {
border-left: none;
}
&:not(:last-child) {
border-right: none;
}
&.active { &.active {
border-right: var(--border) solid #999999;
border-color: yellow; border-color: yellow;
} }

View File

@ -58,7 +58,7 @@ export default function Ui({disconnected}) {
</style> </style>
<Pixi /> <Pixi />
<Dom> <Dom>
<HotBar active={0} slots={Array(10).fill(0).map(() => {})} /> <HotBar active={1} slots={Array(10).fill(0).map(() => {})} />
{showDisconnected && ( {showDisconnected && (
<Disconnected /> <Disconnected />
)} )}