From 06bbc88b3e37ccef13ea70fb332b8efd9d380cd4 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Mon, 4 May 2020 16:07:04 +0100 Subject: [PATCH 1/6] WIP: Changes for property panel --- .../userInterface/CategoryTab.svelte | 43 ++++++ .../ComponentPropertiesPanel.svelte | 129 ++++++++---------- .../ComponentSelectionList.svelte | 16 +-- .../userInterface/DesignView.svelte | 17 +++ .../userInterface/PropertyGroup.svelte | 72 ++++++++++ .../userInterface/propertyCategories.js | 77 +++++++++++ .../userInterface/temporaryPanelStructure.js | 33 +++-- 7 files changed, 289 insertions(+), 98 deletions(-) create mode 100644 packages/builder/src/components/userInterface/CategoryTab.svelte create mode 100644 packages/builder/src/components/userInterface/DesignView.svelte create mode 100644 packages/builder/src/components/userInterface/PropertyGroup.svelte create mode 100644 packages/builder/src/components/userInterface/propertyCategories.js diff --git a/packages/builder/src/components/userInterface/CategoryTab.svelte b/packages/builder/src/components/userInterface/CategoryTab.svelte new file mode 100644 index 0000000000..246c1141e8 --- /dev/null +++ b/packages/builder/src/components/userInterface/CategoryTab.svelte @@ -0,0 +1,43 @@ + + + + + diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index c4c57c8e04..84480b2d69 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -14,17 +14,33 @@ import LayoutEditor from "./LayoutEditor.svelte" import EventsEditor from "./EventsEditor" - let current_view = "props" - let codeEditor + import panelStructure from "./temporaryPanelStructure.js" + import CategoryTab from "./CategoryTab.svelte" + import DesignView from "./DesignView.svelte" + + let current_view = "design" + let codeEditor + let flattenedPanel = flattenComponents(panelStructure.categories) + let categories = [ + { name: "Design" }, + { name: "Settings" }, + { name: "Actions" }, + ] + let selectedCategory = categories[0] - $: component = $store.currentComponentInfo - $: originalName = component.name - $: name = - $store.currentView === "detail" - ? $store.currentPreviewItem.name - : component._component - $: description = component.description $: components = $store.components + $: componentInstance = $store.currentComponentInfo //contains prop values of currently selected component + $: componentDefinition = $store.components.find( + c => c.name === componentInstance._component + ) + + $: panelDefinition = flattenedPanel.find( + //use for getting controls for each component property + c => c._component === componentInstance._component + ) + + // OLD PROPS ============================================= + $: screen_props = $store.currentFrontEndType === "page" ? getProps($store.currentPreviewItem, ["name", "favicon"]) @@ -33,77 +49,47 @@ const onPropChanged = store.setComponentProp const onStyleChanged = store.setComponentStyle + //May be able to remove some of the nested components in PropsView, PropsControl and StateBindingControl tree + + function walkProps(component, action) { + action(component) + if (component.children) { + for (let child of component.children) { + walkProps(child, action) + } + } + } + + function flattenComponents(props) { + const components = [] + props.forEach(comp => + walkProps(comp, c => { + if ("_component" in c) { + components.push(c) + } + }) + ) + return components + } + function getProps(obj, keys) { return keys.map((k, i) => [k, obj[k], obj.props._id + i]) }
- + + (selectedCategory = category)} + {categories} + {selectedCategory} /> +
- - {#if current_view === 'props'} - {#if $store.currentView === 'detail'} - {#each screen_props as [k, v, id] (id)} -
- - store.setMetadataProp(k, target.value)} /> -
- {/each} - - {:else} - - {/if} - {:else if current_view === 'layout'} - - {:else if current_view === 'events'} - + {#if current_view === 'design'} + + {/if} - -
@@ -146,7 +132,6 @@ .root { height: 100%; - padding: 20px; display: flex; flex-direction: column; } diff --git a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte index eb27559933..139dd65c59 100644 --- a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte +++ b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte @@ -2,6 +2,7 @@ import { splitName } from "./pagesParsing/splitRootComponentName.js" import components from "./temporaryPanelStructure.js" import ConfirmDialog from "components/common/ConfirmDialog.svelte" + import CategoryTab from "./CategoryTab.svelte" import { find, sortBy, @@ -85,15 +86,12 @@
- + + (selectedCategory = category)} + {selectedCategory} + {categories} /> +
+ import PropertyGroup from "./PropertyGroup.svelte" + export let panelDefinition = {} + export let componentInstance = {} + export let componentDefinition = {} + const getProperties = prop => panelDefinition.props[prop] + + $: props = !!panelDefinition.props && Object.keys(panelDefinition.props) + + +{#each props as prop} + +{/each} diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte new file mode 100644 index 0000000000..1b424dcd28 --- /dev/null +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -0,0 +1,72 @@ + + +
(show = !show)}> +
+
+ +
+
{capitalize(title)}
+
+
+
    + {#each propertyKeys as key} + +
  • {content[key].displayName || capitalize(key)}
  • + + {/each} +
+
+
+ + diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js new file mode 100644 index 0000000000..8b662d443c --- /dev/null +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -0,0 +1,77 @@ + +/* + TODO: all strings types are really inputs and could be typed as such + TODO: Options types need option items + TODO: Allow for default values for all properties +*/ + +export const layout = { + flexDirection: { displayName: "Direction", type: "string" }, + justifyContent: { displayName: "Justify", type: "string" }, + alignItems: { displayName: "Align", type: "string" }, + flexWrap: { displayName: "Wrap", type: "options" }, +} + +export const spacing = { + padding: { type: "string" }, + margin: { type: "string" }, +} + +export const size = { + width: { type: "string" }, + height: { type: "string" }, + minWidth: { displayName: "Min W", type: "string" }, + minHeight: { displayName: "Min H", type: "string" }, + maxWidth: { displayName: "Max W", type: "string" }, + maxHeight: { displayName: "Max H", type: "string" }, + overflow: { type: "string" }, //custom +} + +export const position = { + position: { type: "options" }, +} + +export const typography = { + font: { type: "options" }, + weight: { type: "options" }, + size: { type: "string" }, + lineHeight: { displayName: "Line H", type: "string" }, + color: { type: "colour" }, + align: { type: "string" }, //custom + transform: { type: "string" }, //custom + style: { type: "string" }, //custom +} + +export const background = { + backgroundColor: { displayName: "Background Color", type: "colour" }, + image: { type: "string" }, //custom +} + +export const border = { + radius: { type: "string" }, + width: { type: "string" }, //custom + color: { type: "colour" }, + style: { type: "options" }, +} + +export const effects = { + opacity: "string", + rotate: "string", + shadow: "string", +} + +export const transitions = { + property: { type: "options" }, + duration: { type: "string" }, + ease: { type: "options" }, +} + +export function excludeProps(props, propsToExclude) { + const modifiedProps = {} + for (const prop in props) { + if (!propsToExclude.includes(prop)) { + modifiedProps[prop] = props[prop] + } + } + return modifiedProps +} diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 5c4188d311..07facd4e28 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1,3 +1,5 @@ +import { layout, background } from "./propertyCategories.js" + export default { categories: [ { @@ -10,7 +12,8 @@ export default { description: 'This component contains things within itself', icon: 'ri-layout-row-fill', commonProps: {}, - children: [] + children: [], + props: { layout, background }, }, { name: 'Text', @@ -24,12 +27,8 @@ export default { description: "A component for displaying heading text", icon: "ri-heading", props: { - type: { - type: "options", - options: ["h1", "h2", "h3", "h4", "h5", "h6"], - default: "h1", - }, - text: "string", + layout, + background, }, }, { @@ -82,15 +81,15 @@ export default { name: 'Button', description: 'A basic html button that is ready for styling', icon: 'ri-radio-button-fill', - commonProps: {}, - children: [] + children: [], + props: {}, }, { _component: "@budibase/standard-components/icon", name: 'Icon', description: 'A basic component for displaying icons', icon: 'ri-sun-fill', - commonProps: {}, + props: {}, children: [] }, { @@ -98,7 +97,7 @@ export default { name: 'Link', description: 'A basic link component for internal and external links', icon: 'ri-link', - commonProps: {}, + props: {}, children: [] } ] @@ -112,14 +111,14 @@ export default { name: 'Card', description: 'A basic card component that can contain content and actions.', icon: 'ri-layout-bottom-line', - commonProps: {}, + props: {}, children: [] }, { name: 'Login', description: 'A component that automatically generates a login screen for your app.', icon: 'ri-login-box-fill', - commonProps: {}, + props: {}, children: [] }, { @@ -127,7 +126,7 @@ export default { _component: "@budibase/standard-components/Navigation", description: "A component for handling the navigation within your app.", icon: "ri-navigation-fill", - commonProps: {}, + props: {}, children: [] } ] @@ -140,15 +139,15 @@ export default { name: 'Table', description: 'A component that generates a table from your data.', icon: 'ri-archive-drawer-fill', - commonProps: {}, + props: {}, children: [] }, { name: 'Form', description: 'A component that generates a form from your data.', icon: 'ri-file-edit-fill', - commonProps: {}, - component: "@budibase/materialdesign-components/Form", + props: {}, + _component: "@budibase/materialdesign-components/Form", template: { component: "@budibase/materialdesign-components/Form", description: "Form for saving a record", From 8ad10976d3f03c2225a04873409014534e9703b3 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Tue, 5 May 2020 10:02:10 +0100 Subject: [PATCH 2/6] Updates to naming conventions --- .../userInterface/DesignView.svelte | 12 ++-- .../userInterface/PropertyGroup.svelte | 18 +++--- .../userInterface/propertyCategories.js | 63 +++++++++---------- .../userInterface/temporaryPanelStructure.js | 30 ++++----- 4 files changed, 62 insertions(+), 61 deletions(-) diff --git a/packages/builder/src/components/userInterface/DesignView.svelte b/packages/builder/src/components/userInterface/DesignView.svelte index 60a6dc8bc3..f8dad08905 100644 --- a/packages/builder/src/components/userInterface/DesignView.svelte +++ b/packages/builder/src/components/userInterface/DesignView.svelte @@ -1,17 +1,19 @@ -{#each props as prop} +{#each propertyGroupNames as groupName} {/each} diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index 1b424dcd28..b2b1e9c9eb 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -1,6 +1,6 @@
(show = !show)}> -
+
-
{capitalize(title)}
+
{capitalize(name)}
    {#each propertyKeys as key} -
  • {content[key].displayName || capitalize(key)}
  • +
  • {properties[key].label || capitalize(key)}
  • {/each}
@@ -42,7 +42,7 @@ padding: 5px; } - .property-group-title { + .property-group-name { cursor: pointer; flex: 0 0 20px; display: flex; @@ -54,7 +54,7 @@ text-align: center; } - .title { + .name { flex: 1; text-align: left; } diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 8b662d443c..352baea93e 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -1,4 +1,3 @@ - /* TODO: all strings types are really inputs and could be typed as such TODO: Options types need option items @@ -6,52 +5,52 @@ */ export const layout = { - flexDirection: { displayName: "Direction", type: "string" }, - justifyContent: { displayName: "Justify", type: "string" }, - alignItems: { displayName: "Align", type: "string" }, - flexWrap: { displayName: "Wrap", type: "options" }, + flexDirection: { label: "Direction", control: "string" }, + justifyContent: { label: "Justify", control: "string" }, + alignItems: { label: "Align", control: "string" }, + flexWrap: { label: "Wrap", control: "options" }, } export const spacing = { - padding: { type: "string" }, - margin: { type: "string" }, + padding: { control: "string" }, + margin: { control: "string" }, } export const size = { - width: { type: "string" }, - height: { type: "string" }, - minWidth: { displayName: "Min W", type: "string" }, - minHeight: { displayName: "Min H", type: "string" }, - maxWidth: { displayName: "Max W", type: "string" }, - maxHeight: { displayName: "Max H", type: "string" }, - overflow: { type: "string" }, //custom + width: { control: "string" }, + height: { control: "string" }, + minWidth: { label: "Min W", control: "string" }, + minHeight: { label: "Min H", control: "string" }, + maxWidth: { label: "Max W", control: "string" }, + maxHeight: { label: "Max H", control: "string" }, + overflow: { control: "string" }, //custom } export const position = { - position: { type: "options" }, + position: { control: "options" }, } export const typography = { - font: { type: "options" }, - weight: { type: "options" }, - size: { type: "string" }, - lineHeight: { displayName: "Line H", type: "string" }, - color: { type: "colour" }, - align: { type: "string" }, //custom - transform: { type: "string" }, //custom - style: { type: "string" }, //custom + font: { control: "options" }, + weight: { control: "options" }, + size: { control: "string" }, + lineHeight: { label: "Line H", control: "string" }, + color: { control: "colour" }, + align: { control: "string" }, //custom + transform: { control: "string" }, //custom + style: { control: "string" }, //custom } export const background = { - backgroundColor: { displayName: "Background Color", type: "colour" }, - image: { type: "string" }, //custom + backgroundColor: { label: "Background Color", control: "colour" }, + image: { control: "string" }, //custom } export const border = { - radius: { type: "string" }, - width: { type: "string" }, //custom - color: { type: "colour" }, - style: { type: "options" }, + radius: { control: "string" }, + width: { control: "string" }, //custom + color: { control: "colour" }, + style: { control: "options" }, } export const effects = { @@ -61,9 +60,9 @@ export const effects = { } export const transitions = { - property: { type: "options" }, - duration: { type: "string" }, - ease: { type: "options" }, + property: { control: "options" }, + duration: { control: "string" }, + ease: { control: "options" }, } export function excludeProps(props, propsToExclude) { diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 07facd4e28..7ec5988def 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -13,7 +13,7 @@ export default { icon: 'ri-layout-row-fill', commonProps: {}, children: [], - props: { layout, background }, + properties: { layout, background }, }, { name: 'Text', @@ -26,7 +26,7 @@ export default { name: 'Headline', description: "A component for displaying heading text", icon: "ri-heading", - props: { + properties: { layout, background, }, @@ -36,7 +36,7 @@ export default { name: 'Paragraph', description: "A component for displaying paragraph text.", icon: 'ri-paragraph', - props: {} + properties: {} } ] }, @@ -51,28 +51,28 @@ export default { name: "Textfield", description: "A textfield component that allows the user to input text.", icon: 'ri-edit-box-line', - props: {} + properties: {} }, { _component: "@budibase/standard-components/checkbox", name: "Checkbox", description: "A selectable checkbox component", icon: 'ri-checkbox-line', - props: {} + properties: {} }, { _component: "@budibase/standard-components/radiobutton", name: "Radiobutton", description: "A selectable radiobutton component", icon: 'ri-radio-button-line', - props: {} + properties: {} }, { _component: "@budibase/standard-components/select", name: "Select", description: "A select component for choosing from different options", icon: 'ri-file-list-line', - props: {} + properties: {} } ] }, @@ -82,14 +82,14 @@ export default { description: 'A basic html button that is ready for styling', icon: 'ri-radio-button-fill', children: [], - props: {}, + properties: {}, }, { _component: "@budibase/standard-components/icon", name: 'Icon', description: 'A basic component for displaying icons', icon: 'ri-sun-fill', - props: {}, + properties: {}, children: [] }, { @@ -97,7 +97,7 @@ export default { name: 'Link', description: 'A basic link component for internal and external links', icon: 'ri-link', - props: {}, + properties: {}, children: [] } ] @@ -111,14 +111,14 @@ export default { name: 'Card', description: 'A basic card component that can contain content and actions.', icon: 'ri-layout-bottom-line', - props: {}, + properties: {}, children: [] }, { name: 'Login', description: 'A component that automatically generates a login screen for your app.', icon: 'ri-login-box-fill', - props: {}, + properties: {}, children: [] }, { @@ -126,7 +126,7 @@ export default { _component: "@budibase/standard-components/Navigation", description: "A component for handling the navigation within your app.", icon: "ri-navigation-fill", - props: {}, + properties: {}, children: [] } ] @@ -139,14 +139,14 @@ export default { name: 'Table', description: 'A component that generates a table from your data.', icon: 'ri-archive-drawer-fill', - props: {}, + properties: {}, children: [] }, { name: 'Form', description: 'A component that generates a form from your data.', icon: 'ri-file-edit-fill', - props: {}, + properties: {}, _component: "@budibase/materialdesign-components/Form", template: { component: "@budibase/materialdesign-components/Form", From b52b9fdd2f65584111646f13b57a9868729cf30a Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Tue, 5 May 2020 14:45:52 +0100 Subject: [PATCH 3/6] solution for rendering --- .../src/components/common/Colorpicker.svelte | 13 +++--- .../ComponentPropertiesPanel.svelte | 7 +++- .../userInterface/DesignView.svelte | 4 ++ .../userInterface/PropertyGroup.svelte | 42 +++++++++++++------ .../userInterface/TempSelect.svelte | 14 +++++++ .../userInterface/propertyCategories.js | 13 ++++-- .../userInterface/temporaryPanelStructure.js | 5 ++- .../standard-components/src/Heading.svelte | 1 - 8 files changed, 71 insertions(+), 28 deletions(-) create mode 100644 packages/builder/src/components/userInterface/TempSelect.svelte diff --git a/packages/builder/src/components/common/Colorpicker.svelte b/packages/builder/src/components/common/Colorpicker.svelte index 9cc3b3926a..28ca92554d 100644 --- a/packages/builder/src/components/common/Colorpicker.svelte +++ b/packages/builder/src/components/common/Colorpicker.svelte @@ -2,7 +2,7 @@ import { onMount, beforeUpdate, afterUpdate } from "svelte" export let value = null - export let onChanged = () => {} + export let onChange = () => {} export let swatches = [] let picker @@ -58,13 +58,10 @@ onMount(() => { getRecentColors() createPicker() - - picker.on("save", (colour, instance) => { - let color = colour.toHEXA().toString() - onChanged(color) - setRecentColor(color) - picker.hide() - }) + return () => { + picker.destroyAndRemove() + picker = null + } }) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 84480b2d69..944862ebee 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -86,8 +86,11 @@
{#if current_view === 'design'} - - + {/if}
diff --git a/packages/builder/src/components/userInterface/DesignView.svelte b/packages/builder/src/components/userInterface/DesignView.svelte index f8dad08905..0aebd7b186 100644 --- a/packages/builder/src/components/userInterface/DesignView.svelte +++ b/packages/builder/src/components/userInterface/DesignView.svelte @@ -4,8 +4,11 @@ export let panelDefinition = {} export let componentInstance = {} export let componentDefinition = {} + export let onPropChanged = () => {} + const getProperties = name => panelDefinition.properties[name] + $: console.log("PDEF", panelDefinition) $: propertyGroupNames = !!panelDefinition.properties && Object.keys(panelDefinition.properties) @@ -14,6 +17,7 @@ {/each} diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index b2b1e9c9eb..fa6dba0156 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -1,20 +1,27 @@ -
(show = !show)}> + +
{}}>
@@ -22,13 +29,20 @@
{capitalize(name)}
-
    - {#each propertyKeys as key} - -
  • {properties[key].label || capitalize(key)}
  • - - {/each} -
+ + {#each propertyDefinition as [key, definition]} +
+ {#if propExistsOnComponentDef(key)} + {definition.label || capitalize(key)} + + {/if} +
+ {/each}
@@ -62,7 +76,11 @@ .property-panel { height: 0px; overflow: hidden; - /* transition: height 2s ease-in-out; */ + } + + .property-control { + display: flex; + flex-flow: row nowrap; } .show { diff --git a/packages/builder/src/components/userInterface/TempSelect.svelte b/packages/builder/src/components/userInterface/TempSelect.svelte new file mode 100644 index 0000000000..514c9b5a20 --- /dev/null +++ b/packages/builder/src/components/userInterface/TempSelect.svelte @@ -0,0 +1,14 @@ + + + diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 352baea93e..6246462ecb 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -1,9 +1,16 @@ -/* +import ColorPicker from "../common/Colorpicker.svelte" +import Input from "../common/Input.svelte" +import TempSelect from "./TempSelect.svelte" +/* TODO: all strings types are really inputs and could be typed as such TODO: Options types need option items TODO: Allow for default values for all properties */ +export const general = { + text: { control: Input } +} + export const layout = { flexDirection: { label: "Direction", control: "string" }, justifyContent: { label: "Justify", control: "string" }, @@ -42,8 +49,8 @@ export const typography = { } export const background = { - backgroundColor: { label: "Background Color", control: "colour" }, - image: { control: "string" }, //custom + backgroundColor: { label: "Background Color", control: ColorPicker }, + image: { control: Input }, //custom } export const border = { diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 7ec5988def..bc60ac2bd6 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1,4 +1,4 @@ -import { layout, background } from "./propertyCategories.js" +import { general, layout, background } from "./propertyCategories.js" export default { categories: [ @@ -13,7 +13,7 @@ export default { icon: 'ri-layout-row-fill', commonProps: {}, children: [], - properties: { layout, background }, + properties: { background }, }, { name: 'Text', @@ -27,6 +27,7 @@ export default { description: "A component for displaying heading text", icon: "ri-heading", properties: { + general, layout, background, }, diff --git a/packages/standard-components/src/Heading.svelte b/packages/standard-components/src/Heading.svelte index 6a3a210dc3..4bbb9d0b36 100644 --- a/packages/standard-components/src/Heading.svelte +++ b/packages/standard-components/src/Heading.svelte @@ -11,7 +11,6 @@ $: containerElement && !text && _bb.attachChildren(containerElement) $: style = buildStyle({ "font-family": fontFamily, color }) - // $: console.log("HEADING", color) {#if type === 'h1'} From 8d8caa9ff5be59147d2b27726074af57fba30121 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Thu, 7 May 2020 14:30:04 +0100 Subject: [PATCH 4/6] Properties panel structure complete --- .../src/components/common/Input.svelte | 5 +- .../ComponentPropertiesPanel.svelte | 86 +-------------- .../ComponentsPaneSwitcher.svelte | 5 +- .../userInterface/DesignView.svelte | 57 ++++++++-- .../userInterface/FlatButton.svelte | 38 +++++++ .../userInterface/FlatButtonGroup.svelte | 54 +++++++++ .../userInterface/OptionSelect.svelte | 22 ++++ .../userInterface/PropertyControl.svelte | 41 +++++++ .../userInterface/PropertyGroup.svelte | 52 ++++----- .../userInterface/TempSelect.svelte | 14 --- .../userInterface/UserInterfaceRoot.svelte | 4 +- .../userInterface/propertyCategories.js | 103 +++++++++++------- .../userInterface/temporaryPanelStructure.js | 6 +- 13 files changed, 305 insertions(+), 182 deletions(-) create mode 100644 packages/builder/src/components/userInterface/FlatButton.svelte create mode 100644 packages/builder/src/components/userInterface/FlatButtonGroup.svelte create mode 100644 packages/builder/src/components/userInterface/OptionSelect.svelte create mode 100644 packages/builder/src/components/userInterface/PropertyControl.svelte delete mode 100644 packages/builder/src/components/userInterface/TempSelect.svelte diff --git a/packages/builder/src/components/common/Input.svelte b/packages/builder/src/components/common/Input.svelte index 50b07f41f0..bc6741e0d8 100644 --- a/packages/builder/src/components/common/Input.svelte +++ b/packages/builder/src/components/common/Input.svelte @@ -1,8 +1,11 @@ - + diff --git a/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte b/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte index 9ca5b1e122..8e72a17c54 100644 --- a/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte +++ b/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte @@ -24,13 +24,13 @@
@@ -55,6 +55,7 @@ display: flex; flex-direction: column; padding: 20px 0; + border-left: solid 1px #e8e8ef; } .switcher { diff --git a/packages/builder/src/components/userInterface/DesignView.svelte b/packages/builder/src/components/userInterface/DesignView.svelte index 0aebd7b186..7fc6af5312 100644 --- a/packages/builder/src/components/userInterface/DesignView.svelte +++ b/packages/builder/src/components/userInterface/DesignView.svelte @@ -1,23 +1,62 @@ -{#each propertyGroupNames as groupName} - -{/each} +
+ +
+ +
+ +
+ {#each propertyGroupNames as groupName} + + {/each} +
+
+ + diff --git a/packages/builder/src/components/userInterface/FlatButton.svelte b/packages/builder/src/components/userInterface/FlatButton.svelte new file mode 100644 index 0000000000..abc4a3dc28 --- /dev/null +++ b/packages/builder/src/components/userInterface/FlatButton.svelte @@ -0,0 +1,38 @@ + + +
onClick(value || text)}> + {#if useIcon} + + {:else} + {text} + {/if} +
+ + diff --git a/packages/builder/src/components/userInterface/FlatButtonGroup.svelte b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte new file mode 100644 index 0000000000..f16d832c67 --- /dev/null +++ b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte @@ -0,0 +1,54 @@ + + +
+ {#each buttonProps as props} +
+ +
+ {/each} +
+ + diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte new file mode 100644 index 0000000000..cbbdb8f91f --- /dev/null +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -0,0 +1,22 @@ + + + diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte new file mode 100644 index 0000000000..23dd223de6 --- /dev/null +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -0,0 +1,41 @@ + + +
+
{label}
+
+ +
+
+ + diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index fa6dba0156..96d5ba7a7b 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -1,28 +1,27 @@ - -
{}}> -
+
+
(show = !show)}>
@@ -31,17 +30,14 @@
{#each propertyDefinition as [key, definition]} -
- {#if propExistsOnComponentDef(key)} - {definition.label || capitalize(key)} - - {/if} -
+ + onChange(key, value)} + props={{ ...excludeProps(definition, ['control']) }} /> + {/each}
@@ -63,14 +59,19 @@ flex-flow: row nowrap; } - .icon { - flex: 0 0 20px; - text-align: center; - } - .name { flex: 1; text-align: left; + padding-top: 2px; + font-size: 14px; + font-weight: 500; + letter-spacing: 0.14px; + color: #393c44; + } + + .icon { + flex: 0 0 20px; + text-align: center; } .property-panel { @@ -78,11 +79,6 @@ overflow: hidden; } - .property-control { - display: flex; - flex-flow: row nowrap; - } - .show { overflow: auto; height: auto; diff --git a/packages/builder/src/components/userInterface/TempSelect.svelte b/packages/builder/src/components/userInterface/TempSelect.svelte deleted file mode 100644 index 514c9b5a20..0000000000 --- a/packages/builder/src/components/userInterface/TempSelect.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte index 4f32c55d24..13d7a7e2a1 100644 --- a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte +++ b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte @@ -114,7 +114,7 @@ .root { display: grid; - grid-template-columns: 275px 1fr 275px; + grid-template-columns: 275px 1fr 300px; height: 100%; width: 100%; background: #fafafa; @@ -151,7 +151,7 @@ .components-pane { grid-column: 3; background-color: var(--white); - min-height: 0px; + height: 100vh; overflow-y: scroll; } diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 6246462ecb..525738f02f 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -1,75 +1,102 @@ -import ColorPicker from "../common/Colorpicker.svelte" import Input from "../common/Input.svelte" -import TempSelect from "./TempSelect.svelte" +import OptionSelect from "./OptionSelect.svelte" /* - TODO: all strings types are really inputs and could be typed as such - TODO: Options types need option items TODO: Allow for default values for all properties */ export const general = { - text: { control: Input } + text: { control: Input }, } export const layout = { - flexDirection: { label: "Direction", control: "string" }, - justifyContent: { label: "Justify", control: "string" }, - alignItems: { label: "Align", control: "string" }, - flexWrap: { label: "Wrap", control: "options" }, + flexDirection: { + label: "Direction", + control: OptionSelect, + initialValue: "columnReverse", + options: [ + { label: "row" }, + { label: "row-reverse", value: "rowReverse" }, + { label: "column" }, + { label: "column-reverse", value: "columnReverse" }, + ], + }, + justifyContent: { label: "Justify", control: Input }, + alignItems: { label: "Align", control: Input }, + flexWrap: { + label: "Wrap", + control: OptionSelect, + options: [{ label: "wrap" }, { label: "no wrap", value: "noWrap" }], + }, } export const spacing = { - padding: { control: "string" }, - margin: { control: "string" }, + padding: { control: Input }, + margin: { control: Input }, } export const size = { - width: { control: "string" }, - height: { control: "string" }, - minWidth: { label: "Min W", control: "string" }, - minHeight: { label: "Min H", control: "string" }, - maxWidth: { label: "Max W", control: "string" }, - maxHeight: { label: "Max H", control: "string" }, - overflow: { control: "string" }, //custom + width: { control: Input }, + height: { control: Input }, + minWidth: { label: "Min W", control: Input }, + minHeight: { label: "Min H", control: Input }, + maxWidth: { label: "Max W", control: Input }, + maxHeight: { label: "Max H", control: Input }, + overflow: { control: Input }, //custom } export const position = { - position: { control: "options" }, + position: { control: Input }, } export const typography = { - font: { control: "options" }, - weight: { control: "options" }, - size: { control: "string" }, - lineHeight: { label: "Line H", control: "string" }, - color: { control: "colour" }, - align: { control: "string" }, //custom - transform: { control: "string" }, //custom - style: { control: "string" }, //custom + font: { control: Input }, + weight: { control: Input }, + size: { control: Input }, + lineHeight: { label: "Line H", control: Input }, + color: { + control: OptionSelect, + options: [{ label: "red" }, { label: "blue" }, { label: "green" }], + }, + align: { control: Input }, //custom + transform: { control: Input }, //custom + style: { control: Input }, //custom } export const background = { - backgroundColor: { label: "Background Color", control: ColorPicker }, + backgroundColor: { label: "Background Color", control: Input }, image: { control: Input }, //custom } export const border = { - radius: { control: "string" }, - width: { control: "string" }, //custom - color: { control: "colour" }, - style: { control: "options" }, + radius: { control: Input }, + width: { control: Input }, //custom + color: { control: Input }, + style: { control: Input }, } export const effects = { - opacity: "string", - rotate: "string", - shadow: "string", + opacity: { control: Input }, + rotate: { control: Input }, + shadow: { control: Input }, } export const transitions = { - property: { control: "options" }, - duration: { control: "string" }, - ease: { control: "options" }, + property: { control: Input }, + duration: { control: Input }, + ease: { control: Input }, +} + +export const all = { + general, + layout, + spacing, + size, + position, + typography, + background, + border, + effects, + transitions, } export function excludeProps(props, propsToExclude) { diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index bc60ac2bd6..c4426d1035 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1,4 +1,4 @@ -import { general, layout, background } from "./propertyCategories.js" +import { general, layout, typography, background, all } from "./propertyCategories.js" export default { categories: [ @@ -13,7 +13,7 @@ export default { icon: 'ri-layout-row-fill', commonProps: {}, children: [], - properties: { background }, + properties: { ...all }, }, { name: 'Text', @@ -29,7 +29,7 @@ export default { properties: { general, layout, - background, + typography, }, }, { From 6b7a3d1d7e4a650a2e071fa1113dec1451dae626 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Fri, 8 May 2020 09:57:41 +0100 Subject: [PATCH 5/6] Style binding options and property categories --- .../userInterface/OptionSelect.svelte | 13 +++- .../userInterface/propertyCategories.js | 75 ++++++++++++++++--- 2 files changed, 75 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte index cbbdb8f91f..b3cfa5e54b 100644 --- a/packages/builder/src/components/userInterface/OptionSelect.svelte +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -4,6 +4,9 @@ export let onChange = value => {} export let options = [] export let initialValue = "" + export let styleBindingProperty = "" + + $: bindOptionToStyle = !!styleBindingProperty onMount(() => { if (!value && !!initialValue) { @@ -17,6 +20,14 @@ {value} on:change={ev => onChange(ev.target.value)}> {#each options as { value, label }} - + {#if bindOptionToStyle} + + {:else} + + {/if} {/each} diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 525738f02f..7505645b65 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -41,25 +41,76 @@ export const size = { minHeight: { label: "Min H", control: Input }, maxWidth: { label: "Max W", control: Input }, maxHeight: { label: "Max H", control: Input }, - overflow: { control: Input }, //custom + overflow: { + control: OptionSelect, + options: [ + { label: "visible" }, + { label: "auto" }, + { label: "hidden" }, + { label: "auto" }, + { label: "scroll" }, + ], + }, //custom } export const position = { - position: { control: Input }, + position: { + control: OptionSelect, + options: [ + { label: "static" }, + { label: "relative" }, + { label: "fixed" }, + { label: "absolute" }, + { label: "sticky" }, + ], + }, } export const typography = { - font: { control: Input }, - weight: { control: Input }, - size: { control: Input }, + fontFamily: { + label: "Font", + control: OptionSelect, + options: [ + { label: "initial" }, + { label: "Times New Roman" }, + { label: "Georgia" }, + { label: "Arial" }, + { label: "Arial Black" }, + { label: "Comic Sans MS" }, + { label: "Impact" }, + { label: "Lucida Sans Unicode" }, + ], + styleBindingProperty: "font-family", + }, + fontWeight: { + label: "weight", + control: OptionSelect, + options: [ + { label: "normal" }, + { label: "bold" }, + { label: "bolder" }, + { label: "lighter" }, + ], + }, + fontSize: { label: "size", control: Input }, lineHeight: { label: "Line H", control: Input }, color: { control: OptionSelect, options: [{ label: "red" }, { label: "blue" }, { label: "green" }], }, - align: { control: Input }, //custom - transform: { control: Input }, //custom - style: { control: Input }, //custom + textAlign: { + label: "align", + control: OptionSelect, + options: [ + { label: "initial" }, + { label: "left" }, + { label: "right" }, + { label: "center" }, + { label: "justify" }, + ], + }, //custom + textTransform: { label: "transform", control: Input }, //custom + fontStyle: { label: "style", control: Input }, //custom } export const background = { @@ -68,10 +119,10 @@ export const background = { } export const border = { - radius: { control: Input }, - width: { control: Input }, //custom - color: { control: Input }, - style: { control: Input }, + borderRadius: { label: "radius", control: Input }, + borderWidth: { label: "width", control: Input }, //custom + borderColor: { label: "color", control: Input }, + borderStyle: { label: "style", control: Input }, } export const effects = { From 2e636dec9347e8fdf6e84408754de51b205def0e Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Fri, 8 May 2020 20:29:15 +0100 Subject: [PATCH 6/6] Pre demo changes --- .../ComponentPropertiesPanel.svelte | 5 ++-- .../userInterface/PropertyGroup.svelte | 15 ++++++++++++ .../userInterface/propertyCategories.js | 20 ++++++++++++++-- .../userInterface/temporaryPanelStructure.js | 24 ++++++++++++------- packages/standard-components/components.json | 4 +++- .../standard-components/src/Button.svelte | 6 ++--- .../standard-components/src/Container.svelte | 12 ++++++++++ 7 files changed, 67 insertions(+), 19 deletions(-) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 94c450823a..12a7b3eb90 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -29,7 +29,7 @@ let selectedCategory = categories[0] $: components = $store.components - $: componentInstance = $store.currentComponentInfo //contains prop values of currently selected component + $: componentInstance = $store.currentComponentInfo $: componentDefinition = $store.components.find( c => c.name === componentInstance._component ) @@ -39,8 +39,7 @@ c => c._component === componentInstance._component ) - // OLD PROPS ============================================= - + // SCREEN PROPS ============================================= $: screen_props = $store.currentFrontEndType === "page" ? getProps($store.currentPreviewItem, ["name", "favicon"]) diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index 96d5ba7a7b..2d88557777 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -1,6 +1,7 @@ +
(show = !show)}>
@@ -41,6 +55,7 @@ {/each}
+