diff --git a/src/common/selectors/index.js b/src/common/selectors/index.js index 9fd4f322..1899c399 100644 --- a/src/common/selectors/index.js +++ b/src/common/selectors/index.js @@ -1,16 +1,24 @@ // @flow -import type {State as AuthState} from 'reducers/auth' -import type {State as LayoutState} from 'reducers/layout' -import type {State as EntitiesLinksState} from 'reducers/links' -import type {GlobalState} from 'reducers' +import {createSelector} from 'reselect' -export const getAuthState = (state: GlobalState): AuthState => state.me.auth -export const getLayoutState = (state: GlobalState): LayoutState => state.layout -export const getEntitiesLinksState = (state: GlobalState): EntitiesLinksState => state.entities.links +export const isLoaded = state => state.fetchStatus === 'loaded' +export const getLayoutState = state => state.layout +export const getEntitiesLinksState = state => state.entities.links -const defaultWindowInnerWidth = 1025 export const getWindowInnerWidth = (window: Object): number => { + const defaultWindowInnerWidth = 1025 return window && window.innerWidth ? window.innerWidth : defaultWindowInnerWidth } + +export const computeLayoutMobileStatuses = ({innerWidth}) => { + const isMobile: boolean = innerWidth < 993 + const isMobileXS: boolean = innerWidth < 481 + const isMobileSM: boolean = innerWidth > 480 && innerWidth < 767 + return {isMobileSM, isMobileXS, isMobile} +} + +export const getLayoutMobileStatuses = createSelector( + getLayoutState, computeLayoutMobileStatuses +)