Add background image component

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

View File

@ -49,6 +49,7 @@
"heading",
"text",
"image",
"backgroundimage",
"link",
"icon",
"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": {
"name": "Icon",
"description": "A basic component for displaying icons",
@ -394,6 +407,11 @@
"type": "boolean",
"label": "New Tab",
"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 icon } from "./Icon.svelte"
export { default as search } from "./Search.svelte"
export { default as backgroundimage } from "./BackgroundImage.svelte"
export * from "./charts"
export * from "./forms"