adds navigation bar block component

This commit is contained in:
kevmodrome 2020-04-23 14:32:36 +02:00
parent 8eafbb74ae
commit d2e83a6acf
4 changed files with 207 additions and 63 deletions

View File

@ -52,28 +52,28 @@ export default {
name: "Textfield", name: "Textfield",
description: "A textfield component that allows the user to input text.", description: "A textfield component that allows the user to input text.",
icon: 'ri-edit-box-line', icon: 'ri-edit-box-line',
props: {} props: {}
}, },
{ {
_component: "@budibase/standard-components/checkbox", _component: "@budibase/standard-components/checkbox",
name: "Checkbox", name: "Checkbox",
description: "A selectable checkbox component", description: "A selectable checkbox component",
icon: 'ri-checkbox-line', icon: 'ri-checkbox-line',
props: {} props: {}
}, },
{ {
_component: "@budibase/standard-components/radiobutton", _component: "@budibase/standard-components/radiobutton",
name: "Radiobutton", name: "Radiobutton",
description: "A selectable radiobutton component", description: "A selectable radiobutton component",
icon: 'ri-radio-button-line', icon: 'ri-radio-button-line',
props: {} props: {}
}, },
{ {
_component: "@budibase/standard-components/select", _component: "@budibase/standard-components/select",
name: "Select", name: "Select",
description: "A select component for choosing from different options", description: "A select component for choosing from different options",
icon: 'ri-file-list-line', icon: 'ri-file-list-line',
props: {} props: {}
} }
] ]
}, },
@ -123,9 +123,10 @@ export default {
children: [] children: []
}, },
{ {
name: 'Navbar', name: "Navigation Bar",
description: 'A component for handling the navigation within your app.', _component: "@budibase/standard-components/Navigation",
icon: 'ri-navigation-fill', description: "A component for handling the navigation within your app.",
icon: "ri-navigation-fill",
commonProps: {}, commonProps: {},
children: [] children: []
} }

View File

@ -1,16 +1,32 @@
{ {
"_lib": "./dist/index.js", "_lib": "./dist/index.js",
"_templates" : { "_templates": {
"saveRecordButton" : { "saveRecordButton": {
"description": "Save record button", "description": "Save record button",
"component": "button" "component": "button"
} }
}, },
"button" : { "Navigation": {
"name": "Navigation",
"description": "A basic header navigation component",
"props": {
"logoUrl": "string",
"title": "string",
"backgroundColor": "string",
"color": "string",
"borderWidth": "string",
"borderColor": "string",
"borderStyle": "string"
}
},
"button": {
"name": "Button", "name": "Button",
"description": "an html <button />", "description": "an html <button />",
"props": { "props": {
"contentText": { "type": "string", "default": "Button" }, "contentText": {
"type": "string",
"default": "Button"
},
"className": "string", "className": "string",
"disabled": "bool", "disabled": "bool",
"onClick": "event", "onClick": "event",
@ -22,76 +38,110 @@
"hoverBackground": "string", "hoverBackground": "string",
"hoverBorder": "string" "hoverBorder": "string"
}, },
"tags": ["layout"], "tags": [
"layout"
],
"presets": { "presets": {
"primary": { "primary": {
"contentText": "Primary Button Preset", "contentText": "Primary Button Preset",
"color": "papayawhip", "color": "papayawhip",
"padding": "20px", "padding": "20px",
"background": "blue" "background": "blue"
}, },
"secondary": { "secondary": {
"contentText": "Secondary Button Preset", "contentText": "Secondary Button Preset",
"color": "rebeccapurple", "color": "rebeccapurple",
"padding": "10px", "padding": "10px",
"background": "#fff", "background": "#fff",
"border": "1px solid red" "border": "1px solid red"
}, },
"error": { "error": {
"contentText": "ERROR", "contentText": "ERROR",
"color": "red", "color": "red",
"padding": "10px", "padding": "10px",
"border": "1px solid red" "border": "1px solid red"
} }
} }
}, },
"login" : { "login": {
"name": "Login Control", "name": "Login Control",
"description": "A control that accepts username, password an also handles password resets", "description": "A control that accepts username, password an also handles password resets",
"props" : { "props": {
"logo": "asset", "logo": "asset",
"loginRedirect": "string", "loginRedirect": "string",
"usernameLabel": {"type":"string", "default": "Username"}, "usernameLabel": {
"passwordLabel": {"type":"string", "default": "Password"}, "type": "string",
"loginButtonLabel": {"type":"string", "default": "Login"}, "default": "Username"
},
"passwordLabel": {
"type": "string",
"default": "Password"
},
"loginButtonLabel": {
"type": "string",
"default": "Login"
},
"buttonClass": "string", "buttonClass": "string",
"inputClass": "string" "inputClass": "string"
}, },
"tags": ["login", "credentials", "password", "logon"] "tags": [
"login",
"credentials",
"password",
"logon"
]
}, },
"input" : { "input": {
"name": "Input", "name": "Input",
"description": "An HTML input", "description": "An HTML input",
"props" : { "props": {
"value": "string", "value": "string",
"type": { "type": {
"type":"options", "type": "options",
"options":[ "options": [
"text", "password", "checkbox", "color", "text",
"date", "datetime-local", "email", "password",
"file", "hidden", "image", "month", "number", "checkbox",
"radio", "range", "reset", "search", "submit", "color",
"tel", "time", "week"], "date",
"default":"text" "datetime-local",
"email",
"file",
"hidden",
"image",
"month",
"number",
"radio",
"range",
"reset",
"search",
"submit",
"tel",
"time",
"week"
],
"default": "text"
}, },
"onChange": "event", "onChange": "event",
"className": "string" "className": "string"
}, },
"tags": ["form"] "tags": [
"form"
]
}, },
"select" : { "select": {
"name": "Select", "name": "Select",
"description": "An HTML <select> (dropdown)", "description": "An HTML <select> (dropdown)",
"props" : { "props": {
"value": "string", "value": "string",
"className": "string" "className": "string"
} }
}, },
"option" : { "option": {
"name": "Option", "name": "Option",
"description": "An HTML <option>, to be used with <select>", "description": "An HTML <option>, to be used with <select>",
"children": false, "children": false,
"props" : { "props": {
"value": "string", "value": "string",
"text": "string" "text": "string"
} }
@ -100,28 +150,32 @@
"name": "Text", "name": "Text",
"description": "stylable block of text", "description": "stylable block of text",
"children": false, "children": false,
"props" : { "props": {
"text": "string", "text": "string",
"font": "string", "font": "string",
"fontSize": "string", "fontSize": "string",
"color": "string", "color": "string",
"textAlign": { "textAlign": {
"type": "options", "type": "options",
"default":"inline", "default": "inline",
"options": [ "options": [
"left", "center", "right" "left",
"center",
"right"
] ]
}, },
"verticalAlign": { "verticalAlign": {
"type": "options", "type": "options",
"default":"inline", "default": "inline",
"options": [ "options": [
"top", "middle", "bottom" "top",
"middle",
"bottom"
] ]
}, },
"formattingTag": { "formattingTag": {
"type": "options", "type": "options",
"default":"none", "default": "none",
"options": [ "options": [
"none", "none",
"<b> - bold", "<b> - bold",
@ -137,7 +191,10 @@
] ]
} }
}, },
"tags": ["div", "container"] "tags": [
"div",
"container"
]
}, },
"textfield": { "textfield": {
"name": "Textfield", "name": "Textfield",
@ -166,13 +223,13 @@
"checked": "bool", "checked": "bool",
"value": "string", "value": "string",
"onchange": "event" "onchange": "event"
} }
}, },
"icon": { "icon": {
"description": "A HTML icon tag", "description": "A HTML icon tag",
"props": { "props": {
"icon": "string", "icon": "string",
"fontSize": "string" "fontSize": "string"
} }
}, },
"link": { "link": {
@ -200,11 +257,11 @@
"container": { "container": {
"name": "Container", "name": "Container",
"description": "An element that contains and lays out other elements. e.g. <div>, <header> etc", "description": "An element that contains and lays out other elements. e.g. <div>, <header> etc",
"props" : { "props": {
"className":"string", "className": "string",
"onLoad": "event", "onLoad": "event",
"type": { "type": {
"type": "options", "type": "options",
"options": [ "options": [
"article", "article",
"aside", "aside",
@ -227,7 +284,7 @@
"borderWidth": "string", "borderWidth": "string",
"borderColor": "string", "borderColor": "string",
"borderStyle": { "borderStyle": {
"type":"options", "type": "options",
"options": [ "options": [
"none", "none",
"solid", "solid",
@ -241,21 +298,31 @@
], ],
"default": "none" "default": "none"
} }
}, },
"container": true, "container": true,
"tags": ["div", "container", "layout"] "tags": [
"div",
"container",
"layout"
]
}, },
"heading": { "heading": {
"name": "Heading", "name": "Heading",
"description": "An HTML H1 - H6 tag", "description": "An HTML H1 - H6 tag",
"props" : { "props": {
"className":"string", "className": "string",
"text": "string", "text": "string",
"type": { "type": {
"type": "options", "type": "options",
"default": "h1", "default": "h1",
"options": ["h1","h2","h3","h4","h5","h6"] "options": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
]
} }
}, },
"tags": [] "tags": []
@ -263,15 +330,15 @@
"thead": { "thead": {
"name": "TableHead", "name": "TableHead",
"description": "an HTML <thead> tab", "description": "an HTML <thead> tab",
"props" : { "props": {
"className":"string" "className": "string"
} }
}, },
"tbody": { "tbody": {
"name": "TableBody", "name": "TableBody",
"description": "an HTML <tbody> tab", "description": "an HTML <tbody> tab",
"props" : { "props": {
"className":"string" "className": "string"
} }
} }
} }

View File

@ -0,0 +1,75 @@
<script>
import { cssVars, createClasses } from "./cssVars"
export let className = ""
export let onLoad
export let backgroundColor
export let color
export let borderWidth
export let borderColor
export let borderStyle
export let logoUrl
export let title
export let _bb
let itemContainer
let hasLoaded
let currentChildren
$: cssVariables = {
backgroundColor,
color,
borderWidth,
borderColor,
borderStyle,
}
$: {
if (itemContainer) {
_bb.attachChildren(itemContainer)
if (!hasLoaded) {
_bb.call(onLoad)
hasLoaded = true
}
}
}
</script>
<nav use:cssVars={cssVariables}>
<a href="/">
<img class="logo" alt="logo" src={logoUrl} height="30" />
<span>{title}</span>
</a>
<div class="menu-items" bind:this={itemContainer} />
</nav>
<style>
nav {
color: var(--color);
background-color: var(--backgroundColor);
align-items: center;
display: flex;
font-weight: bold;
justify-content: space-between;
padding: 20px 0 20px 40px;
}
nav > a {
display: flex;
align-items: center;
font-size: 1.5em;
color: var(--color);
text-decoration: none;
}
nav a img {
border-radius: 15px;
margin-right: 15px;
}
.menu-items {
display: flex;
}
.menu-items > :global(*) {
margin: 0 10px;
}
</style>

View File

@ -13,3 +13,4 @@ export { default as saveRecordButton } from "./Templates/saveRecordButton"
export { default as link } from "./Link.svelte" export { default as link } from "./Link.svelte"
export { default as image } from "./Image.svelte" export { default as image } from "./Image.svelte"
export { default as icon } from "./Icon.svelte" export { default as icon } from "./Icon.svelte"
export { default as Navigation } from "./Navigation.svelte"