0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
svelte/documentation/examples/17-special-elements/00-svelte-self/Folder.svelte
Alimurtuza bbcb5f58ae
docs: handle warnings in examples page (#8836)
ignore some, fix others

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-06-26 10:44:29 +02:00

56 lines
944 B
Svelte

<script>
import File from './File.svelte';
import { slide } from 'svelte/transition';
export let expanded = false;
export let name;
export let files;
function toggle() {
expanded = !expanded;
}
</script>
<button class:expanded on:click={toggle}>{name}</button>
{#if expanded}
<ul transition:slide={{ duration: 300 }}>
{#each files as file}
<li>
{#if file.type === 'folder'}
<svelte:self {...file} />
{:else}
<File {...file} />
{/if}
</li>
{/each}
</ul>
{/if}
<style>
button {
padding: 0 0 0 1.5em;
background: url(/tutorial/icons/folder.svg) 0 0.1em no-repeat;
background-size: 1em 1em;
font-weight: bold;
cursor: pointer;
border:none;
font-size:14px;
}
.expanded {
background-image: url(/tutorial/icons/folder-open.svg);
}
ul {
padding: 0.2em 0 0 0.5em;
margin: 0 0 0 0.5em;
list-style: none;
border-left: 1px solid #eee;
}
li {
padding: 0.2em 0;
}
</style>