HumanBreak/src/ui/toolbar.vue

112 lines
2.1 KiB
Vue
Raw Normal View History

2023-12-17 18:11:58 +08:00
<template>
<Box
2023-12-18 17:10:28 +08:00
class="toolbar-container"
2023-12-17 18:11:58 +08:00
:dragable="true"
:resizable="true"
v-model:left="box.x"
v-model:top="box.y"
v-model:height="box.height"
v-model:width="box.width"
>
<div class="toolbar">
2023-12-18 17:10:28 +08:00
<div
class="toolbar-item"
v-for="item of bar.items"
@click.stop="click"
>
2023-12-17 18:11:58 +08:00
<component
:is="(item.com as any)"
:item="item"
:toolbar="bar"
></component>
</div>
</div>
</Box>
</template>
<script lang="ts" setup>
import Box from '@/components/box.vue';
import { CustomToolbar } from '@/core/main/custom/toolbar';
import { GameUi } from '@/core/main/custom/ui';
import { reactive, watch } from 'vue';
interface BoxData {
x: number;
y: number;
width: number;
height: number;
}
const props = defineProps<{
num: number;
ui: GameUi;
bar: CustomToolbar;
}>();
const bar = props.bar;
const box = reactive<BoxData>({
x: bar.x,
y: bar.y,
width: bar.width,
height: bar.height
});
watch(box, ({ x, y, width, height }) => {
bar.x = x;
bar.y = y;
bar.width = width;
bar.height = height;
});
2023-12-18 17:10:28 +08:00
function click() {
// pass
}
2023-12-17 18:11:58 +08:00
</script>
<style lang="less" scoped>
2023-12-18 17:10:28 +08:00
.toolbar-container {
background-color: #0009;
padding: 5px;
}
2023-12-17 18:11:58 +08:00
.toolbar {
display: flex;
flex-direction: row;
2023-12-18 17:10:28 +08:00
flex-wrap: wrap;
align-items: center;
font-size: 150%;
}
.toolbar-item {
display: flex;
margin: 5px;
min-width: 50px;
height: 50px;
cursor: pointer;
background-color: #222;
border: 1px solid #ddd8;
justify-content: center;
align-items: center;
transition: all 0.1s linear;
}
.toolbar-item::v-deep(> *) {
height: 50px;
min-width: 50px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
text-overflow: clip;
text-wrap: nowrap;
}
.toolbar-item:hover {
background-color: #444;
}
.toolbar-item:active {
background-color: #333;
2023-12-17 18:11:58 +08:00
}
</style>