Add background image component

This commit is contained in:
Andrew Kingston 2021-02-26 09:58:11 +00:00
parent dd0fee3dc3
commit 624ad79c95
4 changed files with 48 additions and 0 deletions

View File

@ -49,6 +49,7 @@
"heading", "heading",
"text", "text",
"image", "image",
"backgroundimage",
"link", "link",
"icon", "icon",
"embed" "embed"

View File

@ -294,6 +294,19 @@
} }
] ]
}, },
"backgroundimage": {
"name": "Background Image",
"description": "A background image",
"icon": "ri-image-line",
"styleable": true,
"settings": [
{
"type": "text",
"label": "URL",
"key": "url"
}
]
},
"icon": { "icon": {
"name": "Icon", "name": "Icon",
"description": "A basic component for displaying icons", "description": "A basic component for displaying icons",
@ -394,6 +407,11 @@
"type": "boolean", "type": "boolean",
"label": "New Tab", "label": "New Tab",
"key": "openInNewTab" "key": "openInNewTab"
},
{
"type": "boolean",
"label": "External",
"key": "external"
} }
] ]
}, },

View File

@ -0,0 +1,28 @@
<script>
import { getContext } from "svelte"
const { styleable } = getContext("sdk")
const component = getContext("component")
export let url = ""
$: style = url ? `background-image: url("${url}")` : ""
</script>
<div class="outer" use:styleable={$component.styles}>
<div class="inner" {style} />
</div>
<style>
.outer {
position: relative;
}
.inner {
position: absolute;
height: 100%;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: top center;
}
</style>

View File

@ -31,5 +31,6 @@ export { default as cardhorizontal } from "./CardHorizontal.svelte"
export { default as cardstat } from "./CardStat.svelte" export { default as cardstat } from "./CardStat.svelte"
export { default as icon } from "./Icon.svelte" export { default as icon } from "./Icon.svelte"
export { default as search } from "./Search.svelte" export { default as search } from "./Search.svelte"
export { default as backgroundimage } from "./BackgroundImage.svelte"
export * from "./charts" export * from "./charts"
export * from "./forms" export * from "./forms"