123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <div
- class="node-book"
- >
- <section
- class="node-book-stack no-events-container"
- :style="`--count: ${nodes.length - 1}; --h: ${stackHeight}px;`"
- >
- <div
- v-for="({ parent, children }, i) in nodes" :key="parent.id"
- class="node-book-stack-item node-book-stack-item-parent splitted"
- :class="{ active: i === nodes.length - 1 }"
- :style="`--nth: ${i}`"
- >
- <node-view-child-list :children="parent.children" :parent-id="parent.id" smartphone />
- <node-view
- :node="parent"
- type="ref"
- mode="view"
- @open-node="$emit('open-node', $event)"
- @open-child="$emit('open-node', parent.id, $event)"
- @close-node="$emit('close-node', $event)"
- />
- <section
- class="node-book-stack no-events-container"
- :style="`--count: ${children.length }; --h: ${getChildrenStackHeight(children.length)}px;`"
- >
- <div
- v-for="(child, j) in children" :key="child.id + '-cont'"
- class="node-book-stack-item"
- :class="{ active: j === children.length - 1 }"
- :style="`--nth: ${j}`"
- >
- <node-view
- :key="child.id"
- :node="child"
- mode="view"
- type="prod"
- @open-node="$emit('open-node', $event)"
- @close-node="$emit('close-node', parent.id, $event)"
- />
- </div>
- </section>
- </div>
- </section>
- </div>
- </template>
- <script>
- import { NodeViewChildList, NodeView } from '@/components/nodes'
- export default {
- name: 'NodeBook',
- components: {
- NodeViewChildList,
- NodeView
- },
- props: {
- nodes: { type: Array, required: true }
- },
- data () {
- return {
- height: undefined
- }
- },
- computed: {
- stackHeight () {
- return Math.min(150 / (this.nodes.length - 1), 75)
- }
- },
- methods: {
- updateSize () {
- this.height = this.$el.getBoundingClientRect().height
- },
- getChildrenStackHeight (childrenLen) {
- return this.stackHeight / childrenLen || this.stackHeight
- }
- },
- mounted () {
- window.addEventListener('resize', () => this.updateSize())
- this.updateSize()
- }
- }
- </script>
- <style lang="scss" scoped>
- .node-book {
- min-height: 100%;
- // top: -100%;
- @include media-breakpoint-up($layout-bp) {
- height: 100%;
- // ╭─╴╶┬╴╭─┐╭─╴╷ ╭
- // ╰─╮ │ ├─┤│ ├┴╮
- // ╶─╯ ╵ ╵ ╵╰─╴╵ ╵
- &-stack {
- position: relative;
- height: 100%;
- width: 100%;
- display: flex;
- flex-direction: column;
- &-item {
- width: 100%;
- height: 100%;
- position: absolute;
- top: calc(var(--h) * var(--nth));
- height: calc(100% - (var(--h) * var(--nth)));
- &-parent > .node-view {
- border-right: $line;
- }
- &-parent > .node-view {
- border-top: $line;
- }
- &:not(.node-book-stack-item-parent):first-child {
- border-top: $line;
- }
- // BLURS
- &-parent:not(.active) {
- &::before,
- &::after {
- content: '';
- pointer-events: none;
- position: absolute;
- z-index: 1;
- display: block;
- top: $border-width;
- height: calc(var(--h) - #{$border-width});
- background-color: rgba($white, .5);
- }
- &::before {
- width: calc(50% - #{$border-width});
- left: 0;
- }
- &::after {
- width: 50%;
- left: 50%;
- }
- }
- &-parent.active {
- background-color: rgba($white, .5);
- }
- &:not(.active) {
- ::v-deep {
- .node-view {
- overflow-y: hidden;
- &-header {
- z-index: 0;
- }
- }
- .node-view-child-list {
- display: none;
- }
- }
- // ::v-deep .node-view:not(:hover) {
- // .node-view-header {
- // padding-top: $node-view-spacer-sm-y;
- // padding-bottom: $node-view-spacer-sm-y;
- // }
- //
- // h4 {
- // font-size: 2rem;
- // > * {
- // display: inline !important;
- // }
- // .edition {
- // display: none !important;
- // }
- // display: block;
- // display: -webkit-box;
- // -webkit-line-clamp: 1;
- // -webkit-box-orient: vertical;
- // text-overflow: ellipsis;
- // overflow: hidden;
- // max-height: 1.5em;
- // }
- //
- // .node-view-header-prod h4 {
- // font-size: 1rem;
- // }
- // }
- //
- // &:hover {
- // ::v-deep .node-view:hover .node-view-header {
- // z-index: calc(var(--count) + 10);
- // border-bottom: $line;
- // }
- // }
- }
- &.splitted {
- display: flex;
- flex-basis: 50%;
- }
- }
- }
- }
- }
- </style>
|