budibase/packages/builder/src/components/userInterface/BindingDropdown.svelte

71 lines
1.3 KiB
Svelte
Raw Normal View History

2020-08-12 17:30:20 +02:00
<script>
2020-08-25 10:15:51 +02:00
import { TextArea } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let bindableProperties
export let value = ""
function addToText(readableBinding) {
value = value + `{{ ${readableBinding} }}`
}
$: dispatch("update", value)
2020-08-12 17:30:20 +02:00
</script>
2020-08-25 10:15:51 +02:00
<div class="container">
<div class="text">
<TextArea
bind:value
2020-08-25 11:40:48 +02:00
placeholder=""
label="Select bindable properties from the right." />
2020-08-25 10:15:51 +02:00
</div>
<div class="list">
<ul>
{#each bindableProperties as { readableBinding }}
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
{/each}
</ul>
</div>
</div>
2020-08-12 17:30:20 +02:00
<style>
2020-08-25 10:15:51 +02:00
.container {
display: grid;
grid-template-columns: auto auto;
}
.text {
2020-08-25 11:40:48 +02:00
padding: var(--spacing-s) 0 var(--spacing-s) var(--spacing-s);
2020-08-25 10:15:51 +02:00
width: 600px;
display: grid;
}
.list {
width: 150px;
}
2020-08-12 17:30:20 +02:00
ul {
list-style: none;
padding-left: 0;
margin: 0;
2020-08-25 11:40:48 +02:00
padding: 0;
2020-08-12 17:30:20 +02:00
}
2020-08-25 11:40:48 +02:00
2020-08-12 17:30:20 +02:00
li {
display: flex;
font-family: var(--font-sans);
font-size: var(--font-size-xs);
color: var(--ink);
padding: var(--spacing-s) var(--spacing-m);
margin: auto 0px;
align-items: center;
cursor: pointer;
}
2020-08-25 11:40:48 +02:00
li:hover {
background-color: var(--grey-2);
}
li:active {
color: var(--blue);
}
2020-08-12 17:30:20 +02:00
</style>