forked from tsai/budibase
9 changed files with 261 additions and 54 deletions
@ -0,0 +1,95 @@ |
|||
<script> |
|||
import Navigation from "./Navigation.svelte" |
|||
import { ActionButton } from "@budibase/bbui" |
|||
import { getContext } from "svelte" |
|||
|
|||
const { styleable, transition } = getContext("sdk") |
|||
const component = getContext("component") |
|||
export let title = "" |
|||
export let hideTitle = false |
|||
export let logoUrl = "https://i.imgur.com/Xhdt1YP.png" |
|||
export let hideLogo = false |
|||
export let navigation = "Top" |
|||
export let links = [ |
|||
{ text: "Some Text", url: "/" }, |
|||
{ text: "Some Text", url: "/" }, |
|||
] |
|||
const navigationTypes = new Map([ |
|||
["Top", "top"], |
|||
["Left", "left"], |
|||
["None", ""], |
|||
]) |
|||
</script> |
|||
|
|||
<div |
|||
class="container {navigationTypes.get(navigation)}" |
|||
in:transition={{ type: $component.transition }} |
|||
use:styleable={$component.styles} |
|||
> |
|||
{#if navigationTypes.get(navigation)} |
|||
<div class="nav"> |
|||
<div class="logo"> |
|||
{#if !hideLogo} |
|||
<img src={logoUrl} alt={title} height="48" /> |
|||
{/if} |
|||
{#if !hideTitle} |
|||
<span>{title}</span> |
|||
{/if} |
|||
</div> |
|||
<div class="links"> |
|||
<Navigation {navigation} {links} /> |
|||
</div> |
|||
<div class="portal"> |
|||
<ActionButton quiet icon="Apps" on:click /> |
|||
</div> |
|||
</div> |
|||
{/if} |
|||
<div class="main"> |
|||
<slot /> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
.container { |
|||
display: grid; |
|||
grid-gap: 16px; |
|||
grid-template-columns: 1fr; |
|||
position: relative; |
|||
} |
|||
.nav { |
|||
display: grid; |
|||
grid-template-columns: 1fr 1fr 1fr; |
|||
grid-template-areas: "burger logo portal"; |
|||
justify-content: space-between; |
|||
padding: var(--spacing-m); |
|||
} |
|||
.top, |
|||
.left { |
|||
grid-template-columns: 1fr; |
|||
} |
|||
.links { |
|||
grid-area: burger; |
|||
} |
|||
.logo { |
|||
display: grid; |
|||
place-items: center; |
|||
grid-area: logo; |
|||
} |
|||
.portal { |
|||
grid-area: portal; |
|||
display: grid; |
|||
justify-content: end; |
|||
} |
|||
|
|||
@media (min-width: 600px) { |
|||
.nav { |
|||
display: initial; |
|||
} |
|||
.top { |
|||
grid-template-columns: 1fr; |
|||
} |
|||
.left { |
|||
grid-template-columns: 200px 1fr; |
|||
} |
|||
} |
|||
</style> |
|||
@ -0,0 +1,33 @@ |
|||
<script> |
|||
import { |
|||
ActionButton, |
|||
SideNavigation, |
|||
SideNavigationItem as Item, |
|||
} from "@budibase/bbui" |
|||
export let links |
|||
</script> |
|||
|
|||
<div class="overlay"> |
|||
<SideNavigation> |
|||
{#each links as { text, url }} |
|||
<!-- Needs logic to select current route --> |
|||
<Item selected={false} href={url} on:click>{text}</Item> |
|||
{/each} |
|||
</SideNavigation> |
|||
<div class="close"> |
|||
<ActionButton quiet icon="Close" on:click /> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
.overlay { |
|||
background: white; |
|||
position: absolute; |
|||
inset: 0; |
|||
} |
|||
.close { |
|||
position: absolute; |
|||
top: var(--spacing-m); |
|||
right: var(--spacing-m); |
|||
} |
|||
</style> |
|||
@ -0,0 +1,72 @@ |
|||
<script> |
|||
import Mobile from "./Mobile.svelte" |
|||
import { |
|||
ActionButton, |
|||
SideNavigation, |
|||
SideNavigationItem as Item, |
|||
} from "@budibase/bbui" |
|||
|
|||
export let navigation |
|||
export let links |
|||
|
|||
let mobileOpen = false |
|||
</script> |
|||
|
|||
<div class="container"> |
|||
{#if navigation === "Top"} |
|||
<ul> |
|||
{#each links as { text, url }} |
|||
<li><a href={url}>{text}</a></li> |
|||
{/each} |
|||
</ul> |
|||
{:else} |
|||
<SideNavigation> |
|||
{#each links as { text, url }} |
|||
<!-- Needs logic to select current route --> |
|||
<Item selected={false} href="/">{text}</Item> |
|||
{/each} |
|||
</SideNavigation> |
|||
{/if} |
|||
</div> |
|||
<div class="mobile"> |
|||
<ActionButton |
|||
quiet |
|||
selected |
|||
icon="ShowMenu" |
|||
on:click={() => (mobileOpen = !mobileOpen)} |
|||
/> |
|||
{#if mobileOpen} |
|||
<Mobile {links} on:click={() => (mobileOpen = !mobileOpen)} /> |
|||
{/if} |
|||
</div> |
|||
|
|||
<style> |
|||
.container { |
|||
display: none; |
|||
} |
|||
ul { |
|||
list-style-type: none; |
|||
display: flex; |
|||
flex-direction: row; |
|||
justify-content: flex-start; |
|||
align-items: center; |
|||
} |
|||
|
|||
ul > * { |
|||
margin-right: 16px; |
|||
} |
|||
|
|||
:global(ul > a) { |
|||
font-size: 1.5em; |
|||
text-decoration: none; |
|||
margin-right: 16px; |
|||
} |
|||
@media (min-width: 600px) { |
|||
.mobile { |
|||
display: none; |
|||
} |
|||
.container { |
|||
display: initial; |
|||
} |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue