LibraryList.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="library-list">
  3. <div class="library-list-container">
  4. <div v-for="(parents, char) in filteredNodes" :key="char">
  5. <h3>{{ char }}</h3>
  6. <div class="library-list-nodes-group">
  7. <node-view
  8. v-for="parent in parents" :key="parent.id"
  9. :node="parent"
  10. mode="card"
  11. @open-node="$emit('open-node', $event)"
  12. />
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. import { searchInNode, tagsInNode } from '@/store/utils'
  21. import { NodeView } from '@/components/nodes'
  22. export default {
  23. name: 'LibraryList',
  24. components: {
  25. NodeView
  26. },
  27. computed: {
  28. ...mapGetters(['orderedTextsDepart', 'search', 'tags']),
  29. filteredNodes () {
  30. if (!this.orderedTextsDepart) return {}
  31. const nodesGroups = {}
  32. const search = this.search.toLowerCase()
  33. Object.entries(this.orderedTextsDepart).forEach(([char, nodes]) => {
  34. const filteredNodes = nodes
  35. .filter(node => tagsInNode(this.tags, node.tags))
  36. .filter(node => searchInNode(search, node))
  37. if (filteredNodes.length) {
  38. nodesGroups[char] = filteredNodes
  39. }
  40. })
  41. return nodesGroups
  42. }
  43. },
  44. created () {
  45. this.$store.dispatch('INIT_LIBRARY_LIST')
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .library-list {
  51. overflow-y: auto;
  52. height: 100%;
  53. h3 {
  54. font-family: $font-family-text;
  55. line-height: 1;
  56. font-size: 16.5rem;
  57. }
  58. &-nodes-group {
  59. display: flex;
  60. flex-wrap: wrap;
  61. .node-view {
  62. margin-bottom: 3.4375rem;
  63. $marg: 4.6875rem;
  64. width: 100%;
  65. height: 20rem;
  66. @include media-breakpoint-only(md) {
  67. max-width: calc(50% - #{($marg / 2)});
  68. margin-right: $marg;
  69. &:nth-of-type(2n) {
  70. margin-right: 0;
  71. }
  72. }
  73. @include media-breakpoint-up(lg) {
  74. margin-right: $marg;
  75. max-width: calc(33.33% - #{(($marg * 2) / 3)});
  76. &:nth-of-type(3n) {
  77. margin-right: 0;
  78. }
  79. }
  80. }
  81. }
  82. }
  83. </style>