Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transitions not working #72

Open
KaungZinHein84 opened this issue Dec 12, 2023 · 0 comments
Open

transitions not working #72

KaungZinHein84 opened this issue Dec 12, 2023 · 0 comments

Comments

@KaungZinHein84
Copy link

I'm using sveltekit 1.27.4 and transitions are not working on both the default notification and custom notification
Here's my CustomToast.svelte component

<script lang="ts">
	import Icon from '@iconify/svelte';
	import { onMount } from 'svelte';
	import { fade } from 'svelte/transition';

	export let notification: { type: string; text: string };
	export let onRemove: () => void;
	let timer: number;
	export let withoutStyles: boolean;

	const handleButtonClick = () => {
		onRemove();
	};

	onMount(() => {
		timer = setTimeout(() => {
			onRemove();
		}, 5000);

		return () => {
			clearTimeout(timer);
		};
	});
</script>

<div
	transition:fade
	class={withoutStyles
		? ''
		: 'bg-white py-2 px-4 rounded-md border border-slate-200 flex items-center justify-between mt-4 min-w-[24rem]'}
>
	<div class="flex items-center space-x-2">
		{#if notification.type === 'error'}
			<Icon icon="mdi:alert-circle" class="text-red-500" />
		{:else if notification.type === 'warning'}
			<Icon icon="mdi:alert-circle" class="text-yellow-500" />
		{:else}
			<Icon icon="mdi:check-circle" class="text-green-500" />
		{/if}
		<p class="text-slate-500 text-sm">{notification.text}</p>
	</div>
	<button on:click={handleButtonClick} class="text-slate-500">
		<Icon icon="mdi:close-thick" /></button
	>
</div>

Here's my +layout.svelte file at the root of routes directory

<script lang="ts">
	import '../app.css';
	import CustomToast from '$lib/components/ui/CustomToast.svelte';
	import Notifications from 'svelte-notifications';
</script>

<Notifications item={CustomToast} zIndex={5000}>
	<slot />
</Notifications>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant