MyCrypto/common/components/ui/Identicon.jsx

24 lines
521 B
React
Raw Normal View History

2017-06-26 16:27:26 -07:00
// @flow
2017-06-26 15:27:55 -07:00
import React from 'react';
import { toDataUrl } from 'ethereum-blockies';
2017-06-26 16:27:26 -07:00
import { isValidETHAddress } from 'libs/validators';
2017-06-26 15:27:55 -07:00
type Props = {
2017-07-01 22:49:06 -07:00
address: string
2017-06-26 15:27:55 -07:00
};
export default function Identicon(props: Props) {
2017-07-01 22:49:06 -07:00
// FIXME breaks on failed checksums
const style = !isValidETHAddress(props.address)
? {}
: { backgroundImage: `url(${toDataUrl(props.address.toLowerCase())})` };
return (
<div
className="addressIdenticon"
style={style}
title="Address Indenticon"
/>
);
2017-06-26 15:27:55 -07:00
}