Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bulma-toast

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulma-toast - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

dist/bulma-toast.cjs.js
/*!
* bulma-toast 1.1.0
* bulma-toast 1.2.0
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});const defaults={message:'Your message here',duration:2e3,position:'top-right',closeOnClick:!0};let initialized=!1,containers={},positions={};function init(){containers={noticesTopLeft:document.createElement('div'),noticesTopRight:document.createElement('div'),noticesBottomLeft:document.createElement('div'),noticesBottomRight:document.createElement('div'),noticesTopCenter:document.createElement('div'),noticesBottomCenter:document.createElement('div'),noticesCenter:document.createElement('div')};containers.noticesTopLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;top:0;text-align:left;align-items:flex-start;`),containers.noticesTopRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;top:0;text-align:right;align-items:flex-end;`),containers.noticesBottomLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;bottom:0;text-align:left;align-items:flex-start;`),containers.noticesBottomRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;bottom:0;text-align:right;align-items:flex-end;`),containers.noticesTopCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesBottomCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}bottom:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(containers).forEach(a=>document.body.appendChild(containers[a])),positions={"top-left":containers.noticesTopLeft,"top-right":containers.noticesTopRight,"top-center":containers.noticesTopCenter,"bottom-left":containers.noticesBottomLeft,"bottom-right":containers.noticesBottomRight,"bottom-center":containers.noticesBottomCenter,center:containers.noticesCenter},initialized=!0}function toast(a){initialized||init();let b=Object.assign({},defaults,a);const c=createToast(b),d=positions[b.position]||positions[defaults.position];d.appendChild(c)}function createToast(a){const b=document.createElement('div');let c=`width:auto;opacity:0.8;pointer-events:auto;display:inline-flex;`,d=['notification'];if(a.type&&d.push(a.type),b.classList=d.join(' '),a.dismissible){let a=document.createElement('button');a.className='delete',a.addEventListener('click',()=>{b.remove()}),b.insertAdjacentElement('afterbegin',a)}else c+='padding: 1.25rem 1.5rem';a.closeOnClick&&b.addEventListener('click',()=>{b.remove()}),b.setAttribute('style',c),b.insertAdjacentText('beforeend',a.message);const e=new Timer(()=>{b.remove()},a.duration);return a.pauseOnHover&&(console.log('added pauseOnHover'),b.addEventListener('mouseover',()=>{e.pause()}),b.addEventListener('mouseout',()=>{e.resume()})),b}function Timer(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}exports.toast=toast;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});const defaults={message:'Your message here',duration:2e3,position:'top-right',closeOnClick:!0,opacity:.8};let initialized=!1,containers={},positions={};function init(){containers={noticesTopLeft:document.createElement('div'),noticesTopRight:document.createElement('div'),noticesBottomLeft:document.createElement('div'),noticesBottomRight:document.createElement('div'),noticesTopCenter:document.createElement('div'),noticesBottomCenter:document.createElement('div'),noticesCenter:document.createElement('div')};containers.noticesTopLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;top:0;text-align:left;align-items:flex-start;`),containers.noticesTopRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;top:0;text-align:right;align-items:flex-end;`),containers.noticesBottomLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;bottom:0;text-align:left;align-items:flex-start;`),containers.noticesBottomRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;bottom:0;text-align:right;align-items:flex-end;`),containers.noticesTopCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesBottomCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}bottom:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(containers).forEach(a=>document.body.appendChild(containers[a])),positions={"top-left":containers.noticesTopLeft,"top-right":containers.noticesTopRight,"top-center":containers.noticesTopCenter,"bottom-left":containers.noticesBottomLeft,"bottom-right":containers.noticesBottomRight,"bottom-center":containers.noticesBottomCenter,center:containers.noticesCenter},initialized=!0}function toast(a){initialized||init();let b=Object.assign({},defaults,a);const c=createToast(b),d=positions[b.position]||positions[defaults.position];d.appendChild(c)}function createToast(a){const b=document.createElement('div');let c=`width:auto;pointer-events:auto;display:inline-flex;opacity:${a.opacity};`,d=['notification'];if(a.type&&d.push(a.type),b.classList=d.join(' '),a.dismissible){let a=document.createElement('button');a.className='delete',a.addEventListener('click',()=>{b.remove()}),b.insertAdjacentElement('afterbegin',a)}else c+='padding: 1.25rem 1.5rem';a.closeOnClick&&b.addEventListener('click',()=>{b.remove()}),b.setAttribute('style',c),b.insertAdjacentText('beforeend',a.message);const e=new Timer(()=>{b.remove()},a.duration);return a.pauseOnHover&&(b.addEventListener('mouseover',()=>{e.pause()}),b.addEventListener('mouseout',()=>{e.resume()})),b}function Timer(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}exports.toast=toast;
/*!
* bulma-toast 1.1.0
* bulma-toast 1.2.0
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
const defaults={message:'Your message here',duration:2e3,position:'top-right',closeOnClick:!0};let initialized=!1,containers={},positions={};function init(){containers={noticesTopLeft:document.createElement('div'),noticesTopRight:document.createElement('div'),noticesBottomLeft:document.createElement('div'),noticesBottomRight:document.createElement('div'),noticesTopCenter:document.createElement('div'),noticesBottomCenter:document.createElement('div'),noticesCenter:document.createElement('div')};containers.noticesTopLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;top:0;text-align:left;align-items:flex-start;`),containers.noticesTopRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;top:0;text-align:right;align-items:flex-end;`),containers.noticesBottomLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;bottom:0;text-align:left;align-items:flex-start;`),containers.noticesBottomRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;bottom:0;text-align:right;align-items:flex-end;`),containers.noticesTopCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesBottomCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}bottom:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(containers).forEach(a=>document.body.appendChild(containers[a])),positions={"top-left":containers.noticesTopLeft,"top-right":containers.noticesTopRight,"top-center":containers.noticesTopCenter,"bottom-left":containers.noticesBottomLeft,"bottom-right":containers.noticesBottomRight,"bottom-center":containers.noticesBottomCenter,center:containers.noticesCenter},initialized=!0}function toast(a){initialized||init();let b=Object.assign({},defaults,a);const c=createToast(b),d=positions[b.position]||positions[defaults.position];d.appendChild(c)}function createToast(a){const b=document.createElement('div');let c=`width:auto;opacity:0.8;pointer-events:auto;display:inline-flex;`,d=['notification'];if(a.type&&d.push(a.type),b.classList=d.join(' '),a.dismissible){let a=document.createElement('button');a.className='delete',a.addEventListener('click',()=>{b.remove()}),b.insertAdjacentElement('afterbegin',a)}else c+='padding: 1.25rem 1.5rem';a.closeOnClick&&b.addEventListener('click',()=>{b.remove()}),b.setAttribute('style',c),b.insertAdjacentText('beforeend',a.message);const e=new Timer(()=>{b.remove()},a.duration);return a.pauseOnHover&&(console.log('added pauseOnHover'),b.addEventListener('mouseover',()=>{e.pause()}),b.addEventListener('mouseout',()=>{e.resume()})),b}function Timer(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}export{toast};
const defaults={message:"Your message here",duration:2e3,position:"top-right",closeOnClick:!0,opacity:.8};let initialized=!1,containers={},positions={};function init(){containers={noticesTopLeft:document.createElement("div"),noticesTopRight:document.createElement("div"),noticesBottomLeft:document.createElement("div"),noticesBottomRight:document.createElement("div"),noticesTopCenter:document.createElement("div"),noticesBottomCenter:document.createElement("div"),noticesCenter:document.createElement("div")};containers.noticesTopLeft.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}left:0;top:0;text-align:left;align-items:flex-start;`),containers.noticesTopRight.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}right:0;top:0;text-align:right;align-items:flex-end;`),containers.noticesBottomLeft.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}left:0;bottom:0;text-align:left;align-items:flex-start;`),containers.noticesBottomRight.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}right:0;bottom:0;text-align:right;align-items:flex-end;`),containers.noticesTopCenter.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}top:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesBottomCenter.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}bottom:0;left:0;right:0;text-align:center;align-items:center;`),containers.noticesCenter.setAttribute("style",`${"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(containers).forEach(a=>document.body.appendChild(containers[a])),positions={"top-left":containers.noticesTopLeft,"top-right":containers.noticesTopRight,"top-center":containers.noticesTopCenter,"bottom-left":containers.noticesBottomLeft,"bottom-right":containers.noticesBottomRight,"bottom-center":containers.noticesBottomCenter,center:containers.noticesCenter},initialized=!0}function toast(a){initialized||init();let b=Object.assign({},defaults,a);const c=createToast(b),d=positions[b.position]||positions[defaults.position];d.appendChild(c)}function createToast(a){const b=document.createElement("div");let c=`width:auto;pointer-events:auto;display:inline-flex;opacity:${a.opacity};`,d=["notification"];if(a.type&&d.push(a.type),b.classList=d.join(" "),a.dismissible){let a=document.createElement("button");a.className="delete",a.addEventListener("click",()=>{b.remove()}),b.insertAdjacentElement("afterbegin",a)}else c+="padding: 1.25rem 1.5rem";a.closeOnClick&&b.addEventListener("click",()=>{b.remove()}),b.setAttribute("style",c),b.insertAdjacentText("beforeend",a.message);const e=new Timer(()=>{b.remove()},a.duration);return a.pauseOnHover&&(b.addEventListener("mouseover",()=>{e.pause()}),b.addEventListener("mouseout",()=>{e.resume()})),b}function Timer(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}export{toast};
/*!
* bulma-toast 1.1.0
* bulma-toast 1.2.0
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports):'function'==typeof define&&define.amd?define(['exports'],b):b(a.bulmaToast={})})(this,function(a){'use strict';function b(){h={noticesTopLeft:document.createElement('div'),noticesTopRight:document.createElement('div'),noticesBottomLeft:document.createElement('div'),noticesBottomRight:document.createElement('div'),noticesTopCenter:document.createElement('div'),noticesBottomCenter:document.createElement('div'),noticesCenter:document.createElement('div')};h.noticesTopLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;top:0;text-align:left;align-items:flex-start;`),h.noticesTopRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;top:0;text-align:right;align-items:flex-end;`),h.noticesBottomLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;bottom:0;text-align:left;align-items:flex-start;`),h.noticesBottomRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;bottom:0;text-align:right;align-items:flex-end;`),h.noticesTopCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;text-align:center;align-items:center;`),h.noticesBottomCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}bottom:0;left:0;right:0;text-align:center;align-items:center;`),h.noticesCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(h).forEach(a=>document.body.appendChild(h[a])),i={"top-left":h.noticesTopLeft,"top-right":h.noticesTopRight,"top-center":h.noticesTopCenter,"bottom-left":h.noticesBottomLeft,"bottom-right":h.noticesBottomRight,"bottom-center":h.noticesBottomCenter,center:h.noticesCenter},g=!0}function c(a){g||b();let c=Object.assign({},f,a);const e=d(c),h=i[c.position]||i[f.position];h.appendChild(e)}function d(a){const b=document.createElement('div');let c=`width:auto;opacity:0.8;pointer-events:auto;display:inline-flex;`,d=['notification'];if(a.type&&d.push(a.type),b.classList=d.join(' '),a.dismissible){let a=document.createElement('button');a.className='delete',a.addEventListener('click',()=>{b.remove()}),b.insertAdjacentElement('afterbegin',a)}else c+='padding: 1.25rem 1.5rem';a.closeOnClick&&b.addEventListener('click',()=>{b.remove()}),b.setAttribute('style',c),b.insertAdjacentText('beforeend',a.message);const f=new e(()=>{b.remove()},a.duration);return a.pauseOnHover&&(console.log('added pauseOnHover'),b.addEventListener('mouseover',()=>{f.pause()}),b.addEventListener('mouseout',()=>{f.resume()})),b}function e(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}const f={message:'Your message here',duration:2e3,position:'top-right',closeOnClick:!0};let g=!1,h={},i={};a.toast=c,Object.defineProperty(a,'__esModule',{value:!0})});
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports):'function'==typeof define&&define.amd?define(['exports'],b):b(a.bulmaToast={})})(this,function(a){'use strict';function b(){h={noticesTopLeft:document.createElement('div'),noticesTopRight:document.createElement('div'),noticesBottomLeft:document.createElement('div'),noticesBottomRight:document.createElement('div'),noticesTopCenter:document.createElement('div'),noticesBottomCenter:document.createElement('div'),noticesCenter:document.createElement('div')};h.noticesTopLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;top:0;text-align:left;align-items:flex-start;`),h.noticesTopRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;top:0;text-align:right;align-items:flex-end;`),h.noticesBottomLeft.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}left:0;bottom:0;text-align:left;align-items:flex-start;`),h.noticesBottomRight.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}right:0;bottom:0;text-align:right;align-items:flex-end;`),h.noticesTopCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;text-align:center;align-items:center;`),h.noticesBottomCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}bottom:0;left:0;right:0;text-align:center;align-items:center;`),h.noticesCenter.setAttribute('style',`${'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`),Object.keys(h).forEach(a=>document.body.appendChild(h[a])),i={"top-left":h.noticesTopLeft,"top-right":h.noticesTopRight,"top-center":h.noticesTopCenter,"bottom-left":h.noticesBottomLeft,"bottom-right":h.noticesBottomRight,"bottom-center":h.noticesBottomCenter,center:h.noticesCenter},g=!0}function c(a){g||b();let c=Object.assign({},f,a);const e=d(c),h=i[c.position]||i[f.position];h.appendChild(e)}function d(a){const b=document.createElement('div');let c=`width:auto;pointer-events:auto;display:inline-flex;opacity:${a.opacity};`,d=['notification'];if(a.type&&d.push(a.type),b.classList=d.join(' '),a.dismissible){let a=document.createElement('button');a.className='delete',a.addEventListener('click',()=>{b.remove()}),b.insertAdjacentElement('afterbegin',a)}else c+='padding: 1.25rem 1.5rem';a.closeOnClick&&b.addEventListener('click',()=>{b.remove()}),b.setAttribute('style',c),b.insertAdjacentText('beforeend',a.message);const f=new e(()=>{b.remove()},a.duration);return a.pauseOnHover&&(b.addEventListener('mouseover',()=>{f.pause()}),b.addEventListener('mouseout',()=>{f.resume()})),b}function e(a,b){let c,d,e=b;this.pause=function(){window.clearTimeout(c),e-=new Date-d},this.resume=function(){d=new Date,window.clearTimeout(c),c=window.setTimeout(a,e)},this.resume()}const f={message:'Your message here',duration:2e3,position:'top-right',closeOnClick:!0,opacity:.8};let g=!1,h={},i={};a.toast=c,Object.defineProperty(a,'__esModule',{value:!0})});
{
"name": "bulma-toast",
"version": "1.1.0",
"version": "1.2.0",
"description": "Bulma's pure JavaScript extension to display toasts",

@@ -38,2 +38,2 @@ "main": "dist/bulma-toast.cjs.js",

]
}
}

@@ -22,2 +22,3 @@ # bulma-toast

- `closeOnClick`: Dismisses the notification when clicked. Default is `true`.
- `opacity`: The notification's container opacity. Default is `0.8`.

@@ -35,2 +36,3 @@ ## Install

1. Link to bulma-toast.min.js
```html

@@ -42,4 +44,4 @@ <script src="bulma-toast.min.js"></script>

```js
bulmaToast.toast({ message: 'Hello There' })
bulmaToast.toast({ message: 'General Kenobi', type: 'is-danger' })
bulmaToast.toast({ message: "Hello There" });
bulmaToast.toast({ message: "General Kenobi", type: "is-danger" });
```

@@ -51,3 +53,3 @@

// Import the toast function
import { toast } from 'bulma-toast'
import { toast } from "bulma-toast";
// Or use

@@ -58,6 +60,6 @@ // import { toast as superToast } from 'bulma-toast'

toast({
message: 'Hello There',
type: 'is-success',
dismissible: true,
})
message: "Hello There",
type: "is-success",
dismissible: true
});
```

@@ -64,0 +66,0 @@

const defaults = {
message: 'Your message here',
message: "Your message here",
duration: 2000,
position: 'top-right',
position: "top-right",
closeOnClick: true,
}
opacity: 0.8
};
let initialized = false
let containers = {}
let positions = {}
let initialized = false;
let containers = {};
let positions = {};
function init() {
containers = {
noticesTopLeft: document.createElement('div'),
noticesTopRight: document.createElement('div'),
noticesBottomLeft: document.createElement('div'),
noticesBottomRight: document.createElement('div'),
noticesTopCenter: document.createElement('div'),
noticesBottomCenter: document.createElement('div'),
noticesCenter: document.createElement('div'),
}
noticesTopLeft: document.createElement("div"),
noticesTopRight: document.createElement("div"),
noticesBottomLeft: document.createElement("div"),
noticesBottomRight: document.createElement("div"),
noticesTopCenter: document.createElement("div"),
noticesBottomCenter: document.createElement("div"),
noticesCenter: document.createElement("div")
};
let style =
'width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;'
"width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;";
containers.noticesTopLeft.setAttribute('style', `${style}left:0;top:0;text-align:left;align-items:flex-start;`)
containers.noticesTopRight.setAttribute('style', `${style}right:0;top:0;text-align:right;align-items:flex-end;`)
containers.noticesBottomLeft.setAttribute('style', `${style}left:0;bottom:0;text-align:left;align-items:flex-start;`)
containers.noticesBottomRight.setAttribute('style', `${style}right:0;bottom:0;text-align:right;align-items:flex-end;`)
containers.noticesTopLeft.setAttribute(
"style",
`${style}left:0;top:0;text-align:left;align-items:flex-start;`
);
containers.noticesTopRight.setAttribute(
"style",
`${style}right:0;top:0;text-align:right;align-items:flex-end;`
);
containers.noticesBottomLeft.setAttribute(
"style",
`${style}left:0;bottom:0;text-align:left;align-items:flex-start;`
);
containers.noticesBottomRight.setAttribute(
"style",
`${style}right:0;bottom:0;text-align:right;align-items:flex-end;`
);
containers.noticesTopCenter.setAttribute(
'style',
`${style}top:0;left:0;right:0;text-align:center;align-items:center;`,
)
"style",
`${style}top:0;left:0;right:0;text-align:center;align-items:center;`
);
containers.noticesBottomCenter.setAttribute(
'style',
`${style}bottom:0;left:0;right:0;text-align:center;align-items:center;`,
)
"style",
`${style}bottom:0;left:0;right:0;text-align:center;align-items:center;`
);
containers.noticesCenter.setAttribute(
'style',
`${style}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`,
)
"style",
`${style}top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;`
);
Object.keys(containers).forEach(key => document.body.appendChild(containers[key]))
Object.keys(containers).forEach(key =>
document.body.appendChild(containers[key])
);
positions = {
'top-left': containers.noticesTopLeft,
'top-right': containers.noticesTopRight,
'top-center': containers.noticesTopCenter,
'bottom-left': containers.noticesBottomLeft,
'bottom-right': containers.noticesBottomRight,
'bottom-center': containers.noticesBottomCenter,
center: containers.noticesCenter,
}
"top-left": containers.noticesTopLeft,
"top-right": containers.noticesTopRight,
"top-center": containers.noticesTopCenter,
"bottom-left": containers.noticesBottomLeft,
"bottom-right": containers.noticesBottomRight,
"bottom-center": containers.noticesBottomCenter,
"center": containers.noticesCenter
};
initialized = true
initialized = true;
}
export function toast(params) {
if (!initialized) init()
let options = Object.assign({}, defaults, params)
if (!initialized) init();
let options = Object.assign({}, defaults, params);
const toast = createToast(options)
const container = positions[options.position] || positions[defaults.position]
const toast = createToast(options);
const container = positions[options.position] || positions[defaults.position];
container.appendChild(toast)
container.appendChild(toast);
}
function createToast(options) {
const toast = document.createElement('div')
let style = `width:auto;opacity:0.8;pointer-events:auto;display:inline-flex;`
let classes = ['notification']
if (options.type) classes.push(options.type)
toast.classList = classes.join(' ')
const toast = document.createElement("div");
let style = `width:auto;pointer-events:auto;display:inline-flex;opacity:${
options.opacity
};`;
let classes = ["notification"];
if (options.type) classes.push(options.type);
toast.classList = classes.join(" ");
if (options.dismissible) {
let dismissButton = document.createElement('button')
dismissButton.className = 'delete'
dismissButton.addEventListener('click', () => {
toast.remove()
})
toast.insertAdjacentElement('afterbegin', dismissButton)
let dismissButton = document.createElement("button");
dismissButton.className = "delete";
dismissButton.addEventListener("click", () => {
toast.remove();
});
toast.insertAdjacentElement("afterbegin", dismissButton);
} else {
style += 'padding: 1.25rem 1.5rem'
style += "padding: 1.25rem 1.5rem";
}
if (options.closeOnClick) {
toast.addEventListener('click', () => {
toast.remove()
})
toast.addEventListener("click", () => {
toast.remove();
});
}
toast.setAttribute('style', style)
toast.insertAdjacentText('beforeend', options.message)
toast.setAttribute("style", style);
toast.insertAdjacentText("beforeend", options.message);
const timer = new Timer(() => {
toast.remove()
}, options.duration)
toast.remove();
}, options.duration);
if (options.pauseOnHover) {
toast.addEventListener('mouseover', () => {
timer.pause()
})
toast.addEventListener('mouseout', () => {
timer.resume()
})
toast.addEventListener("mouseover", () => {
timer.pause();
});
toast.addEventListener("mouseout", () => {
timer.resume();
});
}
return toast
return toast;
}

@@ -110,16 +127,16 @@

start,
remaining = delay
remaining = delay;
this.pause = function() {
window.clearTimeout(timer)
remaining -= new Date() - start
}
window.clearTimeout(timer);
remaining -= new Date() - start;
};
this.resume = function() {
start = new Date()
window.clearTimeout(timer)
timer = window.setTimeout(callback, remaining)
}
start = new Date();
window.clearTimeout(timer);
timer = window.setTimeout(callback, remaining);
};
this.resume()
this.resume();
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc