import { useEditor } from "@/modules/editor";
import { defineUI } from "queenjs";
import { TipIcons } from "../../TipIcons";
import { css } from "@linaria/core";

export default defineUI({
  setup() {
    const { actions, controls } = useEditor();
    const { history } = controls.historyCtrl;
    return () => (
      <>
        <div class="absolute top-20px left-20px space-x-10px z-999">
          <TipIcons.Undo
            disable={!history.state.canUndo}
            class={btnCls}
            onClick={() => history.undo()}
          />
          <TipIcons.Redo
            disable={!history.state.canRedo}
            class={btnCls}
            onClick={() => history.redo()}
          />
        </div>
        <div class="absolute top-20px right-20px z-999">
          <TipIcons.Screenshot
            class={btnCls}
            onClick={() => actions.updateThumbnailByScreenshot(true)}
          />
        </div>
      </>
    );
  },
});

const btnCls = css`
  padding: 10px;
  border-radius: 50%;
  background-color: #333;
  @apply shadow;
`;
