2021-06-11 14:47:57 +02:00
|
|
|
<script>
|
|
|
|
import { getContext } from "svelte"
|
2021-06-17 13:57:36 +02:00
|
|
|
import { Heading, Icon } from "@budibase/bbui"
|
2021-07-30 14:59:56 +02:00
|
|
|
import { routeStore } from "../../client/src/store"
|
2021-06-11 14:47:57 +02:00
|
|
|
|
2021-06-21 20:47:40 +02:00
|
|
|
const { styleable, linkable, builderStore } = getContext("sdk")
|
2021-06-11 14:47:57 +02:00
|
|
|
const component = getContext("component")
|
2021-06-14 17:19:49 +02:00
|
|
|
|
2021-06-17 13:57:36 +02:00
|
|
|
export let title
|
2021-06-11 14:47:57 +02:00
|
|
|
export let hideTitle = false
|
2021-06-17 17:23:38 +02:00
|
|
|
export let logoUrl
|
2021-06-11 14:47:57 +02:00
|
|
|
export let hideLogo = false
|
|
|
|
export let navigation = "Top"
|
2021-06-17 13:57:36 +02:00
|
|
|
export let sticky = false
|
2021-06-17 13:18:48 +02:00
|
|
|
export let links
|
2021-06-17 14:17:24 +02:00
|
|
|
export let width = "Large"
|
2021-06-14 17:19:49 +02:00
|
|
|
|
|
|
|
const navigationClasses = {
|
|
|
|
Top: "top",
|
|
|
|
Left: "left",
|
|
|
|
None: "none",
|
|
|
|
}
|
2021-06-17 14:05:12 +02:00
|
|
|
const widthClasses = {
|
2021-07-10 12:56:32 +02:00
|
|
|
Max: "max",
|
2021-06-17 14:05:12 +02:00
|
|
|
Large: "l",
|
|
|
|
Medium: "m",
|
|
|
|
Small: "s",
|
|
|
|
}
|
|
|
|
|
2021-07-30 14:59:56 +02:00
|
|
|
// Permanently go into peek mode if we ever get the peek flag
|
|
|
|
let isPeeking = false
|
|
|
|
$: {
|
|
|
|
if ($routeStore.queryParams?.peek) {
|
|
|
|
isPeeking = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-17 14:05:12 +02:00
|
|
|
$: validLinks = links?.filter(link => link.text && link.url) || []
|
|
|
|
$: typeClass = navigationClasses[navigation] || "none"
|
2021-06-17 14:17:24 +02:00
|
|
|
$: widthClass = widthClasses[width] || "l"
|
2021-06-17 14:05:12 +02:00
|
|
|
let mobileOpen = false
|
2021-06-14 17:19:49 +02:00
|
|
|
|
2021-06-17 13:18:48 +02:00
|
|
|
const isInternal = url => {
|
|
|
|
return url.startsWith("/")
|
|
|
|
}
|
|
|
|
|
|
|
|
const ensureExternal = url => {
|
|
|
|
return !url.startsWith("http") ? `http://${url}` : url
|
|
|
|
}
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
mobileOpen = false
|
|
|
|
}
|
2021-06-21 20:47:40 +02:00
|
|
|
|
|
|
|
const navigateToPortal = () => {
|
|
|
|
if ($builderStore.inBuilder) return
|
|
|
|
window.location.href = "/builder/apps"
|
|
|
|
}
|
2021-06-11 14:47:57 +02:00
|
|
|
</script>
|
|
|
|
|
2021-06-17 14:05:12 +02:00
|
|
|
<div class="layout layout--{typeClass}" use:styleable={$component.styles}>
|
|
|
|
{#if typeClass !== "none"}
|
2021-07-30 14:59:56 +02:00
|
|
|
<div class="nav-wrapper" class:sticky class:hidden={isPeeking}>
|
2021-06-17 14:17:24 +02:00
|
|
|
<div class="nav nav--{typeClass} size--{widthClass}">
|
2021-06-17 13:18:48 +02:00
|
|
|
<div class="nav-header">
|
|
|
|
{#if validLinks?.length}
|
|
|
|
<div class="burger">
|
|
|
|
<Icon
|
|
|
|
hoverable
|
|
|
|
name="ShowMenu"
|
|
|
|
on:click={() => (mobileOpen = !mobileOpen)}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-06-14 17:19:49 +02:00
|
|
|
{/if}
|
2021-06-17 13:18:48 +02:00
|
|
|
<div class="logo">
|
|
|
|
{#if !hideLogo}
|
2021-06-17 17:23:38 +02:00
|
|
|
<img
|
|
|
|
src={logoUrl || "https://i.imgur.com/Xhdt1YP.png"}
|
|
|
|
alt={title}
|
|
|
|
/>
|
2021-06-17 13:18:48 +02:00
|
|
|
{/if}
|
2021-06-17 17:23:38 +02:00
|
|
|
{#if !hideTitle && title}
|
|
|
|
<Heading size="S">{title}</Heading>
|
2021-06-17 13:18:48 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
<div class="portal">
|
2021-06-21 23:43:15 +02:00
|
|
|
<Icon hoverable name="Apps" on:click={navigateToPortal} />
|
2021-06-17 13:18:48 +02:00
|
|
|
</div>
|
2021-06-14 17:19:49 +02:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="mobile-click-handler"
|
|
|
|
class:visible={mobileOpen}
|
|
|
|
on:click={() => (mobileOpen = false)}
|
|
|
|
/>
|
2021-06-17 13:18:48 +02:00
|
|
|
{#if validLinks?.length}
|
|
|
|
<div class="links" class:visible={mobileOpen}>
|
|
|
|
{#each validLinks as { text, url }}
|
|
|
|
{#if isInternal(url)}
|
|
|
|
<a class="link" href={url} use:linkable on:click={close}>
|
|
|
|
{text}
|
|
|
|
</a>
|
|
|
|
{:else}
|
|
|
|
<a class="link" href={ensureExternal(url)} on:click={close}>
|
|
|
|
{text}
|
|
|
|
</a>
|
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
<div class="close">
|
|
|
|
<Icon
|
|
|
|
hoverable
|
|
|
|
name="Close"
|
|
|
|
on:click={() => (mobileOpen = false)}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-06-14 17:19:49 +02:00
|
|
|
</div>
|
2021-06-17 13:18:48 +02:00
|
|
|
{/if}
|
2021-06-11 14:47:57 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2021-06-14 17:19:49 +02:00
|
|
|
<div class="main-wrapper">
|
2021-06-17 14:17:24 +02:00
|
|
|
<div class="main size--{widthClass}">
|
2021-06-14 17:19:49 +02:00
|
|
|
<slot />
|
|
|
|
</div>
|
2021-06-11 14:47:57 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2021-06-14 17:19:49 +02:00
|
|
|
/* Main components */
|
|
|
|
.layout {
|
2021-06-14 19:24:02 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
|
|
|
height: 100%;
|
|
|
|
overflow: auto;
|
2021-06-24 13:15:22 +02:00
|
|
|
overflow-x: hidden;
|
2021-06-25 16:09:13 +02:00
|
|
|
position: relative;
|
2021-06-28 15:51:47 +02:00
|
|
|
background: var(--spectrum-alias-background-color-secondary);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
2021-06-14 19:24:02 +02:00
|
|
|
|
2021-06-14 17:19:49 +02:00
|
|
|
.nav-wrapper {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: stretch;
|
2021-06-28 15:51:47 +02:00
|
|
|
background: var(--spectrum-alias-background-color-primary);
|
2021-06-25 16:09:13 +02:00
|
|
|
z-index: 2;
|
2021-06-30 09:30:57 +02:00
|
|
|
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
|
2021-06-30 21:40:27 +02:00
|
|
|
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.05);
|
2021-06-14 19:24:02 +02:00
|
|
|
}
|
2021-07-30 14:59:56 +02:00
|
|
|
.nav-wrapper.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-06-14 19:24:02 +02:00
|
|
|
.layout--top .nav-wrapper.sticky {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
2021-06-14 19:24:02 +02:00
|
|
|
|
2021-06-11 14:47:57 +02:00
|
|
|
.nav {
|
2021-06-17 13:18:48 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
2021-06-17 13:57:36 +02:00
|
|
|
padding: var(--spacing-xl) 32px;
|
2021-06-17 13:18:48 +02:00
|
|
|
max-width: 100%;
|
2021-06-17 14:17:24 +02:00
|
|
|
gap: var(--spacing-xl);
|
2021-06-17 13:18:48 +02:00
|
|
|
}
|
|
|
|
.nav-header {
|
|
|
|
flex: 0 0 auto;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
2021-06-17 17:23:38 +02:00
|
|
|
gap: var(--spacing-xl);
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
2021-06-14 17:19:49 +02:00
|
|
|
.main-wrapper {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: stretch;
|
2021-06-14 19:24:02 +02:00
|
|
|
flex: 1 1 auto;
|
2021-06-25 16:09:13 +02:00
|
|
|
z-index: 1;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.main {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
2021-06-17 13:18:48 +02:00
|
|
|
max-width: 100%;
|
2021-06-14 19:24:02 +02:00
|
|
|
position: relative;
|
2021-06-17 13:57:36 +02:00
|
|
|
padding: 32px;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
2021-07-10 12:56:32 +02:00
|
|
|
.layout--none .main {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2021-06-17 14:17:24 +02:00
|
|
|
.size--s {
|
2021-06-17 14:05:12 +02:00
|
|
|
width: 800px;
|
|
|
|
}
|
2021-06-17 14:17:24 +02:00
|
|
|
.size--m {
|
2021-06-17 14:05:12 +02:00
|
|
|
width: 1100px;
|
|
|
|
}
|
2021-06-17 14:17:24 +02:00
|
|
|
.size--l {
|
2021-06-17 14:05:12 +02:00
|
|
|
width: 1400px;
|
|
|
|
}
|
2021-07-10 12:56:32 +02:00
|
|
|
.size--max {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2021-06-14 17:19:49 +02:00
|
|
|
|
|
|
|
/* Nav components */
|
|
|
|
.burger {
|
|
|
|
display: none;
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
|
|
|
.logo {
|
2021-06-14 17:19:49 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
2021-06-17 17:23:38 +02:00
|
|
|
gap: var(--spacing-m);
|
|
|
|
flex: 1 1 auto;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.logo img {
|
2021-06-17 17:23:38 +02:00
|
|
|
height: 36px;
|
|
|
|
}
|
|
|
|
.logo :global(h1) {
|
|
|
|
font-weight: 600;
|
|
|
|
flex: 1 1 auto;
|
|
|
|
width: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
|
|
|
.portal {
|
|
|
|
display: grid;
|
2021-06-17 13:18:48 +02:00
|
|
|
place-items: center;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.links {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
2021-06-17 14:17:24 +02:00
|
|
|
gap: var(--spacing-xl);
|
|
|
|
margin-top: var(--spacing-xl);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.link {
|
|
|
|
color: var(--spectrum-alias-text-color);
|
2021-06-17 13:57:36 +02:00
|
|
|
font-size: var(--spectrum-global-dimension-font-size-200);
|
2021-06-14 17:19:49 +02:00
|
|
|
font-weight: 600;
|
|
|
|
transition: color 130ms ease-out;
|
|
|
|
}
|
|
|
|
.link:hover {
|
2021-06-17 13:57:36 +02:00
|
|
|
color: var(--spectrum-global-color-blue-600);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.close {
|
|
|
|
display: none;
|
|
|
|
position: absolute;
|
2021-06-17 13:18:48 +02:00
|
|
|
top: var(--spacing-xl);
|
|
|
|
right: var(--spacing-xl);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.mobile-click-handler {
|
|
|
|
display: none;
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
|
|
|
|
2021-06-14 17:19:49 +02:00
|
|
|
/* Desktop nav overrides */
|
2021-06-11 14:47:57 +02:00
|
|
|
@media (min-width: 600px) {
|
2021-06-14 17:19:49 +02:00
|
|
|
.layout--left {
|
2021-06-14 19:24:02 +02:00
|
|
|
flex-direction: row;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
.layout--left .main-wrapper {
|
2021-06-14 17:19:49 +02:00
|
|
|
height: 100%;
|
2021-06-14 19:24:02 +02:00
|
|
|
overflow: auto;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav--left {
|
|
|
|
width: 250px;
|
2021-06-17 13:57:36 +02:00
|
|
|
padding: var(--spacing-xl);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav--left .links {
|
2021-06-17 17:23:38 +02:00
|
|
|
margin-top: var(--spacing-m);
|
2021-06-14 17:19:49 +02:00
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
|
|
|
}
|
2021-06-17 13:57:36 +02:00
|
|
|
.nav--left .link {
|
|
|
|
font-size: var(--spectrum-global-dimension-font-size-150);
|
|
|
|
}
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Mobile nav overrides */
|
|
|
|
@media (max-width: 600px) {
|
2021-06-14 19:24:02 +02:00
|
|
|
.nav-wrapper {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
box-shadow: 0 0 8px -1px rgba(0, 0, 0, 0.075);
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Show close button in drawer */
|
|
|
|
.close {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force standard top bar */
|
|
|
|
.nav {
|
2021-06-17 13:57:36 +02:00
|
|
|
padding: var(--spacing-m) 16px;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.burger {
|
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
}
|
2021-06-17 17:23:38 +02:00
|
|
|
.logo {
|
|
|
|
flex: 0 0 auto;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.logo :global(h1) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2021-06-17 13:57:36 +02:00
|
|
|
/* Reduce padding */
|
|
|
|
.main {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
|
2021-06-14 17:19:49 +02:00
|
|
|
/* Transform links into drawer */
|
|
|
|
.links {
|
2021-06-17 14:17:24 +02:00
|
|
|
margin-top: 0;
|
2021-06-14 17:19:49 +02:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: -250px;
|
|
|
|
transform: translateX(0);
|
|
|
|
width: 250px;
|
|
|
|
transition: transform 0.26s ease-in-out, opacity 0.26s ease-in-out;
|
|
|
|
height: 100vh;
|
|
|
|
opacity: 0;
|
2021-07-05 14:56:04 +02:00
|
|
|
background: var(--spectrum-alias-background-color-secondary);
|
2021-06-14 17:19:49 +02:00
|
|
|
z-index: 999;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
|
|
|
padding: var(--spacing-xl);
|
|
|
|
}
|
|
|
|
.link {
|
|
|
|
width: calc(100% - 30px);
|
2021-06-17 13:18:48 +02:00
|
|
|
font-size: 120%;
|
2021-06-14 17:19:49 +02:00
|
|
|
}
|
|
|
|
.links.visible {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translateX(250px);
|
2021-07-05 14:56:04 +02:00
|
|
|
box-shadow: 0 0 80px 20px rgba(0, 0, 0, 0.2);
|
|
|
|
border-right: 1px solid var(--spectrum-global-color-gray-300);
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
2021-06-14 17:19:49 +02:00
|
|
|
.mobile-click-handler.visible {
|
|
|
|
position: fixed;
|
|
|
|
display: block;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
z-index: 998;
|
2021-06-11 14:47:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|