You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 976B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // @flow
  2. import { ReducerRegistry, set } from '../redux';
  3. import { CLIENT_RESIZED, SET_ASPECT_RATIO, SET_REDUCED_UI } from './actionTypes';
  4. import { ASPECT_RATIO_NARROW } from './constants';
  5. const {
  6. innerHeight = 0,
  7. innerWidth = 0
  8. } = window;
  9. /**
  10. * The default/initial redux state of the feature base/responsive-ui.
  11. */
  12. const DEFAULT_STATE = {
  13. aspectRatio: ASPECT_RATIO_NARROW,
  14. clientHeight: innerHeight,
  15. clientWidth: innerWidth,
  16. reducedUI: false
  17. };
  18. ReducerRegistry.register('features/base/responsive-ui', (state = DEFAULT_STATE, action) => {
  19. switch (action.type) {
  20. case CLIENT_RESIZED: {
  21. return {
  22. ...state,
  23. clientWidth: action.clientWidth,
  24. clientHeight: action.clientHeight
  25. };
  26. }
  27. case SET_ASPECT_RATIO:
  28. return set(state, 'aspectRatio', action.aspectRatio);
  29. case SET_REDUCED_UI:
  30. return set(state, 'reducedUI', action.reducedUI);
  31. }
  32. return state;
  33. });