Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Builder App Section Navigation Tabs Anchors #13626

Merged
merged 11 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 67 additions & 25 deletions packages/bbui/src/Tabs/Tab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
export let title
export let icon = ""
export let id
export let href = "#"
export let link = false

const dispatch = createEventDispatcher()
let selected = getContext("tab")
Expand Down Expand Up @@ -38,7 +40,18 @@
}
}

const onClick = () => {
const onAnchorClick = e => {
e.preventDefault()

$selected = {
...$selected,
title,
info: tab_internal.getBoundingClientRect(),
}
dispatch("click")
}

const onClick = e => {

Check failure on line 54 in packages/bbui/src/Tabs/Tab.svelte

View workflow job for this annotation

GitHub Actions / lint

'e' is defined but never used. Allowed unused args must match /^_/u
$selected = {
...$selected,
title,
Expand All @@ -48,30 +61,55 @@
}
</script>

<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div
{id}
bind:this={tab_internal}
on:click={onClick}
class:is-selected={$selected.title === title}
class="spectrum-Tabs-item"
class:emphasized={$selected.title === title && $selected.emphasized}
tabindex="0"
>
{#if icon}
<svg
class="spectrum-Icon spectrum-Icon--sizeM"
focusable="false"
aria-hidden="true"
aria-label="Folder"
>
<use xlink:href="#spectrum-icon-18-{icon}" />
</svg>
{/if}
<span class="spectrum-Tabs-itemLabel">{title}</span>
</div>
{#if link}
<a
{href}
{id}
bind:this={tab_internal}
on:click={onAnchorClick}
class:is-selected={$selected.title === title}
class="spectrum-Tabs-item link"
class:emphasized={$selected.title === title && $selected.emphasized}
tabindex="0"
>
{#if icon}
<svg
class="spectrum-Icon spectrum-Icon--sizeM"
focusable="false"
aria-hidden="true"
aria-label="Folder"
>
<use xlink:href="#spectrum-icon-18-{icon}" />
</svg>
{/if}
<span class="spectrum-Tabs-itemLabel">{title}</span>
</a>
{:else}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div
{id}
bind:this={tab_internal}
on:click={onClick}
class:is-selected={$selected.title === title}
class="spectrum-Tabs-item"
class:emphasized={$selected.title === title && $selected.emphasized}
tabindex="0"
>
{#if icon}
<svg
class="spectrum-Icon spectrum-Icon--sizeM"
focusable="false"
aria-hidden="true"
aria-label="Folder"
>
<use xlink:href="#spectrum-icon-18-{icon}" />
</svg>
{/if}
<span class="spectrum-Tabs-itemLabel">{title}</span>
</div>
{/if}
{#if $selected.title === title}
<Portal target=".spectrum-Tabs-content-{$selected.id}">
<slot />
Expand All @@ -89,4 +127,8 @@
.spectrum-Tabs-item:hover {
color: var(--spectrum-global-color-gray-900);
}
.link {
user-select: none;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
} from "@budibase/bbui"
import AppActions from "components/deploy/AppActions.svelte"
import { API } from "api"
import { isActive, goto, layout, redirect } from "@roxi/routify"
import { isActive, url, goto, layout, redirect } from "@roxi/routify"
import { capitalise } from "helpers"
import { onMount, onDestroy } from "svelte"
import VerificationPromptBanner from "components/common/VerificationPromptBanner.svelte"
Expand Down Expand Up @@ -139,19 +139,16 @@
<div class="top-nav">
{#if $appStore.initialised}
<div class="topleftnav">
<span class="back-to-apps">
<Icon
size="S"
hoverable
name="BackAndroid"
on:click={() => $goto("../../portal/apps")}
/>
</span>
<a href={$url("../../portal/apps")} class="linkWrapper back-to-apps">
<Icon size="S" hoverable name="BackAndroid" />
</a>
<Tabs {selected} size="M">
{#key $builderStore?.fonts}
{#each $layout.children as { path, title }}
<TourWrap stepKeys={[`builder-${title}-section`]}>
<Tab
link
href={$url(path)}
quiet
selected={$isActive(path)}
on:click={topItemNavigate(path)}
Expand Down Expand Up @@ -202,6 +199,11 @@
<EnterpriseBasicTrialModal />

<style>
.linkWrapper {
text-decoration: none;
color: inherit;
}

.back-to-apps {
display: contents;
}
Expand Down