1
0
Fork 0
mirror of synced 2024-06-25 17:40:38 +12:00

Add size styles and placeholder to image component

This commit is contained in:
Andrew Kingston 2021-06-25 15:29:24 +01:00
parent e5b2a21c82
commit 1711331261
3 changed files with 24 additions and 15 deletions

View file

@ -729,6 +729,7 @@
"description": "A basic component for displaying images",
"icon": "Image",
"illegalChildren": ["section"],
"styles": ["size"],
"settings": [
{
"type": "text",

View file

@ -1,21 +1,29 @@
<script>
import { getContext } from "svelte"
import Placeholder from "./Placeholder.svelte"
const { styleable } = getContext("sdk")
const component = getContext("component")
export let className = ""
export let url = ""
export let description = ""
export let height
export let width
export let url
</script>
<img
{height}
{width}
class={className}
src={url}
alt={description}
use:styleable={$component.styles}
/>
{#if url}
<img src={url} alt={$component.name} use:styleable={$component.styles} />
{:else}
<div
class="placeholder"
use:styleable={{ ...$component.styles, empty: true }}
>
<Placeholder />
</div>
{/if}
<style>
.placeholder {
display: grid;
place-items: center;
height: 75px;
width: 150px;
}
</style>

View file

@ -4,12 +4,12 @@
const { builderStore } = getContext("sdk")
const component = getContext("component")
export let text = $component.name || "Placeholder"
export let text
</script>
{#if $builderStore.inBuilder}
<div>
{text}
{text || $component.name || "Placeholder"}
</div>
{/if}