2020-02-14 12:51:45 +01:00
|
|
|
<script>
|
2020-11-18 20:18:18 +01:00
|
|
|
import { getContext } from "svelte"
|
|
|
|
|
2021-06-08 09:00:54 +02:00
|
|
|
const { styleable, transition, builderStore } = getContext("sdk")
|
2020-11-24 12:02:10 +01:00
|
|
|
const component = getContext("component")
|
2021-06-08 09:00:54 +02:00
|
|
|
|
2021-06-10 10:28:10 +02:00
|
|
|
export let direction
|
|
|
|
export let hAlign
|
|
|
|
export let vAlign
|
|
|
|
export let size
|
2021-06-08 09:00:54 +02:00
|
|
|
|
|
|
|
let element
|
2021-06-10 10:28:10 +02:00
|
|
|
|
|
|
|
$: directionClass = direction ? `direction-${direction}` : ""
|
|
|
|
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
|
|
|
|
$: vAlignClass = vAlign ? `vAlign-${vAlign}` : ""
|
|
|
|
$: sizeClass = size ? `size-${size}` : ""
|
2020-02-14 12:51:45 +01:00
|
|
|
</script>
|
|
|
|
|
2021-04-01 20:19:14 +02:00
|
|
|
<div
|
2021-06-10 10:28:10 +02:00
|
|
|
class={[directionClass, hAlignClass, vAlignClass, sizeClass].join(" ")}
|
2021-06-08 09:00:54 +02:00
|
|
|
class:empty={!$component.children && $builderStore.inBuilder}
|
|
|
|
class:selected={$component.selected}
|
2021-04-01 20:19:14 +02:00
|
|
|
in:transition={{ type: $component.transition }}
|
2021-05-04 12:04:42 +02:00
|
|
|
use:styleable={$component.styles}
|
2021-06-08 09:00:54 +02:00
|
|
|
bind:this={element}
|
2021-05-04 12:04:42 +02:00
|
|
|
>
|
2021-06-08 09:00:54 +02:00
|
|
|
{#if !$component.children && $builderStore.inBuilder}
|
|
|
|
<div class="placeholder">Add some content</div>
|
|
|
|
{:else}
|
|
|
|
<slot />
|
|
|
|
{/if}
|
2021-04-01 20:19:14 +02:00
|
|
|
</div>
|
2021-06-08 09:00:54 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.empty {
|
|
|
|
border: 2px dashed rgba(0, 0, 0, 0.25);
|
|
|
|
}
|
|
|
|
.direction-row {
|
2021-06-10 10:28:10 +02:00
|
|
|
display: flex;
|
2021-06-08 09:00:54 +02:00
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.direction-column {
|
2021-06-10 10:28:10 +02:00
|
|
|
display: flex;
|
2021-06-08 09:00:54 +02:00
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.size-shrink {
|
|
|
|
flex: 0 1 auto;
|
|
|
|
}
|
|
|
|
.size-grow {
|
|
|
|
flex: 1 1 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.direction-row.hAlign-left,
|
|
|
|
.direction-column.vAlign-top {
|
|
|
|
justify-content: flex-start;
|
|
|
|
}
|
|
|
|
.direction-row.hAlign-middle,
|
|
|
|
.direction-column.vAlign-middle {
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
.direction-row.hAlign-right,
|
|
|
|
.direction-column.vAlign-bottom {
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
|
|
|
.direction-row.hAlign-stretch,
|
|
|
|
.direction-column.vAlign-stretch {
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
.direction-row.vAlign-top,
|
|
|
|
.direction-column.hAlign-left {
|
|
|
|
align-items: flex-start;
|
|
|
|
}
|
|
|
|
.direction-row.vAlign-middle,
|
|
|
|
.direction-column.hAlign-middle {
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
.direction-row.vAlign-bottom,
|
|
|
|
.direction-column.hAlign-right {
|
|
|
|
align-items: flex-end;
|
|
|
|
}
|
|
|
|
.direction-row.vAlign-stretch,
|
|
|
|
.direction-column.hAlign-stretch {
|
|
|
|
align-items: stretch;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.placeholder {
|
|
|
|
padding: 20px;
|
|
|
|
color: #888;
|
|
|
|
}
|
|
|
|
</style>
|