panel.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div
  3. class="flow-funcs__container"
  4. :class="{active:active}">
  5. <div class="flow-funcs__control">
  6. <!-- make this toggle able -->
  7. <button
  8. class="item"
  9. @click="funcsViewBlocks=!funcsViewBlocks">
  10. {{ funcsViewBlocks ? 'List':'Blocks' }} view
  11. </button>
  12. <button
  13. class="item"
  14. @click="$emit('toggleResizeable')">
  15. Resize
  16. </button>
  17. </div>
  18. <div class="flow-funcs__inner">
  19. <hx-collapsible
  20. v-for="g in funcsGroups"
  21. :key="g">
  22. <div
  23. class="flow-funcs__header"
  24. slot="header">{{ g }}</div>
  25. <div
  26. class="flow-funcs__group"
  27. :class="{blocks:funcsViewBlocks}">
  28. <div
  29. :key="k"
  30. ref="src"
  31. class="flow-funcs__src hover-anim hover"
  32. draggable="true"
  33. v-for="k in funcsGroup(g)"
  34. @dragstart="fnDrag($event,k)"
  35. :style="{'background':registry[k].style && registry[k].style.color}">
  36. {{ k }}
  37. </div>
  38. </div>
  39. </hx-collapsible>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import HxCollapsible from '@/components/shared/hx-collapsible'
  45. export default {
  46. name: 'FlowPanel',
  47. components: {HxCollapsible},
  48. props: {
  49. active: {type: Boolean, default: true},
  50. registry: {type: Object, default: () => {}}
  51. },
  52. data () {
  53. return {
  54. funcsViewBlocks: true
  55. }
  56. },
  57. computed: {
  58. funcsGroups () {
  59. let group = {}
  60. for (let r in this.registry) {
  61. group[this.registry[r].group] = true
  62. }
  63. return Object.keys(group)
  64. },
  65. funcsGroup () {
  66. return (g) => {
  67. const ret = Object.keys(this.registry).filter(v => this.registry[v].group === g)
  68. return ret
  69. }
  70. }
  71. },
  72. methods: {
  73. fnDrag (ev, src) {
  74. ev.dataTransfer.setData('text/plain', src)
  75. }
  76. }
  77. }
  78. </script>
  79. <style>
  80. .flow-funcs__container {
  81. white-space: nowrap;
  82. width:0px;
  83. transition: all .3s;
  84. height:100%;
  85. background:rgba(208,208,208,0.7);
  86. overflow-x:hidden;
  87. overflow-y:auto;
  88. }
  89. .flow-funcs__container.active {
  90. width:300px;
  91. }
  92. .flow-funcs__control {
  93. display:flex;
  94. flex-flow:row;
  95. border-bottom: solid 1px rgba(208,208,208,0.9);
  96. }
  97. .flow-funcs__control .item{
  98. font-size:14px;
  99. padding:13px;
  100. flex:1;
  101. height:100%;
  102. text-align:center;
  103. color:black;
  104. text-overflow: ellipsis;
  105. min-width:50px;
  106. height:50px;
  107. overflow:hidden;
  108. }
  109. .flow-funcs__control .item:not(:last-child){
  110. border-right: solid 1px rgba(208,208,208,0.9);
  111. }
  112. .flow-funcs__inner {
  113. overflow:hidden;
  114. margin-top:20px;
  115. }
  116. .flow-funcs__inner .hx-toggle-arrow {
  117. color: rgba(150,150,150,0.9);
  118. }
  119. .flow-funcs__inner .hx-collapsible {
  120. }
  121. .flow-funcs__inner .hx-collapsible__header {
  122. font-size:14px;
  123. padding:5px 10px;
  124. transition: all .3s;
  125. }
  126. .flow-funcs__inner .hx-collapsible__header:hover {
  127. background: rgba(150,150,150,0.2);
  128. }
  129. .flow-funcs__group{
  130. display:flex;
  131. flex-flow:column;
  132. padding:10px;
  133. background: rgba(108,108,108,0.1);
  134. }
  135. .flow-funcs__src {
  136. font-size:12px;
  137. padding:11px 5px;
  138. background: #777;
  139. color:#eee;
  140. margin-top:1px;
  141. text-align:center;
  142. transition: all .3s;
  143. position:relative;
  144. display:flex;
  145. justify-content: center;
  146. align-items: center;
  147. cursor: move;
  148. cursor: grab;
  149. cursor: -moz-grab;
  150. cursor: -webkit-grab;
  151. }
  152. .flow-funcs__group.blocks {
  153. flex-flow:row;
  154. flex-wrap: wrap;
  155. justify-content: flex-start;
  156. align-content: center;
  157. }
  158. .flow-funcs__group.blocks .flow-funcs__src {
  159. text-overflow: ellipsis;
  160. margin:1px;
  161. width: 60px;
  162. height:60px;
  163. overflow:hidden;
  164. }
  165. .flow-funcs__toggle {
  166. margin:0;
  167. position:relative;
  168. }
  169. </style>