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

47 lines
1.0 KiB
Svelte
Raw Normal View History

2020-06-03 00:26:06 +02:00
<script>
import { getContext } from "svelte"
import Placeholder from "./Placeholder.svelte"
import Container from "./Container.svelte"
export let dataProvider
export let noRowsMessage
export let direction
export let hAlign
export let vAlign
const { Provider } = getContext("sdk")
const component = getContext("component")
2020-06-03 00:26:06 +02:00
$: rows = dataProvider?.rows ?? []
2021-06-11 12:37:05 +02:00
$: loaded = dataProvider?.loaded ?? true
2020-06-03 00:26:06 +02:00
</script>
<Container {direction} {hAlign} {vAlign}>
{#if $component.empty}
<Placeholder />
{:else if rows.length > 0}
{#each rows as row}
<Provider data={row}>
<slot />
</Provider>
{/each}
{:else if loaded && noRowsMessage}
<div class="noRows"><i class="ri-list-check-2" />{noRowsMessage}</div>
{/if}
</Container>
<style>
.noRows {
color: var(--grey-6);
font-size: var(--font-size-s);
padding: var(--spacing-l);
display: grid;
place-items: center;
}
.noRows i {
margin-bottom: var(--spacing-m);
font-size: 1.5rem;
color: var(--grey-5);
}
</style>