Update screen list to match designs. Update nav items to make text clearer. Update screen picker

This commit is contained in:
Andrew Kingston 2022-07-25 17:06:00 +01:00
parent 83305530cd
commit 61481fd50b
5 changed files with 94 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { Icon, StatusLight } from "@budibase/bbui" import { Icon } from "@budibase/bbui"
import { createEventDispatcher, getContext } from "svelte" import { createEventDispatcher, getContext } from "svelte"
export let icon export let icon
@ -14,8 +14,8 @@
export let iconText export let iconText
export let iconColor export let iconColor
export let scrollable = false export let scrollable = false
export let color
export let highlighted = false export let highlighted = false
export let rightAlignIcon = false
const scrollApi = getContext("scroll") const scrollApi = getContext("scroll")
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -78,7 +78,7 @@
{iconText} {iconText}
</div> </div>
{:else if icon} {:else if icon}
<div class="icon"> <div class="icon" class:right={rightAlignIcon}>
<Icon color={iconColor} size="S" name={icon} /> <Icon color={iconColor} size="S" name={icon} />
</div> </div>
{/if} {/if}
@ -88,9 +88,9 @@
<slot /> <slot />
</div> </div>
{/if} {/if}
{#if color} {#if $$slots.right}
<div class="light"> <div class="right">
<StatusLight size="L" {color} /> <slot name="right" />
</div> </div>
{/if} {/if}
</div> </div>
@ -107,7 +107,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: stretch;
} }
.nav-item.scrollable { .nav-item.scrollable {
flex-direction: column; flex-direction: column;
@ -135,10 +135,8 @@
align-items: center; align-items: center;
gap: var(--spacing-xs); gap: var(--spacing-xs);
width: max-content; width: max-content;
overflow: hidden;
position: relative; position: relative;
padding-left: var(--spacing-l); padding-left: var(--spacing-l);
pointer-events: none;
} }
/* Needed to fully display the actions icon */ /* Needed to fully display the actions icon */
@ -153,10 +151,15 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: var(--spectrum-global-color-gray-600); color: var(--spectrum-global-color-gray-600);
order: 1;
}
.icon.right {
order: 4;
} }
.icon.arrow { .icon.arrow {
flex: 0 0 20px; flex: 0 0 20px;
pointer-events: all; pointer-events: all;
order: 0;
} }
.icon.arrow.absolute { .icon.arrow.absolute {
position: absolute; position: absolute;
@ -183,16 +186,19 @@
.text { .text {
font-weight: 600; font-weight: 600;
font-size: 12px; font-size: 14px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
flex: 1 1 auto; flex: 1 1 auto;
color: var(--spectrum-global-color-gray-800); color: var(--spectrum-global-color-gray-900);
order: 2;
width: 0;
} }
.scrollable .text { .scrollable .text {
flex: 0 0 auto; flex: 0 0 auto;
max-width: 160px; max-width: 160px;
width: auto;
} }
.actions { .actions {
@ -201,18 +207,17 @@
display: grid; display: grid;
place-items: center; place-items: center;
visibility: hidden; visibility: hidden;
} order: 3;
.actions, opacity: 0;
.light :global(.spectrum-StatusLight) {
width: 20px; width: 20px;
height: 20px; height: 20px;
margin-left: var(--spacing-s); margin-left: var(--spacing-xs);
} }
.light { .nav-item.withActions:hover .actions {
position: absolute; opacity: 1;
right: 0;
} }
.nav-item.withActions:hover .light {
display: none; .right {
order: 10;
} }
</style> </style>

View File

@ -1,10 +1,9 @@
<script> <script>
import DevicePreviewSelect from "./DevicePreviewSelect.svelte" import DevicePreviewSelect from "./DevicePreviewSelect.svelte"
import AppPreview from "./AppPreview.svelte" import AppPreview from "./AppPreview.svelte"
import { store, selectedScreen, sortedScreens } from "builderStore" import { store, sortedScreens } from "builderStore"
import { Button, Select } from "@budibase/bbui" import { Select } from "@budibase/bbui"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
import { goto } from "@roxi/routify"
</script> </script>
<div class="app-panel"> <div class="app-panel">
@ -15,10 +14,11 @@
options={$sortedScreens} options={$sortedScreens}
getOptionLabel={x => x.routing.route} getOptionLabel={x => x.routing.route}
getOptionValue={x => x._id} getOptionValue={x => x._id}
getOptionIcon={x => (x.routing.homeScreen ? "Home" : "WebPage")}
getOptionColour={x => RoleUtils.getRoleColour(x.routing.roleId)} getOptionColour={x => RoleUtils.getRoleColour(x.routing.roleId)}
value={$store.selectedScreenId} value={$store.selectedScreenId}
on:change={e => store.actions.screens.select(e.detail)} on:change={e => store.actions.screens.select(e.detail)}
quiet
autoWidth
/> />
</div> </div>
<div class="header-right"> <div class="header-right">
@ -62,7 +62,8 @@
gap: var(--spacing-l); gap: var(--spacing-l);
} }
.header-left :global(.spectrum-Picker) { .header-left :global(.spectrum-Picker) {
width: 250px; font-weight: 600;
color: var(--spectrum-global-color-gray-900);
} }
.content { .content {
flex: 1 1 auto; flex: 1 1 auto;

View File

@ -24,7 +24,7 @@
let newOffsets = {} let newOffsets = {}
// Calculate left offset // Calculate left offset
const offsetX = bounds.left + bounds.width + scrollLeft - 58 const offsetX = bounds.left + bounds.width + scrollLeft - 39
if (offsetX > sidebarWidth) { if (offsetX > sidebarWidth) {
newOffsets.left = offsetX - sidebarWidth newOffsets.left = offsetX - sidebarWidth
} else { } else {

View File

@ -0,0 +1,58 @@
<script>
import { RoleUtils } from "@budibase/frontend-core"
import { Tooltip, StatusLight } from "@budibase/bbui"
import { roles } from "stores/backend"
import { Roles } from "constants/backend"
export let roleId
let showTooltip = false
$: color = RoleUtils.getRoleColour(roleId)
$: role = $roles.find(role => role._id === roleId)
$: tooltip =
roleId === Roles.PUBLIC
? "This screen is open to the public"
: `Requires at least ${role?.name} access`
</script>
<div
class="container"
on:mouseover={() => (showTooltip = true)}
on:mouseleave={() => (showTooltip = false)}
style="--color: {color};"
>
<StatusLight square {color} />
{#if showTooltip}
<div class="tooltip">
<Tooltip textWrapping text={tooltip} direction="left" />
</div>
{/if}
</div>
<style>
.container {
position: relative;
}
.tooltip {
z-index: 1;
position: absolute;
top: 50%;
left: calc(50% - 8px);
transform: translateX(-100%) translateY(-50%);
display: flex;
flex-direction: row;
justify-content: flex-end;
width: 130px;
pointer-events: none;
}
.tooltip :global(.spectrum-Tooltip) {
background: var(--color);
color: white;
font-weight: 600;
max-width: 130px;
}
.tooltip :global(.spectrum-Tooltip-tip) {
border-top-color: var(--color);
}
</style>

View File

@ -6,6 +6,7 @@
import NavItem from "components/common/NavItem.svelte" import NavItem from "components/common/NavItem.svelte"
import ScreenDropdownMenu from "./ScreenDropdownMenu.svelte" import ScreenDropdownMenu from "./ScreenDropdownMenu.svelte"
import ScreenWizard from "./ScreenWizard.svelte" import ScreenWizard from "./ScreenWizard.svelte"
import RoleIndicator from "./RoleIndicator.svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
let searchString let searchString
@ -52,14 +53,15 @@
</Layout> </Layout>
{#each filteredScreens as screen (screen._id)} {#each filteredScreens as screen (screen._id)}
<NavItem <NavItem
icon={screen.routing.homeScreen ? "Home" : "WebPage"} icon={screen.routing.homeScreen ? "Home" : null}
indentLevel={0} indentLevel={0}
selected={$store.selectedScreenId === screen._id} selected={$store.selectedScreenId === screen._id}
text={screen.routing.route} text={screen.routing.route}
on:click={() => store.actions.screens.select(screen._id)} on:click={() => store.actions.screens.select(screen._id)}
color={RoleUtils.getRoleColour(screen.routing.roleId)} rightAlignIcon
> >
<ScreenDropdownMenu screenId={screen._id} /> <ScreenDropdownMenu screenId={screen._id} />
<RoleIndicator slot="right" roleId={screen.routing.roleId} />
</NavItem> </NavItem>
{/each} {/each}
{#if !filteredScreens?.length} {#if !filteredScreens?.length}