streamCard.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import { css } from "@linaria/core";
  2. import { defineComponent, onMounted, onUnmounted } from "vue";
  3. import { useEditor } from "../../../..";
  4. import { IconMove, IconClear, IconAdd, IconResizeY } from "@/assets/icons";
  5. export const StreamCardTransfer = defineComponent({
  6. setup() {
  7. const editor = useEditor();
  8. const { store, controls, helper } = editor;
  9. const { streamCardTransferCtrl } = controls;
  10. const { transferStyle } = streamCardTransferCtrl;
  11. onMounted(() => {
  12. setTimeout(() => {
  13. const pageEl = helper.findRootComp()?.$el;
  14. if (pageEl) {
  15. streamCardTransferCtrl.init(pageEl.firstChild as HTMLElement);
  16. streamCardTransferCtrl.currComp = store.currStreamCard;
  17. }
  18. });
  19. });
  20. onUnmounted(() => {
  21. streamCardTransferCtrl.destroy();
  22. });
  23. return () => {
  24. return (
  25. transferStyle.width && (
  26. <div
  27. class="transfer absolute"
  28. style={{
  29. top: transferStyle.top,
  30. left: transferStyle.left,
  31. width: transferStyle.width,
  32. }}
  33. >
  34. <div
  35. class={borderStyle}
  36. style={{
  37. width: transferStyle.width,
  38. height: transferStyle.height,
  39. }}
  40. />
  41. <div
  42. class={resizeHeightBtnCls}
  43. style={{ top: transferStyle.height }}
  44. onMousedown={(e) =>
  45. streamCardTransferCtrl.mousedown(e, "resizeY")
  46. }
  47. >
  48. <IconResizeY />
  49. </div>
  50. {/* <div class={hudStyle}>
  51. <IconMove class="draganchor" />
  52. <IconClear />
  53. <IconAdd />
  54. </div> */}
  55. </div>
  56. )
  57. );
  58. };
  59. },
  60. });
  61. const borderStyle = css`
  62. position: absolute;
  63. top: 0;
  64. left: 0;
  65. width: 100%;
  66. height: 100%;
  67. outline: 2px solid @inf-primary-color;
  68. pointer-events: none;
  69. z-index: 999;
  70. box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.4);
  71. `;
  72. const hudStyle = css`
  73. position: absolute;
  74. top: 0px;
  75. left: -46px;
  76. background-color: white;
  77. flex-direction: column;
  78. color: black;
  79. display: flex;
  80. font-size: 12px;
  81. width: 28px;
  82. align-items: center;
  83. border-radius: 4px;
  84. .inficon {
  85. padding: 8px;
  86. }
  87. z-index: 1000;
  88. `;
  89. const resizeStyle = css`
  90. position: absolute;
  91. bottom: 0;
  92. right: 0;
  93. width: 16px;
  94. height: 16px;
  95. border-radius: 50%;
  96. background-color: #fff;
  97. z-index: 999;
  98. transform: translate(50%, 50%);
  99. box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2);
  100. cursor: nwse-resize;
  101. &:hover {
  102. border-color: @inf-primary-color;
  103. }
  104. `;
  105. const transformBtnsStyle = css`
  106. @apply space-x-10px whitespace-nowrap;
  107. position: absolute;
  108. bottom: 0;
  109. left: 50%;
  110. font-size: 16px;
  111. z-index: 999;
  112. transform: translate(-50%, 50px);
  113. `;
  114. const transBtnStyle = css`
  115. display: inline-block;
  116. width: 36px;
  117. height: 36px;
  118. border-radius: 50%;
  119. background-color: #fff;
  120. text-align: center;
  121. line-height: 36px;
  122. font-size: 20px;
  123. color: #333;
  124. @apply shadow cursor-move;
  125. &:hover {
  126. color: #fff;
  127. background-color: @inf-primary-color;
  128. }
  129. `;
  130. const toolbarStyle = css`
  131. @apply bg-white shadow rounded space-x-4px p-4px whitespace-nowrap;
  132. position: absolute;
  133. top: 0;
  134. left: 50%;
  135. transform: translate(-50%, -40px);
  136. z-index: 999;
  137. `;
  138. const resizeHeightBtnCls = css`
  139. position: absolute;
  140. width: 30px;
  141. height: 8px;
  142. border-radius: 4px;
  143. left: 50%;
  144. transform: translate(-50%, -4px);
  145. cursor: ns-resize;
  146. background: rgba(255, 255, 255, 0.3);
  147. &:hover {
  148. background: @inf-primary-color;
  149. }
  150. @apply shadow;
  151. z-index: 999;
  152. display: flex;
  153. justify-content: center;
  154. .inficon {
  155. font-size: 20px;
  156. position: relative;
  157. top: -6px;
  158. }
  159. `;
  160. const resizeWidthBtnCls = css`
  161. position: absolute;
  162. width: 8px;
  163. height: 30px;
  164. border-radius: 4px;
  165. right: 0;
  166. transform: translate(4px, -50%);
  167. cursor: ew-resize;
  168. background: rgba(255, 255, 255, 0.3);
  169. &:hover {
  170. background: @inf-primary-color;
  171. }
  172. @apply shadow;
  173. z-index: 999;
  174. `;