alignMulti.tsx 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { useEditor } from "@/modules/editor";
  2. import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
  3. import { SelItemsAlignTools, CompAlignTools } from "@/modules/editor/objects/Toolbars/liveTools";
  4. import { css } from "@linaria/core";
  5. import { defineComponent } from "vue";
  6. import { string } from "vue-types";
  7. export default defineComponent({
  8. props: {
  9. value: string(),
  10. },
  11. setup(props) {
  12. const editor = useEditor();
  13. return ()=>{
  14. const state = editor.controls.selectCtrl.gizmo.state;
  15. return (
  16. <>
  17. {
  18. state.transform.selected.length > 1 && <div class={AlignToolsStyle}>
  19. <div>
  20. <span class="text-white">元素 (已选{state.transform.selected.length})</span>
  21. </div>
  22. <div class="flex py-12px px-0px items-center">
  23. <span class="pr-32px">对齐</span>
  24. <div class="row flex-1 flex">
  25. {SelItemsAlignTools.Left.map((item) => {
  26. return item.getVisible.call(editor, null as any) ? (
  27. <item.component
  28. class="p-4px flex-1"
  29. onClick={() => item.onClick.call(editor, null as any)}
  30. />
  31. ) : null;
  32. })}
  33. </div>
  34. <div class="row ml-10px flex-1 flex">
  35. {SelItemsAlignTools.right.map((item) => {
  36. return item.getVisible.call(editor, null as any) ? (
  37. <item.component
  38. class="p-4px flex-1"
  39. onClick={() => item.onClick.call(editor, null as any)}
  40. />
  41. ) : null;
  42. })}
  43. </div>
  44. </div>
  45. <div class = "mt-16px">
  46. <span class="text-white">布局</span>
  47. </div>
  48. <div class="flex py-12px px-0px items-center">
  49. <span class="pr-32px">对齐</span>
  50. <div class="row flex-1 flex">
  51. {CompAlignTools.Left.map((item) => {
  52. return item.getVisible.call(editor, null as any) ? (
  53. <item.component
  54. class="p-4px flex-1"
  55. onClick={() => item.onClick.call(editor, null as any, true)}
  56. />
  57. ) : null;
  58. })}
  59. </div>
  60. <div class="row ml-10px flex-1 flex">
  61. {CompAlignTools.right.map((item) => {
  62. return item.getVisible.call(editor, null as any) ? (
  63. <item.component
  64. class="p-4px flex-1"
  65. onClick={() => item.onClick.call(editor, null as any, true)}
  66. />
  67. ) : null;
  68. })}
  69. </div>
  70. </div>
  71. </div>
  72. }
  73. </>
  74. );
  75. };
  76. },
  77. });
  78. const AlignToolsStyle = css`
  79. flex: 1;
  80. display: flex;
  81. flex-direction: column;
  82. .row {
  83. background: #303030;
  84. border-radius: 4px 4px 4px 4px;
  85. }
  86. `;