Moved components to lib folder; slide animation for announcement bar

This commit is contained in:
2024-08-04 19:06:52 +03:00
parent 91cc11829a
commit f021b80892
3 changed files with 13 additions and 7 deletions

View File

@@ -5,15 +5,20 @@
-->
<script>
import { slide } from 'svelte/transition';
export let message;
export let color = 'red';
let noderef;
let visible = true;
</script>
<div bind:this={noderef} class="announcement" style="background-color: {color};">
{#if visible}
<div transition:slide bind:this={noderef} class="announcement" style="background-color: {color};">
<span>{message}</span>
<input class="close-button" type="button" value="" on:click={() => noderef.parentNode.removeChild(noderef)}>
<input class="close-button" type="button" value="" on:click={() => visible = false}>
</div>
{/if}
<style>
.announcement {

View File

@@ -7,6 +7,9 @@
import '$lib/css/colors.css';
import '$lib/css/anims.css';
import Announcement from '$lib/components/announcement.svelte';
</script>
<Announcement message="This is an announcement" color="var(--col_accent)"/>
<slot></slot>

View File

@@ -1,9 +1,7 @@
<script>
import Announcement from "../components/announcement.svelte";
import Announcement from "../lib/components/announcement.svelte";
</script>
<Announcement message="This is an announcement" color="blue"/>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> <i>(SvelteKit)</i> to read the <b>SvelteKit</b> documentation</p>