alt-notify was designed to be unopinionated for almost any use-case. This means that you can use this library for your flashing notifications like Facebook’s or Twitter’s), or for simple alert messages, or whatever you can think of.
You can dish out the whole thing yourself, but that’s tedious, right?
Here are some examples of the use-cases (Hey, nobody said that these apps use this library, aight?).
Facebook’s Notification Drawer
Dropbox’s Action Notification
alt-notify is undergoing active development, and will be released soon (the same goes for the documentation).
This library was primarily written for use for React and Alt. It will and does not try to cover everyone’s use-cases – the reason why it is and will be kept as simple as possible.
Currently, alt-notify, like alt itself, is written in ES6 and transpiled with Babel.
Right now, this library is a work-in-progress, and will continue to have breaking changes (however follows SemVer) as long as necessary. Until v1.0
, breaking changes will continue to bump v0.x
. For example, v0.4.1
and v0.4.8
will have the same API, but 0.5.0
will have breaking changes.
For now, alt-notify is only available through npm:
npm install alt-notify --save
* Note that the --save
option persists alt-notify to your package.json
.
To check which versions of React and Alt the library supports, please check Supported Dependency Versions.
First, we’ll import the Drawer
component that the library exposes.
import React from 'react';
import { Drawer } from 'alt-notify';
Then, we’ll use it in our top-most component (usually the App
component as we call it).
class App extends React.Component {
render() {
return (
<div>
<Drawer render={(props) => {
return <div>{props.data}</div>
}} />
</div>
)
}
}
To add items in our Drawer
component, we’ll import NotifyActions
.
import React;
import { Drawer, NotifyActions } from 'alt-notify';
And then use it like so:
class App extends React.Component {
render() {
return (
<div>
<Drawer render={(props) => {
return <div>{props.data}</div>
}} />
<button type="button" onClick={this.addNotification}>
Add a notification!
</button>
</div>
)
}
addNotification() {
NotifyActions.add({ data: 'I\'m a message. Hello.' });
}
}
This is how our code should look like now:
import React;
import { Drawer, NotifyActions } from 'alt-notify';
class App extends React.Component {
render() {
return (
<div>
<Drawer render={(data) => {
return <div>{data.text}</div>
}} />
<button type="button" onClick={this.addNotification}>
Add a notification!
</button>
</div>
)
}
addNotification() {
NotifyActions.add({ data: 'I\'m a message. Hello.' });
}
}
Hopefully, now you have an idea on how to use the library.
A plethora of examples has been setup to help you get started. It’s some sort of cookbook or something. You can go ahead check it on our repository.
At the time being, a lot of examples are still in development and will be available soon!
peerDependency
.package.json
not pointing to the recently added build files.Drawer
(this was unclear in v0.2
). Unnecessary properties received from the Drawer
component are no longer exposed (id
, duration
, etc.). Add items through the data
property, e.g., NotifyActions.add({ data: 'Hey', type: 'alert' });
.config
export to be undefined. commit.* Tag was removed due to npm accepts 0.2.0
but not 0.2
(which was the one written in the file).
config
export for testability (I couldn’t stub it without having to do so). Bumped in case somebody imports config
in an unnecessary fashion. config
is now imported as how export default
or module.exports
is imported, import config from 'alt-notify/config'
instead of import * as config from 'alt-notify/config'
. commit.package.json
version commit.The version here will be bumped only if the support dependency version changes. For example, given the scenario that v0.1
; v0.2
; and v0.3
supports React v0.13
and Alt v0.15
, while v0.4
supports a different version of React and Alt, only v0.1
and v0.4
will be noted.
Version | React | Alt |
---|---|---|
v0.1 | v0.13 | 0.15 |