Convert EventPanel to Layout component

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-28 15:04:30 +02:00
parent 15acfc823f
commit 4c19d2d42f
4 changed files with 48 additions and 79 deletions

View File

@ -4,7 +4,6 @@
Label, Label,
Input, Input,
Select, Select,
Spacer,
notifications, notifications,
Body, Body,
ModalContent, ModalContent,
@ -39,10 +38,11 @@
<Input value={capitalise(level)} disabled /> <Input value={capitalise(level)} disabled />
<Select <Select
value={permissions[level]} value={permissions[level]}
on:change={e => changePermission(level, e.detail)} on:change={(e) => changePermission(level, e.detail)}
options={$roles} options={$roles}
getOptionLabel={x => x.name} getOptionLabel={(x) => x.name}
getOptionValue={x => x._id} /> getOptionValue={(x) => x._id}
/>
{/each} {/each}
</div> </div>
</ModalContent> </ModalContent>

View File

@ -5,8 +5,6 @@
Popover, Popover,
Divider, Divider,
Select, Select,
Layout,
Spacer,
Heading, Heading,
Drawer, Drawer,
} from "@budibase/bbui" } from "@budibase/bbui"

View File

@ -1,7 +1,7 @@
<script> <script>
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { dndzone } from "svelte-dnd-action" import { dndzone } from "svelte-dnd-action"
import { Icon, Button, Popover, Spacer, DrawerContent } from "@budibase/bbui" import { Icon, Button, Popover, Layout, DrawerContent } from "@budibase/bbui"
import actionTypes from "./actions" import actionTypes from "./actions"
import { generate } from "shortid" import { generate } from "shortid"
@ -70,12 +70,11 @@
<DrawerContent> <DrawerContent>
<div class="actions-list" slot="sidebar"> <div class="actions-list" slot="sidebar">
<div> <Layout>
<div bind:this={addActionButton}> <div bind:this={addActionButton}>
<Button wide secondary on:click={addActionDropdown.show}> <Button wide secondary on:click={addActionDropdown.show}>
Add Action Add Action
</Button> </Button>
<Spacer small />
</div> </div>
<Popover <Popover
bind:this={addActionDropdown} bind:this={addActionDropdown}
@ -90,55 +89,53 @@
{/each} {/each}
</div> </div>
</Popover> </Popover>
</div>
{#if actions && actions.length > 0} {#if actions && actions.length > 0}
<div <div
class="action-dnd-container" class="action-dnd-container"
use:dndzone={{ use:dndzone={{
items: actions, items: actions,
flipDurationMs, flipDurationMs,
dropTargetStyle: { outline: "none" }, dropTargetStyle: { outline: "none" },
}} }}
on:consider={handleDndConsider} on:consider={handleDndConsider}
on:finalize={handleDndFinalize} on:finalize={handleDndFinalize}
> >
{#each actions as action, index (action.id)} {#each actions as action, index (action.id)}
<div
class="action-container"
animate:flip={{ duration: flipDurationMs }}
>
<div <div
class="action-header" class="action-container"
class:selected={action === selectedAction} animate:flip={{ duration: flipDurationMs }}
on:click={selectAction(action)}
> >
{index + 1}. <div
{action[EVENT_TYPE_KEY]} class="action-header"
class:selected={action === selectedAction}
on:click={selectAction(action)}
>
{index + 1}.
{action[EVENT_TYPE_KEY]}
</div>
<div
on:click={() => deleteAction(index)}
style="margin-left: auto;"
>
<Icon size="S" hoverable name="Close" />
</div>
</div> </div>
<div {/each}
on:click={() => deleteAction(index)}
style="margin-left: auto;"
>
<Icon size="S" hoverable name="Close" />
</div>
</div>
{/each}
</div>
{/if}
</div>
<div class="actions-container">
<div class="action-config">
{#if selectedAction}
<div class="selected-action-container">
<svelte:component
this={selectedActionComponent}
parameters={selectedAction.parameters}
/>
</div> </div>
{/if} {/if}
</div> </Layout>
</div> </div>
<Layout>
{#if selectedAction}
<div class="selected-action-container">
<svelte:component
this={selectedActionComponent}
parameters={selectedAction.parameters}
/>
</div>
{/if}
</Layout>
</DrawerContent> </DrawerContent>
<style> <style>
@ -146,7 +143,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-top: var(--spacing-m); margin-top: var(--spacing-s);
} }
.action-header { .action-header {
@ -162,11 +159,6 @@
color: var(--ink); color: var(--ink);
} }
.actions-list {
border-right: var(--border-light);
padding: var(--spacing-l);
}
.available-action { .available-action {
padding: var(--spacing-s); padding: var(--spacing-s);
font-size: var(--font-size-xs); font-size: var(--font-size-xs);
@ -177,16 +169,6 @@
background: var(--grey-2); background: var(--grey-2);
} }
.actions-container {
height: 40vh;
display: grid;
grid-template-columns: 260px 1fr;
grid-auto-flow: column;
min-height: 0;
padding-top: 0;
overflow-y: auto;
}
.action-container { .action-container {
border-bottom: 1px solid var(--grey-1); border-bottom: 1px solid var(--grey-1);
display: flex; display: flex;
@ -196,10 +178,6 @@
border-bottom: none; border-bottom: none;
} }
.selected-action-container {
padding: var(--spacing-l);
}
i:hover { i:hover {
color: var(--red); color: var(--red);
cursor: pointer; cursor: pointer;

View File

@ -1,12 +1,5 @@
<script> <script>
import { import { Button, Drawer, Body, DrawerContent, Layout } from "@budibase/bbui"
Button,
Drawer,
Spacer,
Body,
DrawerContent,
Layout,
} from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { import {