Add next/previous navigation in modal for media attachments
This commit is contained in:
parent
21972bb398
commit
44fad0160f
7 changed files with 132 additions and 21 deletions
|
@ -1,8 +1,14 @@
|
|||
import { MEDIA_OPEN, MODAL_CLOSE } from '../actions/modal';
|
||||
import Immutable from 'immutable';
|
||||
import {
|
||||
MEDIA_OPEN,
|
||||
MODAL_CLOSE,
|
||||
MODAL_INDEX_DECREASE,
|
||||
MODAL_INDEX_INCREASE
|
||||
} from '../actions/modal';
|
||||
import Immutable from 'immutable';
|
||||
|
||||
const initialState = Immutable.Map({
|
||||
url: '',
|
||||
media: null,
|
||||
index: 0,
|
||||
open: false
|
||||
});
|
||||
|
||||
|
@ -10,11 +16,16 @@ export default function modal(state = initialState, action) {
|
|||
switch(action.type) {
|
||||
case MEDIA_OPEN:
|
||||
return state.withMutations(map => {
|
||||
map.set('url', action.url);
|
||||
map.set('media', action.media);
|
||||
map.set('index', action.index);
|
||||
map.set('open', true);
|
||||
});
|
||||
case MODAL_CLOSE:
|
||||
return state.set('open', false);
|
||||
case MODAL_INDEX_DECREASE:
|
||||
return state.update('index', index => Math.max(index - 1, 0));
|
||||
case MODAL_INDEX_INCREASE:
|
||||
return state.update('index', index => Math.min(index + 1, state.get('media').size - 1));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue