Merge pull request #1891 from Budibase/legacy-styles-compat

Legacy styles compatibility
This commit is contained in:
Martin McKeaveney 2021-07-01 11:34:04 +01:00 committed by GitHub
commit 993383c540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 26 deletions

View File

@ -284,7 +284,7 @@ export const background = {
export const border = {
label: "Border",
columns: "auto 1fr",
columns: "1fr 1fr",
settings: [
{
label: "Color",
@ -295,17 +295,31 @@ export const border = {
label: "Width",
key: "border-width",
control: Select,
column: "1 / 2",
placeholder: "None",
options: [
{ label: "Small", value: "1px" },
{ label: "Medium", value: "2px" },
{ label: "Large", value: "4px" },
],
},
{
label: "Style",
key: "border-style",
control: Select,
column: "2 / 3",
placeholder: "None",
options: [
{ label: "Solid", value: "solid" },
{ label: "Dotted", value: "dotted" },
{ label: "Dashed", value: "dashed" },
],
},
{
label: "Radius",
key: "border-radius",
control: Select,
column: "1 / 3",
placeholder: "None",
options: [
{ label: "Small", value: "0.25rem" },
{ label: "Medium", value: "0.5rem" },
@ -317,7 +331,7 @@ export const border = {
label: "Shadow",
key: "box-shadow",
control: Select,
column: "1 / 3",
placeholder: "None",
options: [
{
label: "Small",

View File

@ -34,11 +34,6 @@ export const styleable = (node, styles = {}) => {
baseStyles.overflow = "hidden"
}
// Append border-style css if border-width is specified
if (newStyles.normal?.["border-width"]) {
baseStyles["border-style"] = "solid"
}
const componentId = newStyles.id
const customStyles = newStyles.custom || ""
const normalStyles = { ...baseStyles, ...newStyles.normal }

View File

@ -19,13 +19,20 @@
// Add color styles to main styles object, otherwise the styleable helper
// overrides the color when it's passed as inline style.
$: styles = {
...$component.styles,
$: styles = enrichStyles($component.styles, color)
const enrichStyles = (styles, color) => {
if (!color) {
return styles
}
return {
...styles,
normal: {
...$component.styles?.normal,
...styles?.normal,
color,
},
}
}
</script>
<h1

View File

@ -23,13 +23,22 @@
// Add color styles to main styles object, otherwise the styleable helper
// overrides the color when it's passed as inline style.
$: styles = {
...$component.styles,
// Add color styles to main styles object, otherwise the styleable helper
// overrides the color when it's passed as inline style.
$: styles = enrichStyles($component.styles, color)
const enrichStyles = (styles, color) => {
if (!color) {
return styles
}
return {
...styles,
normal: {
...$component.styles?.normal,
...styles?.normal,
color,
},
}
}
</script>
{#if $builderStore.inBuilder || componentText}

View File

@ -19,13 +19,20 @@
// Add color styles to main styles object, otherwise the styleable helper
// overrides the color when it's passed as inline style.
$: styles = {
...$component.styles,
$: styles = enrichStyles($component.styles, color)
const enrichStyles = (styles, color) => {
if (!color) {
return styles
}
return {
...styles,
normal: {
...$component.styles?.normal,
...styles?.normal,
color,
},
}
}
</script>
<p