improve NodeBook layout

This commit is contained in:
axolotle
2021-08-01 14:43:28 +02:00
parent 507b447b5f
commit fab868c7ed
4 changed files with 121 additions and 125 deletions
+42 -13
View File
@@ -2,16 +2,18 @@
<article
class="node-view"
:class="['node-view-' + mode, 'node-view-' + type, 'node-view-' + nodeVariant, { 'preview': preview }]"
:style="`--scroll-top: ${scrollValue}px; --h-height: ${h}px;`"
>
<div v-if="!loading" class="node-view-wrapper" :id="`node-${mode}-${node.id}`">
<component
ref="header"
:is="'node-view-header-' + nodeType"
v-bind="{ node, mode, showOrigin }"
class="node-view-header"
:class="{ scrolling }"
:class="{ scrolling: scrollValue }"
/>
<node-view-body v-bind="{ node, type: nodeType, mode }" :class="{ scrolling }"/>
<node-view-body v-bind="{ node, type: nodeType, mode }" :class="{ scrolling: scrollValue }"/>
<node-view-footer
v-bind="{ node, mode, type: nodeType, preview, showOrigin }"
@@ -66,7 +68,7 @@ export default {
data () {
return {
scrolling: false
scrollValue: 0
}
},
@@ -87,13 +89,25 @@ export default {
},
methods: {
onScroll ({ target }) {
const prev = this.scrolling
this.scrolling = target.scrollTop !== 0
if (this.scrolling && !prev) {
this.$el.scrollTo(0, 1)
onScroll ({ target = this.$el }, fix = false) {
const prev = this.scrollValue
this.scrollValue = target.scrollTop
if (this.scrollValue && !prev) {
const h = this.$refs.header.$el.getBoundingClientRect().height
this.$nextTick(() => {
this.h = h - this.$refs.header.$el.getBoundingClientRect().height
})
}
}
if (fix) {
setTimeout(() => {
if (this.scrollValue > 0 && target.scrollTop === 0) {
target.scrollTop = this.scrollValue
}
}, 50)
}
},
},
mounted () {
@@ -180,7 +194,11 @@ export default {
padding: $node-view-spacer-sm-y $node-view-spacer-sm-x 0;
@include media-breakpoint-up($size-bp) {
padding: $node-view-spacer-y $node-view-spacer-x 0;
padding: $node-view-spacer-y $node-view-spacer-x $node-view-spacer-y * .75;
h4 {
margin-bottom: 0;
}
}
@include media-breakpoint-up($layout-bp) {
@@ -189,21 +207,32 @@ export default {
z-index: 1;
&-ref.scrolling {
h4 {
font-size: 1.2rem;
}
.edition {
font-size: 0.8rem;
}
.btn-url {
width: 20px;
height: 20px;
}
}
}
}
&-view &-body {
@include media-breakpoint-up($layout-bp) {
&-ref.scrolling {
padding-top: 4rem;
max-height: 100%;
&.scrolling {
clip-path: inset(var(--scroll-top) 0px 0px 0px);
&.node-view-body-ref {
padding-top: var(--h-height);
}
}
}
}
+3 -14
View File
@@ -13,7 +13,7 @@
</div>
</h4>
<button-close v-if="mode === 'view'" @click="onClose()" :style="`--offset: ${offset}px;`" />
<button-close v-if="mode === 'view'" @click="onClose()" />
</div>
</div>
</template>
@@ -47,12 +47,6 @@ export default {
}
},
data () {
return {
offset: 0
}
},
methods: {
trim,
toCommaList,
@@ -60,12 +54,6 @@ export default {
onClose () {
this.$parent.$emit('close-node', this.node.id)
}
},
mounted () {
const parentContH = this.$el.parentElement.offsetWidth
const parentH = this.$el.parentElement.parentElement.offsetWidth
this.offset = (parentH - parentContH) * -1
}
}
</script>
@@ -115,8 +103,9 @@ export default {
position: relative;
display: flex;
float: right;
@include media-breakpoint-up($layout-bp) {
right: var(--offset);
right: -13px;
}
}
}
+2 -14
View File
@@ -3,7 +3,7 @@
class="node-view-header-ref" :class="'node-view-header-' + mode"
>
<div class="node-view-header-wrapper w-100">
<div class="nav-container" :style="`--offset: ${offset}px;`">
<div class="nav-container">
<node-view-child-list
v-if="mode === 'view' && node.children && node.children.length"
:children="node.children"
@@ -39,12 +39,6 @@ export default {
mode: { type: String, required: true }
},
data () {
return {
offset: 0
}
},
methods: {
trim,
toCommaList,
@@ -52,12 +46,6 @@ export default {
onClose () {
this.$parent.$emit('close-node', this.node.id)
}
},
mounted () {
const parentContH = this.$el.parentElement.offsetWidth
const parentH = this.$el.parentElement.parentElement.offsetWidth
this.offset = (parentH - parentContH) * -1
}
}
</script>
@@ -73,7 +61,7 @@ export default {
display: flex;
float: right;
@include media-breakpoint-up($layout-bp) {
right: var(--offset);
right: -13px;
}
}