Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
import React from 'react';
import PropTypes from 'prop-types';
Luke Schoen
committed
import { Clickable, ClickToCopy } from 'fether-ui';
import { Address } from './Address';
import { Avatar } from './Avatar';
import { Information } from './Information';
import { Name } from './Name';
Luke Schoen
committed
const CopyContainer = ({ address, children, ...otherProps }) => (
<ClickToCopy label='Copy address' textToCopy={address} {...otherProps}>
<Clickable>{children}</Clickable>
</ClickToCopy>
);
const CardContents = ({ address, name, screen, shortAddress, type }) => (
<div className='account'>
<Avatar address={address} type={type} />
<Information>
<Name name={name} screen={screen} />
<Address address={address} screen={screen} short={shortAddress} />
</Information>
</div>
);
export const AccountCard = ({
address,
Luke Schoen
committed
copyAddress,
screen,
shortAddress,
...otherProps
}) => (
Luke Schoen
committed
{copyAddress ? (
<CopyContainer address={address}>
<CardContents
address={address}
name={name}
screen={screen}
shortAddress={shortAddress}
type={type}
/>
</CopyContainer>
) : (
<CardContents
address={address}
name={name}
screen={screen}
shortAddress={shortAddress}
type={type}
/>
)}
AccountCard.Address = Address;
AccountCard.Avatar = Avatar;
AccountCard.Information = Information;
AccountCard.Name = Name;
AccountCard.propTypes = {
address: PropTypes.string,
Luke Schoen
committed
copyAddress: PropTypes.bool,
screen: PropTypes.string,