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

44 lines
1013 B
Svelte
Raw Normal View History

2020-06-03 00:26:06 +02:00
<script>
import { getContext } from "svelte"
import Placeholder from "./Placeholder.svelte"
export let dataProvider
export let noRowsMessage
const { API, styleable, builderStore, Provider } = getContext("sdk")
const component = getContext("component")
const context = getContext("context")
2020-06-03 00:26:06 +02:00
$: rows = dataProvider?.rows ?? []
$: loaded = dataProvider?.loaded ?? false
2020-06-03 00:26:06 +02:00
</script>
<div use:styleable={$component.styles}>
{#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}
</div>
<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>