2022-01-13 22:25:47 -06:00
|
|
|
<template>
|
2022-04-23 15:23:38 -05:00
|
|
|
<div
|
2023-02-15 20:00:36 -06:00
|
|
|
v-if="isVisible(visibility)"
|
|
|
|
:style="{ visibility: isHidden(visibility) ? 'hidden' : undefined }"
|
2022-01-13 22:25:47 -06:00
|
|
|
:class="{
|
|
|
|
treeNode: true,
|
2022-01-24 22:25:34 -06:00
|
|
|
can: unref(canClick),
|
|
|
|
...unref(classes)
|
2022-01-13 22:25:47 -06:00
|
|
|
}"
|
2022-04-27 08:20:09 -05:00
|
|
|
@click="onClick"
|
|
|
|
@mousedown="start"
|
|
|
|
@mouseleave="stop"
|
|
|
|
@mouseup="stop"
|
2022-05-02 21:10:18 -05:00
|
|
|
@touchstart.passive="start"
|
|
|
|
@touchend.passive="stop"
|
|
|
|
@touchcancel.passive="stop"
|
2022-01-13 22:25:47 -06:00
|
|
|
>
|
2022-03-27 10:25:14 -05:00
|
|
|
<div
|
2022-01-13 22:25:47 -06:00
|
|
|
:style="[
|
|
|
|
{
|
2022-01-24 22:25:34 -06:00
|
|
|
backgroundColor: unref(color),
|
|
|
|
boxShadow: `-4px -4px 4px rgba(0, 0, 0, 0.25) inset, 0 0 20px ${unref(
|
|
|
|
glowColor
|
|
|
|
)}`
|
2022-01-13 22:25:47 -06:00
|
|
|
},
|
2022-01-24 22:25:34 -06:00
|
|
|
unref(style) ?? []
|
2022-01-13 22:25:47 -06:00
|
|
|
]"
|
|
|
|
>
|
2022-02-27 13:49:34 -06:00
|
|
|
<component :is="unref(comp)" />
|
2022-03-27 10:25:14 -05:00
|
|
|
</div>
|
2022-01-24 22:25:34 -06:00
|
|
|
<MarkNode :mark="unref(mark)" />
|
2022-03-20 13:57:45 -05:00
|
|
|
<Node :id="id" />
|
2022-04-23 15:23:38 -05:00
|
|
|
</div>
|
2022-01-13 22:25:47 -06:00
|
|
|
</template>
|
|
|
|
|
2022-01-24 22:25:34 -06:00
|
|
|
<script lang="ts">
|
2022-03-03 21:39:48 -06:00
|
|
|
import MarkNode from "components/MarkNode.vue";
|
2022-06-26 19:17:22 -05:00
|
|
|
import Node from "components/Node.vue";
|
|
|
|
import type { CoercableComponent, StyleValue } from "features/feature";
|
2023-02-15 20:00:36 -06:00
|
|
|
import { isHidden, isVisible, Visibility } from "features/feature";
|
2022-01-24 22:25:34 -06:00
|
|
|
import {
|
|
|
|
computeOptionalComponent,
|
|
|
|
isCoercableComponent,
|
2022-02-27 13:49:34 -06:00
|
|
|
processedPropType,
|
2022-04-23 15:23:38 -05:00
|
|
|
setupHoldToClick
|
2022-03-03 21:39:48 -06:00
|
|
|
} from "util/vue";
|
2022-06-26 19:17:22 -05:00
|
|
|
import type { PropType } from "vue";
|
|
|
|
import { defineComponent, toRefs, unref } from "vue";
|
2022-01-24 22:25:34 -06:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
2022-02-27 13:49:34 -06:00
|
|
|
display: processedPropType<CoercableComponent>(Object, String, Function),
|
2022-01-24 22:25:34 -06:00
|
|
|
visibility: {
|
2023-02-15 20:00:36 -06:00
|
|
|
type: processedPropType<Visibility | boolean>(Number, Boolean),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 13:49:34 -06:00
|
|
|
style: processedPropType<StyleValue>(String, Object, Array),
|
|
|
|
classes: processedPropType<Record<string, boolean>>(Object),
|
2022-03-27 00:14:35 -05:00
|
|
|
onClick: Function as PropType<(e?: MouseEvent | TouchEvent) => void>,
|
2022-01-24 22:25:34 -06:00
|
|
|
onHold: Function as PropType<VoidFunction>,
|
2022-02-27 13:49:34 -06:00
|
|
|
color: processedPropType<string>(String),
|
|
|
|
glowColor: processedPropType<string>(String),
|
2022-01-24 22:25:34 -06:00
|
|
|
canClick: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 13:49:34 -06:00
|
|
|
mark: processedPropType<boolean | string>(Boolean, String),
|
2022-01-24 22:25:34 -06:00
|
|
|
id: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: String,
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
2022-04-23 14:28:48 -05:00
|
|
|
}
|
2022-02-27 13:49:34 -06:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
MarkNode,
|
2022-03-20 13:57:45 -05:00
|
|
|
Node
|
2022-01-24 22:25:34 -06:00
|
|
|
},
|
|
|
|
setup(props) {
|
2022-04-23 15:23:38 -05:00
|
|
|
const { onClick, onHold, display } = toRefs(props);
|
2022-01-13 22:25:47 -06:00
|
|
|
|
2022-02-27 13:49:34 -06:00
|
|
|
const comp = computeOptionalComponent(display);
|
2022-01-24 22:25:34 -06:00
|
|
|
|
|
|
|
const { start, stop } = setupHoldToClick(onClick, onHold);
|
2022-01-13 22:25:47 -06:00
|
|
|
|
2022-01-24 22:25:34 -06:00
|
|
|
return {
|
|
|
|
start,
|
|
|
|
stop,
|
2022-02-27 13:49:34 -06:00
|
|
|
comp,
|
2022-01-24 22:25:34 -06:00
|
|
|
unref,
|
|
|
|
Visibility,
|
2023-02-15 20:00:36 -06:00
|
|
|
isCoercableComponent,
|
|
|
|
isVisible,
|
|
|
|
isHidden
|
2022-01-24 22:25:34 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2022-01-13 22:25:47 -06:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.treeNode {
|
|
|
|
height: 100px;
|
|
|
|
width: 100px;
|
|
|
|
border-radius: 50%;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0 10px 0 10px;
|
|
|
|
}
|
|
|
|
|
2022-03-27 10:25:14 -05:00
|
|
|
.treeNode > *:first-child {
|
2022-01-13 22:25:47 -06:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border: 2px solid rgba(0, 0, 0, 0.125);
|
|
|
|
border-radius: inherit;
|
|
|
|
font-size: 40px;
|
|
|
|
color: rgba(0, 0, 0, 0.5);
|
|
|
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
|
|
|
|
box-shadow: -4px -4px 4px rgba(0, 0, 0, 0.25) inset, 0px 0px 20px var(--background);
|
2022-03-27 10:25:14 -05:00
|
|
|
display: flex;
|
2022-01-13 22:25:47 -06:00
|
|
|
}
|
2022-04-24 01:03:25 -05:00
|
|
|
|
|
|
|
.treeNode > *:first-child > * {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2022-01-13 22:25:47 -06:00
|
|
|
</style>
|