Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(selectors): fix getAuthState, add getLayoutMobileStatuses selector
Browse files Browse the repository at this point in the history
feat(selectors): fix getAuthState, add getLayoutMobileStatuses selector
  • Loading branch information
Metnew committed Dec 5, 2017
1 parent c836e7c commit 757c302
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/common/selectors/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
// @flow
import {createSelector} from 'reselect'
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'

export const getAuthState = (state: GlobalState): AuthState => state.me.auth
export const getAuthState = (state: GlobalState): AuthState => state.auth
export const getLayoutState = (state: GlobalState): LayoutState => state.layout
export const getEntitiesLinksState = (state: GlobalState): EntitiesLinksState => state.entities.links
export const getEntitiesLinksState = (state: GlobalState): EntitiesLinksState =>
state.entities.links

const defaultWindowInnerWidth = 1025
export const getWindowInnerWidth = (window: Object): number => {
const defaultWindowInnerWidth = 1025
return window && window.innerWidth
? window.innerWidth
: defaultWindowInnerWidth
}

export const getLayoutMobileStatuses = createSelector(
getLayoutState,
({innerWidth}) => {
const isMobile: boolean = innerWidth < 1025 // 1024px - breakpoint
const isMobileXS: boolean = innerWidth < 481
const isMobileSM: boolean = innerWidth > 480 && innerWidth < 767
return {isMobileSM, isMobileXS, isMobile}
}
)

0 comments on commit 757c302

Please sign in to comment.