2020-02-14 12:51:45 +01:00
|
|
|
<script>
|
2020-11-18 20:18:18 +01:00
|
|
|
import { getContext } from "svelte"
|
|
|
|
|
2021-06-18 13:41:15 +02:00
|
|
|
const { styleable } = 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-24 12:29:20 +02:00
|
|
|
export let gap
|
2021-06-24 13:15:04 +02:00
|
|
|
export let wrap
|
2021-06-08 09:00:54 +02:00
|
|
|
|
2021-06-10 12:34:01 +02:00
|
|
|
$: directionClass = direction ? `valid-container direction-${direction}` : ""
|
2021-06-10 10:28:10 +02:00
|
|
|
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
|
|
|
|
$: vAlignClass = vAlign ? `vAlign-${vAlign}` : ""
|
|
|
|
$: sizeClass = size ? `size-${size}` : ""
|
2021-06-24 12:29:20 +02:00
|
|
|
$: gapClass = gap ? `gap-${gap}` : ""
|
|
|
|
$: classNames = [
|
|
|
|
directionClass,
|
|
|
|
hAlignClass,
|
|
|
|
vAlignClass,
|
|
|
|
sizeClass,
|
|
|
|
gapClass,
|
|
|
|
].join(" ")
|
2020-02-14 12:51:45 +01:00
|
|
|
</script>
|
|
|
|
|
2021-06-24 13:15:04 +02:00
|
|
|
<div class={classNames} use:styleable={$component.styles} class:wrap>
|
2021-06-11 09:05:49 +02:00
|
|
|
<slot />
|
2021-04-01 20:19:14 +02:00
|
|
|
</div>
|
2021-06-08 09:00:54 +02:00
|
|
|
|
|
|
|
<style>
|
2021-06-10 12:34:01 +02:00
|
|
|
.valid-container {
|
2021-06-10 10:28:10 +02:00
|
|
|
display: flex;
|
2021-06-10 11:20:47 +02:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
2021-06-10 12:34:01 +02:00
|
|
|
.valid-container :global([data-type="component"] > *) {
|
2021-06-10 11:20:47 +02:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
.direction-row {
|
2021-06-08 09:00:54 +02:00
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.direction-column {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
2021-06-10 11:59:00 +02:00
|
|
|
/* Grow containers inside a row need 0 width 0 so that they ignore content */
|
|
|
|
/* The nested selector for data-type is the wrapper around all components */
|
|
|
|
.direction-row :global(> [data-type="component"] > .size-grow) {
|
|
|
|
width: 0;
|
|
|
|
}
|
|
|
|
|
2021-06-08 09:00:54 +02:00
|
|
|
.size-shrink {
|
|
|
|
flex: 0 1 auto;
|
|
|
|
}
|
|
|
|
.size-grow {
|
2021-06-10 11:59:00 +02:00
|
|
|
flex: 1 1 auto;
|
2021-06-08 09:00:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.direction-row.hAlign-left,
|
|
|
|
.direction-column.vAlign-top {
|
|
|
|
justify-content: flex-start;
|
|
|
|
}
|
2021-06-10 10:48:08 +02:00
|
|
|
.direction-row.hAlign-center,
|
2021-06-08 09:00:54 +02:00
|
|
|
.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,
|
2021-06-10 10:48:08 +02:00
|
|
|
.direction-column.hAlign-center {
|
2021-06-08 09:00:54 +02:00
|
|
|
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;
|
|
|
|
}
|
2021-06-24 12:29:20 +02:00
|
|
|
|
|
|
|
.gap-S {
|
|
|
|
gap: 8px;
|
|
|
|
}
|
|
|
|
.gap-M {
|
|
|
|
gap: 16px;
|
|
|
|
}
|
|
|
|
.gap-L {
|
|
|
|
gap: 32px;
|
|
|
|
}
|
2021-06-24 13:15:04 +02:00
|
|
|
|
|
|
|
.wrap {
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
2021-06-08 09:00:54 +02:00
|
|
|
</style>
|