This repository has been archived by the owner on Jan 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(selectors): fix getAuthState, add getLayoutMobileStatuses selector
feat(selectors): fix getAuthState, add getLayoutMobileStatuses selector
- Loading branch information
Showing
1 changed file
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
} | ||
) |