forked from shivamkantival/test-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f29d283
commit 3b59b75
Showing
22 changed files
with
599 additions
and
78 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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"bracketSpacing": true, | ||
"arrowParens": "avoid", | ||
"printWidth": 100 | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, {memo} from 'react'; | ||
|
||
//components | ||
import StyledHeader from "./styles" | ||
|
||
interface HeaderProps {} | ||
|
||
const Header: React.FC<HeaderProps> = () => { | ||
return <StyledHeader><h4>Users</h4></StyledHeader> | ||
}; | ||
|
||
export default memo(Header); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from 'styled-components'; | ||
import { COLORS } from 'styles/theme'; | ||
import { flexContainer } from 'styles/mixins'; | ||
|
||
export default styled.header` | ||
position: sticky; | ||
top: 0; | ||
background: ${COLORS.GAINS_BORO}; | ||
height: 50px; | ||
${flexContainer({ alignItems: 'center', justifyContent: 'center' })} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, {memo} from "react"; | ||
|
||
//typeDefs | ||
import {LoaderProps} from "./interfaces"; | ||
|
||
//components | ||
import StyledLoader from "./styles" | ||
|
||
const Loader:React.FC<LoaderProps> = (props) => { | ||
return <StyledLoader dimension={props.dimension}> | ||
<div className="fixedCenter" /> | ||
<div className="outerExpandingConcentric" /> | ||
<div className="innerExpandingConcentric" /> | ||
</StyledLoader> | ||
} | ||
|
||
|
||
Loader.defaultProps = { | ||
dimension: 100 | ||
} | ||
|
||
export default memo(Loader); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface LoaderProps { | ||
dimension?: number; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//styles | ||
import { circular, centerToParent } from 'styles/mixins'; | ||
import { COLORS } from 'styles/theme'; | ||
|
||
import styled from 'styled-components'; | ||
import { LoaderProps } from './interfaces'; | ||
|
||
const ANIMATION_NAME = 'slowExpand', | ||
ANIMATION_PARAMS = ` | ||
animation-name: ${ANIMATION_NAME}; | ||
animation-duration: 2s; | ||
animation-timing-function: linear; | ||
animation-iteration-count: infinite; | ||
animation-fill-mode: backwards; | ||
`, | ||
INITIAL_DIMENSIONS_FOR_EXPANDING_CONCENTRICS = ` | ||
width: 0; | ||
height: 0; | ||
`, | ||
LOADER_COLOR: string = COLORS.PARROT_GREEN; | ||
|
||
export default styled.div` | ||
width: ${(props: LoaderProps) => `${props.dimension}px`}; | ||
height: ${(props: LoaderProps) => `${props.dimension}px`}; | ||
position: relative; | ||
@keyframes ${ANIMATION_NAME} { | ||
from { | ||
width: 30%; | ||
height: 30%; | ||
opacity: 0.3; | ||
} | ||
to { | ||
width: 100%; | ||
height: 100%; | ||
opacity: 0; | ||
} | ||
} | ||
.fixedCenter { | ||
width: 20%; | ||
height: 20%; | ||
background: ${LOADER_COLOR}; | ||
${circular()} | ||
${centerToParent()} | ||
} | ||
.outerExpandingConcentric { | ||
background: ${LOADER_COLOR}; | ||
${INITIAL_DIMENSIONS_FOR_EXPANDING_CONCENTRICS} | ||
${ANIMATION_PARAMS} | ||
${circular()} | ||
${centerToParent()} | ||
} | ||
.innerExpandingConcentric { | ||
background: ${LOADER_COLOR}; | ||
animation-delay: 0.7s; | ||
${INITIAL_DIMENSIONS_FOR_EXPANDING_CONCENTRICS} | ||
${ANIMATION_PARAMS} | ||
${circular()} | ||
${centerToParent()} | ||
} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const USER_DATA = 'USER_DATA'; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './actionTypes'; | ||
|
||
export const STATE_KEYS = { | ||
USERS: 'users', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface UserData { | ||
name: string; | ||
profileImage: string; | ||
} | ||
|
||
export interface UserDataState { | ||
data: Array<UserData>; | ||
error: boolean; | ||
hasError: boolean; | ||
hasMore: boolean; | ||
isLoading: boolean; | ||
loaded: boolean; | ||
total: number; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createStore, applyMiddleware } from 'redux'; | ||
|
||
//reducers | ||
import appReducer from 'reducers'; | ||
|
||
export default () => createStore(appReducer); |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//utils | ||
import { combineReducers } from 'redux'; | ||
|
||
//constants | ||
import { STATE_KEYS, USER_DATA } from 'config/constants'; | ||
|
||
//typeDefs | ||
import { UserData as UserDataType, UserDataState as UserDataStateType } from 'config/interfaces'; | ||
|
||
// @ts-ignore | ||
import { createReducer } from 'configurable-redux-example/src/utils/index'; | ||
|
||
const userDataReducer: ( | ||
state: UserDataStateType, | ||
action: object | ||
) => UserDataStateType = createReducer({ | ||
name: USER_DATA, | ||
options: { | ||
async: true, | ||
initialState: { data: [], hasMore: false, total: null }, | ||
}, | ||
}); | ||
|
||
export default combineReducers({ | ||
[STATE_KEYS.USERS]: userDataReducer, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//typeDefs | ||
import { FlexContainerOptions } from './interfaces'; | ||
|
||
export function centerToParent(): string { | ||
return ` | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
`; | ||
} | ||
|
||
export function circular(): string { | ||
return `border-radius: 50%;`; | ||
} | ||
|
||
export function flexContainer({ | ||
flexDirection = 'row', | ||
alignItems = 'flex-start', | ||
justifyContent = 'flex-start', | ||
flexWrap = 'nowrap', | ||
}: FlexContainerOptions) { | ||
return ` | ||
display: flex; | ||
flex-direction: ${flexDirection}; | ||
align-items: ${alignItems}; | ||
justify-content: ${justifyContent}; | ||
flex-wrap: ${flexWrap} | ||
`; | ||
} | ||
|
||
export function centerContent() { | ||
return `${flexContainer({ alignItems: 'center', justifyContent: 'center' })}`; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface FlexContainerOptions { | ||
flexDirection?: 'row' | 'column'; | ||
alignItems?: 'center' | 'flex-start' | 'flex-end'; | ||
justifyContent?: 'flex-start' | 'center' | 'space-around' | 'space-between' | 'flex-end'; | ||
flexWrap?: 'wrap' | 'nowrap'; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const COLORS: { | ||
readonly [index: string]: string; | ||
} = { | ||
PARROT_GREEN: '#ace600', | ||
GAINS_BORO: 'gainsboro', | ||
}; |
Oops, something went wrong.