component.tsx 1015 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { defineComponent } from "vue";
  2. import { string } from "vue-types";
  3. import { useCompData } from ".";
  4. import { useEditor } from "../../../..";
  5. import { useCompRef } from "../hooks";
  6. import { css } from "@linaria/core";
  7. export const Component = defineComponent({
  8. props: {
  9. compId: string().isRequired,
  10. },
  11. setup(props, { slots }) {
  12. const editor = useEditor();
  13. const { helper } = editor;
  14. const { children, layout } = useCompData(props.compId);
  15. const compRef = useCompRef(props.compId);
  16. return () => (
  17. <div ref={compRef} style={helper.createStyle(layout)} class={["!h-auto" , editor.store.isEditMode? pageEditStyle :""]}>
  18. <div class="relative">
  19. {slots.Container?.(
  20. children.default.map((compId) => {
  21. const comp = helper.findComp(compId);
  22. return slots.CompItem?.(comp);
  23. })
  24. )}
  25. </div>
  26. </div>
  27. );
  28. },
  29. });
  30. const pageEditStyle = css`
  31. box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.4);
  32. `