diff --git a/packages/builder/src/builderStore/generate_css.js b/packages/builder/src/builderStore/generate_css.js index bc82cb48f1..5d811c6f37 100644 --- a/packages/builder/src/builderStore/generate_css.js +++ b/packages/builder/src/builderStore/generate_css.js @@ -1,5 +1,3 @@ -import { toNumber } from "lodash/fp" - export const generate_screen_css = component_arr => { let styles = "" for (const { _styles, _id, _children, _component } of component_arr) { @@ -19,16 +17,13 @@ export const generate_screen_css = component_arr => { export const generate_css = style => { let cssString = Object.entries(style).reduce((str, [key, value]) => { - //TODO Handle arrays and objects here also if (typeof value === "string") { if (value) { return (str += `${key}: ${value};\n`) } } else if (Array.isArray(value)) { if (value.length > 0 && !value.every(v => v === "")) { - return (str += `${key}: ${value - .map(generate_array_styles) - .join(" ")};\n`) + return (str += `${key}: ${value.join(" ")};\n`) } } }, "") @@ -36,16 +31,6 @@ export const generate_css = style => { return (cssString || "").trim() } -export const generate_array_styles = item => { - let safeItem = item === "" ? 0 : item - let hasPx = new RegExp("px$") - if (!hasPx.test(safeItem) && !isNaN(toNumber(safeItem))) { - return `${safeItem}px` - } else { - return safeItem - } -} - export const apply_class = (id, name = "element", styles, selector) => { if (selector === "normal") { return `.${name}-${id} {\n${styles}\n}` diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 06a1f5b51d..9f91550bca 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -364,6 +364,7 @@ const addChildComponent = store => (componentToAdd, presetName) => { /** * @param {string} props - props to add, as child of current component */ + const addTemplatedComponent = store => props => { store.update(state => { walkProps(props, p => { diff --git a/packages/builder/src/components/common/Input.svelte b/packages/builder/src/components/common/Input.svelte index b80e24e000..04272c1d76 100644 --- a/packages/builder/src/components/common/Input.svelte +++ b/packages/builder/src/components/common/Input.svelte @@ -1,29 +1,42 @@ - + diff --git a/packages/builder/src/components/common/Inputs/InputGroup.svelte b/packages/builder/src/components/common/Inputs/InputGroup.svelte index 95ebf1a3b4..d0b1465762 100644 --- a/packages/builder/src/components/common/Inputs/InputGroup.svelte +++ b/packages/builder/src/components/common/Inputs/InputGroup.svelte @@ -1,27 +1,35 @@
{label}
-
- {#each meta as { placeholder }, i} - + {#each meta as m, i} + handleChange(e.target.value || 0, i)} /> {/each}
@@ -32,39 +40,8 @@ flex: 0; } - .inputs { + .inputs-group { flex: 1; } - input { - width: 40px; - height: 32px; - font-size: 12px; - font-weight: 700; - margin: 0px 0px 0px 1px; - text-align: center; - color: var(--ink); - opacity: 0.7; - padding: 0px 4px; - box-sizing: border-box; - border: 1px solid var(--grey); - border-radius: 2px; - outline: none; - } - - input[type="text"]::-webkit-inner-spin-button, - input[type="text"]::-webkit-outer-spin-button { - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; - margin: 0; - } - - input[type="text"] { - -moz-appearance: textfield; - } - - input::placeholder { - text-align: center; - } diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index ab02d0c4ff..1731be54f8 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -106,10 +106,12 @@ height: 100%; display: flex; flex-direction: column; + /* Merge Check */ overflow-x: hidden; overflow-y: hidden; padding: 20px; box-sizing: border-box; + /* Merge Check */ } .title > div:nth-child(1) { diff --git a/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte b/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte index de523cd7bf..9df2a928ca 100644 --- a/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte +++ b/packages/builder/src/components/userInterface/ComponentsPaneSwitcher.svelte @@ -54,7 +54,7 @@ height: 100%; display: flex; flex-direction: column; - padding: 20px 20px; + padding: 20px 5px 20px 10px; border-left: solid 1px var(--grey); } @@ -78,4 +78,8 @@ .switcher > .selected { color: var(--ink); } + + .panel { + height: 100%; + } diff --git a/packages/builder/src/components/userInterface/DesignView.svelte b/packages/builder/src/components/userInterface/DesignView.svelte index 40aac9027a..f13f62663e 100644 --- a/packages/builder/src/components/userInterface/DesignView.svelte +++ b/packages/builder/src/components/userInterface/DesignView.svelte @@ -55,6 +55,7 @@ display: flex; flex-direction: column; width: 100%; + height: 100%; } .design-view-state-categories { @@ -63,6 +64,9 @@ .design-view-property-groups { flex: 1; + overflow-y: auto; + overflow-x: hidden; + max-height: 500px; } .no-design { diff --git a/packages/builder/src/components/userInterface/FlatButton.svelte b/packages/builder/src/components/userInterface/FlatButton.svelte index 7fb5742c46..e9798fc89c 100644 --- a/packages/builder/src/components/userInterface/FlatButton.svelte +++ b/packages/builder/src/components/userInterface/FlatButton.svelte @@ -1,21 +1,26 @@ -
onClick(value || text)}> +
onClick(value || text)}> {#if useIcon} {:else} - {text} + {@html text} {/if}
+ diff --git a/packages/builder/src/components/userInterface/FlatButtonGroup.svelte b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte index ffa1a98393..ad1107b1f1 100644 --- a/packages/builder/src/components/userInterface/FlatButtonGroup.svelte +++ b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte @@ -27,13 +27,18 @@ } onChange(val) } + + + const checkSelected = val => + isMultiSelect ? value.includes(val) : value === val +
{#each buttonProps as props}
diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte index 4fbedde4ac..d226e6129c 100644 --- a/packages/builder/src/components/userInterface/OptionSelect.svelte +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -1,36 +1,223 @@ - +
toggleSelect(!open)}> +
+ {displayLabel} + +
+
+
    + {#if isOptionsObject} + {#each options as { value: v, label }} +
  • + {label} +
  • + {/each} + {:else} + {#each options as v} +
  • + {v} +
  • + {/each} + {/if} +
+
+
+{#if open} +
toggleSelect(false)} class="overlay" /> +{/if} + + diff --git a/packages/builder/src/components/userInterface/OptionSelectOld.svelte b/packages/builder/src/components/userInterface/OptionSelectOld.svelte new file mode 100644 index 0000000000..db3c19de35 --- /dev/null +++ b/packages/builder/src/components/userInterface/OptionSelectOld.svelte @@ -0,0 +1,33 @@ + + + diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte index 82acb8b3f9..a7ea35c014 100644 --- a/packages/builder/src/components/userInterface/PropertyControl.svelte +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -50,6 +50,9 @@ .label { flex: 0 0 50px; + display: flex; + align-items: center; + padding: 0px 5px; font-size: 12px; font-weight: 400; text-align: left; @@ -60,6 +63,7 @@ .control { flex: 1; + display: flex; padding-left: 2px; max-width: 164px; } diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index 6d0cf63ab0..a51607833a 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -71,12 +71,16 @@ } .property-panel { - height: 0px; - overflow: hidden; + /* height: 0px; + overflow: hidden; */ + display: none; } .show { - overflow: auto; - height: auto; + /* overflow: auto; + height: auto; */ + display: flex; + flex-direction: column; + flex: 1; } diff --git a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte index da57b134a0..d2924675e6 100644 --- a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte +++ b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte @@ -123,8 +123,7 @@ .components-pane { grid-column: 3; background-color: var(--white); - height: 100vh; - overflow-y: scroll; + height: calc(100vh - 49px); } .components-nav-page { diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 2a81b5fcf7..719396a2fb 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -1,6 +1,7 @@ import Input from "../common/Input.svelte" import OptionSelect from "./OptionSelect.svelte" import InputGroup from "../common/Inputs/InputGroup.svelte" +import FlatButtonGroup from "./FlatButtonGroup.svelte" // import Colorpicker from "../common/Colorpicker.svelte" /* TODO: Allow for default values for all properties @@ -11,9 +12,8 @@ export const layout = [ label: "Display", key: "display", control: OptionSelect, - initialValue: "Select Option", + initialValue: "Flex", options: [ - { label: "Select Option", value: "" }, { label: "Flex", value: "flex" }, { label: "Inline Flex", value: "inline-flex" }, ], @@ -21,23 +21,24 @@ export const layout = [ { label: "Direction", key: "flex-direction", - control: OptionSelect, - initialValue: "Select Option", - options: [ - { label: "Select Option", value: "" }, - { label: "Row", value: "row" }, - { label: "Row Reverse", value: "rowReverse" }, - { label: "Column", value: "column" }, - { label: "Column Reverse", value: "columnReverse" }, + control: FlatButtonGroup, + buttonProps: [ + { icon: "ri-arrow-right-line", padding: "0px 5px", value: "row" }, + { icon: "ri-arrow-left-line", padding: "0px 5px", value: "rowReverse" }, + { icon: "ri-arrow-down-line", padding: "0px 5px", value: "column" }, + { + icon: "ri-arrow-up-line", + padding: "0px 5px", + value: "columnReverse", + }, ], }, { label: "Justify", key: "justify-content", control: OptionSelect, - initialValue: "Select Option", + initialValue: "Flex Start", options: [ - { label: "Select Option", value: "" }, { label: "Flex Start", value: "flex-start" }, { label: "Flex End", value: "flex-end" }, { label: "Center", value: "center" }, @@ -50,9 +51,8 @@ export const layout = [ label: "Align", key: "align-items", control: OptionSelect, - initialValue: "Select Option", + initialValue: "Flex Start", options: [ - { label: "Select Option", value: "" }, { label: "Flex Start", value: "flex-start" }, { label: "Flex End", value: "flex-end" }, { label: "Center", value: "center" }, @@ -64,12 +64,9 @@ export const layout = [ label: "Wrap", key: "flex-wrap", control: OptionSelect, - initialValue: "Select Option", options: [ - { label: "Select Option", value: "" }, - { label: "No Wrap", value: "nowrap" }, - { label: "Wrap", value: "wrap" }, - { label: "Wrap Reverse", value: "wrap-reverse" }, + { label: "wrap", value: "wrap" }, + { label: "no wrap", value: "noWrap" }, ], }, ] @@ -82,22 +79,73 @@ const spacingMeta = [ ] export const spacing = [ - { label: "Margin", key: "margin", control: InputGroup, meta: spacingMeta }, + { + label: "Margin", + key: "margin", + control: InputGroup, + meta: spacingMeta, + suffix: "px", + defaultValue: ["0", "0", "0", "0"], + }, { label: "Padding", key: "padding", control: InputGroup, meta: spacingMeta, + suffix: "px", + defaultValue: ["0", "0", "0", "0"], }, ] export const size = [ - { label: "Width", key: "width", control: Input }, - { label: "Height", key: "height", control: Input }, - { label: "Min W", key: "min-width", control: Input }, - { label: "Min H", key: "min-height", control: Input }, - { label: "Max W", key: "max-width", control: Input }, - { label: "Max H", key: "max-height", control: Input }, + { + label: "Width", + key: "width", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Height", + key: "height", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Min W", + key: "min-width", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Min H", + key: "min-height", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Max W", + key: "max-width", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Max H", + key: "max-height", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, ] export const position = [ @@ -118,26 +166,41 @@ export const position = [ label: "Top", key: "top", control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", }, { label: "Right", key: "right", control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", }, { label: "Bottom", key: "bottom", control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", }, { label: "Left", key: "left", control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", }, { label: "Z-index", key: "z-index", control: Input, + placeholder: "num", + width: "48px", + textAlign: "center", }, ] @@ -171,47 +234,59 @@ export const typography = [ label: "Weight", key: "font-weight", control: OptionSelect, - options: [ - { label: "100", value: "100" }, - { label: "200", value: "200" }, - { label: "300", value: "300" }, - { label: "400", value: "400" }, - { label: "500", value: "500" }, - { label: "600", value: "600" }, - { label: "700", value: "700" }, - { label: "800", value: "800" }, - { label: "900", value: "900" }, - ], + options: ["normal", "bold", "bolder", "lighter"], + }, + { + label: "size", + key: "font-size", + defaultValue: "", + control: Input, + placeholder: "px", + width: "48px", + textAlign: "center", + }, + { + label: "Line H", + key: "line-height", + control: Input, + placeholder: "lh", + width: "48px", + textAlign: "center", }, - { label: "size", key: "font-size", defaultValue: "", control: Input }, - { label: "Line H", key: "line-height", control: Input }, { label: "Color", key: "color", control: Input, + placeholder: "hex", }, { label: "align", key: "text-align", - control: OptionSelect, - options: ["initial", "left", "right", "center", "justify"], - }, //custom - { - label: "Decoration", - key: "text-decoration-line", - control: OptionSelect, - defaultValue: "None", - options: [ - { label: "None", value: "none" }, - { label: "Underline", value: "underline" }, - { label: "Overline", value: "overline" }, - { label: "Line-through", value: "line-through" }, - { label: "Under Over", value: "underline overline" }, + control: FlatButtonGroup, + buttonProps: [ + { icon: "ri-align-left", padding: "0px 5px", value: "left" }, + { icon: "ri-align-center", padding: "0px 5px", value: "center" }, + { icon: "ri-align-right", padding: "0px 5px", value: "right" }, + { icon: "ri-align-justify", padding: "0px 5px", value: "justify" }, ], }, - - { label: "transform", key: "text-transform", control: Input }, //custom - { label: "style", key: "font-style", control: Input }, //custom + { + label: "transform", + key: "text-transform", + control: FlatButtonGroup, + buttonProps: [ + { text: "BB", padding: "0px 5px", fontWeight: 500, value: "uppercase" }, + { text: "Bb", padding: "0px 5px", fontWeight: 500, value: "capitalize" }, + { text: "bb", padding: "0px 5px", fontWeight: 500, value: "lowercase" }, + { + text: "×", + padding: "0px 5px", + fontWeight: 500, + value: "none", + }, + ], + }, + { label: "style", key: "font-style", control: Input }, ] export const background = [ @@ -220,12 +295,31 @@ export const background = [ key: "background", control: Input, }, - { label: "Image", key: "image", control: Input }, //custom + { + label: "Image", + key: "background-image", + control: Input, + placeholder: "src", + }, ] export const border = [ - { label: "Radius", key: "border-radius", control: Input }, - { label: "Width", key: "border-width", control: Input }, //custom + { + label: "Radius", + key: "border-radius", + control: Input, + width: "48px", + placeholder: "px", + textAlign: "center", + }, + { + label: "Width", + key: "border-width", + control: Input, + width: "48px", + placeholder: "px", + textAlign: "center", + }, //custom { label: "Color", key: "border-color", @@ -251,30 +345,65 @@ export const border = [ ] export const effects = [ - { label: "Opacity", key: "opacity", control: Input }, + { + label: "Opacity", + key: "opacity", + control: Input, + width: "48px", + textAlign: "center", + placeholder: "%", + }, { label: "Rotate", key: "transform", - control: OptionSelect, - options: [ - { label: "None", value: "rotate(0deg)" }, - { label: "45 degrees", value: "rotate(45deg)" }, - { label: "90 degrees", value: "rotate(90deg)" }, - { label: "135 degrees", value: "rotate(135deg)" }, - { label: "180 degrees", value: "rotate(180deg)" }, - { label: "225 degrees", value: "rotate(225deg)" }, - { label: "270 degrees", value: "rotate(270deg)" }, - { label: "315 degrees", value: "rotate(315deg)" }, - { label: "360 degrees", value: "rotate(360deg)" }, - ], + control: Input, + width: "48px", + textAlign: "center", + placeholder: "deg", }, //needs special control - { label: "Shadow", key: "box-shadow", control: Input }, + { + label: "Shadow", + key: "box-shadow", + control: InputGroup, + meta: [{ placeholder: "X" }, { placeholder: "Y" }, { placeholder: "B" }], + }, ] export const transitions = [ - { label: "Property", key: "transition-property", control: Input }, - { label: "Duration", key: "transition-timing-function", control: Input }, - { label: "Ease", key: "transition-ease", control: Input }, + { + label: "Property", + key: "transition-property", + control: OptionSelect, + options: [ + "None", + "All", + "Background Color", + "Color", + "Font Size", + "Font Weight", + "Height", + "Margin", + "Opacity", + "Padding", + "Rotate", + "Shadow", + "Width", + ], + }, + { + label: "Duration", + key: "transition-timing-function", + control: Input, + width: "48px", + textAlign: "center", + placeholder: "sec", + }, + { + label: "Ease", + key: "transition-ease", + control: OptionSelect, + options: ["linear", "ease", "ease-in", "ease-out", "ease-in-out"], + }, ] export const all = { diff --git a/packages/builder/src/helpers.js b/packages/builder/src/helpers.js new file mode 100644 index 0000000000..5d9ff750af --- /dev/null +++ b/packages/builder/src/helpers.js @@ -0,0 +1,14 @@ +export const buildStyle = styles => { + let str = "" + for (let s in styles) { + if (styles[s]) { + let key = convertCamel(s) + str += `${key}: ${styles[s]}; ` + } + } + return str +} + +export const convertCamel = str => { + return str.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`) +} diff --git a/packages/builder/src/pages/[application]/frontend/_layout.svelte b/packages/builder/src/pages/[application]/frontend/_layout.svelte index 95f3f1fd67..9acdfe70fc 100644 --- a/packages/builder/src/pages/[application]/frontend/_layout.svelte +++ b/packages/builder/src/pages/[application]/frontend/_layout.svelte @@ -84,7 +84,7 @@ .ui-nav { grid-column: 1; background-color: var(--white); - height: calc(100vh - 49px); + height: calc(100vh - 69px); padding: 0; display: flex; flex-direction: column; @@ -101,6 +101,47 @@ .components-pane { grid-column: 3; background-color: var(--white); + min-height: 0px; + height: calc(100vh - 69px); + overflow-y: hidden; + } + + .components-nav-page { + font-size: 13px; + color: var(--ink); + padding-left: 20px; + margin-top: 20px; + font-weight: 600; + opacity: 0.4; + letter-spacing: 1px; + } + + .components-nav-header { + font-size: 13px; + color: var(--ink); + margin-top: 20px; + font-weight: 600; + opacity: 0.4; + letter-spacing: 1px; + } + + .nav-header { + display: flex; + flex-direction: column; + margin-top: 20px; + } + + .nav-items-container { + padding: 1rem 0rem 0rem 0rem; + } + + .nav-group-header { + display: flex; + padding: 0px 20px 0px 20px; + font-size: 0.9rem; + font-weight: bold; + justify-content: space-between; + align-items: center; min-height: 0; } diff --git a/packages/builder/tests/generate_css.spec.js b/packages/builder/tests/generate_css.spec.js index b2a7fca64d..5fcdef25c1 100644 --- a/packages/builder/tests/generate_css.spec.js +++ b/packages/builder/tests/generate_css.spec.js @@ -1,14 +1,10 @@ import { generate_css, generate_screen_css, - generate_array_styles } from "../src/builderStore/generate_css.js" describe("generate_css", () => { - test("Check how partially empty arrays are handled", () => { - expect(["", "5", "", ""].map(generate_array_styles)).toEqual(["0px", "5px", "0px", "0px"]) - }) test("Check how array styles are output", () => { expect(generate_css({ margin: ["0", "10", "0", "15"] })).toBe("margin: 0px 10px 0px 15px;")