budibase/packages/standard-components/src/StackedList.svelte

85 lines
1.5 KiB
Svelte
Raw Normal View History

2020-07-31 13:02:29 +02:00
<script>
import { getContext } from "svelte"
const { styleable, linkable } = getContext("sdk")
const component = getContext("component")
2020-07-31 13:02:29 +02:00
export let imageUrl = ""
export let heading = ""
export let subheading = ""
export let destinationUrl = "/"
2020-07-31 13:02:29 +02:00
$: showImage = !!imageUrl
</script>
<div class="container" use:styleable={$component.styles}>
<a use:linkable href={destinationUrl}>
<div class="stackedlist">
2020-07-31 13:02:29 +02:00
{#if showImage}
<div class="image-block">
<img class="image" src={imageUrl} alt="" />
</div>
{/if}
<div class="content">
<div class="heading">{heading}</div>
<div class="subheading">{subheading}</div>
</div>
2020-07-31 13:02:29 +02:00
</div>
</a>
</div>
<style>
a {
text-decoration: none;
color: inherit;
cursor: pointer;
2020-07-31 13:02:29 +02:00
}
.container {
padding: 1rem 1.5rem;
min-height: 3rem;
display: block;
align-items: flex-start;
2020-07-31 13:02:29 +02:00
}
.stackedlist {
2020-07-31 13:02:29 +02:00
display: flex;
flex-direction: row;
overflow: hidden;
max-width: 100%;
2020-07-31 13:02:29 +02:00
}
.subheading {
opacity: 0.6;
white-space: pre-wrap;
2020-07-31 13:02:29 +02:00
}
.content {
min-width: 0;
max-width: 100%;
flex: 1 1 auto;
2020-07-31 13:02:29 +02:00
}
.heading {
font-weight: 600;
white-space: pre-wrap;
2020-07-31 13:02:29 +02:00
}
.image-block {
display: flex;
flex: 0 0 auto;
margin-right: 1.5rem;
color: inherit;
text-decoration: none;
2020-07-31 13:02:29 +02:00
}
.image {
display: block;
overflow: hidden;
width: 3rem;
max-width: 100%;
-webkit-user-select: none;
user-select: none;
border-radius: 99px;
2020-07-31 13:02:29 +02:00
}
</style>