2018-12-10 09:07:45 -08:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
|
|
import { TextComponent } from './text';
|
|
|
|
import { RowComponent } from './row';
|
2018-12-10 13:24:25 -08:00
|
|
|
import { DropdownComponent } from './dropdown';
|
2018-12-12 11:04:44 -08:00
|
|
|
import MenuIcon from '../assets/images/menu_icon.svg';
|
2018-12-10 13:24:25 -08:00
|
|
|
|
2018-12-12 13:13:13 -08:00
|
|
|
import formatNumber from '../utils/formatNumber';
|
|
|
|
|
2018-12-10 13:24:25 -08:00
|
|
|
import theme from '../theme';
|
2018-12-10 09:07:45 -08:00
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
2018-12-10 16:11:53 -08:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2018-12-10 09:07:45 -08:00
|
|
|
background-color: ${props => props.theme.colors.cardBackgroundColor};
|
2018-12-10 16:21:07 -08:00
|
|
|
border-radius: 5px;
|
2018-12-11 14:26:28 -08:00
|
|
|
padding: 37px 45px;
|
2018-12-11 16:35:26 -08:00
|
|
|
margin-top: 20px;
|
2018-12-10 13:24:25 -08:00
|
|
|
position: relative;
|
2018-12-10 09:07:45 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const AllAddresses = styled(TextComponent)`
|
|
|
|
margin-bottom: 2.5px;
|
2018-12-12 11:04:44 -08:00
|
|
|
font-size: ${props => `${props.theme.fontSize.text}em`};
|
2018-12-10 09:07:45 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const ValueBox = styled.div`
|
|
|
|
margin-bottom: 15px;
|
|
|
|
margin-right: 25px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Label = styled(TextComponent)`
|
2018-12-11 14:26:28 -08:00
|
|
|
margin-top: 10px;
|
|
|
|
margin-bottom: 5px;
|
|
|
|
margin-left: -7.5px;
|
2018-12-10 09:07:45 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const USDValue = styled(TextComponent)`
|
2018-12-11 14:26:28 -08:00
|
|
|
opacity: 0.5;
|
2018-12-10 09:07:45 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const ShieldedValue = styled(Label)`
|
|
|
|
color: ${props => props.theme.colors.activeItem};
|
|
|
|
`;
|
|
|
|
|
2018-12-10 13:24:25 -08:00
|
|
|
const SeeMoreButton = styled.button`
|
2018-12-10 16:21:07 -08:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2018-12-10 13:24:25 -08:00
|
|
|
outline: none;
|
2018-12-12 11:04:44 -08:00
|
|
|
border-style: solid;
|
2018-12-10 13:24:25 -08:00
|
|
|
border-radius: 100%;
|
|
|
|
border-width: 1px;
|
2018-12-15 07:10:39 -08:00
|
|
|
border-color: ${props => (props.isOpen
|
|
|
|
? props.theme.colors.activeItem
|
|
|
|
: props.theme.colors.inactiveItem)};
|
2018-12-10 13:24:25 -08:00
|
|
|
background-color: transparent;
|
2018-12-11 04:13:17 -08:00
|
|
|
padding: 5px;
|
2018-12-10 13:24:25 -08:00
|
|
|
cursor: pointer;
|
|
|
|
position: absolute;
|
|
|
|
right: 10px;
|
|
|
|
top: 10px;
|
2018-12-11 04:13:17 -08:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
border-color: ${props => props.theme.colors.activeItem};
|
|
|
|
}
|
2018-12-10 13:24:25 -08:00
|
|
|
`;
|
|
|
|
|
2018-12-12 11:04:44 -08:00
|
|
|
const SeeMoreIcon = styled.img`
|
|
|
|
width: 25px;
|
|
|
|
height: 25px;
|
|
|
|
`;
|
|
|
|
|
2018-12-10 09:07:45 -08:00
|
|
|
type Props = {
|
|
|
|
total: number,
|
|
|
|
shielded: number,
|
|
|
|
transparent: number,
|
2018-12-13 13:37:15 -08:00
|
|
|
zecPrice: number,
|
2018-12-10 16:11:53 -08:00
|
|
|
addresses: string[],
|
2018-12-10 09:07:45 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const WalletSummaryComponent = ({
|
2018-12-15 07:10:39 -08:00
|
|
|
total,
|
|
|
|
shielded,
|
|
|
|
transparent,
|
|
|
|
zecPrice,
|
|
|
|
addresses,
|
2018-12-10 09:07:45 -08:00
|
|
|
}: Props) => (
|
|
|
|
<Wrapper>
|
2018-12-10 13:24:25 -08:00
|
|
|
<DropdownComponent
|
2018-12-10 16:52:45 -08:00
|
|
|
label='All Addresses'
|
2018-12-10 13:24:25 -08:00
|
|
|
renderTrigger={(toggleVisibility, isOpen) => (
|
|
|
|
<SeeMoreButton onClick={toggleVisibility} isOpen={isOpen}>
|
2018-12-12 11:04:44 -08:00
|
|
|
<SeeMoreIcon src={MenuIcon} alt='Menu Icon' />
|
2018-12-10 13:24:25 -08:00
|
|
|
</SeeMoreButton>
|
|
|
|
)}
|
2018-12-10 16:11:53 -08:00
|
|
|
options={addresses.map(addr => ({ label: addr, onClick: x => x }))}
|
2018-12-10 13:24:25 -08:00
|
|
|
/>
|
2018-12-10 09:07:45 -08:00
|
|
|
<AllAddresses value='ALL ADDRESSES' isBold />
|
|
|
|
<ValueBox>
|
2018-12-15 07:10:39 -08:00
|
|
|
<TextComponent
|
|
|
|
size={theme.fontSize.zecValueBase * 2.5}
|
|
|
|
value={`ZEC ${formatNumber({ value: total })}`}
|
|
|
|
isBold
|
|
|
|
/>
|
|
|
|
<USDValue
|
|
|
|
value={`USD $${formatNumber({ value: total * zecPrice })}`}
|
|
|
|
size={theme.fontSize.zecValueBase * 2}
|
|
|
|
/>
|
2018-12-10 09:07:45 -08:00
|
|
|
</ValueBox>
|
|
|
|
<RowComponent>
|
|
|
|
<ValueBox>
|
2018-12-15 07:10:39 -08:00
|
|
|
<ShieldedValue
|
|
|
|
value='● SHIELDED'
|
|
|
|
isBold
|
|
|
|
size={theme.fontSize.text * 0.8}
|
|
|
|
/>
|
|
|
|
<TextComponent
|
|
|
|
value={`ZEC ${formatNumber({ value: shielded })}`}
|
|
|
|
isBold
|
|
|
|
size={theme.fontSize.zecValueBase}
|
|
|
|
/>
|
|
|
|
<USDValue
|
|
|
|
value={`USD $${formatNumber({ value: shielded * zecPrice })}`}
|
|
|
|
/>
|
2018-12-10 09:07:45 -08:00
|
|
|
</ValueBox>
|
|
|
|
<ValueBox>
|
2018-12-15 07:10:39 -08:00
|
|
|
<Label
|
|
|
|
value='● TRANSPARENT'
|
|
|
|
isBold
|
|
|
|
size={theme.fontSize.text * 0.8}
|
|
|
|
/>
|
2018-12-13 12:20:22 -08:00
|
|
|
<TextComponent
|
|
|
|
value={`ZEC ${formatNumber({ value: transparent })}`}
|
|
|
|
isBold
|
|
|
|
size={theme.fontSize.zecValueBase}
|
|
|
|
/>
|
2018-12-15 07:10:39 -08:00
|
|
|
<USDValue
|
|
|
|
value={`USD $${formatNumber({ value: transparent * zecPrice })}`}
|
|
|
|
/>
|
2018-12-10 09:07:45 -08:00
|
|
|
</ValueBox>
|
|
|
|
</RowComponent>
|
|
|
|
</Wrapper>
|
|
|
|
);
|