import { string } from "vue-types";
import { useCompData } from ".";
import { useEditor } from "../../../../..";
import { Image, Text } from "../../../basicUI";
import { createUIComp } from "../../../defines/createUIComp";

export const Component = createUIComp({
  props: {
    compId: string().isRequired,
  },
  setup(props) {
    const { designToNaturalSize } = useEditor().helper;
    const { value, children } = useCompData(props.compId);

    return () => (
      <div class="flex">
        <Image.Component
          class="overflow-hidden"
          style={{
            width: designToNaturalSize(value.imgSize[0]),
            height: designToNaturalSize(value.imgSize[1]),
          }}
          compId={children.img}
        />
        <Text.Component class="flex-1 ml-5px" compId={children.desc} />
      </div>
    );
  },
});
