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

alpine-toast

v0.0.2

Published

A toast library using alpine-js for phoenix-liveview

Downloads

8

Readme

Apline Toast

Alpine toast is a toast library which allows users to label an element with x-toast and will make it a toast.

The library aims to be configurable for the 99% use case an forkable for the last 1%.

AlpineToast does not use the Alpine library but follows the simplicity of the project.

Demo

mcraealex.github.io/AlpineToast/dist/index.html

Install

If using node just npm i alpine-toast then start using the lib.

npm i alpine-toast

If you need a cdn link create an issue and I will make it avaiable through a cdn.

Usage

First we have to create the instance of the AlpineToast library

import {AlpineToast, TailWindCSSConfig} from 'alpine-toast';

// Good defaults if your using tailwindcss
const toaster = AlpineToast(TailWindCSSConfig);

// Then we convert all the elements with x-toast into toasts
document.addEventListener('DOMContentLoaded', () => {
    toaster.start();
})

Then we can add toasts by adding it to attributes. But we must remember that start must be called to convert these so if you doing this using flashes like in phoenix then you will need to call toaster.start again.

Important: AlpineToast does not create a new element. It transforms the elemen given into a toast by adding the classes passed into the config and adding it to the toast container. All attributes but the x-toast attribute are maintained

<div x-toast="{ duration: 1000, showProgressBar: true }">

Alternatively if its easier for you to use JS

toaster.newToast('content', optionalConfig);

This will create a new toast with text content

Lastly if you already have a element which you are building in js to add as a toast.

toaster.makeToast(elem, optionalConfig);

This will covert the element into a toast.

Contributing

The easiest way to get started editing the codebase is by running

npm install

Then start the dev server

npm run dev

To see the changes do the same thing in the example dir which will allow you to modify both the example code and the library code an see you changes right away.

To do:

  • Add the ability to have types of toasts passed in as a config field which changes the config.
    • Not sure if this type would map to another config or just add classes to the config being used.
  • Early cancellation with button
  • Add usage for using with Phoenix LiveView
  • TailWindCSS config
  • Add generated API documentation
  • Create another page in the demo application which shows all the different configuration options turning different ones on and off still using the tailwindcss classes
  • VanillaCSS config for non tailwind users
    • This just means copying the tailwindcss styles to another css class and putting them under a single class name instead of adding a bunch of different ones. (May be possible to just automate this)
  • Write hooks which make sure before the package it uploaded to github it passes test cases and it builds so people have access to the compiled code