|
@@ -0,0 +1,190 @@
|
|
|
+import { css } from "@linaria/core";
|
|
|
+import { defineComponent, onMounted, onUnmounted } from "vue";
|
|
|
+import { useEditor } from "../../../..";
|
|
|
+import { IconMove, IconClear, IconAdd, IconResizeY } from "@/assets/icons";
|
|
|
+
|
|
|
+export const StreamCardTransfer = defineComponent({
|
|
|
+ setup() {
|
|
|
+ const editor = useEditor();
|
|
|
+ const { store, controls, helper } = editor;
|
|
|
+ const { streamCardTransferCtrl } = controls;
|
|
|
+ const { transferStyle } = streamCardTransferCtrl;
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ const pageEl = helper.findRootComp()?.$el;
|
|
|
+ if (pageEl) {
|
|
|
+ streamCardTransferCtrl.init(pageEl.firstChild as HTMLElement);
|
|
|
+ streamCardTransferCtrl.currComp = store.currStreamCard;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ streamCardTransferCtrl.destroy();
|
|
|
+ });
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ return (
|
|
|
+ transferStyle.width && (
|
|
|
+ <div
|
|
|
+ class="transfer absolute"
|
|
|
+ style={{
|
|
|
+ top: transferStyle.top,
|
|
|
+ left: transferStyle.left,
|
|
|
+ width: transferStyle.width,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ class={borderStyle}
|
|
|
+ style={{
|
|
|
+ width: transferStyle.width,
|
|
|
+ height: transferStyle.height,
|
|
|
+ }}
|
|
|
+ />
|
|
|
+
|
|
|
+ <div
|
|
|
+ class={resizeHeightBtnCls}
|
|
|
+ style={{ top: transferStyle.height }}
|
|
|
+ onMousedown={(e) =>
|
|
|
+ streamCardTransferCtrl.mousedown(e, "resizeY")
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <IconResizeY />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* <div class={hudStyle}>
|
|
|
+ <IconMove class="draganchor" />
|
|
|
+ <IconClear />
|
|
|
+ <IconAdd />
|
|
|
+ </div> */}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ );
|
|
|
+ };
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const borderStyle = css`
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ outline: 2px solid @inf-primary-color;
|
|
|
+ pointer-events: none;
|
|
|
+ z-index: 999;
|
|
|
+ box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.4);
|
|
|
+`;
|
|
|
+
|
|
|
+const hudStyle = css`
|
|
|
+ position: absolute;
|
|
|
+ top: 0px;
|
|
|
+ left: -46px;
|
|
|
+ background-color: white;
|
|
|
+ flex-direction: column;
|
|
|
+ color: black;
|
|
|
+ display: flex;
|
|
|
+ font-size: 12px;
|
|
|
+ width: 28px;
|
|
|
+ align-items: center;
|
|
|
+ border-radius: 4px;
|
|
|
+ .inficon {
|
|
|
+ padding: 8px;
|
|
|
+ }
|
|
|
+ z-index: 1000;
|
|
|
+`;
|
|
|
+
|
|
|
+const resizeStyle = css`
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ right: 0;
|
|
|
+ width: 16px;
|
|
|
+ height: 16px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: #fff;
|
|
|
+ z-index: 999;
|
|
|
+ transform: translate(50%, 50%);
|
|
|
+ box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2);
|
|
|
+ cursor: nwse-resize;
|
|
|
+ &:hover {
|
|
|
+ border-color: @inf-primary-color;
|
|
|
+ }
|
|
|
+`;
|
|
|
+
|
|
|
+const transformBtnsStyle = css`
|
|
|
+ @apply space-x-10px whitespace-nowrap;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ left: 50%;
|
|
|
+ font-size: 16px;
|
|
|
+ z-index: 999;
|
|
|
+ transform: translate(-50%, 50px);
|
|
|
+`;
|
|
|
+
|
|
|
+const transBtnStyle = css`
|
|
|
+ display: inline-block;
|
|
|
+ width: 36px;
|
|
|
+ height: 36px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: #fff;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 36px;
|
|
|
+ font-size: 20px;
|
|
|
+ color: #333;
|
|
|
+ @apply shadow cursor-move;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ color: #fff;
|
|
|
+ background-color: @inf-primary-color;
|
|
|
+ }
|
|
|
+`;
|
|
|
+
|
|
|
+const toolbarStyle = css`
|
|
|
+ @apply bg-white shadow rounded space-x-4px p-4px whitespace-nowrap;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 50%;
|
|
|
+ transform: translate(-50%, -40px);
|
|
|
+ z-index: 999;
|
|
|
+`;
|
|
|
+
|
|
|
+const resizeHeightBtnCls = css`
|
|
|
+ position: absolute;
|
|
|
+ width: 30px;
|
|
|
+ height: 8px;
|
|
|
+ border-radius: 4px;
|
|
|
+ left: 50%;
|
|
|
+ transform: translate(-50%, -4px);
|
|
|
+ cursor: ns-resize;
|
|
|
+ background: rgba(255, 255, 255, 0.3);
|
|
|
+ &:hover {
|
|
|
+ background: @inf-primary-color;
|
|
|
+ }
|
|
|
+ @apply shadow;
|
|
|
+ z-index: 999;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+
|
|
|
+ .inficon {
|
|
|
+ font-size: 20px;
|
|
|
+ position: relative;
|
|
|
+ top: -6px;
|
|
|
+ }
|
|
|
+`;
|
|
|
+
|
|
|
+const resizeWidthBtnCls = css`
|
|
|
+ position: absolute;
|
|
|
+ width: 8px;
|
|
|
+ height: 30px;
|
|
|
+ border-radius: 4px;
|
|
|
+ right: 0;
|
|
|
+ transform: translate(4px, -50%);
|
|
|
+ cursor: ew-resize;
|
|
|
+ background: rgba(255, 255, 255, 0.3);
|
|
|
+ &:hover {
|
|
|
+ background: @inf-primary-color;
|
|
|
+ }
|
|
|
+ @apply shadow;
|
|
|
+ z-index: 999;
|
|
|
+`;
|