1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00
budibase/packages/standard-components/src/BackgroundImage.svelte
2021-03-01 14:05:54 +00:00

39 lines
689 B
Svelte

<script>
import { getContext } from "svelte"
const { styleable } = getContext("sdk")
const component = getContext("component")
export let url
export let position
let style = ""
$: {
if (url) {
style += `background-image: url("${url}");`
}
if (position) {
style += `background-position: ${position};`
}
}
</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: center center;
}
</style>