alignMulti.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. return (
  15. <>
  16. {
  17. editor.store.selected.length > 1 && <div class={AlignToolsStyle}>
  18. <div>
  19. <span class="text-white">元素 (已选{editor.store.selected.length})</span>
  20. </div>
  21. <div class="flex py-12px px-0px items-center">
  22. <span class="pr-32px">对齐</span>
  23. <div class="row flex-1 flex">
  24. {SelItemsAlignTools.Left.map((item) => {
  25. return item.getVisible.call(editor, null as any) ? (
  26. <item.component
  27. class="p-4px flex-1"
  28. onClick={() => item.onClick.call(editor, null as any)}
  29. />
  30. ) : null;
  31. })}
  32. </div>
  33. <div class="row ml-10px flex-1 flex">
  34. {SelItemsAlignTools.right.map((item) => {
  35. return item.getVisible.call(editor, null as any) ? (
  36. <item.component
  37. class="p-4px flex-1"
  38. onClick={() => item.onClick.call(editor, null as any)}
  39. />
  40. ) : null;
  41. })}
  42. </div>
  43. </div>
  44. <div class = "mt-16px">
  45. <span class="text-white">布局</span>
  46. </div>
  47. <div class="flex py-12px px-0px items-center">
  48. <span class="pr-32px">对齐</span>
  49. <div class="row flex-1 flex">
  50. {CompAlignTools.Left.map((item) => {
  51. return item.getVisible.call(editor, null as any) ? (
  52. <item.component
  53. class="p-4px flex-1"
  54. onClick={() => item.onClick.call(editor, null as any, true)}
  55. />
  56. ) : null;
  57. })}
  58. </div>
  59. <div class="row ml-10px flex-1 flex">
  60. {CompAlignTools.right.map((item) => {
  61. return item.getVisible.call(editor, null as any) ? (
  62. <item.component
  63. class="p-4px flex-1"
  64. onClick={() => item.onClick.call(editor, null as any, true)}
  65. />
  66. ) : null;
  67. })}
  68. </div>
  69. </div>
  70. </div>
  71. }
  72. </>
  73. );
  74. };
  75. },
  76. });
  77. const AlignToolsStyle = css`
  78. flex: 1;
  79. display: flex;
  80. flex-direction: column;
  81. .row {
  82. background: #303030;
  83. border-radius: 4px 4px 4px 4px;
  84. }
  85. `;