NodeViewChildList.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <nav class="node-view-child-list" :class="{ 'smartphone': smartphone }">
  3. <ul>
  4. <li
  5. v-for="(child, i) in orderedChildren" :key="child.id"
  6. class="node-view-child-list-item"
  7. >
  8. <dot-button
  9. @click="onOpen(child.id)"
  10. :variant="child.variant"
  11. :active="activeNodes.includes(child.id)"
  12. dot-only
  13. :pos="smartphone ? getDir(i) : 'left'"
  14. >
  15. {{ $t('variants.' + child.variant) }}
  16. </dot-button>
  17. </li>
  18. </ul>
  19. </nav>
  20. </template>
  21. <script>
  22. import { mapGetters } from 'vuex'
  23. import { orderByVariant } from '@/helpers/common'
  24. export default {
  25. name: 'NodeViewChildList',
  26. props: {
  27. children: { type: Array, required: true },
  28. smartphone: { type: Boolean, default: false }
  29. },
  30. data () {
  31. return {
  32. }
  33. },
  34. computed: {
  35. ...mapGetters(['activeNodes']),
  36. orderedChildren () {
  37. return orderByVariant(this.children)
  38. }
  39. },
  40. methods: {
  41. getDir (index) {
  42. const len = this.children.length
  43. if (index === 0) return 'right'
  44. if (index === this.children.length - 1) return 'left'
  45. return 'middle'
  46. },
  47. onOpen (childId) {
  48. this.$emit('open-child', { childId })
  49. }
  50. },
  51. mounted () {
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .node-view-child-list {
  57. ul {
  58. display: flex;
  59. align-items: center;
  60. justify-content: center;
  61. height: 26px;
  62. padding: 0;
  63. margin: 0;
  64. list-style: none;
  65. }
  66. &-item {
  67. margin-right: 20px;
  68. line-height: 0;
  69. }
  70. &.smartphone {
  71. padding: $node-view-spacer-sm-y $node-view-spacer-sm-x;
  72. background-color: $white;
  73. position: sticky;
  74. top: 0;
  75. z-index: 1;
  76. ul {
  77. justify-content: space-between;
  78. }
  79. @include media-breakpoint-up($layout-bp) {
  80. display: none;
  81. }
  82. }
  83. }
  84. </style>