chromatic-lattice/src/features/trees/Tree.vue

106 lines
2.6 KiB
Vue
Raw Normal View History

2022-01-14 04:25:47 +00:00
<template>
<span class="row" v-for="(row, index) in unref(nodes)" :key="index" v-bind="$attrs">
2022-01-25 04:25:34 +00:00
<TreeNode
v-for="(node, nodeIndex) in row"
:key="nodeIndex"
v-bind="gatherNodeProps(node)"
2022-01-25 04:25:34 +00:00
:force-tooltip="node.forceTooltip"
/>
2022-01-14 04:25:47 +00:00
</span>
<span class="left-side-nodes" v-if="unref(leftSideNodes)">
2022-01-14 04:25:47 +00:00
<TreeNode
v-for="(node, nodeIndex) in unref(leftSideNodes)"
2022-01-14 04:25:47 +00:00
:key="nodeIndex"
v-bind="gatherNodeProps(node)"
2022-01-25 04:25:34 +00:00
:force-tooltip="node.forceTooltip"
2022-01-14 04:25:47 +00:00
small
/>
</span>
<span class="side-nodes" v-if="unref(rightSideNodes)">
2022-01-14 04:25:47 +00:00
<TreeNode
v-for="(node, nodeIndex) in unref(rightSideNodes)"
2022-01-14 04:25:47 +00:00
:key="nodeIndex"
v-bind="gatherNodeProps(node)"
2022-01-25 04:25:34 +00:00
:force-tooltip="node.forceTooltip"
2022-01-14 04:25:47 +00:00
small
/>
</span>
</template>
2022-01-25 04:23:30 +00:00
<script lang="ts">
import "@/components/common/table.css";
2022-02-27 22:04:56 +00:00
import { GenericTreeNode } from "@/features/trees/tree";
import { processedPropType } from "@/util/vue";
import { defineComponent, unref } from "vue";
2022-01-14 04:25:47 +00:00
import TreeNode from "./TreeNode.vue";
2022-01-25 04:25:34 +00:00
export default defineComponent({
props: {
nodes: {
type: processedPropType<GenericTreeNode[][]>(Array),
2022-01-25 04:25:34 +00:00
required: true
},
leftSideNodes: processedPropType<GenericTreeNode[]>(Array),
rightSideNodes: processedPropType<GenericTreeNode[]>(Array)
2022-01-25 04:25:34 +00:00
},
components: { TreeNode },
2022-01-25 04:25:34 +00:00
setup() {
function gatherNodeProps(node: GenericTreeNode) {
const {
display,
visibility,
style,
classes,
tooltip,
onClick,
onHold,
color,
glowColor,
forceTooltip,
canClick,
mark,
id
} = node;
return {
display,
visibility,
style,
classes,
tooltip,
onClick,
onHold,
color,
glowColor,
forceTooltip,
canClick,
mark,
id
};
}
return {
gatherNodeProps,
unref
};
2022-01-25 04:25:34 +00:00
}
2022-01-25 04:23:30 +00:00
});
2022-01-14 04:25:47 +00:00
</script>
<style scoped>
.row {
margin: 50px auto;
}
.left-side-nodes {
position: absolute;
left: 15px;
top: 65px;
}
.side-nodes {
position: absolute;
right: 15px;
top: 65px;
}
</style>