Merge pull request #354 from Budibase/Props-update-Shadow-fix,-rotate-improved,-border-updated

Props update, including flex, border, shadow, rotate
This commit is contained in:
Joe 2020-06-11 13:26:41 +01:00 committed by GitHub
commit 02469dec2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 46 deletions

View File

@ -19,9 +19,10 @@
onChange(_value) onChange(_value)
} }
$: displayValues = value && suffix $: displayValues =
? value.map(v => v.replace(new RegExp(`${suffix}$`), "")) value && suffix
: value || [] ? value.map(v => v.replace(new RegExp(`${suffix}$`), ""))
: value || []
</script> </script>
<div class="input-container"> <div class="input-container">

View File

@ -21,7 +21,7 @@
return componentName || "element" return componentName || "element"
} }
const screenPlaceholder = { const screenPlaceholder = {
name: "Screen Placeholder", name: "Screen Placeholder",
route: "*", route: "*",
props: { props: {
@ -60,9 +60,8 @@
}, },
} }
$: hasComponent = !!$store.currentPreviewItem $: hasComponent = !!$store.currentPreviewItem
$: { $: {
styles = "" styles = ""
// Apply the CSS from the currently selected page and its screens // Apply the CSS from the currently selected page and its screens
@ -88,9 +87,9 @@
libraries: $store.libraries, libraries: $store.libraries,
page: $store.pages[$store.currentPageName], page: $store.pages[$store.currentPageName],
screens: [ screens: [
$store.currentFrontEndType === "page" $store.currentFrontEndType === "page"
? screenPlaceholder ? screenPlaceholder
: $store.currentPreviewItem, : $store.currentPreviewItem,
], ],
appRootPath: "", appRootPath: "",
} }
@ -102,20 +101,25 @@
: "" : ""
const refreshContent = () => { const refreshContent = () => {
iframe.contentWindow.postMessage(JSON.stringify({ iframe.contentWindow.postMessage(
styles, JSON.stringify({
stylesheetLinks, styles,
selectedComponentType, stylesheetLinks,
selectedComponentId, selectedComponentType,
frontendDefinition, selectedComponentId,
})) frontendDefinition,
})
)
} }
$: if(iframe) iframe.contentWindow.addEventListener("bb-ready", refreshContent, { once: true }) $: if (iframe)
iframe.contentWindow.addEventListener("bb-ready", refreshContent, {
once: true,
})
$: if(iframe && frontendDefinition) { $: if (iframe && frontendDefinition) {
refreshContent() refreshContent()
} }
</script> </script>
<div class="component-container"> <div class="component-container">

View File

@ -37,27 +37,32 @@
//use for getting controls for each component property //use for getting controls for each component property
c => c._component === componentInstance._component c => c._component === componentInstance._component
) || {} ) || {}
let panelDefinition = {} let panelDefinition = {}
$: { $: {
if(componentPropDefinition.properties) { if (componentPropDefinition.properties) {
if(selectedCategory.value === "design") { if (selectedCategory.value === "design") {
panelDefinition = componentPropDefinition.properties["design"] panelDefinition = componentPropDefinition.properties["design"]
}else{ } else {
let panelDef = componentPropDefinition.properties["settings"] let panelDef = componentPropDefinition.properties["settings"]
if($store.currentFrontEndType === "page" && $store.currentView !== "component") { if (
panelDefinition = [...page,...panelDef] $store.currentFrontEndType === "page" &&
}else if($store.currentFrontEndType === "screen" && $store.currentView !== "component") { $store.currentView !== "component"
) {
panelDefinition = [...page, ...panelDef]
} else if (
$store.currentFrontEndType === "screen" &&
$store.currentView !== "component"
) {
panelDefinition = [...screen, ...panelDef] panelDefinition = [...screen, ...panelDef]
}else { } else {
panelDefinition = panelDef panelDefinition = panelDef
} }
} }
} }
} }
const onStyleChanged = store.setComponentStyle const onStyleChanged = store.setComponentStyle
const onPropChanged = store.setComponentProp const onPropChanged = store.setComponentProp

View File

@ -12,8 +12,9 @@ export const layout = [
label: "Display", label: "Display",
key: "display", key: "display",
control: OptionSelect, control: OptionSelect,
initialValue: "Flex", initialValue: "",
options: [ options: [
{ label: "", value: "" },
{ label: "Flex", value: "flex" }, { label: "Flex", value: "flex" },
{ label: "Inline Flex", value: "inline-flex" }, { label: "Inline Flex", value: "inline-flex" },
], ],
@ -39,6 +40,7 @@ export const layout = [
control: OptionSelect, control: OptionSelect,
initialValue: "Flex Start", initialValue: "Flex Start",
options: [ options: [
{ label: "", value: "" },
{ label: "Flex Start", value: "flex-start" }, { label: "Flex Start", value: "flex-start" },
{ label: "Flex End", value: "flex-end" }, { label: "Flex End", value: "flex-end" },
{ label: "Center", value: "center" }, { label: "Center", value: "center" },
@ -317,19 +319,31 @@ export const border = [
{ {
label: "Radius", label: "Radius",
key: "border-radius", key: "border-radius",
control: Input, control: OptionSelect,
width: "48px", defaultValue: "None",
placeholder: "px", options: [
textAlign: "center", { label: "None", value: "0" },
{ label: "small", value: "0.125rem" },
{ label: "Medium", value: "0.25rem;" },
{ label: "Large", value: "0.375rem" },
{ label: "Extra large", value: "0.5rem" },
{ label: "Full", value: "5678px" },
],
}, },
{ {
label: "Width", label: "Width",
key: "border-width", key: "border-width",
control: Input, control: OptionSelect,
width: "48px", defaultValue: "None",
placeholder: "px", options: [
textAlign: "center", { label: "None", value: "0" },
}, //custom { label: "Extra small", value: "0.5px" },
{ label: "Small", value: "1px" },
{ label: "Medium", value: "2px" },
{ label: "Large", value: "4px" },
{ label: "Extra large", value: "8px" },
],
},
{ {
label: "Color", label: "Color",
key: "border-color", key: "border-color",
@ -339,6 +353,7 @@ export const border = [
label: "Style", label: "Style",
key: "border-style", key: "border-style",
control: OptionSelect, control: OptionSelect,
defaultValue: "None",
options: [ options: [
"none", "none",
"hidden", "hidden",
@ -365,17 +380,50 @@ export const effects = [
}, },
{ {
label: "Rotate", label: "Rotate",
key: "transform", key: "transform-rotate",
control: Input, control: OptionSelect,
width: "48px", defaultValue: "0",
textAlign: "center", options: [
placeholder: "deg", "0",
"45deg",
"90deg",
"90deg",
"135deg",
"180deg",
"225deg",
"270deg",
"315dev",
],
}, //needs special control }, //needs special control
{ {
label: "Shadow", label: "Shadow",
key: "box-shadow", key: "box-shadow",
control: InputGroup, control: OptionSelect,
meta: [{ placeholder: "X" }, { placeholder: "Y" }, { placeholder: "B" }], defaultValue: "None",
options: [
{ label: "None", value: "none" },
{ label: "Extra small", value: "0 1px 2px 0 rgba(0, 0, 0, 0.05)" },
{
label: "Small",
value:
"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",
},
{
label: "Medium",
value:
"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
},
{
label: "Large",
value:
"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
},
{
label: "Extra large",
value:
"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
},
],
}, },
] ]