npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@friendofsvelte/toasted

v0.0.1-alpha.1

Published

Fast and easy toast and flash messages for svelte.

Downloads

3

Readme

Toasted by Friend Of Svelte

Fast and easy toast and flash messages for svelte.

Installation

npm install @friendofsvelte/toasted

Usage

Here's how you can set your toast/flash messages. Usually from +page.server.ts or +server.ts file.

import type { RequestHandler } from './$types';
import { flash_redirect } from '@friendofsvelte/toasted';

export const GET: RequestHandler = async ({ cookies }) => {
	throw flash_redirect(
		cookies,
		{
			messages: [ 'This is just a simple toast message.', 'This is just another simple toast message'], // or message: 'This is just a simple toast message.'
			message_type: 'success',
			alias: 'already_confirmed'
		},
		302,
		'/_dev'
	);
};

And here's how you can display them in your svelte component.

<script lang="ts">
    import Toasted from '@friendofsvelte/toasted/Toasted.svelte';
    import '@friendofsvelte/toasted/toasted.css';
    import "iconify-icon";
</script>

<Toasted/>

Manual addition or removal of messages

import { addToast, dismissAllToasts, dismissToast, triggerMessage, setFlashMessage } from '@friendofsvelte/toasted';

addToast({
	message: 'Init message',
	message_type: 'error',
	alias: 'init',
}, 2000);
  • addToast adds a toast message to the list of messages to be displayed. It accepts message, message_type, messages, alias and action_path as parameters (MessageOut). message is the message to be displayed. message_type is the type of the message. messages is an array of messages to be displayed. alias is the alias of the message. action_path is the path to be redirected to when the user clicks on the button in the toast message.
  • dismissAllToasts removes all messages from the list of messages to be displayed.
  • dismissToast removes a specific message from the list of messages to be displayed. Accepts toast id as parameter.
  • triggerMessage seeks message data from the server and adds it to the list of messages to be displayed.
  • setFlashMessage gets the message data from the server (cookie) and adds it to the list of messages to be displayed.

Message types

  • success
  • info
  • warning
  • error

Message aliases

Message aliases are used to identify messages, and use them for some specific message detection purposes.

Components import

import Toasted from '@friendofsvelte/toasted/Toasted.svelte';
import Toast from '@friendofsvelte/toasted/Toast.svelte'; // Sigle toast message
import InitToasts from '@friendofsvelte/toasted/InitToasts.svelte'; // Initial toast messages

InitToasts is used to display initial toast messages stored in the cookie, or as fallback messages.

About Friend Of Svelte

Friend Of Svelte Logo

Friend Of Svelte is a community driven project to help Svelte developers to find and develop awesome Svelte resources.

If you like this project, you can be one of the friend by contributing to the project. Memberships are open for everyone.