Jack Mallers
7 years ago
11 changed files with 204 additions and 8 deletions
@ -0,0 +1,29 @@ |
|||
import React from 'react' |
|||
import PropTypes from 'prop-types' |
|||
import FaAngleLeft from 'react-icons/lib/fa/angle-left' |
|||
import styles from './Fiat.scss' |
|||
|
|||
const Fiat = ({ disableSubMenu }) => { |
|||
return ( |
|||
<div> |
|||
<header className={styles.submenuHeader} onClick={disableSubMenu}> |
|||
<FaAngleLeft /> |
|||
<span>Fiat currency</span> |
|||
</header> |
|||
<ul> |
|||
<li>USD</li> |
|||
<li>JPY</li> |
|||
<li>CNY</li> |
|||
<li>SGD</li> |
|||
<li>HKD</li> |
|||
<li>CAD</li> |
|||
</ul> |
|||
</div> |
|||
) |
|||
} |
|||
|
|||
Fiat.propTypes = { |
|||
disableSubMenu: PropTypes.func.isRequired |
|||
} |
|||
|
|||
export default Fiat |
@ -0,0 +1,9 @@ |
|||
.submenuHeader { |
|||
padding: 15px; |
|||
background: lighten(#1d1f27, 20%); |
|||
font-size: 10px; |
|||
display: flex; |
|||
flex-direction: row; |
|||
justify-content: end; |
|||
align-items: center; |
|||
} |
@ -0,0 +1,21 @@ |
|||
import React from 'react' |
|||
import PropTypes from 'prop-types' |
|||
import FaAngleRight from 'react-icons/lib/fa/angle-right' |
|||
import styles from './Menu.scss' |
|||
|
|||
const Menu = ({ setActiveSubMenu }) => { |
|||
return ( |
|||
<ul> |
|||
<li className={styles.fiat} onClick={() => setActiveSubMenu('fiat')}> |
|||
<span>Fiat Currency</span> |
|||
<FaAngleRight /> |
|||
</li> |
|||
</ul> |
|||
) |
|||
} |
|||
|
|||
Menu.propTypes = { |
|||
setActiveSubMenu: PropTypes.func.isRequired |
|||
} |
|||
|
|||
export default Menu |
@ -0,0 +1,25 @@ |
|||
import React from 'react' |
|||
import PropTypes from 'prop-types' |
|||
import Menu from './Menu' |
|||
import Fiat from './Fiat' |
|||
import styles from './Settings.scss' |
|||
|
|||
const Settings = ({ settings, setActiveSubMenu, fiatProps }) => { |
|||
const renderSettings = () => { |
|||
switch (settings.activeSubMenu) { |
|||
case 'fiat': |
|||
return <Fiat {...fiatProps} /> |
|||
default: |
|||
return <Menu setActiveSubMenu={setActiveSubMenu} /> |
|||
} |
|||
} |
|||
return <div className={styles.container}>{renderSettings()}</div> |
|||
} |
|||
|
|||
Settings.propTypes = { |
|||
settings: PropTypes.object.isRequired, |
|||
setActiveSubMenu: PropTypes.func.isRequired, |
|||
fiatProps: PropTypes.object.isRequired |
|||
} |
|||
|
|||
export default Settings |
@ -0,0 +1,22 @@ |
|||
.container { |
|||
background: #1d1f27; |
|||
position: absolute; |
|||
width: 200px; |
|||
top: 30px; |
|||
left: -100px; |
|||
z-index: 10; |
|||
|
|||
li { |
|||
padding: 20px; |
|||
display: flex; |
|||
flex-direction: row; |
|||
justify-content: space-between; |
|||
font-size: 10px; |
|||
cursor: pointer; |
|||
transition: all 0.25s; |
|||
|
|||
&:hover { |
|||
background: #0f0f0f; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
// ------------------------------------
|
|||
// Constants
|
|||
// ------------------------------------
|
|||
export const SET_SETTINGS_OPEN = 'SET_SETTINGS_OPEN' |
|||
export const SET_ACTIVE_SUBMENU = 'SET_ACTIVE_SUBMENU' |
|||
export const DISABLE_SUBMENU = 'DISABLE_SUBMENU' |
|||
|
|||
// ------------------------------------
|
|||
// Actions
|
|||
// ------------------------------------
|
|||
export function setSettingsOpen(settingsOpen) { |
|||
return { |
|||
type: SET_SETTINGS_OPEN, |
|||
settingsOpen |
|||
} |
|||
} |
|||
|
|||
export function setActiveSubMenu(activeSubMenu) { |
|||
return { |
|||
type: SET_ACTIVE_SUBMENU, |
|||
activeSubMenu |
|||
} |
|||
} |
|||
|
|||
export function disableSubMenu() { |
|||
return { |
|||
type: DISABLE_SUBMENU |
|||
} |
|||
} |
|||
|
|||
// ------------------------------------
|
|||
// Action Handlers
|
|||
// ------------------------------------
|
|||
const ACTION_HANDLERS = { |
|||
[SET_SETTINGS_OPEN]: (state, { settingsOpen }) => ({ ...state, settingsOpen }), |
|||
[SET_ACTIVE_SUBMENU]: (state, { activeSubMenu }) => ({ ...state, activeSubMenu }), |
|||
[DISABLE_SUBMENU]: state => ({ ...state, activeSubMenu: null }) |
|||
} |
|||
|
|||
// ------------------------------------
|
|||
// Reducer
|
|||
// ------------------------------------
|
|||
const initialState = { |
|||
settingsOpen: false, |
|||
activeSubMenu: null |
|||
} |
|||
|
|||
export default function settingsReducer(state = initialState, action) { |
|||
const handler = ACTION_HANDLERS[action.type] |
|||
|
|||
return handler ? handler(state, action) : state |
|||
} |
Loading…
Reference in new issue