Commit 408996e8 authored by Imran Salam's avatar Imran Salam
Browse files

refactor global helper files

parent 47b023ca
import { createAction } from 'typesafe-actions';
import { WidthType } from './globalState';
import { BreakpointWidth } from './globalConfig';
export const updateGlobalWidth = createAction(
'browser/update-global-width',
export const updateBreakpointWidth = createAction(
'browser/update-breakpoint-width',
(resolve) => {
return (globalWidth: WidthType) => resolve(globalWidth);
return (breakpointWidth: BreakpointWidth) => resolve(breakpointWidth);
}
);
export const assetsUrl = '/static';
export const imgBaseUrl = `${assetsUrl}/img`;
export enum BreakpointWidth {
SMALL = 0,
MEDIUM = 900,
LARGE = 1400
}
......@@ -8,8 +8,8 @@ export default function globalReducer(
action: ActionType<typeof global>
) {
switch (action.type) {
case getType(global.updateGlobalWidth):
return { ...state, globalWidth: action.payload };
case getType(global.updateBreakpointWidth):
return { ...state, breakpointWidth: action.payload };
default:
return state;
}
......
import { RootState } from './rootReducer';
import { WidthType } from './globalState';
import { BreakpointWidth } from './globalConfig';
export const getGlobalWidth = (state: RootState): WidthType =>
state.global.globalWidth;
export const getBreakpointWidth = (state: RootState): BreakpointWidth =>
state.global.breakpointWidth;
export enum WidthType {
SMALL = 'small',
MEDIUM = 'medium',
LARGE = 'medium'
}
import { BreakpointWidth } from './globalConfig';
export type GlobalState = Readonly<{
globalWidth: WidthType;
breakpointWidth: BreakpointWidth;
}>;
export const defaultState: GlobalState = {
globalWidth: WidthType.LARGE
breakpointWidth: BreakpointWidth.LARGE
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment