
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
A small js library for alerts
####View a demo here
Alert-js is an easy way to integrate userfriendly, smoothly animated, in material design held alerts. Use them to display important information that needs to be seen NOW and let the user take actions. The action buttons have ripple effects, which are also styleable. You can show alerts with one function call and detect the clicked action just as easily. Users can also dismiss an alert by pressing esc
and click the right-most action with enter
. If you try to show an alert while one is already open, it gets stored in a queue and shown after the current one gets closed.
With npm:
1. At the root of your index, type npm install ripple-js
into the command line.
2. Add the tag <script src="node_modules/alert-js/alert.min.js"></script>
to your index file. If you want to show alerts on finished load, also add the script tag <script src="node_modules/ripple-js/ripple.min.js"></script>
BEFORE!
string
°Corresponds to the css color
and ripple-color
property. Click here for more information
°Example: alert.accentColor = "green";
°Default value: "orange"
Float
°Corresponds to the ripple-opacity
property. Click here for more information
°Example: alert.rippleOpacity = 0.3;
°Default value: 0.6
Float
°Corresponds to the ripple-press-expand-time
property. Click here for more information
°Example: alert.ripplePressExpandTime = 3.3;
°Default value: 1.5
Float
°Corresponds to the ripple-release-expand-time
property. Click here for more information
°Example: alert.rippleReleaseExpandTime = 0.5;
°Default value: 0.3
Float
°Corresponds to the ripple-leave-collapse-time
property. Click here for more information
°Example: alert.rippleLeaveCollapseTime = 0.1;
°Default value: 0.4
Boolean
read-only
°Example: var isAlertOpen = alert.open;
###Methods
°Parameters:
Ā Ā text: String
Ā Ā Ā Ā The text the alert should display. You can use html elements and style attributes just like in the document.
Ā Ā actions: Array of Strings
optional
Ā Ā Ā Ā For every entry a corresponding button will be displayed in the alert. If ommited or empty, only an "OK" button will be displayed
Ā Ā options: Object
optional
Ā Ā Ā Ā If you don't want to apply the global options to this alert, you can change the settings for only this alert with all properties (except open) described here. Possible example: {accentColor: "blue", rippleOpacity: 0.7}
Ā Ā mode String
optional
Ā Ā Ā Ā Change how the queue should behave with one of the three following options:
Ā Ā Ā Ā Ā Ā Ā "replace" This clears the queue, closes the old alert and instantly shows the new one
Ā Ā Ā Ā Ā Ā Ā "next-in-queue" Instead of putting the alert at the end of the queue, this places the alert as the next one in the waiting queue
Ā Ā Ā Ā Ā Ā Ā "next" Use this to show the new alert instantly instead of the current one, but preserve the queue
°Return value:
Ā Ā The function returns a Promise, which resolves to the action the user clicked. See the examples for working code
°Examples:
Ā Ā -alert.show("Hello world");
The most simple form of an alert.
Ā Ā -alert.show("We couldn't find your position for one of the following reasons:<ul><li>Your device doesn't support gps</li><li>You didn't grant us access to your position</li><li>The device can't find it's position</li></ul>");
You can use html tags just as you would expect.
Ā Ā -alert.show("Do you want to switch to our mobile website?", ["No", "Yes"]);
While you should build responsive websites, this approach is also possible.
Ā Ā -alert.show("If you prefer green more...", [], {accentColor: "green"});
How to change the settings for only this alert. Note how actions
is empty, so only "OK" will be displayed.
Ā Ā -alert.show("This information is so important that it needs to be displayed instantly, instead of all other alerts!", [], {}, "replace");
This will clear the queue and display the alert instantly.
Ā Ā -alert.show("Dou you want to delete this photo? There is no going back!", ["Cancel", "OK"]).then(function(action) { if(action == "OK") { //delete the photo }});
Detect what action the user clicks with this pattern.
°Example: alert.hide();
°Example: alert.clearQueue();
alert.clearQueue();
before calling alert.hide();
.ripple-js
before importing alert-js
. If those uses don't fit your use case, you don't need to import ripple-js
, as it will be imported automatically.rippleOpacity
to 0
.FAQs
A small js library for alerts
The npm package alert-js receives a total of 2 weekly downloads. As such, alert-js popularity was classified as not popular.
We found that alert-js 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.