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",
|
||||
"icon": "Image",
|
||||
"illegalChildren": ["section"],
|
||||
"styles": ["size"],
|
||||
"settings": [
|
||||
{
|
||||
"type": "text",
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
Loading…
Reference in New Issue