Last active
November 20, 2020 19:03
-
-
Save matryer/8eda4036144efa1d0d0b4303fe5502db to your computer and use it in GitHub Desktop.
Simple Accordian component for Svelte (from https://firesearch.dev)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang='ts'> | |
import { slide } from 'svelte/transition' | |
export let open: boolean = false | |
export function toggle() { | |
open = !open | |
} | |
</script> | |
<a | |
href='#open' | |
on:click|preventDefault={ toggle } | |
><slot name='link' {open}></slot></a> | |
{#if open} | |
<div transition:slide> | |
<slot name='content'></slot> | |
</div> | |
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang='ts'> | |
import Accordian from './Accordian.svelte' | |
</script> | |
<Accordian let:open> | |
<span slot='link'> | |
{#if !open} | |
Show more | |
{:else} | |
Hide | |
{/if} | |
</span> | |
<div slot='content'> | |
Content goes here | |
</div> | |
</Accordian> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment