2020-03-06 18:00:54 +01:00
|
|
|
<script>
|
|
|
|
import PlusButton from "../common/PlusButton.svelte"
|
|
|
|
|
|
|
|
export let meta = []
|
|
|
|
export let size = ""
|
|
|
|
export let values = []
|
|
|
|
export let propertyName
|
|
|
|
export let onStyleChanged = () => {}
|
|
|
|
|
2020-03-08 00:57:19 +01:00
|
|
|
let selectedLayoutValues = values.map(v => v)
|
2020-03-06 18:00:54 +01:00
|
|
|
|
2020-03-08 00:57:19 +01:00
|
|
|
$: onStyleChanged(selectedLayoutValues)
|
2020-03-06 18:00:54 +01:00
|
|
|
|
|
|
|
const PROPERTY_OPTIONS = {
|
|
|
|
Direction: {
|
2020-03-08 00:50:43 +01:00
|
|
|
vertical: ["column", "ri-arrow-up-down-line"],
|
|
|
|
horizontal: ["row", "ri-arrow-left-right-line"],
|
2020-03-06 18:00:54 +01:00
|
|
|
},
|
|
|
|
Align: {
|
2020-03-08 00:50:43 +01:00
|
|
|
left: ["flex-start", "ri-layout-bottom-line"],
|
|
|
|
center: ["center", "ri-layout-row-line"],
|
|
|
|
right: ["flex-end", "ri-layout-top-line"],
|
2020-03-06 18:00:54 +01:00
|
|
|
space: ["space-between", "ri-space"],
|
|
|
|
},
|
|
|
|
Justify: {
|
2020-03-08 00:50:43 +01:00
|
|
|
left: ["flex-start", "ri-layout-left-line"],
|
|
|
|
center: ["center", "ri-layout-column-line"],
|
|
|
|
right: ["flex-end", "ri-layout-right-line"],
|
2020-03-06 18:00:54 +01:00
|
|
|
space: ["space-between", "ri-space"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
$: propertyChoices = Object.entries(PROPERTY_OPTIONS[propertyName])
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="inputs {size}">
|
|
|
|
{#each meta as { placeholder }, i}
|
|
|
|
{#each propertyChoices as [displayName, [cssPropValue, icon]]}
|
|
|
|
<button
|
2020-03-08 00:57:19 +01:00
|
|
|
class:selected={cssPropValue === selectedLayoutValues[i]}
|
2020-03-06 18:00:54 +01:00
|
|
|
on:click={() => {
|
2020-03-08 00:57:19 +01:00
|
|
|
const newPropertyValue = cssPropValue === selectedLayoutValues[i] ? '' : cssPropValue
|
|
|
|
selectedLayoutValues[i] = newPropertyValue
|
2020-03-06 18:00:54 +01:00
|
|
|
}}>
|
|
|
|
<i class={icon} />
|
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.selected {
|
2020-06-23 09:19:16 +02:00
|
|
|
color: var(--blue);
|
2020-03-16 19:18:42 +01:00
|
|
|
background: #f9f9f9;
|
|
|
|
opacity: 1;
|
2020-03-06 18:00:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
|
|
|
cursor: pointer;
|
|
|
|
outline: none;
|
|
|
|
border: none;
|
2020-03-16 19:18:42 +01:00
|
|
|
border-radius: 3px;
|
2020-03-06 18:00:54 +01:00
|
|
|
|
2020-03-08 00:50:43 +01:00
|
|
|
min-width: 1.6rem;
|
|
|
|
min-height: 1.6rem;
|
2020-03-06 18:00:54 +01:00
|
|
|
|
|
|
|
display: flex;
|
2020-03-16 19:18:42 +01:00
|
|
|
justify-content: space-between;
|
2020-03-06 18:00:54 +01:00
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
font-size: 1.2rem;
|
2020-03-08 00:50:43 +01:00
|
|
|
font-weight: 500;
|
2020-06-23 09:19:16 +02:00
|
|
|
color: var(--ink);
|
2020-03-06 18:00:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.inputs {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
</style>
|