1
0
Fork 0
mirror of synced 2024-09-21 03:43:21 +12:00
budibase/packages/builder/src/components/userInterface/StateBindingControl.svelte

59 lines
1.5 KiB
Svelte
Raw Normal View History

2019-09-20 19:01:35 +12:00
<script>
2020-02-03 22:50:30 +13:00
import IconButton from "../common/IconButton.svelte"
import Input from "../common/Input.svelte"
2020-02-22 07:02:02 +13:00
import PropertyCascader from "./PropertyCascader"
2020-02-03 22:50:30 +13:00
import { isBinding, getBinding, setBinding } from "../common/binding"
import Colorpicker from "../common/Colorpicker.svelte"
2020-02-03 22:50:30 +13:00
export let value = ""
export let onChanged = () => {}
export let type = ""
export let options = []
export let styleBindingProperty = ""
$: bindOptionToStyle = !!styleBindingProperty
2019-09-20 19:01:35 +12:00
</script>
2020-02-11 05:58:20 +13:00
<div class="unbound-container">
{#if type === 'bool'}
<div>
2020-02-03 22:50:30 +13:00
<IconButton
2020-02-11 05:58:20 +13:00
icon={value == true ? 'check-square' : 'square'}
size="19"
on:click={() => onChanged(!value)} />
</div>
2020-02-11 05:58:20 +13:00
{:else if type === 'options'}
<select
class="uk-select uk-form-small"
{value}
on:change={ev => onChanged(ev.target.value)}>
2020-02-26 04:21:23 +13:00
{#each options || [] as option}
{#if bindOptionToStyle}
<option style={`${styleBindingProperty}: ${option};`} value={option}>
{option}
</option>
{:else}
<option value={option}>{option}</option>
{/if}
2020-02-11 05:58:20 +13:00
{/each}
</select>
{:else if type === 'colour'}
<Colorpicker {onChanged} {value} />
2020-02-11 05:58:20 +13:00
{:else}
2020-02-11 06:11:22 +13:00
<PropertyCascader {onChanged} {value} />
2020-02-11 05:58:20 +13:00
{/if}
</div>
2019-09-20 19:01:35 +12:00
<style>
2020-02-03 22:50:30 +13:00
.unbound-container {
display: flex;
}
.bound-header > div:nth-child(1) {
flex: 1 0 auto;
width: 30px;
color: var(--secondary50);
padding-left: 5px;
}
</style>