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

boop-svelte

v0.0.3

Published

Extremely simple and customizable toast notifications for Svelte.

Downloads

2

Readme

Boop-Svelte - Notifications for Svelte

Extremely simple and customizable toast notifications for Svelte in a repository that responds to requests and issues.

Forked from keenethics/svelte-notifications. That repository didn't seem to be getting much love, and its typings were completely broken, making it unusable for any TypeScript project.

Why boop?

Because every permutation of "toast" was taken, and because I was feeling cute.

Demonstration

git clone https://github.com/tcc-sejohnson/boop-svelte.git
cd boop-svelte
yarn dev

Getting started

yarn add --dev boop-svelte
npm install --save boop-svelte

Basic usage

Render Boops beside any component. I recommend as high up your application tree as possible to guarantee it's available:

// MainComponent.svelte

<script lang="ts">
  import Boops from 'boop-svelte';
  import App from './App.svelte';
</script>

<Boops />
<App />

Import the store anywhere in your app to add or remove boops:

// ChildComponent.svelte

<script lang="ts">
  import boopStore from 'boop-svelte/store';
  import { BoopTypes, BoopPositions } from 'boop-svelte/constants';

  const { addBoop } = boopStore;
</script>

<!-- All are optional except text; these are the defaults -->
<button
  on:click={() => addBoop({
    id: myIdFunction(),
	  text: "Hello, Svelte!",
	  position: BoopPositions.TOP_CENTER,
	  removeAfter: 4000,
	  type: BoopTypes.SUCCESS,
  })}
>
  Add Boop
</button>

Create your own wrappers to make your life easier:

// lib/boops/Success.ts
import boopStore from 'boop-svelte/store';
const { addBoop } = boopStore;

export const successBoop = (text: string): void =>
	addBoop({
		id: myIdFunction(),
		text: `Success: ${text}`,
		position: BoopPositions.TOP_RIGHT,
		removeAfter: 5000,
		type: BoopTypes.SUCCESS,
	});

Providing a custom boop component

// MainComponent.svelte

<script>
  import Boops from 'boop-svelte';
  import CustomBoop from './CustomBoop.svelte';

  import App from './App.svelte';
</script>

<Boops customBoop={CustomBoop} />
<App />

Custom components must fulfill the following type (all types are exported from boop-svelte/types):

interface BoopProps {
	id?: string;
	text: string;
	position?: BoopPositions;
	removeAfter?: number;
	type?: BoopTypes;
}

type CustomBoopComponentProps = {
	boopProps: BoopProps;
	onRemove: () => void;
};

// Implement this:
type CustomBoop = SvelteComponentTyped<CustomBoopComponentProps>;

API

Boops

The Boops component renders each Boop in its appropriate location.

Props:

  • customBoop - optional - a component implementing the CustomBoop type to override the DefaultBoop.
  • width - optional - a number indicating the width of your boops.
  • withUnits - optional - a valid CSS unit for your boop width.

boopStore

The store controlling which boops are displayed.

addBoop

Adds a boop given the boop definition (see BoopProps in boop-svelte/types):

  • id - optional - a unique identifier for your boop. If you don't want to provide one, this function will assign your boop one and return it.
  • text - required - the text to boop with.
  • position - optional - the position on the viewport to render the boop. import { BoopPositions } from 'boop-svelte/constants.
  • removeAfter - optional - milliseconds to wait before removing the boop.
  • type - optional - the type of boop to render. import { BoopTypes } from 'boop-svelte/constants.

Returns: The ID of the boop.

removeBoop

  • id - required - Unique boop identifier supplied when calling addBoop.

clearBoops

What it says on the tin. Goodbye, boops.

subscribe

Default Svelte subscribe method allowing you to watch the Boops store.