1.0.0 • Published 1 year ago

toastia v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Toastia

this is a simple project for show toast in your project. you can use your own class and styles or use my own predefined.

How to use it?

it's simple. 1. add link and script tag

<link href="/path/to/toastia.css" rel="stylesheet">
<script src="/path/to/toastia.min.js"></script>
  1. add this to your html
<ul class="toastia"></ul>
  1. initialize it
const toastia = new Toastia();

// you can pass your own options like this

const toastia = new Toastia(options);
  1. call toast.
toastia.toast("this is a test","info");

//or

toastia.toastInfo("this is a test");

//or

toastia.toastInfo("<span>this is a test</span>");

// toastInfo, toastSuccess, toastWarning, toastError
  1. if you use toast first parameter is toast text and second is type of toast that is info, success, warning, error.

  2. done.

Options.

optionvaluedefaultdescription
durationnumber > 0 in ms2000how long toast show?
timeoutnumber > 0 in ms450how long hide toast?
positionstring"topRight"where should i show toast? one of key from positionClass.
childItemstring"li"what type of child create for toast item?
placementstring"afterbegin"how it show toast? from new to old? or old to new? only accept afterbegin for new to old and beforeend for old to new.
toastnodeulwhich node is container of toast

Position class

this object is for add all type of class for each postion.

positionvaluedefault
topLeftstring"toastia-top-left"
topCenterstring"toastia-top-center"
topRightstring"toastia-top-right"
bottomLeftstring"toastia-bottom-left"
bottomCenterstring"toastia-bottom-center"
bottomRightstring"toastia-bottom-right"

Type class

this object is for add all type of class for each type.

typevaluedefault
infostring"toastia-info"
successstring"toastia-success"
warningstring"toastia-warning"
errorstring"toastia-error"
nonestring"toast-item"

Animation class

this object is for add all type of class for each animation.

animationvaluedefault
addstring"toastia-fade-in"
removestring"toastia-fade-out"
1.0.0

1 year ago