MyCrypto/common/components/ui/Identicon.jsx

24 lines
521 B
React
Raw Normal View History

2017-06-26 23:27:26 +00:00
// @flow
2017-06-26 22:27:55 +00:00
import React from 'react';
import { toDataUrl } from 'ethereum-blockies';
2017-06-26 23:27:26 +00:00
import { isValidETHAddress } from 'libs/validators';
2017-06-26 22:27:55 +00:00
type Props = {
2017-07-02 05:49:06 +00:00
address: string
2017-06-26 22:27:55 +00:00
};
export default function Identicon(props: Props) {
2017-07-02 05:49:06 +00: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 22:27:55 +00:00
}