-
Notifications
You must be signed in to change notification settings - Fork 1
/
Card.svelte
31 lines (27 loc) · 1.04 KB
/
Card.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!-- @component
[`Card`](https://github.com/txstate-etc/svelte-components/blob/main/src/lib/components/Card.svelte)
-->
<script lang="ts">
export let className = ''
import { getContext } from 'svelte'
import { resize, passActions, type HTMLActionEntry } from '$lib/actions'
import { CARDLAYOUT } from '$lib/types'
import type { CardLayoutContext, Block } from '$lib/types'
export let use: HTMLActionEntry[] = []
const block: Block = { element: undefined }
const { registerBlock, gutter, recalculate } = getContext<CardLayoutContext>(CARDLAYOUT)
const { width, order, linebreak } = registerBlock(block)
</script>
<li class="cardlayout-card {className}" bind:this={block.element} use:passActions={use} use:resize on:resize={recalculate} style="margin-bottom: {$gutter}px; width: {$width}; order: {$order};">
<slot></slot>
</li>
{#if $linebreak}
<li aria-hidden="true" class="cardlayout-columnbreak" style:order={$order}></li>
{/if}
<style>
.cardlayout-columnbreak {
width: 0;
height: 100%;
visibility: hidden;
}
</style>