1
0
Fork 0
mirror of synced 2024-10-03 02:27:06 +13:00

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"