toggleColorpicker(true)}
+ class="color-preview"
+ style={`background: ${value}`} />
+
+
+
toggleColorpicker(false)} />
+
+
+
+
+
+
+
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/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte
index a1ceac9eeb..27a4851c8d 100644
--- a/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte
+++ b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte
@@ -16,6 +16,11 @@
return props
}
+ const getComponentTypeName = component => {
+ let [componentName] = component._component.match(/[a-z]*$/)
+ return componentName || "element"
+ }
+
$: iframe &&
console.log(
iframe.contentDocument.head.insertAdjacentHTML(
@@ -60,7 +65,7 @@
_children: [
{
_component: "@budibase/standard-components/container",
- _styles: { position: {}, layout: {} },
+ _styles: { normal: {}, hover: {}, active: {}, selected: {} },
_id: "__screenslot__text",
_code: "",
className: "",
@@ -69,7 +74,12 @@
_children: [
{
_component: "@budibase/standard-components/text",
- _styles: { position: {}, layout: {} },
+ _styles: {
+ normal: {},
+ hover: {},
+ active: {},
+ selected: {},
+ },
_id: "__screenslot__text_2",
_code: "",
text: "content",
@@ -88,6 +98,8 @@
appRootPath: "",
}
+ $: selectedComponentType = getComponentTypeName($store.currentComponentInfo)
+
$: selectedComponentId = $store.currentComponentInfo
? $store.currentComponentInfo._id
: ""
@@ -102,6 +114,7 @@
srcdoc={iframeTemplate({
styles,
stylesheetLinks,
+ selectedComponentType,
selectedComponentId,
frontendDefinition: JSON.stringify(frontendDefinition),
currentPageFunctions: $store.currentPageFunctions,
diff --git a/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js b/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js
index 3c774cc4b8..dd2ca69dbb 100644
--- a/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js
+++ b/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js
@@ -1,6 +1,7 @@
export default ({
styles,
stylesheetLinks,
+ selectedComponentType,
selectedComponentId,
frontendDefinition,
currentPageFunctions,
@@ -11,7 +12,7 @@ export default ({
diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte
index 76d0c5605c..507d04c356 100644
--- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte
+++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte
@@ -1,4 +1,5 @@
-
- -
-
-
- -
-
-
- {#if !component._component.startsWith('##')}
- -
-
-
- -
-
-
- {/if}
-
+
+
(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 selectedCategory.value === 'design'}
+
+ {:else if selectedCategory.value === 'settings'}
+
{/if}
-
-
diff --git a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte
index 169c3ab284..3ffab198e9 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,
@@ -36,15 +37,12 @@
-
- {#each categories as category}
- - (selectedCategory = category)}
- class:active={selectedCategory === category}>
- {category.name}
-
- {/each}
-
+
+
(selectedCategory = category)}
+ {selectedCategory}
+ {categories} />
+
selectTab(PROPERTIES_TAB)}>
- Properties
+ Edit
@@ -50,6 +50,14 @@
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 @@
+
+
+
+
+
diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte
new file mode 100644
index 0000000000..4fbedde4ac
--- /dev/null
+++ b/packages/builder/src/components/userInterface/OptionSelect.svelte
@@ -0,0 +1,36 @@
+
+
+
diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte
new file mode 100644
index 0000000000..cd1bad35f7
--- /dev/null
+++ b/packages/builder/src/components/userInterface/PropertyControl.svelte
@@ -0,0 +1,63 @@
+
+
+
+
{label}
+
+ 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
new file mode 100644
index 0000000000..240618a4c7
--- /dev/null
+++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte
@@ -0,0 +1,81 @@
+
+
+
+
(show = !show)}>
+
+
+
+
{capitalize(name)}
+
+
+
+ {#each properties as props}
+
onStyleChanged(styleCategory, key, value)}
+ props={{ ...excludeProps(props, ['control', 'label']) }} />
+ {/each}
+
+
+
+
diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte
new file mode 100644
index 0000000000..36b2ab9c75
--- /dev/null
+++ b/packages/builder/src/components/userInterface/SettingsView.svelte
@@ -0,0 +1,41 @@
+
+
+{#if panelDefinition.length > 0}
+ {#each panelDefinition as definition}
+ {#if propExistsOnComponentDef(definition.key)}
+
+ {/if}
+ {/each}
+{:else}
+
+ This component does not have any settings.
+
+{/if}
+
+
diff --git a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte
new file mode 100644
index 0000000000..13d7a7e2a1
--- /dev/null
+++ b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte
@@ -0,0 +1,240 @@
+
+
+
+
+
+
+
+
+
+
+ {#if $store.currentFrontEndType === 'screen' || $store.currentFrontEndType === 'page'}
+
+
+
+ {/if}
+
+
+
+
+
+
+
store.deleteComponent(componentToDelete)} />
+
+
diff --git a/packages/builder/src/components/userInterface/pagesParsing/createProps.js b/packages/builder/src/components/userInterface/pagesParsing/createProps.js
index c37e05e023..de4de1c2a6 100644
--- a/packages/builder/src/components/userInterface/pagesParsing/createProps.js
+++ b/packages/builder/src/components/userInterface/pagesParsing/createProps.js
@@ -24,7 +24,7 @@ export const createProps = (componentDefinition, derivedFromProps) => {
const props = {
_id: uuid(),
_component: componentDefinition._component,
- _styles: { position: {}, layout: {} },
+ _styles: { normal: {}, hover: {}, active: {}, selected: {} },
_code: "",
}
@@ -71,7 +71,7 @@ export const makePropsSafe = (componentDefinition, props) => {
}
if (!props._styles) {
- props._styles = { layout: {}, position: {} }
+ props._styles = { normal: {}, hover: {}, active: {}, selected: {} }
}
return props
diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js
new file mode 100644
index 0000000000..07101779a5
--- /dev/null
+++ b/packages/builder/src/components/userInterface/propertyCategories.js
@@ -0,0 +1,173 @@
+import Input from "../common/Input.svelte"
+import OptionSelect from "./OptionSelect.svelte"
+import InputGroup from "../common/Inputs/InputGroup.svelte"
+// import Colorpicker from "../common/Colorpicker.svelte"
+/*
+ TODO: Allow for default values for all properties
+*/
+
+export const layout = [
+ {
+ label: "Direction",
+ key: "flex-direction",
+ control: OptionSelect,
+ initialValue: "columnReverse",
+ options: [
+ { label: "row" },
+ { label: "row-reverse", value: "rowReverse" },
+ { label: "column" },
+ { label: "column-reverse", value: "columnReverse" },
+ ],
+ },
+ { label: "Justify", key: "justify-content", control: Input },
+ { label: "Align", key: "align-items", control: Input },
+ {
+ label: "Wrap",
+ key: "flex-wrap",
+ control: OptionSelect,
+ options: [{ label: "wrap" }, { label: "no wrap", value: "noWrap" }],
+ },
+]
+
+const spacingMeta = [
+ { placeholder: "T" },
+ { placeholder: "R" },
+ { placeholder: "B" },
+ { placeholder: "L" },
+]
+export const spacing = [
+ {
+ label: "Padding",
+ key: "padding",
+ control: InputGroup,
+ meta: spacingMeta,
+ },
+ { label: "Margin", key: "margin", control: InputGroup, meta: spacingMeta },
+]
+
+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 },
+]
+
+export const position = [
+ {
+ label: "Position",
+ key: "position",
+ control: OptionSelect,
+ options: [
+ { label: "static" },
+ { label: "relative" },
+ { label: "fixed" },
+ { label: "absolute" },
+ { label: "sticky" },
+ ],
+ },
+]
+
+export const typography = [
+ {
+ label: "Font",
+ key: "font-family",
+ control: OptionSelect,
+ defaultValue: "initial",
+ options: [
+ "initial",
+ "Times New Roman",
+ "Georgia",
+ "Arial",
+ "Arial Black",
+ "Comic Sans MS",
+ "Impact",
+ "Lucida Sans Unicode",
+ ],
+ styleBindingProperty: "font-family",
+ },
+ {
+ label: "Weight",
+ key: "font-weight",
+ control: OptionSelect,
+ options: [
+ { label: "normal" },
+ { label: "bold" },
+ { label: "bolder" },
+ { label: "lighter" },
+ ],
+ },
+ { label: "size", key: "font-size", defaultValue: "", control: Input },
+ { label: "Line H", key: "line-height", control: Input },
+ {
+ label: "Color",
+ key: "color",
+ control: OptionSelect,
+ options: ["black", "white", "red", "blue", "green"],
+ },
+ {
+ label: "align",
+ key: "text-align",
+ control: OptionSelect,
+ options: ["initial", "left", "right", "center", "justify"],
+ }, //custom
+ { label: "transform", key: "text-transform", control: Input }, //custom
+ { label: "style", key: "font-style", control: Input }, //custom
+]
+
+export const background = [
+ {
+ label: "Background",
+ key: "background",
+ control: OptionSelect,
+ options: ["black", "white", "red", "blue", "green"],
+ },
+ { label: "Image", key: "image", control: Input }, //custom
+]
+
+export const border = [
+ { label: "Radius", key: "border-radius", control: Input },
+ { label: "Width", key: "border-width", control: Input }, //custom
+ {
+ label: "Color",
+ key: "border-color",
+ control: OptionSelect,
+ options: ["black", "white", "red", "blue", "green"],
+ },
+ { label: "Style", key: "border-style", control: Input },
+]
+
+export const effects = [
+ { label: "Opacity", key: "opacity", control: Input },
+ { label: "Rotate", key: "transform", control: Input }, //needs special control
+ { label: "Shadow", key: "box-shadow", control: Input },
+]
+
+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 },
+]
+
+export const all = {
+ layout,
+ spacing,
+ size,
+ position,
+ typography,
+ background,
+ border,
+ effects,
+ transitions,
+}
+
+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 ce64b37945..ae6a658e7a 100644
--- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js
+++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js
@@ -1,3 +1,9 @@
+import Input from "../common/Input.svelte"
+import OptionSelect from "./OptionSelect.svelte"
+import Checkbox from "../common/Checkbox.svelte"
+
+import { all } from "./propertyCategories.js"
+
export default {
categories: [
{
@@ -20,6 +26,31 @@ export default {
icon: "ri-layout-row-fill",
commonProps: {},
children: [],
+ properties: {
+ design: { ...all },
+ settings: [
+ {
+ key: "type",
+ label: "Type",
+ control: OptionSelect,
+ options: [
+ { label: "article" },
+ { label: "aside" },
+ { label: "details" },
+ { label: "div" },
+ { label: "figure" },
+ { label: "figcaption" },
+ { label: "footer" },
+ { label: "header" },
+ { label: "main" },
+ { label: "mark" },
+ { label: "nav" },
+ { label: "paragraph" },
+ { label: "summary" },
+ ],
+ },
+ ],
+ },
},
{
name: "Text",
@@ -32,13 +63,21 @@ export default {
name: "Headline",
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",
+ properties: {
+ design: { ...all },
+ settings: [
+ {
+ key: "text",
+ label: "Text",
+ control: Input,
+ },
+ {
+ key: "type",
+ label: "Type",
+ control: OptionSelect,
+ options: ["h1", "h2", "h3", "h4", "h5", "h6"],
+ },
+ ],
},
},
{
@@ -46,7 +85,34 @@ export default {
name: "Paragraph",
description: "A component for displaying paragraph text.",
icon: "ri-paragraph",
- props: {},
+ properties: {
+ design: { ...all },
+ settings: [
+ {
+ label: "Text",
+ key: "text",
+ control: Input,
+ },
+ {
+ label: "Type",
+ key: "type",
+ control: OptionSelect,
+ options: [
+ "none",
+ "bold",
+ "strong",
+ "italic",
+ "emphasis",
+ "mark",
+ "small",
+ "del",
+ "ins",
+ "sub",
+ "sup",
+ ],
+ },
+ ],
+ },
},
],
},
@@ -62,21 +128,38 @@ export default {
description:
"A textfield component that allows the user to input text.",
icon: "ri-edit-box-line",
- props: {},
+ properties: {
+ design: { ...all },
+ settings: [
+ { label: "Label", key: "label", control: Input },
+ {
+ label: "Type",
+ key: "type",
+ control: OptionSelect,
+ options: ["text", "password"],
+ },
+ ],
+ },
},
{
_component: "@budibase/standard-components/checkbox",
name: "Checkbox",
description: "A selectable checkbox component",
icon: "ri-checkbox-line",
- props: {},
+ properties: {
+ design: { ...all },
+ settings: [{ label: "Label", key: "label", control: Input }],
+ },
},
{
_component: "@budibase/standard-components/radiobutton",
name: "Radiobutton",
description: "A selectable radiobutton component",
icon: "ri-radio-button-line",
- props: {},
+ properties: {
+ design: { ...all },
+ settings: [{ label: "Label", key: "label", control: Input }],
+ },
},
{
_component: "@budibase/standard-components/select",
@@ -84,7 +167,10 @@ export default {
description:
"A select component for choosing from different options",
icon: "ri-file-list-line",
- props: {},
+ properties: {
+ design: { ...all },
+ settings: [],
+ },
},
],
},
@@ -93,24 +179,51 @@ export default {
name: "Button",
description: "A basic html button that is ready for styling",
icon: "ri-radio-button-fill",
- commonProps: {},
children: [],
+ properties: {
+ design: {
+ ...all,
+ },
+ settings: [
+ { label: "Text", key: "text", control: Input },
+ {
+ label: "Disabled",
+ key: "disabled",
+ valueKey: "checked",
+ control: Checkbox,
+ },
+ ],
+ },
},
{
_component: "@budibase/standard-components/icon",
name: "Icon",
description: "A basic component for displaying icons",
icon: "ri-sun-fill",
- commonProps: {},
children: [],
+ properties: {
+ design: { ...all },
+ },
},
{
_component: "@budibase/standard-components/link",
name: "Link",
description: "A basic link component for internal and external links",
icon: "ri-link",
- commonProps: {},
children: [],
+ properties: {
+ design: { ...all },
+ settings: [
+ { label: "Text", key: "text", control: Input },
+ { label: "Url", key: "url", control: Input },
+ {
+ label: "Open New Tab",
+ key: "openInNewTab",
+ valueKey: "checked",
+ control: Checkbox,
+ },
+ ],
+ },
},
],
},
@@ -124,17 +237,16 @@ export default {
description:
"A basic card component that can contain content and actions.",
icon: "ri-layout-bottom-line",
- commonProps: {},
children: [],
+ properties: { design: { ...all } },
},
{
- _component: "@budibase/standard-components/login",
name: "Login",
description:
"A component that automatically generates a login screen for your app.",
icon: "ri-login-box-fill",
- commonProps: {},
children: [],
+ properties: { design: { ...all } },
},
{
name: "Navigation Bar",
@@ -142,8 +254,8 @@ export default {
description:
"A component for handling the navigation within your app.",
icon: "ri-navigation-fill",
- commonProps: {},
children: [],
+ properties: { design: { ...all } },
},
],
},
@@ -153,19 +265,17 @@ export default {
children: [
{
name: "Table",
- _component: "@budibase/materialdesign-components/Datatable",
description: "A component that generates a table from your data.",
icon: "ri-archive-drawer-fill",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
{
- _component: "@budibase/materialdesign-components/Form",
name: "Form",
description: "A component that generates a form from your data.",
icon: "ri-file-edit-fill",
- commonProps: {},
- component: "@budibase/materialdesign-components/Form",
+ properties: { design: { ...all } },
+ _component: "@budibase/materialdesign-components/Form",
template: {
component: "@budibase/materialdesign-components/Form",
description: "Form for saving a record",
@@ -178,7 +288,7 @@ export default {
name: "DataTable",
description: "A table for displaying data from the backend.",
icon: "ri-archive-drawer-fill",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
{
@@ -186,7 +296,7 @@ export default {
name: "DataForm",
description: "Form stuff",
icon: "ri-file-edit-fill",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
{
@@ -194,7 +304,7 @@ export default {
_component: "@budibase/standard-components/datachart",
description: "Shiny chart",
icon: "ri-bar-chart-line",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
{
@@ -202,7 +312,7 @@ export default {
_component: "@budibase/standard-components/datalist",
description: "Shiny list",
icon: "ri-file-list-line",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
{
@@ -210,7 +320,7 @@ export default {
_component: "@budibase/standard-components/datamap",
description: "Shiny map",
icon: "ri-map-pin-line",
- commonProps: {},
+ properties: { design: { ...all } },
children: [],
},
],
diff --git a/packages/builder/src/pages/[application]/backend/_layout.svelte b/packages/builder/src/pages/[application]/backend/_layout.svelte
index 4a4a715534..069e720b17 100644
--- a/packages/builder/src/pages/[application]/backend/_layout.svelte
+++ b/packages/builder/src/pages/[application]/backend/_layout.svelte
@@ -38,12 +38,12 @@
height: 100%;
}
-@media only screen and (min-width: 1800px) {
- .nav {
- overflow: auto;
- flex: 0 1 auto;
- width: 300px;
- height: 100%;
+ @media only screen and (min-width: 1800px) {
+ .nav {
+ overflow: auto;
+ flex: 0 1 auto;
+ width: 300px;
+ height: 100%;
+ }
}
-}
diff --git a/packages/builder/tests/generate_css.spec.js b/packages/builder/tests/generate_css.spec.js
index 5fa4a94db9..b2a7fca64d 100644
--- a/packages/builder/tests/generate_css.spec.js
+++ b/packages/builder/tests/generate_css.spec.js
@@ -1,320 +1,55 @@
import {
generate_css,
- make_margin,
generate_screen_css,
+ generate_array_styles
} from "../src/builderStore/generate_css.js"
-describe("make_margin", () => {
- test("it should generate a valid rule", () => {
- expect(make_margin(["1", "1", "1", "1"])).toEqual("1px 1px 1px 1px")
- })
-
- test("empty values should output 0", () => {
- expect(make_margin(["1", "1", "", ""])).toEqual("1px 1px 0px 0px")
- expect(make_margin(["1", "", "", "1"])).toEqual("1px 0px 0px 1px")
- expect(make_margin(["", "", "", ""])).toEqual("0px 0px 0px 0px")
- })
-})
-
describe("generate_css", () => {
- test("it should generate a valid css rule: grid-area", () => {
- expect(generate_css({ layout: { gridarea: ["", "", "", ""] } })).toEqual({
- layout: "",
- position: "",
- })
+
+ test("Check how partially empty arrays are handled", () => {
+ expect(["", "5", "", ""].map(generate_array_styles)).toEqual(["0px", "5px", "0px", "0px"])
})
- test("it should generate a valid css rule: grid-gap", () => {
- expect(generate_css({ layout: { gap: "10" } })).toEqual({
- layout: "grid-gap: 10px;\ndisplay: grid;",
- position: "",
- })
+ test("Check how array styles are output", () => {
+ expect(generate_css({ margin: ["0", "10", "0", "15"] })).toBe("margin: 0px 10px 0px 15px;")
})
- test("it should generate a valid css rule: column 1", () => {
- expect(generate_css({ position: { column: ["", ""] } })).toEqual({
- layout: "",
- position: "",
- })
+ test("Check handling of an array with empty string values", () => {
+ expect(generate_css({ padding: ["", "", "", ""] })).toBe("")
})
- test("it should generate a valid css rule: column 2", () => {
- expect(generate_css({ position: { column: ["1", ""] } })).toEqual({
- position: "grid-column-start: 1;",
- layout: "",
- })
+ test("Check handling of an empty array", () => {
+ expect(generate_css({ margin: [] })).toBe("")
})
- test("it should generate a valid css rule: column 3", () => {
- expect(generate_css({ position: { column: ["", "1"] } })).toEqual({
- position: "grid-column-end: 1;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: column 4", () => {
- expect(generate_css({ position: { column: ["1", "1"] } })).toEqual({
- position: "grid-column-start: 1;\ngrid-column-end: 1;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: row 1", () => {
- expect(generate_css({ position: { row: ["", ""] } })).toEqual({
- layout: "",
- position: "",
- })
- })
-
- test("it should generate a valid css rule: row 2", () => {
- expect(generate_css({ position: { row: ["1", ""] } })).toEqual({
- position: "grid-row-start: 1;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: row 3", () => {
- expect(generate_css({ position: { row: ["", "1"] } })).toEqual({
- position: "grid-row-end: 1;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: row 4", () => {
- expect(generate_css({ position: { row: ["1", "1"] } })).toEqual({
- position: "grid-row-start: 1;\ngrid-row-end: 1;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: padding 1", () => {
- expect(
- generate_css({ position: { padding: ["1", "1", "1", "1"] } })
- ).toEqual({
- position: "padding: 1px 1px 1px 1px;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: padding 2", () => {
- expect(generate_css({ position: { padding: ["1", "", "", "1"] } })).toEqual(
- {
- position: "padding: 1px 0px 0px 1px;",
- layout: "",
- }
- )
- })
-
- test("it should generate a valid css rule: margin 1", () => {
- expect(
- generate_css({ position: { margin: ["1", "1", "1", "1"] } })
- ).toEqual({
- position: "margin: 1px 1px 1px 1px;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: margin 2", () => {
- expect(generate_css({ position: { margin: ["1", "", "", "1"] } })).toEqual({
- position: "margin: 1px 0px 0px 1px;",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: z-index 1", () => {
- expect(generate_css({ position: { zindex: "" } })).toEqual({
- position: "",
- layout: "",
- })
- })
-
- test("it should generate a valid css rule: z-index 2", () => {
- expect(generate_css({ position: { zindex: "1" } })).toEqual({
- position: "z-index: 1;",
- layout: "",
- })
+ test("Check handling of valid font property", () => {
+ expect(generate_css({ "font-size": "10px" })).toBe("font-size: 10px;")
})
})
+
describe("generate_screen_css", () => {
- test("it should compile the css for a list of components", () => {
- const components = [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 1,
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 2,
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 3,
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 4,
- },
- ]
-
- const compiled = `.pos-1 {
-margin: 1px 1px 1px 1px;
-}
-.lay-1 {
-
-}
-.pos-2 {
-margin: 1px 1px 1px 1px;
-}
-.lay-2 {
-
-}
-.pos-3 {
-margin: 1px 1px 1px 1px;
-}
-.lay-3 {
-
-}
-.pos-4 {
-margin: 1px 1px 1px 1px;
-}
-.lay-4 {
-
-}`
-
- expect(generate_screen_css(components)).toEqual(compiled)
+ const normalComponent = { _id: "123-456", _component: "@standard-components/header", _children: [], _styles: { normal: { "font-size": "16px" }, hover: {}, active: {}, selected: {} } }
+
+ test("Test generation of normal css styles", () => {
+ expect(generate_screen_css([normalComponent])).toBe(".header-123-456 {\nfont-size: 16px;\n}")
})
- test("it should compile the css for a list of components", () => {
- const components = [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 1,
- _children: [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 2,
- _children: [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 3,
- _children: [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 4,
- _children: [
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 5,
- _children: [],
- },
- ],
- },
- ],
- },
- ],
- },
- ],
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 6,
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 7,
- },
- {
- _styles: {
- layout: { gridarea: ["", "", "", ""] },
- position: { margin: ["1", "1", "1", "1"] },
- },
- _id: 8,
- },
- ]
+ const hoverComponent = { _id: "123-456", _component: "@standard-components/header", _children: [], _styles: { normal: {}, hover: {"font-size": "16px"}, active: {}, selected: {} } }
- const compiled = `.pos-1 {
-margin: 1px 1px 1px 1px;
-}
-.lay-1 {
-
-}
-.pos-2 {
-margin: 1px 1px 1px 1px;
-}
-.lay-2 {
-
-}
-.pos-3 {
-margin: 1px 1px 1px 1px;
-}
-.lay-3 {
-
-}
-.pos-4 {
-margin: 1px 1px 1px 1px;
-}
-.lay-4 {
-
-}
-.pos-5 {
-margin: 1px 1px 1px 1px;
-}
-.lay-5 {
-
-}
-.pos-6 {
-margin: 1px 1px 1px 1px;
-}
-.lay-6 {
-
-}
-.pos-7 {
-margin: 1px 1px 1px 1px;
-}
-.lay-7 {
-
-}
-.pos-8 {
-margin: 1px 1px 1px 1px;
-}
-.lay-8 {
-
-}`
-
- expect(generate_screen_css(components)).toEqual(compiled)
+ test("Test generation of hover css styles", () => {
+ expect(generate_screen_css([hoverComponent])).toBe(".header-123-456:hover {\nfont-size: 16px;\n}")
})
-})
+
+ const selectedComponent = { _id: "123-456", _component: "@standard-components/header", _children: [], _styles: { normal: {}, hover: {}, active: {}, selected: { "font-size": "16px" } } }
+
+ test("Test generation of selection css styles", () => {
+ expect(generate_screen_css([selectedComponent])).toBe(".header-123-456::selection {\nfont-size: 16px;\n}")
+ })
+
+ const emptyComponent = { _id: "123-456", _component: "@standard-components/header", _children: [], _styles: { normal: {}, hover: {}, active: {}, selected: {} } }
+
+ test.only("Testing handling of empty component styles", () => {
+ expect(generate_screen_css([emptyComponent])).toBe("")
+ })
+})
\ No newline at end of file
diff --git a/packages/cli/src/commands/new/appDirectoryTemplate/pages/main/page.json b/packages/cli/src/commands/new/appDirectoryTemplate/pages/main/page.json
index 4f25934bba..af75ddec68 100644
--- a/packages/cli/src/commands/new/appDirectoryTemplate/pages/main/page.json
+++ b/packages/cli/src/commands/new/appDirectoryTemplate/pages/main/page.json
@@ -9,8 +9,10 @@
"_id": 0,
"type": "div",
"_styles": {
- "layout": {},
- "position": {}
+ "normal": {},
+ "hover": {},
+ "active": {},
+ "selected": {}
},
"_code": ""
},
diff --git a/packages/cli/src/commands/new/appDirectoryTemplate/pages/unauthenticated/page.json b/packages/cli/src/commands/new/appDirectoryTemplate/pages/unauthenticated/page.json
index 298d73e8b6..3452a6df55 100644
--- a/packages/cli/src/commands/new/appDirectoryTemplate/pages/unauthenticated/page.json
+++ b/packages/cli/src/commands/new/appDirectoryTemplate/pages/unauthenticated/page.json
@@ -9,8 +9,10 @@
"_id": 1,
"type": "div",
"_styles": {
- "layout": {},
- "position": {}
+ "normal": {},
+ "hover": {},
+ "active": {},
+ "selected": {}
},
"_code": ""
},
diff --git a/packages/cli/src/commands/new/page.template.json b/packages/cli/src/commands/new/page.template.json
index 89a23a78e5..6f02b78c62 100644
--- a/packages/cli/src/commands/new/page.template.json
+++ b/packages/cli/src/commands/new/page.template.json
@@ -9,8 +9,10 @@
"_id": 0,
"type": "div",
"_styles": {
- "layout": {},
- "position": {}
+ "normal": {},
+ "hover": {},
+ "active": {},
+ "selected": {}
},
"_code": ""
},
diff --git a/packages/client/src/render/attachChildren.js b/packages/client/src/render/attachChildren.js
index ebb5dd34da..22dff2b2a8 100644
--- a/packages/client/src/render/attachChildren.js
+++ b/packages/client/src/render/attachChildren.js
@@ -31,7 +31,7 @@ export const attachChildren = initialiseOpts => (htmlElement, options) => {
}
}
- htmlElement.classList.add(`lay-${treeNode.props._id}`)
+ // htmlElement.classList.add(`lay-${treeNode.props._id}`)
const childNodes = []
for (let childProps of treeNode.props._children) {
diff --git a/packages/client/src/render/prepareRenderComponent.js b/packages/client/src/render/prepareRenderComponent.js
index 916ac82960..a7c3e6ddcf 100644
--- a/packages/client/src/render/prepareRenderComponent.js
+++ b/packages/client/src/render/prepareRenderComponent.js
@@ -35,8 +35,9 @@ export const prepareRenderComponent = ({
thisNode.rootElement =
htmlElement.children[htmlElement.children.length - 1]
+ let [componentName] = props._component.match(/[a-z]*$/)
if (props._id && thisNode.rootElement) {
- thisNode.rootElement.classList.add(`pos-${props._id}`)
+ thisNode.rootElement.classList.add(`${componentName}-${props._id}`)
}
}
}
diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json
index 4705f2b45b..f9c800489e 100644
--- a/packages/standard-components/components.json
+++ b/packages/standard-components/components.json
@@ -12,10 +12,10 @@
"props": {
"logoUrl": "string",
"title": "string",
- "backgroundColor": "colour",
- "color": "colour",
+ "backgroundColor": "string",
+ "color": "string",
"borderWidth": "string",
- "borderColor": "colour",
+ "borderColor": "string",
"borderStyle": "string"
}
},
@@ -23,35 +23,10 @@
"name": "Button",
"description": "an html ",
"props": {
- "contentText": {
- "type": "string",
- "default": "Button"
- },
+ "text": "string",
"className": "string",
"disabled": "bool",
- "onClick": "event",
- "background": "colour",
- "color": "colour",
- "border": "string",
- "padding": "string",
- "hoverColor": "string",
- "hoverBackground": "string",
- "hoverBorder": "string",
- "fontFamily": {
- "type": "options",
- "default": "initial",
- "styleBindingProperty": "font-family",
- "options": [
- "initial",
- "Times New Roman",
- "Georgia",
- "Arial",
- "Arial Black",
- "Comic Sans MS",
- "Impact",
- "Lucida Sans Unicode"
- ]
- }
+ "onClick": "event"
},
"tags": [
"layout"
@@ -167,58 +142,7 @@
"children": false,
"props": {
"text": "string",
- "color": "colour",
- "fontFamily": {
- "type": "options",
- "default": "initial",
- "styleBindingProperty": "font-family",
- "options": [
- "initial",
- "Times New Roman",
- "Georgia",
- "Arial",
- "Arial Black",
- "Comic Sans MS",
- "Impact",
- "Lucida Sans Unicode"
- ]
- },
- "fontSize": "string",
- "textAlign": {
- "type": "options",
- "default": "inline",
- "options": [
- "left",
- "center",
- "right"
- ]
- },
- "verticalAlign": {
- "type": "options",
- "default": "inline",
- "options": [
- "top",
- "middle",
- "bottom"
- ]
- },
- "formattingTag": {
- "type": "options",
- "default": "none",
- "options": [
- "none",
- " - bold",
- " - important",
- " - italic",
- " - emphasized",
- " - marked text",
- " - small",
- " - deleted",
- " - inserted",
- " - subscript",
- " - superscript"
- ]
- }
+ "type": {"type": "string", "default": "none"}
},
"tags": [
"div",
@@ -230,6 +154,7 @@
"description": "A component that allows the user to input text.",
"props": {
"label": "string",
+ "type": "string",
"value": "string",
"onchange": "event"
}
@@ -259,7 +184,7 @@
"props": {
"icon": "string",
"fontSize": "string",
- "color": "colour"
+ "color": "string"
}
},
"datatable": {
@@ -328,8 +253,8 @@
"url": "string",
"openInNewTab": "bool",
"text": "string",
- "color": "colour",
- "hoverColor": "colour",
+ "color": "string",
+ "hoverColor": "string",
"underline": "bool",
"fontSize": "string",
"fontFamily": {
@@ -383,27 +308,8 @@
"summary"
],
"default": "div"
- },
- "backgroundColor": "string",
- "color": "string",
- "borderWidth": "string",
- "borderColor": "string",
- "borderStyle": {
- "type": "options",
- "options": [
- "none",
- "solid",
- "dotted",
- "dashed",
- "double",
- "groove",
- "ridge",
- "inset",
- "outset"
- ],
- "default": "none"
}
- },
+ },
"container": true,
"tags": [
"div",
@@ -416,7 +322,6 @@
"description": "An HTML H1 - H6 tag",
"props": {
"className": "string",
- "color":"colour",
"text": "string",
"type": {
"type": "options",
@@ -429,21 +334,6 @@
"h5",
"h6"
]
- },
- "fontFamily": {
- "type": "options",
- "default": "initial",
- "styleBindingProperty": "font-family",
- "options": [
- "initial",
- "Times New Roman",
- "Georgia",
- "Arial",
- "Arial Black",
- "Comic Sans MS",
- "Impact",
- "Lucida Sans Unicode"
- ]
}
},
"tags": []
diff --git a/packages/standard-components/src/Button.svelte b/packages/standard-components/src/Button.svelte
index 3d50c22df5..eac2150274 100644
--- a/packages/standard-components/src/Button.svelte
+++ b/packages/standard-components/src/Button.svelte
@@ -1,58 +1,15 @@
{#if type === 'div'}
-
+
{:else if type === 'header'}
-
+
{:else if type === 'main'}
-
+
{:else if type === 'footer'}
-
+
{:else if type === 'aside'}
-
+
{:else if type === 'summary'}
-
+
{:else if type === 'details'}
-
+
{:else if type === 'article'}
-
+
{:else if type === 'nav'}
-
+
{:else if type === 'mark'}
-
+
{:else if type === 'figure'}
-
+
{:else if type === 'figcaption'}
-
+
{:else if type === 'paragraph'}
-
+
{/if}
-
-
diff --git a/packages/standard-components/src/Heading.svelte b/packages/standard-components/src/Heading.svelte
index 6a3a210dc3..4760ae05db 100644
--- a/packages/standard-components/src/Heading.svelte
+++ b/packages/standard-components/src/Heading.svelte
@@ -2,28 +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 })
- // $: console.log("HEADING", 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/Link.svelte b/packages/standard-components/src/Link.svelte
index 0ac3d9f628..ef0b71d62e 100644
--- a/packages/standard-components/src/Link.svelte
+++ b/packages/standard-components/src/Link.svelte
@@ -4,11 +4,6 @@
export let url = ""
export let text = ""
export let openInNewTab = false
- export let color
- export let hoverColor
- export let underline = false
- export let fontFamily
- export let fontSize
export let _bb
@@ -16,43 +11,12 @@
$: anchorElement && !text && _bb.attachChildren(anchorElement)
$: target = openInNewTab ? "_blank" : "_self"
- $: cssVariables = {
- hoverColor,
- color,
- textDecoration: underline ? "underline" : "none",
- fontSize,
- fontFamily,
- }
- $: classes = createClasses(cssVariables)
-
- {text}
-
+{text}
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}