Ensure new components are created with any default styles already applied

This commit is contained in:
Andrew Kingston 2021-01-05 11:46:31 +00:00
parent 2a478f7f03
commit 4ea8b34ff1
1 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import { isString, isUndefined, cloneDeep } from "lodash/fp"
import { TYPE_MAP } from "./types"
import { assign } from "lodash"
import { uuid } from "builderStore/uuid"
import { defaults } from "../propertyCategories"
export const getBuiltin = _component => {
const { props } = createProps({ _component })
@ -24,7 +25,11 @@ export const createProps = (componentDefinition, derivedFromProps) => {
const props = {
_id: uuid(),
_component: componentDefinition._component,
_styles: { normal: {}, hover: {}, active: {}, selected: {} },
_styles: {
normal: defaults,
hover: defaults,
active: defaults,
},
}
const errors = []
@ -75,7 +80,11 @@ export const makePropsSafe = (componentDefinition, props) => {
}
if (!props._styles) {
props._styles = { normal: {}, hover: {}, active: {}, selected: {} }
props._styles = {
normal: defaults,
hover: defaults,
active: defaults,
}
}
return props