Comparing version 1.1.1 to 1.1.2
@@ -0,0 +0,0 @@ const chalk = require('chalk'); |
{ | ||
"name": "toast-me", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Creates toast messages", | ||
@@ -5,0 +5,0 @@ "main": "lib/toast-me.min.js", |
@@ -0,0 +0,0 @@ # toast-me |
@@ -0,0 +0,0 @@ // @flow |
@@ -0,0 +0,0 @@ // @flow |
@@ -0,0 +0,0 @@ // @flow |
@@ -9,2 +9,23 @@ // @flow | ||
export default class ToastMeClass { | ||
static getContainer(position): Element { | ||
const onBottom = position === 'bottom'; | ||
const selector = `.${styles.container} ${onBottom ? `.${styles.bottom}` : ''}`; | ||
let node = document.querySelector(selector); | ||
if (!node) { | ||
node = document.createElement('div'); | ||
node.classList.add(styles.container); | ||
if (onBottom) node.classList.add(styles.bottom); | ||
document.body.appendChild(node); | ||
} | ||
return node; | ||
} | ||
static removeAll(position) { | ||
const node = ToastMeClass.getContainer(position); | ||
const closeButtons = node.querySelectorAll(`.${styles.close}`); | ||
for (let i = 0, l = closeButtons.length; i < l; i += 1) { | ||
closeButtons[i].click(); | ||
} | ||
} | ||
/** | ||
@@ -31,6 +52,6 @@ * @param content {String} - text to show | ||
this.content = content; | ||
this.domNode = this.createToastNode(action); | ||
ToastMeClass | ||
.getContainer(options.position) | ||
.appendChild(this.domNode); | ||
this.domNode = this.createToastNode(action); | ||
this.startTimer(); | ||
@@ -95,23 +116,2 @@ } | ||
static getContainer(position): Element { | ||
const onBottom = position === 'bottom'; | ||
const selector = `.${styles.container} ${onBottom ? `.${styles.bottom}` : ''}`; | ||
let node = document.querySelector(selector); | ||
if (!node) { | ||
node = document.createElement('div'); | ||
node.classList.add(styles.container); | ||
if (onBottom) node.classList.add(styles.bottom); | ||
document.body.appendChild(node); | ||
} | ||
return node; | ||
} | ||
static removeAll(position) { | ||
const node = ToastMeClass.getContainer(position); | ||
const closeButtons = node.querySelectorAll(`.${styles.close}`); | ||
for (let i = 0, l = closeButtons.length; i < l; i += 1) { | ||
closeButtons[i].click(); | ||
} | ||
} | ||
close() { | ||
@@ -118,0 +118,0 @@ this.stopTimer(); |
@@ -0,0 +0,0 @@ // @flow |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346975