NodeViewChildList.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <nav class="node-view-child-list" :class="{ 'smartphone': smartphone }">
  3. <ul>
  4. <li
  5. v-for="(child, i) in children" :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. export default {
  24. name: 'NodeViewChildList',
  25. props: {
  26. children: { type: Array, required: true },
  27. smartphone: { type: Boolean, default: false }
  28. },
  29. data () {
  30. return {
  31. }
  32. },
  33. computed: {
  34. ...mapGetters(['activeNodes'])
  35. },
  36. methods: {
  37. getDir (index) {
  38. const len = this.children.length
  39. if (index === 0) return 'right'
  40. if (index === this.children.length - 1) return 'left'
  41. return 'middle'
  42. },
  43. onOpen (childId) {
  44. this.$emit('open-child', { childId })
  45. }
  46. },
  47. mounted () {
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .node-view-child-list {
  53. ul {
  54. display: flex;
  55. align-items: center;
  56. justify-content: center;
  57. height: 26px;
  58. padding: 0;
  59. margin: 0;
  60. list-style: none;
  61. }
  62. &-item {
  63. margin-right: 20px;
  64. line-height: 0;
  65. }
  66. &.smartphone {
  67. padding: $node-view-spacer-sm-y $node-view-spacer-sm-x;
  68. background-color: $white;
  69. position: sticky;
  70. top: 0;
  71. z-index: 1;
  72. ul {
  73. justify-content: space-between;
  74. }
  75. @include media-breakpoint-up($layout-bp) {
  76. display: none;
  77. }
  78. }
  79. }
  80. </style>