From 96a8a5ed5b22b78368e25209059866915256cc56 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Tue, 10 May 2022 11:20:42 +1000 Subject: Enable display of active-root with overflow --- src/components/AncestryBar.vue | 10 ++++----- src/components/Tile.vue | 46 +++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 19 deletions(-) (limited to 'src/components') diff --git a/src/components/AncestryBar.vue b/src/components/AncestryBar.vue index a156a96..ca865e9 100644 --- a/src/components/AncestryBar.vue +++ b/src/components/AncestryBar.vue @@ -24,7 +24,7 @@ export default defineComponent({ }, tileSz(){ return (this.wideArea ? this.dims[1] : this.dims[0]) - - (this.uiOpts.ancestryTileMargin * 2) - this.uiOpts.ancestryBarScrollGap; + (this.uiOpts.ancestryTileMargin * 2) - this.uiOpts.scrollGap; }, usedNodes(){ // Childless versions of 'nodes' used to parameterise return this.nodes.map(n => { @@ -39,10 +39,10 @@ export default defineComponent({ return len > (this.wideArea ? this.dims[0] : this.dims[1]); }, width(){ - return this.dims[0] + (this.wideArea || this.overflowing ? 0 : -this.uiOpts.ancestryBarScrollGap); + return this.dims[0] + (this.wideArea || this.overflowing ? 0 : -this.uiOpts.scrollGap); }, height(){ - return this.dims[1] + (!this.wideArea || this.overflowing ? 0 : -this.uiOpts.ancestryBarScrollGap); + return this.dims[1] + (!this.wideArea || this.overflowing ? 0 : -this.uiOpts.scrollGap); }, styles(): Record { return { @@ -54,8 +54,8 @@ export default defineComponent({ overflowX: this.wideArea ? 'auto' : 'hidden', overflowY: this.wideArea ? 'hidden' : 'auto', // Extra padding for scrollbar inclusion - paddingRight: (this.overflowing && !this.wideArea ? this.uiOpts.ancestryBarScrollGap : 0) + 'px', - paddingBottom: (this.overflowing && this.wideArea ? this.uiOpts.ancestryBarScrollGap : 0) + 'px', + paddingRight: (this.overflowing && !this.wideArea ? this.uiOpts.scrollGap : 0) + 'px', + paddingBottom: (this.overflowing && this.wideArea ? this.uiOpts.scrollGap : 0) + 'px', // For child layout display: 'flex', flexDirection: this.wideArea ? 'row' : 'column', diff --git a/src/components/Tile.vue b/src/components/Tile.vue index 429973f..dc9c87d 100644 --- a/src/components/Tile.vue +++ b/src/components/Tile.vue @@ -15,8 +15,11 @@ export default defineComponent({ // Options lytOpts: {type: Object as PropType, required: true}, uiOpts: {type: Object, required: true}, - // For a leaf node, prevents usage of absolute positioning (used by AncestryBar) + // Other nonAbsPos: {type: Boolean, default: false}, + // For a leaf node, prevents usage of absolute positioning (used by AncestryBar) + overflownDim: {type: Number, default: 0}, + // For a non-leaf node, display with overflow within area of this height }, data(){ return { @@ -46,6 +49,9 @@ export default defineComponent({ displayName(): string { return capitalizeWords(this.tolNode.commonName || this.layoutNode.name); }, + isOverflownRoot(): boolean { + return this.overflownDim > 0 && !this.layoutNode.hidden && this.layoutNode.children.length > 0; + }, // Style related nonleafBgColor(): string { let colorArray = this.uiOpts.nonleafBgColors; @@ -68,16 +74,6 @@ export default defineComponent({ width: this.layoutNode.dims[0] + 'px', height: this.layoutNode.dims[1] + 'px', visibility: 'visible', - }; - if (this.layoutNode.hidden){ - layoutStyles.left = layoutStyles.top = layoutStyles.width = layoutStyles.height = '0'; - layoutStyles.visibility = 'hidden'; - } - if (this.nonAbsPos){ - layoutStyles.position = 'static'; - } - return { - ...layoutStyles, // Transition related transitionDuration: this.uiOpts.tileChgDuration + 'ms', transitionProperty: 'left, top, width, height, visibility', @@ -88,6 +84,19 @@ export default defineComponent({ '--nonleafBgColor': this.nonleafBgColor, '--tileSpacing': this.lytOpts.tileSpacing + 'px', }; + if (this.layoutNode.hidden){ + layoutStyles.left = layoutStyles.top = layoutStyles.width = layoutStyles.height = '0'; + layoutStyles.visibility = 'hidden'; + } + if (this.nonAbsPos){ + layoutStyles.position = 'static'; + } + if (this.isOverflownRoot){ + layoutStyles.width = (this.layoutNode.dims[0] + this.uiOpts.scrollGap) + 'px'; + layoutStyles.height = this.overflownDim + 'px'; + layoutStyles.overflow = 'scroll'; + } + return layoutStyles; }, leafStyles(): Record { return { @@ -128,11 +137,20 @@ export default defineComponent({ `${borderR} ${borderR} ${borderR} 0` : `${borderR} 0 ${borderR} ${borderR}`; } - return { + let styles = { + position: 'static', + width: '100%', + height: '100%', backgroundColor: this.nonleafBgColor, borderRadius: borderR, boxShadow: this.boxShadow, }; + if (this.isOverflownRoot){ + styles.position = 'absolute'; + styles.width = this.layoutNode.dims[0] + 'px'; + styles.height = this.layoutNode.dims[1] + 'px'; + } + return styles; }, nonleafHeaderStyles(): Record { let borderR = this.uiOpts.borderRadius + 'px'; @@ -327,7 +345,7 @@ export default defineComponent({ class="self-end text-white/10 hover:text-white hover:cursor-pointer" @click.stop="onInfoIconClick" @mousedown.stop @mouseup.stop/> -
+

{{displayName}}

@@ -345,7 +363,7 @@ export default defineComponent({
-- cgit v1.2.3