From 4ae50f4abef0241d6517645ada0b28ed8d1103ee Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sun, 13 Mar 2022 21:06:46 +1100
Subject: Merge TreeNode into FormatNode

---
 src/components/Tile.vue | 54 +++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

(limited to 'src/components/Tile.vue')

diff --git a/src/components/Tile.vue b/src/components/Tile.vue
index 1790dc3..054bfed 100644
--- a/src/components/Tile.vue
+++ b/src/components/Tile.vue
@@ -1,6 +1,6 @@
 <script lang="ts">
 import {defineComponent, PropType} from 'vue';
-import {TreeNode} from '../types';
+import {LayoutNode} from '../types';
 
 const TRANSITION_DURATION = 300;
 export default defineComponent({
@@ -13,31 +13,31 @@ export default defineComponent({
 		}
 	},
 	props: {
-		tree: {type: Object as PropType<TreeNode>, required: true},
+		layoutNode: {type: Object as PropType<LayoutNode>, required: true},
 	},
 	computed: {
-		name(){return this.tree.tolNode.name.replaceAll('\'', '\\\'')}
+		name(){return this.layoutNode.tolNode.name.replaceAll('\'', '\\\'')}
 	},
 	methods: {
 		onImgClick(){
-			this.$emit('tile-clicked', [this.tree]);
+			this.$emit('tile-clicked', [this.layoutNode]);
 			//increase z-index and hide overflow during transition
 			this.zIdx = 1;
 			this.overFlow = 'hidden';
 			setTimeout(() => {this.zIdx = 0; this.overFlow = 'visible'}, this.transitionDuration);
 		},
-		onInnerTileClicked(nodeList: TreeNode[]){
-			this.$emit('tile-clicked', [...nodeList, this.tree]);
+		onInnerTileClicked(nodeList: LayoutNode[]){
+			this.$emit('tile-clicked', [...nodeList, this.layoutNode]);
 		},
 		onHeaderClick(){
-			this.$emit('header-clicked', [this.tree]);
+			this.$emit('header-clicked', [this.layoutNode]);
 			//increase z-index and hide overflow during transition
 			this.zIdx = 1;
 			this.overFlow = 'hidden';
 			setTimeout(() => {this.zIdx = 0; this.overFlow = 'visible'}, this.transitionDuration);
 		},
-		onInnerHeaderClicked(nodeList: TreeNode[]){
-			this.$emit('header-clicked', [...nodeList, this.tree]);
+		onInnerHeaderClicked(nodeList: LayoutNode[]){
+			this.$emit('header-clicked', [...nodeList, this.layoutNode]);
 		}
 	}
 })
@@ -46,36 +46,38 @@ export default defineComponent({
 <template>
 <div
 	:style="{position: 'absolute',
-		left: tree.x+'px', top: tree.y+'px', width: tree.w+'px', height: tree.h+'px',
+		left: layoutNode.x+'px', top: layoutNode.y+'px', width: layoutNode.w+'px', height: layoutNode.h+'px',
 		zIndex: zIdx, overflow: overFlow, transitionDuration: transitionDuration+'ms'}"
 	class="transition-[left,top,width,height] ease-out border border-stone-900 bg-white">
-	<div v-if="tree.children.length == 0"
+	<div v-if="layoutNode.children.length == 0"
 		:style="{backgroundImage: 'url(\'/img/' + name + '.jpg\')',
-			opacity: (tree.tolNode.children.length > 0 ? 1 : 0.7)}"
+			opacity: (layoutNode.tolNode.children.length > 0 ? 1 : 0.7)}"
 		class="hover:cursor-pointer w-full h-full bg-cover" @click="onImgClick"
 		/>
 	<div v-else>
-		<div v-if="(tree.headerSz && !tree.sepSweptArea) || (tree.sepSweptArea && tree.sepSweptArea.sweptLeft)"
-			:style="{height: tree.headerSz+'px'}"
+		<div
+			v-if="(layoutNode.headerSz && !layoutNode.sepSweptArea) || 
+				(layoutNode.sepSweptArea && layoutNode.sepSweptArea.sweptLeft)"
+			:style="{height: layoutNode.headerSz+'px'}"
 			class="text-center hover:cursor-pointer bg-stone-300" @click="onHeaderClick">
-			{{tree.tolNode.name}}
+			{{layoutNode.tolNode.name}}
 		</div>
-		<div v-if="tree.sepSweptArea"
-			:style="{position: 'absolute', left: tree.sepSweptArea.x+'px', top: tree.sepSweptArea.y+'px',
-				width: (tree.sepSweptArea.w +
-					(tree.sepSweptArea.sweptLeft ? tree.sepSweptArea.tileSpacing+1 : 0))+'px',
-				height: (tree.sepSweptArea.h +
-					(tree.sepSweptArea.sweptLeft ? 0 : tree.sepSweptArea.tileSpacing+1))+'px',
-				borderRightColor: (tree.sepSweptArea.sweptLeft ? 'white' : 'currentColor'),
-				borderBottomColor: (tree.sepSweptArea.sweptLeft ? 'currentColor' : 'white'),
+		<div v-if="layoutNode.sepSweptArea"
+			:style="{position: 'absolute', left: layoutNode.sepSweptArea.x+'px', top: layoutNode.sepSweptArea.y+'px',
+				width: (layoutNode.sepSweptArea.w +
+					(layoutNode.sepSweptArea.sweptLeft ? layoutNode.sepSweptArea.tileSpacing+1 : 0))+'px',
+				height: (layoutNode.sepSweptArea.h +
+					(layoutNode.sepSweptArea.sweptLeft ? 0 : layoutNode.sepSweptArea.tileSpacing+1))+'px',
+				borderRightColor: (layoutNode.sepSweptArea.sweptLeft ? 'white' : 'currentColor'),
+				borderBottomColor: (layoutNode.sepSweptArea.sweptLeft ? 'currentColor' : 'white'),
 				transitionDuration: transitionDuration+'ms'}"
 			class="transition-[left,top,width,height] ease-out border border-stone-900 bg-white">
-			<div v-if="!tree.sepSweptArea.sweptLeft" :style="{height: tree.headerSz+'px'}"
+			<div v-if="!layoutNode.sepSweptArea.sweptLeft" :style="{height: layoutNode.headerSz+'px'}"
 				class="text-center hover:cursor-pointer bg-stone-300" @click="onHeaderClick">
-				{{tree.tolNode.name}}
+				{{layoutNode.tolNode.name}}
 			</div>
 		</div>
-		<tile v-for="child in tree.children" :key="child.tolNode.name" :tree="child"
+		<tile v-for="child in layoutNode.children" :key="child.tolNode.name" :layoutNode="child"
 			@tile-clicked="onInnerTileClicked" @header-clicked="onInnerHeaderClicked"
 			></tile>
 	</div>
-- 
cgit v1.2.3

