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

@ -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,7 +38,9 @@
"hoverBackground": "string", "hoverBackground": "string",
"hoverBorder": "string" "hoverBorder": "string"
}, },
"tags": ["layout"], "tags": [
"layout"
],
"presets": { "presets": {
"primary": { "primary": {
"contentText": "Primary Button Preset", "contentText": "Primary Button Preset",
@ -45,53 +63,85 @@
} }
} }
}, },
"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",
@ -200,8 +257,8 @@
"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",
@ -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"