component.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { css } from "@linaria/core";
  2. import { number, string } from "vue-types";
  3. import { useCompData } from ".";
  4. import { useEditor } from "../../../../..";
  5. import { Image, Text } from "../../../basicUI";
  6. import { createUIComp } from "../../../defines/createUIComp";
  7. import { WidthEditlayer } from "../../../basicUI/utils";
  8. import { View } from "../../../basicUI/View";
  9. export const Component = createUIComp({
  10. props: {
  11. compId: string().isRequired,
  12. },
  13. setup(props) {
  14. const { store , helper} = useEditor();
  15. const { children } = useCompData(props.compId);
  16. const designToNaturalSize = helper.designToNaturalSize;
  17. function fixedSize(id:string, w:number, h:number)
  18. {
  19. const item1Comp = store.compMap[id]
  20. if ( !item1Comp ) return;
  21. if (item1Comp.layout.size) {
  22. const isDefault = item1Comp.layout.size[0] == 750 && item1Comp.layout.size[1] == 400
  23. if (isDefault) {
  24. item1Comp.layout.size[0] = w;
  25. item1Comp.layout.size[1] = h;
  26. }
  27. }
  28. }
  29. function upgrade() {
  30. const item1Comp = store.compMap[children.item1]
  31. if ( !item1Comp.layout.transformMatrix) {
  32. item1Comp.layout.transformMatrix = "matrix(1,0,0,1, 40, 170)"
  33. item1Comp.layout.position = "absolute";
  34. }
  35. const item2Comp = store.compMap[children.item1]
  36. if ( !item2Comp.layout.transformMatrix) {
  37. item2Comp.layout.transformMatrix = "matrix(1, 0, 0, 1, 153, 136)",
  38. item2Comp.layout.position = "absolute";
  39. }
  40. const item3Comp = store.compMap[children.item1]
  41. if ( !item3Comp.layout.transformMatrix) {
  42. item3Comp.layout.transformMatrix = "matrix(1, 0, 0, 1, 269, 100)",
  43. item3Comp.layout.position = "absolute";
  44. }
  45. }
  46. upgrade();
  47. fixedSize(children.item1, 191, 191);
  48. fixedSize(children.item2, 191, 191);
  49. fixedSize(children.item3, 191, 191);
  50. return () => (
  51. <div class="absolute">
  52. <div class={style}>
  53. <Image.Component compId={children.bgImg} />
  54. </div>
  55. <Image.Component
  56. class="rounded-1/2 overflow-hidden top-0"
  57. editlayer = {false}
  58. compId={children.item1}
  59. />
  60. <Image.Component
  61. class="rounded-1/2 overflow-hidden top-0"
  62. compId={children.item2}
  63. editlayer = {false}
  64. />
  65. <Image.Component
  66. class="rounded-1/2 overflow-hidden top-0"
  67. compId={children.item3}
  68. editlayer = {false}
  69. />
  70. <Text.Component compId={children.text1} class={"top-0"} />
  71. <Text.Component compId={children.text2} class={"top-0"} />
  72. </div>
  73. );
  74. },
  75. });
  76. const style = css`
  77. background: gray;
  78. clip-path: polygon(0 0, 100% 0, 100% 57%, 0 100%);
  79. `;