Move new component panel to right side, animate via sliding in and remove add component button above preview

This commit is contained in:
Andrew Kingston 2022-07-25 10:20:59 +01:00
parent d266b6ca84
commit 8296c8f996
10 changed files with 106 additions and 128 deletions

View File

@ -3,11 +3,13 @@
export let title export let title
export let icon export let icon
export let expandable = false
export let showAddButton = false export let showAddButton = false
export let showBackButton = false export let showBackButton = false
export let showExpandIcon = false export let showCloseButton = false
export let onClickAddButton export let onClickAddButton
export let onClickBackButton export let onClickBackButton
export let onClickCloseButton
export let borderLeft = false export let borderLeft = false
export let borderRight = false export let borderRight = false
@ -25,7 +27,7 @@
<div class="title"> <div class="title">
<Heading size="XXS">{title || ""}</Heading> <Heading size="XXS">{title || ""}</Heading>
</div> </div>
{#if showExpandIcon} {#if expandable}
<Icon <Icon
name={wide ? "Minimize" : "Maximize"} name={wide ? "Minimize" : "Maximize"}
hoverable hoverable
@ -37,6 +39,9 @@
<Icon name="Add" /> <Icon name="Add" />
</div> </div>
{/if} {/if}
{#if showCloseButton}
<Icon name="Close" hoverable on:click={onClickCloseButton} />
{/if}
</div> </div>
<div class="body"> <div class="body">
<slot /> <slot />

View File

@ -25,14 +25,6 @@
{#if $store.clientFeatures.devicePreview} {#if $store.clientFeatures.devicePreview}
<DevicePreviewSelect /> <DevicePreviewSelect />
{/if} {/if}
<Button
newStyles
secondary
icon="Add"
on:click={() => $goto(`../${$selectedScreen._id}/components/new`)}
>
Component
</Button>
</div> </div>
</div> </div>
<div class="content"> <div class="content">
@ -59,6 +51,7 @@
justify-content: space-between; justify-content: space-between;
align-items: flex-start; align-items: flex-start;
gap: var(--spacing-l); gap: var(--spacing-l);
margin: 0 2px;
} }
.header-left, .header-left,
.header-right { .header-right {

View File

@ -9,7 +9,7 @@
import { setContext } from "svelte" import { setContext } from "svelte"
import DNDPositionIndicator from "./DNDPositionIndicator.svelte" import DNDPositionIndicator from "./DNDPositionIndicator.svelte"
import { DropPosition } from "./dndStore" import { DropPosition } from "./dndStore"
import { Button, Layout } from "@budibase/bbui" import { Button } from "@budibase/bbui"
let scrollRef let scrollRef
@ -64,7 +64,7 @@
<Panel title="Components" showExpandIcon borderRight> <Panel title="Components" showExpandIcon borderRight>
<div class="add-component"> <div class="add-component">
<Button on:click={() => $goto("../new")} cta>Add component</Button> <Button on:click={() => $goto("./new")} cta>Add component</Button>
</div> </div>
<div class="nav-items-container" bind:this={scrollRef}> <div class="nav-items-container" bind:this={scrollRef}>
<ul> <ul>

View File

@ -4,6 +4,8 @@
import * as routify from "@roxi/routify" import * as routify from "@roxi/routify"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
import { findComponent } from "builderStore/componentUtils" import { findComponent } from "builderStore/componentUtils"
import ComponentListPanel from "./_components/navigation/ComponentListPanel.svelte"
import ComponentSettingsPanel from "./_components/settings/ComponentSettingsPanel.svelte"
// Keep URL and state in sync for selected component ID // Keep URL and state in sync for selected component ID
const stopSyncing = syncURLToState({ const stopSyncing = syncURLToState({
@ -18,4 +20,6 @@
onDestroy(stopSyncing) onDestroy(stopSyncing)
</script> </script>
<ComponentListPanel />
<ComponentSettingsPanel />
<slot /> <slot />

View File

@ -1,7 +1,4 @@
<script> <!--
import ComponentListPanel from "./_components/navigation/ComponentListPanel.svelte" Placeholder file so that routify works.
import ComponentSettingsPanel from "./_components/settings/ComponentSettingsPanel.svelte" No unique content is needed in this index page.
</script> -->
<ComponentListPanel />
<ComponentSettingsPanel />

View File

@ -15,6 +15,7 @@
import structure from "./componentStructure.json" import structure from "./componentStructure.json"
import { store, selectedComponent } from "builderStore" import { store, selectedComponent } from "builderStore"
import { onMount } from "svelte" import { onMount } from "svelte"
import { fly } from "svelte/transition"
let section = "components" let section = "components"
let searchString let searchString
@ -150,75 +151,95 @@
}) })
</script> </script>
<Panel <div class="new-component" transition:fly|local={{ x: 260 }}>
title="Add component" <Panel
showBackButton title="Add component"
onClickBackButton={() => $goto("../slot")} showCloseButton
borderRight onClickCloseButton={() => $goto("../")}
> borderLeft
<Layout paddingX="L" paddingY="XL" gap="S"> >
<Search <Layout paddingX="L" paddingY="XL" gap="S">
placeholder="Search" <Search
value={searchString} placeholder="Search"
on:change={e => (searchString = e.detail)} value={searchString}
bind:inputRef={searchRef} on:change={e => (searchString = e.detail)}
/> bind:inputRef={searchRef}
{#if !searchString} />
<ActionGroup compact justified> {#if !searchString}
<ActionButton <ActionGroup compact justified>
fullWidth <ActionButton
selected={section === "components"} fullWidth
on:click={() => (section = "components")}>Components</ActionButton selected={section === "components"}
> on:click={() => (section = "components")}>Components</ActionButton
<ActionButton >
fullWidth <ActionButton
selected={section === "blocks"} fullWidth
on:click={() => (section = "blocks")}>Blocks</ActionButton selected={section === "blocks"}
> on:click={() => (section = "blocks")}>Blocks</ActionButton
</ActionGroup> >
{/if} </ActionGroup>
</Layout> {/if}
<div> </Layout>
<Divider noMargin noGrid /> <div>
</div> <Divider noMargin noGrid />
{#if searchString || section === "components"} </div>
{#each filteredStructure as category} {#if searchString || section === "components"}
<DetailSummary name={category.name} collapsible={false}> {#if filteredStructure.length}
<div class="component-grid"> {#each filteredStructure as category}
{#each category.children as component} <DetailSummary name={category.name} collapsible={false}>
<div class="component-grid">
{#each category.children as component}
<div
class="component"
class:wide={component.name?.length > 15}
class:selected={selectedIndex ===
orderMap[component.component]}
on:click={() => addComponent(component.component)}
on:mouseover={() => (selectedIndex = null)}
>
<Icon name={component.icon} />
<Body size="XS">{component.name}</Body>
</div>
{/each}
</div>
</DetailSummary>
{/each}
{:else}
<Layout paddingY="M" paddingX="L">
<Body size="S">
There aren't any components matching the current filter
</Body>
</Layout>
{/if}
{:else}
<Layout paddingX="L" paddingY="XL" gap="S">
<Body size="S">Blocks are collections of pre-built components</Body>
<Layout noPadding gap="XS">
{#each blocks as block}
<div <div
class="component" class="component block"
class:wide={component.name?.length > 15} on:click={() => addComponent(block.component)}
class:selected={selectedIndex === orderMap[component.component]}
on:click={() => addComponent(component.component)}
on:mouseover={() => (selectedIndex = null)}
> >
<Icon name={component.icon} /> <Icon name={block.icon} />
<Body size="XS">{component.name}</Body> <Body size="XS">{block.name}</Body>
</div> </div>
{/each} {/each}
</div> </Layout>
</DetailSummary>
{/each}
{:else}
<Layout paddingX="L" paddingY="XL" gap="S">
<Body size="S">Blocks are collections of pre-built components</Body>
<Layout noPadding gap="XS">
{#each blocks as block}
<div
class="component block"
on:click={() => addComponent(block.component)}
>
<Icon name={block.icon} />
<Body size="XS">{block.name}</Body>
</div>
{/each}
</Layout> </Layout>
</Layout> {/if}
{/if} </Panel>
</Panel> </div>
<style> <style>
.new-component {
position: fixed;
right: 0;
z-index: 1;
height: 100%;
display: flex;
flex-direction: row;
align-items: stretch;
}
.component-grid { .component-grid {
display: grid; display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-columns: repeat(3, minmax(0, 1fr));

View File

@ -0,0 +1,5 @@
<script>
import NewComponentPanel from "./_components/NewComponentPanel.svelte"
</script>
<NewComponentPanel />

View File

@ -1,21 +0,0 @@
<script>
import Panel from "components/design/Panel.svelte"
import { Body, Layout } from "@budibase/bbui"
import { selectedComponent, selectedScreen, store } from "builderStore"
$: componentDefinition = store.actions.components.getDefinition(
$selectedComponent?._component
)
$: isScreen = $selectedComponent?._id === $selectedScreen?.props._id
$: title = isScreen ? "Screen" : $selectedComponent?._instanceName
$: position = componentDefinition?.hasChildren ? "inside" : "below"
</script>
<Panel {title} icon={componentDefinition?.icon} borderLeft>
<Layout paddingX="L" paddingY="XL">
<Body size="S">
Components that you add will be placed {position}
{title}
</Body>
</Layout>
</Panel>

View File

@ -1,26 +0,0 @@
<script>
import NewComponentPanel from "./_components/NewComponentPanel.svelte"
import NewComponentTargetPanel from "./_components/NewComponentTargetPanel.svelte"
import { onMount } from "svelte"
import { store, selectedComponent, selectedScreen } from "builderStore"
import { redirect } from "@roxi/routify"
// Select the screen slot as the target to add to, if no component
// is selected
onMount(() => {
if (!$selectedComponent) {
if ($selectedScreen) {
store.update(state => {
state.selectedComponentId = $selectedScreen.props._id
return state
})
} else {
// Otherwise go back out of the add screen
$redirect("../")
}
}
})
</script>
<NewComponentPanel />
<NewComponentTargetPanel />