Separate row coin logic into a 'AsideRowCoin' component

pull/3/head
Vasek Mlejnsky 6 years ago
parent d3c601c41f
commit d511a9d2f4

@ -1,30 +1,39 @@
import styled from 'styled-components'; import styled, { css } from 'styled-components';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import colors from 'config/colors'; import colors from 'config/colors';
import { FONT_SIZE, TRANSITION_TIME } from 'config/variables'; import { TRANSITION_TIME } from 'config/variables';
const Wrapper = styled.div` const Wrapper = styled.div`
padding: 16px 24px;
display: flex; display: flex;
flex-direction: row;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
${props => props.column && css`
padding: 16px 24px; flex-direction: column;
align-items: flex-start;
`}
cursor: pointer; cursor: pointer;
font-size: ${FONT_SIZE.BASE};
transition: background-color ${TRANSITION_TIME.BASE}, color ${TRANSITION_TIME.BASE}; transition: background-color ${TRANSITION_TIME.BASE}, color ${TRANSITION_TIME.BASE};
&:hover {
background-color: ${colors.GRAY_LIGHT};
}
`; `;
const AsideRow = (props) => ( const AsideRow = ({ children, column }) => (
<Wrapper> <Wrapper
{props.children} column={column}
>{children}
</Wrapper> </Wrapper>
); );
AsideRow.propTypes = {
column: PropTypes.bool,
};
AsideRow.defaultProps = {
column: false,
}
export default AsideRow; export default AsideRow;

@ -0,0 +1,24 @@
import styled from 'styled-components';
import React from 'react';
import colors from 'config/colors';
import { FONT_SIZE } from 'config/variables';
const Wrapper = styled.div`
display: block;
height: 50px;
font-size: ${FONT_SIZE.BASE};
color: ${colors.TEXT_PRIMARY};
&:hover {
background-color: ${colors.GRAY_LIGHT};
}
`;
const AsideRowCoin = ({ children }) => (
<Wrapper>
{children}
</Wrapper>
);
export default AsideRowCoin;

@ -4,29 +4,28 @@ import PropTypes from 'prop-types';
import Icon from 'components/common/Icon'; import Icon from 'components/common/Icon';
import AsideRow from './AsideRow'; import AsideRow from './AsideRow';
import AsideRowCoin from './AsideRowCoin';
import CoinName from './CoinName'; import CoinName from './CoinName';
import ICONS from 'constants/icons'; import ICONS from 'constants/icons';
import colors from 'config/colors'; import colors from 'config/colors';
import { coinProp } from './common'; import { coinProp } from './common';
const A = styled.a`
display: block;
`;
const AsideRowCoinExternal = ({ coin, url }) => ( const AsideRowCoinExternal = ({ coin, url }) => (
<A href={url}> <a href={url}>
<AsideRow> <AsideRowCoin>
<CoinName <AsideRow>
coinImg={coin.img} <CoinName
text={coin.name} coinImg={coin.img}
/> text={coin.name}
<Icon />
icon={ICONS.REDIRECT} <Icon
color={colors.TEXT_SECONDARY} icon={ICONS.REDIRECT}
/> color={colors.TEXT_SECONDARY}
</AsideRow> />
</A> </AsideRow>
</AsideRowCoin>
</a>
); );
AsideRowCoinExternal.propTypes = { AsideRowCoinExternal.propTypes = {

@ -4,23 +4,23 @@ import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import AsideRow from './AsideRow'; import AsideRow from './AsideRow';
import AsideRowCoin from './AsideRowCoin';
import CoinName from './CoinName'; import CoinName from './CoinName';
import colors from 'config/colors';
import { coinProp } from './common'; import { coinProp } from './common';
const Wrapper = styled(NavLink)`
display: block;
`;
const AsideRowCoinWallet = ({ coin, url }) => ( const AsideRowCoinWallet = ({ coin, url }) => (
<Wrapper to={url}> <NavLink to={url}>
<AsideRow> <AsideRowCoin>
<CoinName <AsideRow>
coinImg={coin.img} <CoinName
text={coin.name} coinImg={coin.img}
/> text={coin.name}
</AsideRow> />
</Wrapper> </AsideRow>
</AsideRowCoin>
</NavLink>
); );
AsideRowCoinWallet.propTypes = { AsideRowCoinWallet.propTypes = {

@ -9,10 +9,6 @@ const Wrapper = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
p {
color: ${colors.TEXT_PRIMARY};
}
`; `;
const Logo = styled.div` const Logo = styled.div`

Loading…
Cancel
Save