mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-22 00:21:34 +00:00
attempt to add components display
This commit is contained in:
parent
fc653e6e5a
commit
096fea964a
2 changed files with 41 additions and 8 deletions
|
@ -1,5 +1,22 @@
|
|||
<template>
|
||||
<div ref="element" style="factory" />
|
||||
<div>
|
||||
<div>Info on components</div>
|
||||
<div class="componentDisp">
|
||||
<div class="componentSelect">
|
||||
<div class="i">
|
||||
<h2>Components!</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="element"
|
||||
class="factoryDisp"
|
||||
@click="e => $emit('click', e)"
|
||||
@mousemove="e => $emit('mouseMove', e)"
|
||||
@mouseenter="e => $emit('mouseEnter', e)"
|
||||
@mouseleave="e => $emit('mouseLeave', e)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type { Application } from "@pixi/app";
|
||||
|
@ -10,6 +27,13 @@ const element = shallowRef<HTMLElement | null>(null);
|
|||
const props = defineProps<{
|
||||
application: Application;
|
||||
}>();
|
||||
|
||||
defineEmits<{
|
||||
(e: "mouseMove", i: MouseEvent): void;
|
||||
(e: "mouseEnter", i: MouseEvent): void;
|
||||
(e: "mouseLeave", i: MouseEvent): void;
|
||||
(e: "click", i: MouseEvent): void;
|
||||
}>();
|
||||
onMounted(() => {
|
||||
if (element.value !== null) {
|
||||
element.value?.append(props.application.view);
|
||||
|
@ -19,8 +43,17 @@ onMounted(() => {
|
|||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
.factory {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.componentDisp {
|
||||
display: flex;
|
||||
border: 2px solid grey;
|
||||
align-items: stretch;
|
||||
}
|
||||
.componentSelect {
|
||||
flex-grow: 1;
|
||||
border: 2px solid green;
|
||||
}
|
||||
.factoryDisp {
|
||||
flex-grow: 1;
|
||||
border: 2px solid green;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -44,7 +44,7 @@ function roundDownTo(num: number, multiple: number) {
|
|||
return Math.floor(num / multiple) * multiple;
|
||||
}
|
||||
function getRelativeCoords(e: MouseEvent) {
|
||||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
||||
const rect = (e.target as HTMLElement).getBoundingClientRect();
|
||||
return {
|
||||
x: e.clientX - rect.left,
|
||||
y: e.clientY - rect.top
|
||||
|
@ -125,9 +125,9 @@ const factory = createLayer(id, () => {
|
|||
body: () => (
|
||||
<Factory
|
||||
application={app}
|
||||
onMousemove={onMouseMove}
|
||||
onMouseenter={onMouseEnter}
|
||||
onMouseleave={onMouseLeave}
|
||||
onMouseMove={onMouseMove}
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
onClick={onClick}
|
||||
/>
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue