diff --git a/packages/builder/src/builderStore/generate_css.js b/packages/builder/src/builderStore/generate_css.js index 4311950a58..279c800396 100644 --- a/packages/builder/src/builderStore/generate_css.js +++ b/packages/builder/src/builderStore/generate_css.js @@ -87,6 +87,7 @@ const css_map = { }, } +//Only used here export const generate_rule = ([name, values]) => `${css_map[name].name}: ${css_map[name].generate(values)};` @@ -110,6 +111,7 @@ const object_to_css_string = [ join_with("\n"), ] +//USED BY generate_screen_css export const generate_css = style => { // let cssString = pipe(style, object_to_css_string) let cssString = Object.entries(style).reduce((str, [key, value]) => { @@ -128,6 +130,7 @@ export const generate_css = style => { const apply_class = (id, name, styles) => `.${name}-${id} {\n${styles}\n}` +//USED IN MULTIPLE PLACES IN THE BUILDER STORE export const generate_screen_css = component_array => { let styles = "" let emptyStyles = {} diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 051bc48bc2..b1b07c514e 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -46,9 +46,6 @@ ? getProps($store.currentPreviewItem, ["name", "favicon"]) : getProps($store.currentPreviewItem, ["name", "description", "route"]) - // const onStyleChanged = store.setComponentStyle - // const onStyleChanged = store.onStyleChanged - const onStyleChanged = store.setComponentStyle const onPropChanged = store.setComponentProp @@ -87,14 +84,11 @@
{#if selectedCategory.value === 'design'} - + {:else if selectedCategory.value === 'settings'} {/if} diff --git a/packages/builder/src/components/userInterface/ComponentsHierarchy.svelte b/packages/builder/src/components/userInterface/ComponentsHierarchy.svelte index 10628b09a1..31ada23230 100644 --- a/packages/builder/src/components/userInterface/ComponentsHierarchy.svelte +++ b/packages/builder/src/components/userInterface/ComponentsHierarchy.svelte @@ -16,12 +16,15 @@ const joinPath = join("/") const normalizedName = name => - pipe(name, [ - trimCharsStart("./"), - trimCharsStart("~/"), - trimCharsStart("../"), - trimChars(" "), - ]) + pipe( + name, + [ + trimCharsStart("./"), + trimCharsStart("~/"), + trimCharsStart("../"), + trimChars(" "), + ] + ) const lastPartOfName = c => { if (!c) return "" @@ -31,10 +34,10 @@ const isComponentSelected = (current, comp) => current === comp - $: _screens = pipe(screens, [ - map(c => ({ component: c, title: lastPartOfName(c) })), - sortBy("title"), - ]) + $: _screens = pipe( + screens, + [map(c => ({ component: c, title: lastPartOfName(c) })), sortBy("title")] + ) const confirmDeleteComponent = component => { componentToDelete = component @@ -42,6 +45,7 @@ } const changeScreen = screen => { + debugger store.setCurrentScreen(screen.title) $goto(`./:page/${screen.title}`) } diff --git a/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte b/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte index eafc1834d0..36d401f500 100644 --- a/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte +++ b/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte @@ -22,7 +22,11 @@ const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1) const get_name = s => (!s ? "" : last(s.split("/"))) - const get_capitalised_name = name => pipe(name, [get_name, capitalise]) + const get_capitalised_name = name => + pipe( + name, + [get_name, capitalise] + ) const moveDownComponent = component => { const c = component @@ -33,6 +37,7 @@ const selectComponent = component => { // Set current component + debugger store.selectComponent(component) // Get ID path diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte index b3cfa5e54b..4fbedde4ac 100644 --- a/packages/builder/src/components/userInterface/OptionSelect.svelte +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -6,7 +6,10 @@ export let initialValue = "" export let styleBindingProperty = "" - $: bindOptionToStyle = !!styleBindingProperty + const handleStyleBind = value => + !!styleBindingProperty ? { style: `${styleBindingProperty}: ${value}` } : {} + + $: isOptionsObject = options.every(o => typeof o === "object") onMount(() => { if (!value && !!initialValue) { @@ -19,15 +22,15 @@ class="uk-select uk-form-small" {value} on:change={ev => onChange(ev.target.value)}> - {#each options as { value, label }} - {#if bindOptionToStyle} - - {:else} - - {/if} - {/each} + {/each} + {:else} + {#each options as value} + + {/each} + {/if} diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte index 4c018f49e4..99d91fcbd8 100644 --- a/packages/builder/src/components/userInterface/PropertyControl.svelte +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -3,9 +3,20 @@ export let label = "" export let control = null + export let key = "" export let value = "" + export let valueType = "" export let props = {} export let onChange = () => {} + + function handleChange(key, v) { + !!v.target + ? onChange(name, key, valueType ? v.target[valueType] : v.target.value) + : onChange(name, key, v) + } + + const handleValueType = value => + valueType ? { [valueType]: value } : { value }
@@ -13,9 +24,9 @@
handleChange(key, val)} + onChange={val => handleChange(key, val)} {...props} />
diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index be0e257355..e1e3a98980 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -5,37 +5,21 @@ export let name = "" export let properties = [] export let componentInstance = {} - export let componentDefinition = {} export let onStyleChanged = () => {} export let show = false - let showComponentGroup = false - const propExistsOnComponentDef = prop => prop in componentDefinition.props const capitalize = name => name[0].toUpperCase() + name.slice(1) function onChange(key, v) { - console.log("PROPERTY GROUP ON CHANGE") !!v.target ? onStyleChanged(name, key, v.target.value) : onStyleChanged(name, key, v) } - $: { - let res = false - let componentProps = Object.keys(componentDefinition.props) - for (let prop in properties) { - if (componentProps.includes(prop)) { - showComponentGroup = true - } - if (showComponentGroup) break - } - } - $: icon = show ? "ri-arrow-down-s-fill" : "ri-arrow-right-s-fill" -
(show = !show)}>
@@ -46,18 +30,16 @@
{#each properties as props} - onChange(props.cssKey, value)} + key={props.cssKey} + value={componentInstance['_styles'][props.cssKey]} + onChange={onStyleChanged} props={{ ...excludeProps(props, ['control']) }} /> - {/each}
- diff --git a/packages/standard-components/src/Heading.svelte b/packages/standard-components/src/Heading.svelte index 4bbb9d0b36..4760ae05db 100644 --- a/packages/standard-components/src/Heading.svelte +++ b/packages/standard-components/src/Heading.svelte @@ -2,27 +2,25 @@ import { buildStyle } from "./buildStyle.js" export let className = "" export let type - export let _bb export let text = "" - export let fontFamily = "" - export let color = "" + + export let _bb let containerElement $: containerElement && !text && _bb.attachChildren(containerElement) - $: style = buildStyle({ "font-family": fontFamily, color }) {#if type === 'h1'} -

{text}

+

{text}

{:else if type === 'h2'} -

{text}

+

{text}

{:else if type === 'h3'} -

{text}

+

{text}

{:else if type === 'h4'} -

{text}

+

{text}

{:else if type === 'h5'} -
{text}
+
{text}
{:else if type === 'h6'} -
{text}
+
{text}
{/if} diff --git a/packages/standard-components/src/Text.svelte b/packages/standard-components/src/Text.svelte index b6d3c159e9..96fc09e025 100644 --- a/packages/standard-components/src/Text.svelte +++ b/packages/standard-components/src/Text.svelte @@ -4,45 +4,35 @@ export let text = "" export let className = "" - export let formattingTag = "" - - export let fontFamily = "" - export let fontSize = "1em" - export let textAlign = "" - export let verticalAlign = "" - export let color = "" + export let type = "" export let _bb - const isTag = tag => (formattingTag || "").indexOf(tag) > -1 - - $: style = buildStyle({ - "font-size": fontSize, - "font-family": fontFamily, - color, - }) + const isTag = tag => type === tag {#if isTag('none')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else if isTag('')} - {text} -{:else}{text}{/if} + {text} +{:else if isTag('bold')} + {text} +{:else if isTag('strong')} + {text} +{:else if isTag('italic')} + {text} +{:else if isTag('emphasis')} + {text} +{:else if isTag('mark')} + {text} +{:else if isTag('small')} + {text} +{:else if isTag('del')} + {text} +{:else if isTag('ins')} + {text} +{:else if isTag('sub')} + {text} +{:else if isTag('sup')} + {text} +{:else} + {text} +{/if}