1
0
Fork 0
mirror of synced 2024-06-29 03:20:34 +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", "description": "A basic component for displaying images",
"icon": "Image", "icon": "Image",
"illegalChildren": ["section"], "illegalChildren": ["section"],
"styles": ["size"],
"settings": [ "settings": [
{ {
"type": "text", "type": "text",

View file

@ -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>

View file

@ -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}