All Projects → AKolodeev → redux-promising-modals

AKolodeev / redux-promising-modals

Licence: MIT license
A middleware, reducer and actions for manipulating modal windows using Redux.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to redux-promising-modals

Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (+1013.04%)
Mutual labels:  modals
Jquery Confirm
A multipurpose plugin for alert, confirm & dialog, with extended features.
Stars: ✭ 1,776 (+7621.74%)
Mutual labels:  modals
React Native Modalfy
🥞 Modal citizen of React Native.
Stars: ✭ 212 (+821.74%)
Mutual labels:  modals
Ngx Bootstrap
Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
Stars: ✭ 5,343 (+23130.43%)
Mutual labels:  modals
Vuedals
Vue modals with a single component
Stars: ✭ 102 (+343.48%)
Mutual labels:  modals
Izimodal
Elegant, responsive, flexible and lightweight modal plugin with jQuery.
Stars: ✭ 2,122 (+9126.09%)
Mutual labels:  modals
scalable-react-redux-modals
A scalable React and Redux solution for modals
Stars: ✭ 27 (+17.39%)
Mutual labels:  modals
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (+26.09%)
Mutual labels:  modals
V Dialogs
A simple and clean instructional dialog plugin for Vue2, dialog type including Modal, Alert, Mask and Toast
Stars: ✭ 121 (+426.09%)
Mutual labels:  modals
Heyui
🎉UI Toolkit for Web, Vue2.0 http://www.heyui.top
Stars: ✭ 2,373 (+10217.39%)
Mutual labels:  modals
Django Admin Interface
django's default admin interface made customizable. popup windows replaced by modals. :mage: ⚡️
Stars: ✭ 717 (+3017.39%)
Mutual labels:  modals
Modals
Simple modal dialogue windows
Stars: ✭ 85 (+269.57%)
Mutual labels:  modals
Decktransition
A library to recreate the iOS Apple Music now playing transition
Stars: ✭ 2,207 (+9495.65%)
Mutual labels:  modals
Modal
A powerful and customizable modal implementation for Blazor applications.
Stars: ✭ 406 (+1665.22%)
Mutual labels:  modals
Focus Layers
Tiny React hooks for isolating focus within subsections of the DOM.
Stars: ✭ 238 (+934.78%)
Mutual labels:  modals
react-portal-hoc
A stupid HOC to make a stupid portal so you can make stupid modals
Stars: ✭ 14 (-39.13%)
Mutual labels:  modals
Featherlight
Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB – in total.
Stars: ✭ 2,037 (+8756.52%)
Mutual labels:  modals
ember-modal-service
An ember-cli addon to manage modals as promises
Stars: ✭ 27 (+17.39%)
Mutual labels:  modals
laravel-livewire-modals
Dynamic Laravel Livewire Bootstrap modals.
Stars: ✭ 63 (+173.91%)
Mutual labels:  modals
Accessible modal window
Accessible modal dialogs
Stars: ✭ 196 (+752.17%)
Mutual labels:  modals

Deprecation note

The approach suggested in this repository is outdated. Thus, the repository is not going to be supported.
Please, choose a different solution.

Synopsis

A middleware, reducer and actions for manipulating modal windows.
The library provides only these things. If you want to see modal window, you could use react-modal.
See working example at gh-pages.

Code Example

Adding modals' reducer:

import { combineReducers } from 'redux';
import { modalsReducer } from 'redux-promising-modals';

export default combineReducers({
    /* your's reducers */
    modals: modalsReducer
});

Creating a store:

import { createStore, applyMiddleware } from 'redux';
import { modalsMiddleware } from 'redux-promising-modals';
import yourReducer from 'yourReducerDirectory';

const store = createStore(yourReducer, applyMiddleware(modalsMiddleware));

Show single modal:

import { pushModalWindow } from 'redux-promising-modals';
// ToDo: bind pushModalWindow to dispatch

pushModalWindow('EDIT_FILE_DIALOG', {fileName: 'my_file.txt'})
  .then(result => { /* do something with the result */ });

Show series of modals

import { pushModalWindow } from 'redux-promising-modals';
// ToDo: bind pushModalWindow to dispatch

const promisesArray = pushModalWindow(
    ['EDIT_FILE_DIALOG', 'REMOVE_FILE_DIALOG'],
    [{fileName: 'my_file.txt'}, {fileName: 'old_file.txt', _createdOn: 1480021259507}]
);

Promise.all(promisesArray).then(() => { /* all promises are resolved (each window was closed) */ });

Close current modal and return result

import { popModalWindow } from 'redux-promising-modals';
/* ToDo: bind popModalWindow to dispatch */

popModalWindow({newFileName: 'your_file.txt'});

Motivation

For example:
You need to show a modal window to a user. The user manipulates with the content of the window and then closes it. You want to see the result of these manipulation.

Installation

npm i --save redux-promising-modals

API Reference

Actions' types

PUSH_MODAL_WINDOW,
INSERT_MODAL_WINDOW,
POP_MODAL_WINDOW,
CLEAR_MODAL_WINDOWS

You can import theses types from library and handle them separately.

Middleware

modalsMiddleware

If the type of action passing through it is PUSH_MODAL_WINDOW or INSERT_MODAL_WINDOW you can expect that a Promise will be returned.
If the type is SHIFT_MODAL_WINDOW or POP_MODAL_WINDOW the Promise will be resolved and the result will be granted.
CLEAR_MODAL_WINDOWS resolves all Promises.

Actions

pushModalWindow(modalTypes, modalProps) - adds modal of type modalType (expects a String type but this is not necessary) with modalProps (could be anything) in the end of modals array. modalTypes and modalProps can be either an array or a single element (see Code Example).
insertModalWindow(modalTypes, modalProps) - adds a modal in the beginning of modals array.
popModalWindow(values) - removes the last window from modals array.
shiftModalWindow(values) - remove the first (current) window from modals array.
clearModalWindows() - clears modals array.
nextModalWindow() - replaces current window by the next.
prevModalWindow() - replaces current window by the previous one.

Reducer

modalsReducer - a reducer for modals (keep modals types and props in an array).

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].