reapop

WebJar for reapop

Лицензия

Лицензия

Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

reapop
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

reapop
WebJar for reapop
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/LouisBarranqueiro/reapop

Скачать reapop

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/reapop/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>reapop</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/reapop/
implementation 'org.webjars.npm:reapop:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/reapop/
implementation ("org.webjars.npm:reapop:1.0.0")
'org.webjars.npm:reapop:jar:1.0.0'
<dependency org="org.webjars.npm" name="reapop" rev="1.0.0">
  <artifact name="reapop" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='reapop', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "reapop" % "1.0.0"
[org.webjars.npm/reapop "1.0.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : react-addons-css-transition-group jar [15.4.1,16)

Модули Проекта

Данный проект не имеет модулей.

Reapop

npm version npm download/month coveralls status

A simple and customizable React notifications system

Summary

Compatibility

Supported browsers

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
IE10, IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

Demo

Check out the demo.

Installation

npm install reapop --save

Integration & usage

With React and Redux

1 - Add the notifications reducer to your Redux store.

import {combineReducers, createStore} from 'redux'
import {reducer as notificationsReducer} from 'reapop'

const rootReducer = combineReducers({
    notifications: notificationsReducer(),
    ... your other reducers
})
const store = createStore(rootReducer)

2 - Add the NotificationsSystem component to your app. Place this component at the root of your application to avoid position conflicts.

import React from 'react'
import NotificationsSystem, {atalhoTheme, dismissNotification} from 'reapop'

const ATopLevelComponent = () => {
    // 1. Retrieve the notifications to display.
    const {notifications} = useSelector((state) => state.notification)
    return (
        <div>
            <NotificationsSystem
                // 2. Pass the notifications you want Reapop to display.
                notifications={notifications}
                // 3. Pass the function used to dismiss a notification.
                dismissNotification={(id) => dismissNotification(id)}
                // 4. Pass a builtIn theme or a custom theme.
                theme={atalhoTheme}
            />
        </div>
    )
}

3 - Upsert or dismiss notification from any React components.

import React from 'react'
// 1. Retrieve the action to create/update a notification, or any other actions.
import {notify} from 'reapop'

const AComponent = () => {
    // 2. Retrieve the function to dispatch an action.
    const dispatch = useDispatch() 
    useEffect(() => {
        // 3. Create a notification.
        dispatch(notify('Welcome to the documentation', 'info'))
    }, [])

    return (
        ...
    )
}

4 - Upsert or dismiss notification from Redux actions.

// 1. Retrieve the action to create/update a notification.
import {notify} from 'reapop'

const sendResetPasswordLink = () => (dispatch) => {
    axios.post('https://api.example.com/users/ask-reset-password')
        // 2. Create a notification.
        .then((resp) => dispatch(notify(resp.data.detail, 'success'))
        .catch((resp) => dispatch(notify(resp.data.detail, 'error'))
    }
}

With React alone (react >= 16.8.0)

1 - Add the NotificationsProvider at the root of your application. It is important that this component wraps all the components where you want to access the notifications and the actions to manipule notifications.

import React from 'react'
import {NotificationsProvider} from 'reapop'

const ARootComponent = () => {
    return (
        <NotificationsProvider>
            // ... components
        </NotificationsProvider>
    )
}

2 - Add the NotificationsSystem component to your app. Place this component at the root of your application to avoid position conflicts.

import React from 'react'
import NotificationsSystem, {atalhoTheme, useNotifications} from 'reapop'

const ATopLevelComponent = () => {
    // 1. Retrieve the notifications to display, and the function used to dismiss a notification.
    const {notifications, dismissNotification} = useNotifications()
    return (
        <div>
            <NotificationsSystem
                // 2. Pass the notifications you want Reapop to display.
                notifications={notifications}
                // 3. Pass the function used to dismiss a notification.
                dismissNotification={(id) => dismissNotification(id)}
                // 4. Pass a builtIn theme or a custom theme.
                theme={atalhoTheme}
            />
        </div>
    )
}

3 - Upsert or dismiss notification from any React components.

import React from 'react'
import {useNotifications} from 'reapop'

const AComponent = () => {
    // 1. Retrieve the action to create/update a notification.
    const {notify} = useNotifications()
    
    useEffect(() => {
        // 2. Create a notification.
        notify('Welcome to the documentation', 'info')
    }, [])

    return (
        ...
    )
}

Documentation

Read the documentation to learn more and see what you can with it.

License

Reapop is under MIT License

Версии библиотеки

Версия
1.0.0
0.6.1