Skip to content

Commit

Permalink
adds duration to alert type
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmartin committed Mar 25, 2017
1 parent 9c6b411 commit 2390839
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface AlertOptions {
color?: string;
position?: string;
backdrop?: boolean;
duration?: number;
}
export interface ConfirmOptions {
template: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/mystical.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mystical-notification",
"version": "0.4.0",
"version": "0.5.0",
"description": "Web alerts I needed.",
"main": "dist/mystical",
"typings": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface AlertOptions {
color?: string;
position?: string;
backdrop?: boolean;
duration?: number;
}
export interface ConfirmOptions {
template: string;
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export class Mystical {
// after the note div is on the DOM - to trigger the CSS transition
startTransition(defaults, note, iStyles.top, iStyles.bottom)

if (defaults.duration !== undefined) {
wait(defaults.duration).then(() => {
removeNoteFromDom(note, backdrop, defaults.pos)
})
}

}

/**
Expand Down Expand Up @@ -227,9 +233,10 @@ function initDefaults(opts) {
const fg = opts.color ? opts.color : "#fff"
const pos = opts.position ? opts.position : "top"
const backdrop = opts.backdrop ? opts.backdrop : true
const duration = opts.duration ? opts.duration : undefined
const posText = opts.positiveText ? opts.positiveText : "Yes"
const negText = opts.negativeText ? opts.negativeText : "No"
return { bg, fg, pos, backdrop, posText, negText }
return { bg, fg, pos, backdrop, duration, posText, negText }
}

/**
Expand All @@ -246,6 +253,7 @@ export interface AlertOptions {
color?: string
position?: string
backdrop?: boolean
duration?: number
}
export interface ConfirmOptions {
template: string
Expand Down

0 comments on commit 2390839

Please sign in to comment.