Update top nav to use tabs and fix a few tab layout issues
This commit is contained in:
parent
b92083bf83
commit
fef61ba25f
|
@ -1,9 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext, onMount } from "svelte"
|
import { getContext, onMount, createEventDispatcher } from "svelte"
|
||||||
import Portal from "svelte-portal"
|
import Portal from "svelte-portal"
|
||||||
export let title
|
export let title
|
||||||
export let icon = ""
|
export let icon = ""
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
const selected = getContext("tab")
|
const selected = getContext("tab")
|
||||||
let tab
|
let tab
|
||||||
let tabInfo
|
let tabInfo
|
||||||
|
@ -17,11 +18,16 @@
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
setTabInfo()
|
setTabInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const onClick = () => {
|
||||||
|
$selected = { ...$selected, title, info: tab.getBoundingClientRect() }
|
||||||
|
dispatch("click")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={tab}
|
bind:this={tab}
|
||||||
on:click={() => ($selected = { ...$selected, title, info: tab.getBoundingClientRect() })}
|
on:click={onClick}
|
||||||
class:is-selected={$selected.title === title}
|
class:is-selected={$selected.title === title}
|
||||||
class="spectrum-Tabs-item"
|
class="spectrum-Tabs-item"
|
||||||
tabindex="0">
|
tabindex="0">
|
||||||
|
|
|
@ -33,10 +33,8 @@
|
||||||
function calculateIndicatorOffset() {
|
function calculateIndicatorOffset() {
|
||||||
if (!vertical) {
|
if (!vertical) {
|
||||||
left = $tab.info?.left - container?.getBoundingClientRect().left + "px"
|
left = $tab.info?.left - container?.getBoundingClientRect().left + "px"
|
||||||
top = $tab.info?.top
|
|
||||||
} else {
|
} else {
|
||||||
top = $tab.info?.top - container?.getBoundingClientRect().top + "px"
|
top = $tab.info?.top - container?.getBoundingClientRect().top + "px"
|
||||||
left = $tab.info?.left
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +70,8 @@
|
||||||
.spectrum-Tabs {
|
.spectrum-Tabs {
|
||||||
padding-left: var(--spacing-xl);
|
padding-left: var(--spacing-xl);
|
||||||
padding-right: var(--spacing-xl);
|
padding-right: var(--spacing-xl);
|
||||||
|
position: relative;
|
||||||
|
border-width: 1px !important;
|
||||||
}
|
}
|
||||||
.spectrum-Tabs-content {
|
.spectrum-Tabs-content {
|
||||||
margin-top: var(--spectrum-global-dimension-static-size-150);
|
margin-top: var(--spectrum-global-dimension-static-size-150);
|
||||||
|
@ -79,4 +79,7 @@
|
||||||
.indicator-transition {
|
.indicator-transition {
|
||||||
transition: all 200ms;
|
transition: all 200ms;
|
||||||
}
|
}
|
||||||
|
.spectrum-Tabs--horizontal .spectrum-Tabs-selectionIndicator {
|
||||||
|
bottom: 0 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
<script>
|
<script>
|
||||||
import { store, automationStore } from "builderStore"
|
import { store, automationStore } from "builderStore"
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
import { Button, ActionGroup, ActionButton, Icon } from "@budibase/bbui"
|
import { Button, ActionGroup, ActionButton, Tabs, Tab } from "@budibase/bbui"
|
||||||
import SettingsLink from "components/settings/Link.svelte"
|
import SettingsLink from "components/settings/Link.svelte"
|
||||||
import ThemeEditorDropdown from "components/settings/ThemeEditorDropdown.svelte"
|
import ThemeEditorDropdown from "components/settings/ThemeEditorDropdown.svelte"
|
||||||
import FeedbackNavLink from "components/feedback/FeedbackNavLink.svelte"
|
import FeedbackNavLink from "components/feedback/FeedbackNavLink.svelte"
|
||||||
import { get } from "builderStore/api"
|
import { get } from "builderStore/api"
|
||||||
import { isActive, goto, layout } from "@roxi/routify"
|
import { isActive, goto, layout, params } from "@roxi/routify"
|
||||||
import Logo from "/assets/bb-logo.svg"
|
import Logo from "/assets/bb-logo.svg"
|
||||||
|
import { capitalise } from "../../../helpers"
|
||||||
|
|
||||||
// Get Package and set store
|
// Get Package and set store
|
||||||
export let application
|
export let application
|
||||||
|
|
||||||
let promise = getPackage()
|
let promise = getPackage()
|
||||||
|
$: selected = capitalise(
|
||||||
|
$layout.children.find(layout => $isActive(layout.path))?.title ?? "data"
|
||||||
|
)
|
||||||
|
|
||||||
async function getPackage() {
|
async function getPackage() {
|
||||||
const res = await get(`/api/applications/${application}/appPackage`)
|
const res = await get(`/api/applications/${application}/appPackage`)
|
||||||
|
@ -59,17 +63,20 @@
|
||||||
on:click={() => $goto(`/builder/`)} />
|
on:click={() => $goto(`/builder/`)} />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div class="tabs">
|
||||||
|
<Tabs {selected}>
|
||||||
|
{#each $layout.children as { path, title }}
|
||||||
|
<Tab
|
||||||
|
quiet
|
||||||
|
selected={$isActive(path)}
|
||||||
|
on:click={topItemNavigate(path)}
|
||||||
|
title={capitalise(title)} />
|
||||||
|
{/each}
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- This gets all indexable subroutes and sticks them in the top nav. -->
|
<!-- This gets all indexable subroutes and sticks them in the top nav. -->
|
||||||
<ActionGroup>
|
<ActionGroup />
|
||||||
{#each $layout.children as { path, title }}
|
|
||||||
<ActionButton
|
|
||||||
quiet
|
|
||||||
selected={$isActive(path)}
|
|
||||||
on:click={topItemNavigate(path)}>
|
|
||||||
{title}
|
|
||||||
</ActionButton>
|
|
||||||
{/each}
|
|
||||||
</ActionGroup>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="toprightnav">
|
<div class="toprightnav">
|
||||||
<ThemeEditorDropdown />
|
<ThemeEditorDropdown />
|
||||||
|
@ -127,9 +134,8 @@
|
||||||
|
|
||||||
.top-nav {
|
.top-nav {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
height: 60px;
|
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
padding: 0 20px;
|
padding: 0 var(--spacing-xl);
|
||||||
display: flex;
|
display: flex;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -146,28 +152,15 @@
|
||||||
|
|
||||||
.topleftnav {
|
.topleftnav {
|
||||||
display: flex;
|
display: flex;
|
||||||
place-items: center;
|
flex-direction: row;
|
||||||
}
|
justify-content: flex-start;
|
||||||
|
|
||||||
.topnavitem {
|
|
||||||
cursor: pointer;
|
|
||||||
color: var(--grey-5);
|
|
||||||
margin: 0 0 0 20px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: var(--font-size-m);
|
|
||||||
height: 100%;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnavitem:hover {
|
.tabs {
|
||||||
color: var(--grey-7);
|
display: flex;
|
||||||
font-weight: 500;
|
position: relative;
|
||||||
}
|
margin-bottom: -1px;
|
||||||
|
|
||||||
.active {
|
|
||||||
color: var(--ink);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnavitemright a {
|
.topnavitemright a {
|
||||||
|
@ -192,9 +185,9 @@
|
||||||
background-color: rgba(0, 0, 0, 0);
|
background-color: rgba(0, 0, 0, 0);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: none;
|
outline: none;
|
||||||
height: 40px;
|
padding: 0 10px 0 0;
|
||||||
padding: 0px 10px 8px 0;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-logo:active {
|
.home-logo:active {
|
||||||
|
@ -202,10 +195,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-logo img {
|
.home-logo img {
|
||||||
height: 40px;
|
height: 32px;
|
||||||
}
|
|
||||||
span:first-letter {
|
|
||||||
text-transform: capitalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
|
|
Loading…
Reference in New Issue