MyCrypto/common/components/ui/Identicon.tsx
William O'Beirne 994fa03828 Add RSK network w/ network agnostic refactors (#1939)
* Rsk network with checksum

* Initial change from chainid everywhere to selectors

* Fix ternary

* Check in address book changes to lower case. Currently a little busted.

* Fix validation

* Fix tests.

* Identicon back to SFC

* Remove unnecessary prop

* Paper Wallet Refactor (#1950)

* Convert print wallet to save png image. Move all styles into CSS.

* Fix re-print paper wallet with save modal

* Address PR comments
2018-06-15 18:28:42 -05:00

44 lines
1.2 KiB
TypeScript

import React from 'react';
import makeBlockie from 'ethereum-blockies-base64';
import { connect } from 'react-redux';
import { getIsValidAddressFn } from 'selectors/config';
import { AppState } from 'reducers';
import './Identicon.scss';
interface OwnProps {
address: string;
className?: string;
size?: string;
}
interface StateProps {
isValidAddress: ReturnType<typeof getIsValidAddressFn>;
}
type Props = OwnProps & StateProps;
const Identicon: React.SFC<Props> = props => {
const size = props.size || '4rem';
const { address, isValidAddress, className = '' } = props;
const identiconDataUrl = isValidAddress(address) ? makeBlockie(address) : '';
return (
// Use inline styles for printable wallets
<div
className={`Identicon ${className}`}
title="Address Identicon"
style={{ width: size, height: size }}
aria-hidden={!identiconDataUrl}
>
{identiconDataUrl && (
<img className="Identicon-img" src={identiconDataUrl} alt="Unique Address Image" />
)}
<div className="Identicon-shadow" />
</div>
);
};
export default connect((state: AppState): StateProps => ({
isValidAddress: getIsValidAddressFn(state)
}))(Identicon);