|
@@ -1,11 +1,14 @@
|
|
|
import { css } from "@linaria/core";
|
|
|
+import { omit } from "lodash";
|
|
|
import { defineComponent, onMounted, reactive, ref } from "vue";
|
|
|
-import { string } from "vue-types";
|
|
|
+import { any } from "vue-types";
|
|
|
import { useEditor } from "../../..";
|
|
|
+import { Background, Layout } from "../../../typings";
|
|
|
|
|
|
export const View = defineComponent({
|
|
|
props: {
|
|
|
- bgSrc: string(),
|
|
|
+ background: any<Background>(),
|
|
|
+ layout: any<Layout>(),
|
|
|
},
|
|
|
setup(props, { slots }) {
|
|
|
const { store, actions } = useEditor();
|
|
@@ -22,9 +25,13 @@ export const View = defineComponent({
|
|
|
const isSelected = store.isEditMode && store.currCompId === state.compId;
|
|
|
|
|
|
const styleObj: any = {};
|
|
|
- if (props.bgSrc) {
|
|
|
- styleObj["--view-bg-src"] = `url(${props.bgSrc})`;
|
|
|
+ if (props.background?.image) {
|
|
|
+ styleObj["backgroundImage"] = `url(${props.background.image})`;
|
|
|
+ } else if (props.background?.color) {
|
|
|
+ styleObj["backgroundColor"] = props.background.color;
|
|
|
}
|
|
|
+ const bgOpts = Object.values(omit(props.background, ["image", "color"]));
|
|
|
+ const bgClasses = bgOpts.length ? `bg-${bgOpts.join(" bg-")}` : "";
|
|
|
|
|
|
return (
|
|
|
<div
|
|
@@ -32,7 +39,7 @@ export const View = defineComponent({
|
|
|
class={[
|
|
|
store.isEditMode && isComp ? viewStyle : "view_inside",
|
|
|
store.isEditMode && isSelected && "view_selected",
|
|
|
- props.bgSrc && viewBgStyle,
|
|
|
+ bgClasses,
|
|
|
]}
|
|
|
style={styleObj}
|
|
|
onClick={
|
|
@@ -51,10 +58,6 @@ export const View = defineComponent({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
-const viewBgStyle = css`
|
|
|
- background-image: var(--view-bg-src);
|
|
|
-`;
|
|
|
-
|
|
|
const viewStyle = css`
|
|
|
position: relative;
|
|
|
&:hover {
|