improve NodeView components and style

This commit is contained in:
axolotle
2021-06-24 16:13:31 +02:00
parent f4d81dffcf
commit a25123f4f9
13 changed files with 54 additions and 71 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ $popover-body-color: $white;
$popover-body-padding-y: 18px; $popover-body-padding-y: 18px;
$popover-body-padding-x: 18px; $popover-body-padding-x: 18px;
$popover-arrow-width: 0; $popover-arrow-width: 2rem;
$popover-arrow-height: 2rem; $popover-arrow-height: 2rem;
$popover-arrow-outer-color: null; $popover-arrow-outer-color: null;
@@ -30,6 +30,14 @@ a:hover {
.popover { .popover {
font-family: $font-family-text; font-family: $font-family-text;
.arrow {
visibility: hidden;
}
&-body {
color: inherit;
}
} }
.btn { .btn {
+3 -2
View File
@@ -23,12 +23,13 @@ export default {
props: { props: {
variant: { type: String, required: true }, variant: { type: String, required: true },
active: { type: Boolean, default: false } active: { type: Boolean, default: false },
hovered: { type: Boolean, default: false }
}, },
data () { data () {
return { return {
show: false show: this.hovered
} }
}, },
-17
View File
@@ -14,7 +14,6 @@
> >
<node-view-child-list <node-view-child-list
:children="parent.children" :children="parent.children"
:parent-id="parent.id"
smartphone smartphone
@open-child="$emit('open-node', { parentId: parent.id, ...$event })" @open-child="$emit('open-node', { parentId: parent.id, ...$event })"
/> />
@@ -69,12 +68,6 @@ export default {
nodes: { type: Array, required: true } nodes: { type: Array, required: true }
}, },
data () {
return {
height: undefined
}
},
computed: { computed: {
stackHeight () { stackHeight () {
return Math.min(150 / (this.nodes.length - 1), 75) return Math.min(150 / (this.nodes.length - 1), 75)
@@ -82,18 +75,9 @@ export default {
}, },
methods: { methods: {
updateSize () {
this.height = this.$el.getBoundingClientRect().height
},
getChildrenStackHeight (childrenLen) { getChildrenStackHeight (childrenLen) {
return this.stackHeight / childrenLen || this.stackHeight return this.stackHeight / childrenLen || this.stackHeight
} }
},
mounted () {
window.addEventListener('resize', () => this.updateSize())
this.updateSize()
} }
} }
</script> </script>
@@ -101,7 +85,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.node-book { .node-book {
min-height: 100%; min-height: 100%;
// top: -100%;
@include media-breakpoint-up($layout-bp) { @include media-breakpoint-up($layout-bp) {
height: 100%; height: 100%;
+5 -8
View File
@@ -86,11 +86,12 @@ export default {
// ╰─╴╵ ╵╵ ╰└─╯ // ╰─╴╵ ╵╵ ╰└─╯
&-card { &-card {
width: $node-card-width; max-width: $node-card-width;
height: $node-card-height; width: 100%;
.node-view-wrapper { &-wrapper {
height: 100%; width: 100%;
max-height: $node-card-height;
overflow: hidden; overflow: hidden;
} }
@@ -101,8 +102,6 @@ export default {
&-card &-header { &-card &-header {
padding: $node-card-spacer-sm-y $node-card-spacer-sm-x 0; padding: $node-card-spacer-sm-y $node-card-spacer-sm-x 0;
position: sticky;
top: 0;
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
padding: $node-card-spacer-y $node-card-spacer-x 0; padding: $node-card-spacer-y $node-card-spacer-x 0;
@@ -111,8 +110,6 @@ export default {
&-card &-footer { &-card &-footer {
padding: $node-card-spacer-sm-y $node-card-spacer-sm-x $node-card-spacer-sm-y * 2; padding: $node-card-spacer-sm-y $node-card-spacer-sm-x $node-card-spacer-sm-y * 2;
position: sticky;
bottom: 0;
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
padding: $node-card-spacer-y $node-card-spacer-x $node-card-spacer-y * 2; padding: $node-card-spacer-y $node-card-spacer-x $node-card-spacer-y * 2;
+2 -5
View File
@@ -37,6 +37,7 @@
</template> </template>
<script> <script>
import { getRelation } from '@/store/utils'
import { NodeViewTitle } from '@/components/nodes' import { NodeViewTitle } from '@/components/nodes'
@@ -74,11 +75,7 @@ export default {
onFootnoteLinkClick (node, popoverBtnId) { onFootnoteLinkClick (node, popoverBtnId) {
this.$root.$emit('bv::hide::popover', popoverBtnId) this.$root.$emit('bv::hide::popover', popoverBtnId)
if (node.parents && node.parents.length) { this.$parent.$emit('open-node', getRelation(node))
this.$parent.$emit('open-node', { parentId: node.parents[0].id, childId: node.id })
} else {
this.$parent.$emit('open-node', { parentId: node.id })
}
} }
}, },
@@ -26,7 +26,6 @@ export default {
props: { props: {
children: { type: Array, required: true }, children: { type: Array, required: true },
parentId: { type: Number, required: true },
smartphone: { type: Boolean, default: false } smartphone: { type: Boolean, default: false }
}, },
+8 -3
View File
@@ -27,7 +27,7 @@
<node-view-title <node-view-title
:node="sibling" :node="sibling"
link edition block link edition block
@open-node="onOpen(sibling.id, 'siblings-' + node.id)" @open-node="onOpenSibling(sibling.id, 'siblings-' + node.id)"
/> />
</li> </li>
</ul> </ul>
@@ -35,16 +35,17 @@
</div> </div>
<div v-if="mode === 'card'"> <div v-if="mode === 'card'">
<b-button @click="onOpen(node.id)" variant="outline-dark">
{{ $t('text.read') }} {{ $t('text.read') }}
</b-button> </b-button>
</div> </div>
<b-button @click="onOpenSelf()" variant="outline-dark">
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { toCommaList } from '@/helpers/common' import { toCommaList } from '@/helpers/common'
import { getRelation } from '@/store/utils'
import { NodeViewTitle } from '@/components/nodes' import { NodeViewTitle } from '@/components/nodes'
@@ -72,9 +73,13 @@ export default {
methods: { methods: {
toCommaList, toCommaList,
onOpen (parentId, popoverBtnId) { onOpenSibling (parentId, popoverBtnId) {
this.$root.$emit('bv::hide::popover', popoverBtnId) this.$root.$emit('bv::hide::popover', popoverBtnId)
this.$parent.$emit('open-node', { parentId }) this.$parent.$emit('open-node', { parentId })
},
onOpenSelf () {
this.$parent.$emit('open-node', getRelation(this.node))
} }
} }
} }
+1 -1
View File
@@ -9,7 +9,7 @@
</div> </div>
<div v-if="mode === 'card' && node.parents && node.parents.length" class="node-view-header-parent"> <div v-if="mode === 'card' && node.parents && node.parents.length" class="node-view-header-parent">
<node-view-title :node="node.parents[0]" edition /> <node-view-title :node="node.parents[0]" edition tag="div" />
</div> </div>
</h4> </h4>
+10 -28
View File
@@ -3,21 +3,15 @@
class="node-view-header-ref" :class="'node-view-header-' + mode" class="node-view-header-ref" :class="'node-view-header-' + mode"
> >
<div class="d-flex w-100"> <div class="d-flex w-100">
<h4 class="mr-auto"> <node-view-title
<strong class="d-block"> :node="node" tag="h4"
{{ toCommaList(node.authors) }}, block edition
</strong> class="mr-auto"
<span v-if="node.preTitle" v-html="trim(node.preTitle) + ', '" /> />
<em v-html="(trim(node.title) || 'pas de titre ital') + ','" />
<div v-if="node.edition" class="edition">
{{ node.edition.map(ed => ed.name).join(' ') }}
</div>
</h4>
<node-view-child-list <node-view-child-list
v-if="mode === 'view'" v-if="mode === 'view'"
:children="node.children" :children="node.children"
:parent-id="node.id"
@open-child="$parent.$emit('open-child', $event)" @open-child="$parent.$emit('open-child', $event)"
/> />
<button-close v-if="mode === 'view'" @click="onClose()" /> <button-close v-if="mode === 'view'" @click="onClose()" />
@@ -27,14 +21,15 @@
<script> <script>
import { trim, toCommaList } from '@/helpers/common' import { trim, toCommaList } from '@/helpers/common'
import { NodeViewChildList } from '@/components/nodes' import { NodeViewChildList, NodeViewTitle } from '@/components/nodes'
export default { export default {
name: 'NodeViewHeaderRef', name: 'NodeViewHeaderRef',
components: { components: {
NodeViewChildList NodeViewChildList,
NodeViewTitle
}, },
props: { props: {
@@ -53,23 +48,10 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss">
.node-view-header { .node-view-header {
&-ref { &-ref {
font: { font-family: $font-family-text;
family: $font-family-text;
size: inherit;
line-height: inherit;
}
h4 {
font-weight: $font-weight-base;
font-size: 32px;
.authors {
font-weight: $font-weight-bold;
}
}
} }
+3 -2
View File
@@ -12,8 +12,9 @@
<slot name="default" /> <slot name="default" />
<span><strong>{{ toCommaList(node.authors) }}</strong>,</span> <span><strong>{{ toCommaList(node.authors) }}</strong>,</span>
<span> <span>
<span v-if="node.preTitle" v-html="trim(node.preTitle) + ', '" /> <span v-if="node.preTitle" v-html="' ' + trim(node.preTitle) + ','" />
<em v-html="trim(node.title) || 'pas de titre ital'" /> <em v-html="' ' + trim(node.title) || 'pas de titre ital'" />
<span v-if="edition && node.edition">, </span>
</span> </span>
<div v-if="edition && node.edition" class="edition"> <div v-if="edition && node.edition" class="edition">
{{ node.edition.map(ed => ed.name).join(' ') }} {{ node.edition.map(ed => ed.name).join(' ') }}
+3 -2
View File
@@ -102,8 +102,9 @@ export default {
async 'INIT_LIBRARY_MAP' ({ state, commit, dispatch }) { async 'INIT_LIBRARY_MAP' ({ state, commit, dispatch }) {
const departIds = await dispatch('INIT_LIBRARY') const departIds = await dispatch('INIT_LIBRARY')
const departNodes = await dispatch('GET_NODES', { ids: departIds.slice(0, 3), dataLevel: 'partial' }) const ids = departIds.slice(0, 3)
const relatedIds = getRelatedNodesIds(departNodes) const departNodes = await dispatch('GET_NODES', { ids, dataLevel: 'partial' })
const relatedIds = getRelatedNodesIds(departNodes, ids)
const relatedNodes = await dispatch('GET_NODES', { ids: relatedIds, dataLevel: 'partial' }) const relatedNodes = await dispatch('GET_NODES', { ids: relatedIds, dataLevel: 'partial' })
return [...departNodes, ...relatedNodes] return [...departNodes, ...relatedNodes]
}, },
+10 -1
View File
@@ -58,12 +58,13 @@ export function getUniqueNodesIds (tree) {
} }
export function getRelatedNodesIds (nodes) { export function getRelatedNodesIds (nodes, ignored) {
const ids = new Set() const ids = new Set()
for (const node of nodes) { for (const node of nodes) {
for (const relation of RELATIONS) { for (const relation of RELATIONS) {
if (relation in node && node[relation]) { if (relation in node && node[relation]) {
node[relation].forEach(({ id }) => { node[relation].forEach(({ id }) => {
if (ignored.includes(id)) return
ids.add(id) ids.add(id)
}) })
} }
@@ -137,3 +138,11 @@ export function tagsInNode (tags, nodeTags) {
if (!nodeTags || nodeTags.length === 0) return false if (!nodeTags || nodeTags.length === 0) return false
return tags.every(tag => nodeTags.some(nodeTag => nodeTag.name === tag)) return tags.every(tag => nodeTags.some(nodeTag => nodeTag.name === tag))
} }
export function getRelation (node) {
if (node.type === 'prod' && node.parents && node.parents.length) {
return { parentId: node.parents[0].id, childId: node.id }
}
return { parentId: node.id }
}