EggyJS is a Javascript micro Library for simple, lightweight toast popups focused on being dependency-less, lightweight, quick and efficient.

Overview

EggyJS

EggyJS is a Javascript micro Library for simple, lightweight toast popups. The goal of this library was to create something that meets the following criteria

  • Dependency-less

  • Lightweight

  • Quick and efficient

  • As minimal as possible, but still ticking all boxes

Current Version

1.2.0

For more detailed release notes, see releases.md

Install

Eggy JS can be installed one of the following ways

NPM

To install via NPM run the following


npm i @s-r0/eggy-js

then import the module using

import { Eggy } from  '@s-r0/eggy-js';

Manually

Manual installation can be done by simply downloading this library and including the build eggy.js file. Once downloaded and placed in your directory, import the module like so.

import { Eggy } from  '{{path_to_eggy.js}}';

EggyJS builds the basic CSS required and adds it to the DOM when initialised, so there is no need to link the provided CSS files.

Important Information when using

For EggyJS to behave as expected, the following must be met when using

  • EggyJS resolves a promise, but when its first initialised it checks to see if a div in the requested position exists first before building. This is done so that there are no traces of HTML or CSS on the page when its loaded, to avoid any speed issues. To run multiple EggyJS toasts in the same position it must be done synchronously. The first instance of EggyJS must be resolved before trying to add another toast in the same position. Failure to run multiple at the same time synchronously will provide in 2 toasts being stacked directly on top of each other, making only 1 visible.

Basic Usage

Eggy has the default options of showing a success toast with the title Success! and the message Task complete successfully!, so you can get a standard toast popup simply by running

Eggy()

But if you want to edit the simple basics of the EggyJS, the most common options to edit are title, message and type. For example

Eggy({
    title:  'Whoops!',
    message:  'You done burnt your eggs!',
    type:  'error'
})

Options

Param | Type | Default | Details

------------ | ------------- | ------------- | -------------

title | string/boolean | 'Success' | The title that gets displayed at the top of the notification. Can be removed by providing false.

message | string/boolean | 'Task complete successfully!' | The main message inside the notification. Can be removed by providing false.

position | string | 'top-right' | Options avaiable are 'top-right', 'top-left', 'bottom-right' and 'bottom-left'

type | string | 'success' | Options available are 'success', 'warning', 'info' and 'error'

duration | integer | 5000 | Duration of the toast notification in milliseconds

styles | boolean | true | Enable the provided styling for the notifications. If set to false, the basic animation and positioning styles will still be applied, but no 'theme' styles will be added.

progressBar | boolean | true | Enable progress bars. The progress bars will be animated and the duration matches the duration of each individual eggy popup. The html only for the progress bar will be added if styles is set to false, so custom styling can be applied.

Callbacks

Calling eggy returns a promise containing the toast HTMLElement, so callbacks can be used to modify the toast once its initialised. For example, if we wanted to add a custom class to the toast, we could write

Eggy().then((eggytoast) => {
    eggytoast.classList.add('sunny-side-up');
})

or if youd prefer async/await

let eggytoast = await Eggy();
eggytoast.classList.add('sunny-side-up');

Stacking

EggyJS will automatically stack if a toast has already been initialised in the specified position. For example

await  Eggy({title:  'Top right 1'});
await  Eggy({title:  'Top right 2'});
await  Eggy({title:  'Top left 1', position:  'top-left'});
await  Eggy({title:  'Top left 2', position:  'top-left'});

Will build 2 stacked in the top left, and 2 stacked in the top right. Stacking toasts in the same position must be done synchronously, please see Important Information above.

Editing EggyJS

Eggys resources are managed via npm scripts. To edit EggyJS, simply clone this repository and run the command npm run watch, then make whatever changes required in the src directory. Once complete, run npm run prod to build for production.

Javascript

Edit the file src/eggy.js to edit the core functionality.

CSS/ScSS

EggyJS comes with the scss files used to build the styles. To make your changes, simply edit the scss files.

If you decide you want to make changes to the core styles or theme, then make any changes to the eggy.scss and theme.scss files in the src/scss directory, once complete run npm run prod and eggy will replace inserted string replacers in the JS with your output css. EggyJs builds the styles and appends them on the page only once first initialised to avoid any page load or speed issues. The only thing thats loaded on the page initially is the module itself.

Alternatively you can just disable the styles when using EggyJS using the styles option and then add your own css to your page as you see fit.

Icons

To edit the icons, change the SVG files in the src/img directory and run npm run prod once complete.

Please note, be careful to watch for any extra classes that have been added to the svg files, make sure to include them in your new icons if you want eggy to perform as expected

Authors

Sam Rutter

Copyright

Copyright © 2021 Samgraphic

License

EggyJS is under the MIT License

You might also like...

A vanilla JavaScript toast library

Vanilla Toasts (also refered to as vtoast) is a lightweight VanillaJS toast library. It does not require any framework to run. It is inspired from toa

Jan 18, 2022

A simple, jQuery free Snackbar (Toast) alert

js-snackbar What is a SnackBar? According to Material Design a Snackbar or Toast provides "brief messages about app processes at the bottom of the scr

Jan 5, 2023

✨ Small and Clean JavaScript Toast Notifications

✨ Small and Clean JavaScript Toast Notifications

BuzzNotify Small and Clean JavaScript Toast Notifications New version introduces breaking changes! Now the styles come separately and you will have to

Aug 23, 2022

Toaster is a Pure Javascript plugin for displaying toast notifications. It comes with different options e.g custom text or HTML message, duration, custom class, toggle close button, position, custom close icon and backgorund color.

Pure Javascript Toaster Requires Nothing Demo Toaster is a Pure Javascript plugin for displaying toast notifications. It comes with different options

Jun 21, 2022

🥰 Mini world simulator is a terminal application made in JavaScript to control the world that is being generated.

Mini-world "Simulator" Mini world simulator is a terminal application made in JavaScript to control the world that is being generated. It has no other

Mar 14, 2022

This repo was made to bring to light all discord scams, and show how to tell if you are being scammed and how to remove malware from scams

This repo was made to bring to light all discord scams, and show how to tell if you are being scammed and how to remove malware from scams

DMV (Discord Malware Variants) is a repository made to bring light to harmful programs used by bad actors in order to steal sensitive information from

Dec 29, 2022

This repo was made to bring to light all discord scams, and show how to tell if you are being scammed and how to remove malware from scams

This repo was made to bring to light all discord scams, and show how to tell if you are being scammed and how to remove malware from scams

DMV (Discord Malware Variants) is a repository made to bring light to harmful programs used by bad actors in order to steal sensitive information from

Sep 5, 2022

Vanilla JS toast notification.

Toasting Toasting - is a javascript library for notifications. There is no dependencies needed. Installing There is no npm or cdn is available yet. by

Jun 30, 2022

Jquery Plugin for Make easy Toast

Jquery Plugin for Make easy Toast

Nice Toast JS nice and easy toast for jquery Requirements jQuery Installation NPM npm install nice-toast-js Yarn yarn add nice-toast-js CDN - jsDelivr

Jul 26, 2022
Comments
  • Specify style programmatically

    Specify style programmatically

    Default styling is very nice But would be more useful if could pass colour codes programmatically. It's a pain to compile sass offline and use stylesheets this way, particularly if you have a dynamically themed app.

    opened by azidyn 1
Owner
Sam
Sam
A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

Glide.js is a dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more What can co

null 6.7k Jan 3, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Speed up the your micro-frontend development. Configure less and delivery more.

React Micro Speed up the your micro-frontend development. Configure less and delivery more. You don't need to waste more time trying to change your ap

Nevinha 7 Nov 7, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Micro.publish is an Obsidian plugin to publish notes directly to Micro.blog, written in TypeScript

Micro.publish Micro.publish is a community maintained plugin for Obsidian to publish notes to a Micro.blog blog. Installing This plugin will be availa

Otavio Cordeiro 14 Dec 9, 2022
It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm and toast with the library.

asteroid-alert It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm with the library. It has also e

Khan Md Sagar 4 Mar 12, 2021
Useful JavaScript base classes for efficient and quick solutions to common problems.

JavaScript Base Classes You can find the full documentation on the website. Description Useful JavaScript base classes for efficient and quick solutio

Ruben Arushanyan 9 Nov 15, 2022
🦉The jQuery plugin "Stick to me" allows you to create exit-popups on your web page, so you can capture visitors just as they are about to leave.

?? The jQuery plugin "Stick to me" allows you to create exit-popups on your web page, so you can capture visitors just as they are about to leave. How

Guilherme Assemany 18 Feb 10, 2022
A simple and light jquery library for toast notification!

What is notify message? Notify message it's a simple jquery library for create a simple and light push notification in your website! How does this wor

Ivan Persiani 3 Feb 23, 2022