Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
A JavaScript/TypeScript notification, confirmation, and prompt library.
Notifications can display as toast style, snackbar style, banners, dialogs, alerts, or desktop notifications (using the Web Notifications spec) with fall back to an in-browser notice.
PNotify provides a unique notification flow called modalish that provides a good user experience, even when many notifications are shown at once.
Latest Stable - http://sciactive.com/pnotify/
Development - https://sciactive.github.io/pnotify/
You can get PNotify using NPM or Yarn. (You can also use jsDelivr.)
You should install the packages you need individually. Alternatively, you can install all of them at once with the pnotify
package.
# Install the packages you need individually.
# You definitely need this one.
npm install --save-dev @pnotify/core
# These are the optional ones.
npm install --save-dev @pnotify/animate
npm install --save-dev @pnotify/bootstrap3
npm install --save-dev @pnotify/bootstrap4
npm install --save-dev @pnotify/confirm
npm install --save-dev @pnotify/countdown
npm install --save-dev @pnotify/desktop
npm install --save-dev @pnotify/font-awesome4
npm install --save-dev @pnotify/font-awesome5-fix
npm install --save-dev @pnotify/font-awesome5
npm install --save-dev @pnotify/glyphicon
npm install --save-dev @pnotify/mobile
# ...
# Or, you can install this to get them all.
npm install --save-dev pnotify
In addition to the JS and CSS, be sure to include a PNotify style.
import { alert, defaultModules } from '@pnotify/core';
import * as PNotifyMobile from '@pnotify/mobile';
defaultModules.set(PNotifyMobile, {});
alert({
text: 'Notice me, senpai!'
});
import { alert, defaultModules } from '@pnotify/core';
import '@pnotify/core/dist/PNotify.css';
import * as PNotifyMobile from '@pnotify/mobile';
import '@pnotify/mobile/dist/PNotifyMobile.css';
defaultModules.set(PNotifyMobile, {});
alert({
text: 'Notice me, senpai!'
});
import { alert, defaultModules } from '@pnotify/core';
import '@pnotify/core/dist/PNotify.css';
import * as PNotifyMobile from '@pnotify/mobile';
import '@pnotify/mobile/dist/PNotifyMobile.css';
defaultModules.set(PNotifyMobile, {});
//...
export class WhateverComponent {
constructor() {
alert({
text: 'Notice me, senpai!'
});
}
}
For IE support, see this issue.
PNotify in Angular (Injectable)
// pnotify.service.ts
import { Injectable } from '@angular/core';
import { alert, defaultModules } from '@pnotify/core';
import '@pnotify/core/dist/PNotify.css';
import * as PNotifyMobile from '@pnotify/mobile';
import '@pnotify/mobile/dist/PNotifyMobile.css';
defaultModules.set(PNotifyMobile, {});
@Injectable()
export class PNotifyService {
getPNotifyAlert() {
return alert;
}
}
// whatever.module.ts
//...
import { PNotifyService } from './pnotify.service';
@NgModule({
declarations: [...],
imports: [...],
providers: [PNotifyService],
bootstrap: [...]
})
export class WhateverModule {}
// whatever.component.ts
import { PNotifyService } from './pnotify.service';
//...
export class WhateverComponent {
alert = undefined;
constructor(pnotifyService: PNotifyService) {
this.alert = pnotifyService.getPNotifyAlert();
this.alert({
text: 'Notice me, senpai!'
});
}
}
<link href="node_modules/@pnotify/core/dist/PNotify.css" rel="stylesheet" type="text/css" />
<link href="node_modules/@pnotify/mobile/dist/PNotifyMobile.css" rel="stylesheet" type="text/css" />
var angular = require('angular');
var PNotify = require('@pnotify/core');
var PNotifyMobile = require('@pnotify/mobile');
PNotify.defaultModules.set(PNotifyMobile, {});
angular.module('WhateverModule', [])
.value('PNotify', PNotify)
.controller('WhateverController', ['PNotify', function(PNotify) {
PNotify.alert({
text: 'Notice me, senpai!'
});
}]);
PNotify in vanilla ES5
<script type="text/javascript" src="node_modules/@pnotify/core/dist/PNotify.js"></script>
<link href="node_modules/@pnotify/core/dist/PNotify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="node_modules/@pnotify/mobile/dist/PNotifyMobile.js"></script>
<link href="node_modules/@pnotify/mobile/dist/PNotifyMobile.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
PNotify.defaultModules.set(PNotifyMobile, {});
PNotify.alert({
text: 'Notice me, senpai!'
});
</script>
<link href="node_modules/@pnotify/core/dist/PNotify.css" rel="stylesheet" type="text/css" />
<link href="node_modules/@pnotify/mobile/dist/PNotifyMobile.css" rel="stylesheet" type="text/css" />
<script type="module">
import { alert, defaultModules } from 'node_modules/@pnotify/core/dist/PNotify.js';
import * as PNotifyMobile from 'node_modules/@pnotify/mobile/dist/PNotifyMobile.js';
defaultModules.set(PNotifyMobile, {});
alert({
text: 'Notice me, senpai!'
});
</script>
The default theme, Bright Theme. Supports dark mode. Include the CSS file in your page:
<link href="node_modules/@pnotify/core/dist/BrightTheme.css" rel="stylesheet" type="text/css" />
Or if you're using a packager that imports CSS:
import '@pnotify/core/dist/BrightTheme.css';
The Material theme. Supports dark mode. Requires material-design-icons and optionally the Roboto font. Include the CSS file in your page:
<link href="node_modules/@pnotify/core/dist/Material.css" rel="stylesheet" type="text/css" />
Or if you're using a packager that imports CSS:
import '@pnotify/core/dist/Material.css';
Then set the default styling and icons to 'material':
import { defaults } from '@pnotify/core';
// or
const { defaults } = require('@pnotify/core');
// Set default styling.
defaults.styling = 'material';
// This icon setting requires the Material Icons font. (See below.)
defaults.icons = 'material';
To use the Material Style icons, include the Material Design Icons Font in your page.
# The official Google package:
npm install --save material-design-icons
# OR, An unofficial package that only includes the font:
npm install --save material-design-icon-fonts
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css" />
Or if you're using a packager that imports CSS:
import 'material-design-icons/iconfont/material-icons.css';
Alternatively, you can use the Google Fonts CDN:
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
Or a clone from jsDelivr:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/material-icons-font@2.0.0/material-icons-font.css" />
The Material style uses the "400" and "500" weights of Roboto. It will fall back to "sans-serif".
You can use the Google Font CDN:
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" />
The Angeler theme. Supports dark mode. Include the CSS file in your page:
<link href="node_modules/@pnotify/core/dist/Angeler.css" rel="stylesheet" type="text/css" />
Or if you're using a packager that imports CSS:
import '@pnotify/core/dist/Angeler.css';
It's recommended that you set the close button to not hide by default, as that is how Angela designed the theme to look best.
import { defaults } from '@pnotify/core';
// or
const { defaults } = require('@pnotify/core');
defaults.closerHover = false;
You can use the angeler-extended
class to use the alternate, more spacious styling for the Angeler theme. This works great for big, center of the page notices, like page errors.
alert({
text: "I'll be more expanded than normal, with a separated title line.",
addClass: 'angeler-extended'
});
:info: It's named after Angela Murrell, who designed it, and it's pronounced like An-jel-er.
npm install --save-dev @pnotify/bootstrap3 @pnotify/glyphicon
# or
npm install --save-dev @pnotify/bootstrap4
Styling for the popular Bootstrap library. Doesn't support dark mode (but you can use a Bootstrap theme).
Include the CSS:
<link rel="stylesheet" href="node_modules/@pnotify/bootstrap4/dist/PNotifyBootstrap4.css" />
Or if you're using a packager that imports CSS:
import '@pnotify/bootstrap4/dist/PNotifyBootstrap4.css';
Include the appropriate line(s) from below:
import { defaultModules } from '@pnotify/core';
import * as PNotifyBootstrap4 from '@pnotify/bootstrap4';
// or
const { defaultModules } = require('@pnotify/core');
const PNotifyBootstrap4 = require('@pnotify/bootstrap4');
Then set it as a default module:
defaultModules.set(PNotifyBootstrap4, {});
Change the "4" to "3" for Bootstrap 3, and also import and set PNotifyGlyphicon
to use Bootstrap 3's glyphicons. PNotifyGlyphicon
doesn't have any CSS to import.
npm install --save-dev @pnotify/font-awesome4
To set Font Awesome 4 as the default icons, include the appropriate line from below:
import { defaultModules } from '@pnotify/core';
import * as PNotifyFontAwesome4 from '@pnotify/font-awesome4';
// or
const { defaultModules } = require('@pnotify/core');
const PNotifyFontAwesome4 = require('@pnotify/font-awesome4');
Then set it as a default module:
defaultModules.set(PNotifyFontAwesome4, {});
npm install --save-dev @pnotify/font-awesome5 @pnotify/font-awesome5-fix
To set Font Awesome 5 as the default icons, include the appropriate line from below:
import { defaultModules } from '@pnotify/core';
import * as PNotifyFontAwesome5Fix from '@pnotify/font-awesome5-fix';
import * as PNotifyFontAwesome5 from '@pnotify/font-awesome5';
// or
const { defaultModules } = require('@pnotify/core');
const PNotifyFontAwesome5Fix = require('@pnotify/font-awesome5-fix');
const PNotifyFontAwesome5 = require('@pnotify/font-awesome5');
Then set them as default modules:
defaultModules.set(PNotifyFontAwesome5Fix, {});
defaultModules.set(PNotifyFontAwesome5, {});
If you don't want to use Font Awesome 5 as your default icons, but you still want support for them in your notices, you should include only the @pnotify/font-awesome5-fix
package. Font Awesome 5 does some mysterious magic in its code that breaks PNotify. This module has a workaround for it.
To make a notice, use the factory functions. Each one takes an options object as its only argument. It will return a PNotify notice instance.
import { alert, notice, info, success, error } from '@pnotify/core';
// or
const { alert, notice, info, success, error } = require('@pnotify/core');
// Manually set the type.
const myAlert = alert({
text: "I'm an alert.",
type: 'info'
});
// Automatically set the type.
const myNotice = notice({
text: "I'm a notice."
});
const myInfo = info({
text: "I'm an info message."
});
const mySuccess = success({
text: "I'm a success message."
});
const myError = error({
text: "I'm an error message."
});
PNotify options and default values.
defaults = {
type: 'notice'
title: false
false
for no title.titleTrusted: false
text: false
false
for no text.textTrusted: false
styling: 'brighttheme'
icons: 'brighttheme'
mode: 'no-preference'
addClass: ''
addModalClass: ''
addModelessClass: ''
autoOpen: true
width: '360px'
minHeight: '16px'
maxTextHeight: '200px'
Maximum height of the text container. If the text goes beyond this height, scrollbars will appear. Use null to remove this restriction.icon: true
animation: 'fade'
animateSpeed: 'normal'
shadow: true
hide: true
delay: 8000
Infinity
, the notice will not close, but it will not be considered sticky, so it will be closed along with all unstuck notices if the modal backdrop is clicked.mouseReset: true
closer: true
closerHover: true
sticker: true
stickerHover: true
labels: {close: 'Close', stick: 'Pin', unstick: 'Unpin'}
remove: true
destroy: true
stack: defaultStack
modules: defaultModules
module => options
entries.}
defaultStack = new Stack({
dir1: 'down',
dir2: 'left',
firstpos1: 25,
firstpos2: 25,
spacing1: 36,
spacing2: 36,
push: 'bottom',
context: document.body
})
defaultModules = new Map()
import { defaults } from '@pnotify/core';
// or
const { defaults } = require('@pnotify/core');
defaults.width = '400px';
Adding/removing a module to the defaults:
import { defaultModules } from '@pnotify/core';
import * as PNotifyMobile from '@pnotify/mobile';
// or
const { defaultModules } = require('@pnotify/core');
const PNotifyMobile = require('@pnotify/mobile');
// Add a module to the defaults. Note that the second argument should
// always be `{}`.
defaultModules.set(PNotifyMobile, {});
// Removing a module from the defaults.
defaultModules.delete(PNotifyMobile);
Changing a module's defaults:
import { defaults } from '@pnotify/animate';
// or
const { defaults } = require('@pnotify/animate');
// then
defaults.inClass = 'fadeInDown';
defaults.outClass = 'fadeOutUp';
Besides using the default modules, you can remove or add modules and set their options when you call a notice. The modules Map has modules themselves as keys, and an options object as values.
import { notice, defaultModules } from '@pnotify/core';
import * as PNotifyBootstrap4 from '@pnotify/bootstrap4';
import * as PNotifyFontAwesome4 from '@pnotify/font-awesome4';
import * as PNotifyMobile from '@pnotify/mobile';
import * as PNotifyAnimate from '@pnotify/animate';
defaultModules.set(PNotifyBootstrap4, {});
defaultModules.set(PNotifyFontAwesome4, {});
defaultModules.set(PNotifyMobile, {});
// Remove one of the default modules.
notice({
text: "I don't have the Mobile module.",
modules: new Map([
...[...defaultModules].filter(([mod]) => mod !== PNotifyMobile)
])
});
// Add an additional module and options.
notice({
text: "I use the Animate module in addition to the defaults.",
modules: new Map([
...defaultModules,
[PNotifyAnimate, {
inClass: 'fadeInDown',
outClass: 'fadeOutUp'
}]
])
});
// Don't worry about adding a module that's already in the defaults.
// It's a Map, so only the last instance/options will end up in there.
notice({
text: "I use the Mobile module with options I specify.",
modules: new Map([
...defaultModules,
[PNotifyMobile, {
swipeDismiss: false
}]
])
});
Using modules with TypeScript requires types assertions for module entries, and possibly the downlevelIteration
TypeScript option.
import {notice, defaultModules, Notice, ModuleEntry} from '@pnotify/core';
import * as PNotifyConfirm from '@pnotify/confirm';
notice({
text: "I'm a notice with modules, and my module options are checked by TypeScript.",
modules: new Map([
// This requires `"downlevelIteration": true` in your TypeScript config.
...defaultModules,
[PNotifyConfirm, {
confirm: true,
buttons: [{
text: 'Ok',
primary: true,
click: (notice: Notice) => notice.close()
}]
// ***
// Notice the type assertion here. It tells TypeScript that the options
// are for the Confirm module.
// ***
}] as ModuleEntry<typeof PNotifyConfirm>,
])
});
Notifications that display even when the web page is not visible. Implements the Web Notifications spec.
If the user's browser doesn't support Web Notifications, or they deny permission to show them, they will see regular in-browser notices, unless fallback
is false.
npm install --save-dev @pnotify/desktop
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyDesktop from '@pnotify/desktop';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyDesktop, {
// Desktop Module Options
}]
])
});
PNotifyDesktop.defaults = {
fallback: true
icon: null
tag: null
update
function.title: null
text: null
options: {}
}
Notices on mobile phones and tablets.
npm install --save-dev @pnotify/mobile
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyMobile from '@pnotify/mobile';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyMobile, {
// Mobile Module Options
}]
])
});
PNotifyMobile.defaults = {
swipeDismiss: true
}
Give an indication of how much time is left.
npm install --save-dev @pnotify/countdown
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyCountdown from '@pnotify/countdown';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyCountdown, {
// Countdown Module Options
}]
])
});
PNotifyCountdown.defaults = {
anchor: 'bottom'
reverse: false
}
Fluid CSS animations using Animate.css.
npm install --save-dev @pnotify/animate
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyAnimate from '@pnotify/animate';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyAnimate, {
// Animate Module Options
}]
])
});
PNotifyAnimate.defaults = {
inClass: null
outClass: null
}
The Animate module also creates a method, attention(aniClass, callback)
, on notices which accepts an attention grabber class and an animation completed callback.
Confirmation dialogs and prompts.
npm install --save-dev @pnotify/confirm
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyConfirm from '@pnotify/confirm';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyConfirm, {
// Confirm Module Options
}]
])
});
PNotifyConfirm.defaults = {
confirm: false
focus: null
prompt: false
promptClass: ''
promptValue: ''
promptMultiLine: false
align: 'flex-end'
buttons: [
{
text: 'Ok',
primary: true,
promptTrigger: true,
click: (notice, value) => {
notice.close();
notice.fire('pnotify:confirm', {notice, value});
}
},
{
text: 'Cancel',
click: (notice) => {
notice.close();
notice.fire('pnotify:cancel', {notice});
}
}
]
}
Because the default buttons fire notice events on confirmation and cancellation, you can listen for them like this:
import { alert } from '@pnotify/core';
const notice = alert({
title: 'Confirmation Needed',
text: 'Are you sure?',
hide: false,
modules: {
Confirm: {
confirm: true
}
}
});
notice.on('pnotify:confirm', () => {
// User confirmed, continue here...
});
notice.on('pnotify:cancel', () => {
// User canceled, continue here...
});
Provide an index and count of the notices in the stack, and/or buttons to let the user page through them.
npm install --save-dev @pnotify/paginate
import {notice, defaultModules} from '@pnotify/core';
import * as PNotifyPaginate from '@pnotify/paginate';
const myNotice = notice({
text: "I'm a notice.",
modules: new Map([
...defaultModules,
[PNotifyPaginate, {
// Paginate Module Options
}]
])
});
PNotifyPaginate.defaults = {
buttons: true
count: true
immediateTransition: true
waiting: true
labels: {previous: 'Previous', next: 'Next', of: 'of'}
}
alert(options)
notice(options)
info(options)
success(options)
error(options)
defaults
defaultStack
styles
icons
notice.open(immediate)
notice.close(immediate, timerHide, waitAfterward)
notice.update(options)
notice.on(eventName, callback)
event
argument with a detail
prop. Returns a function that removes the handler when invoked.notice.fire(eventName, detail)
notice.getState()
notice.addModuleClass(element, ...classNames)
notice.removeModuleClass(element, ...classNames)
notice.hasModuleClass(element, ...classNames)
notice.refs.elem
notice.refs.container
notice.refs.content
notice.refs.titleContainer
notice.refs.textContainer
notice.refs.iconContainer
Event objects have a detail
property that contains information about the event, including a reference to the notice itself.
pnotify:init
- Fired upon initialization of a new notice. This event bubbles.pnotify:mount
- Fired when the notice has been mounted into the DOM. This event bubbles.pnotify:update
- Fired when the notice's state changes. Careful, this includes internal state and can be very noisy (don't do anything computationally expensive on this one).pnotify:beforeOpen
- Fired before the notice opens. Use preventDefault()
on the event to cancel this action.pnotify:afterOpen
- Fired after the notice opens.pnotify:enterModal
- Fired when the notice enters a modal state. (Opens in a modal stack, or a modalish stack that is in modal state.)pnotify:leaveModal
- Fired when the notice leaves a modal state.pnotify:beforeClose
- Fired before the notice closes. Use preventDefault()
on the event to cancel this action.pnotify:afterClose
- Fired after the notice closes.pnotify:beforeDestroy
- Fired before the notice is destroyed. Use preventDefault()
on the event to cancel this action.pnotify:afterDestroy
- Fired after the notice is destroyed.From the Svelte Component API.
Don't use these. I'm putting them in here to document that you should not use them. That way, if you do, and you file a bug report, I can point to this section in the README, and tell you that you did a bad.
notice.$set(options)
update(options)
instead. The Svelte API may change.notice.$on(event, callback)
on(event, callback)
instead. The Svelte API may change.notice.$destroy()
close()
with destroy: true
instead. It will animate the notice out and remove it from the stack.notices
array. Removes the component from the DOM and any observers/event listeners.A stack is an instance of the Stack
class used to determine where to position notices and how they interact with each other.
import {alert, Stack} from '@pnotify/core';
const myStack = new Stack({
dir1: 'up'
});
alert({
text: 'I\'m a notice centered at the bottom!',
stack: myStack
});
Stack options and their defaults:
dir1: null
'up'
, 'down'
, 'right'
, or 'left'
.firstpos1: null
dir1
, the first notice will appear. If null, the current position of the notice, whatever that is, will be used.spacing1: 25
dir1
.dir2: null
dir1
. The notices will continue in this direction when they reach the edge of the viewport along dir1
.firstpos2: null
dir2
, the first notice will appear. If null, the current position of the notice, whatever that is, will be used.spacing2: 25
dir2
.push: 'bottom'
'top'
or 'bottom'
.maxOpen: 1
maxStrategy: 'wait'
maxOpen
. Can be 'wait'
, which will cause new notices to wait their turn, or 'close'
, which will remove the oldest notice to make room for a new one.maxClosureCausesWait: true
maxOpen
when maxStrategy === 'close'
should wait and reopen in turn.modal: 'ish'
true
), modeless (false
), or modalish ('ish'
). Modalish stacks are cool. See https://sciactive.com/2020/02/11/the-modalish-notification-flow/.modalishFlash: true
overlayClose: true
overlayClosesPinned: false
hide === false
).positioned: true
context: document.body
Stack behavior:
dir1
property, the notice will be centered in the context.dir1
and no dir2
, the notices will be centered along the axis of dir1
.firstpos*
values are relative to an edge determined by the corresponding dir*
value.
dirX === 'up'
means firstposX
is relative to the bottom edge.dirX === 'down'
means firstposX
is relative to the top edge.dirX === 'left'
means firstposX
is relative to the right edge.dirX === 'right'
means firstposX
is relative to the left edge.stack: new Stack({...})
in your options if you intend to have only one notice open like that.Stack methods:
forEach(callback, { start = 'oldest', dir = 'newer', skipModuleHandled = false } = {})
start
can be 'head', 'tail', 'oldest', or 'newest'. dir
can be 'next', 'prev', 'older', or 'newer'.position()
queuePosition(milliseconds = 10)
close(immediate)
open(immediate)
openLast()
swap(one, theOther, immediate = false, waitAfter = false)
one
is open, close it and open theOther
instead. Returns a promise that is rejected on failure or resolved on completion.on(event, callback)
There are other methods on the stack class, but you shouldn't use them. They're meant to be internal, so they begin with an underscore.
Stack properties:
stack.notices
- An "array" of notices. It's actually built on the fly from the double linked list the notices are really stored in.stack.length
- How many notices there are in the stack.stack.leader
- When a stack is modalish, this is the notice that is open in the non-modal state.All of the options are properties as well.
Stack events and event.detail
contents:
'beforePosition', { stack }
'afterPosition', { stack }
'beforeAddNotice', { stack, notice }
'afterAddNotice', { stack, notice }
'beforeOpenNotice', { stack, notice }
'afterOpenNotice', { stack, notice }
'beforeCloseNotice', { stack, notice }
'afterCloseNotice', { stack, notice }
'beforeRemoveNotice', { stack, notice }
'afterRemoveNotice', { stack, notice }
'beforeSetLeader', { stack, leader }
'afterSetLeader', { stack, leader }
'beforeAddOverlay', { stack }
'afterAddOverlay', { stack }
'beforeRemoveOverlay', { stack }
'afterRemoveOverlay', { stack }
'overlayClose', { stack, clickEvent }
clickEvent.preventDefault()
to cancel the close action.:warning: Calling something like
alert({text: 'notice', stack: new Stack({dir1: 'down', firstpos1: 25})});
may not do what you want. It will create a notice, but that notice will be in its own stack and will overlap other notices.
Here is an example stack with comments to explain. You can play with it here.
const stackBottomModal = new Stack({
dir1: 'up', // With a dir1 of 'up', the stacks will start appearing at the bottom.
// Without a `dir2`, this stack will be horizontally centered, since the `dir1` axis is vertical.
firstpos1: 25, // The notices will appear 25 pixels from the bottom of the context.
// Without a `spacing1`, this stack's notices will be placed 25 pixels apart.
push: 'top', // Each new notice will appear at the bottom of the screen, which is where the 'top' of the stack is. Other notices will be pushed up.
modal: true, // When a notice appears in this stack, a modal overlay will be created.
overlayClose: true, // When the user clicks on the overlay, all notices in this stack will be closed.
context: document.getElementById('page-container') // The notices will be placed in the 'page-container' element.
});
If you just want to position a single notice programmatically, and don't want to add any other notices into the stack, you can use something like this:
alert({
text: "Notice that's positioned in its own stack.",
stack: new Stack({
dir1: 'down', dir2: 'right', // Position from the top left corner.
firstpos1: 90, firstpos2: 90 // 90px from the top, 90px from the left.
})
});
PNotify provides prebuilt JS files, and those files are run through Babel to provide compatibility with older browsers. As such, their build size grows to maintain compatibility. If this is not acceptable, you can build much smaller (~80% of original) files yourself with:
git clone https://github.com/sciactive/pnotify.git
cd pnotify
npm i
mv .browserslistrc-smallbuild .browserslistrc
npx lerna bootstrap
npm build
You should now have dist
folders in all the packages with smaller (but only compatible with newer browsers) build files. Note that this doesn't apply to Svelte projects, because they build the PNotify *.svelte source files anyway.
Copyright 2009-2020 Hunter Perrin Copyright 2015 Google, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
See http://sciactive.com/pnotify/ for more information, and demos.
5.2.0 (2020-11-06)
FAQs
Beautiful notifications and prompts.
The npm package pnotify receives a total of 4,470 weekly downloads. As such, pnotify popularity was classified as popular.
We found that pnotify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.