Add size styles and placeholder to image component
This commit is contained in:
parent
79b3732ef4
commit
1599c8433d
|
@ -729,6 +729,7 @@
|
||||||
"description": "A basic component for displaying images",
|
"description": "A basic component for displaying images",
|
||||||
"icon": "Image",
|
"icon": "Image",
|
||||||
"illegalChildren": ["section"],
|
"illegalChildren": ["section"],
|
||||||
|
"styles": ["size"],
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|
|
@ -1,21 +1,29 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
import Placeholder from "./Placeholder.svelte"
|
||||||
|
|
||||||
const { styleable } = getContext("sdk")
|
const { styleable } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
export let className = ""
|
export let url
|
||||||
export let url = ""
|
|
||||||
export let description = ""
|
|
||||||
export let height
|
|
||||||
export let width
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<img
|
{#if url}
|
||||||
{height}
|
<img src={url} alt={$component.name} use:styleable={$component.styles} />
|
||||||
{width}
|
{:else}
|
||||||
class={className}
|
<div
|
||||||
src={url}
|
class="placeholder"
|
||||||
alt={description}
|
use:styleable={{ ...$component.styles, empty: true }}
|
||||||
use:styleable={$component.styles}
|
>
|
||||||
/>
|
<Placeholder />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.placeholder {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
height: 75px;
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
const { builderStore } = getContext("sdk")
|
const { builderStore } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
export let text = $component.name || "Placeholder"
|
export let text
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $builderStore.inBuilder}
|
{#if $builderStore.inBuilder}
|
||||||
<div>
|
<div>
|
||||||
{text}
|
{text || $component.name || "Placeholder"}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue