fix DeviceIcon component

pull/463/head
slowbackspace 5 years ago
parent 50a7bcf97e
commit 6ea3aac8aa

@ -2,8 +2,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { colors as COLORS, icons as ICONS } from 'trezor-ui-components'; import { Icon, colors as COLORS, icons } from 'trezor-ui-components';
import styled from 'styled-components';
import type { TrezorDevice } from 'flowtype'; import type { TrezorDevice } from 'flowtype';
type Props = { type Props = {
@ -14,26 +13,14 @@ type Props = {
onClick?: any, onClick?: any,
}; };
const SvgWrapper = styled.svg`
:hover {
path {
fill: ${props => props.hoverColor};
}
}
`;
const Path = styled.path`
fill: ${props => props.color};
`;
const getDeviceIcon = (majorVersion: number) => { const getDeviceIcon = (majorVersion: number) => {
switch (majorVersion) { switch (majorVersion) {
case 1: case 1:
return ICONS.T1; return icons.T1;
case 2: case 2:
return ICONS.T2; return icons.T2;
default: default:
return ICONS.T2; return icons.T2;
} }
}; };
@ -45,17 +32,8 @@ const DeviceIcon = ({
onClick, onClick,
}: Props) => { }: Props) => {
const majorVersion = device.features ? device.features.major_version : 2; const majorVersion = device.features ? device.features.major_version : 2;
return ( const icon = getDeviceIcon(majorVersion);
<SvgWrapper return <Icon icon={icon} hoverColor={hoverColor} onClick={onClick} color={color} size={size} />;
hoverColor={hoverColor}
width={`${size}`}
height={`${size}`}
viewBox="0 0 1024 1024"
onClick={onClick}
>
<Path key={majorVersion} color={color} d={getDeviceIcon(majorVersion)} />
</SvgWrapper>
);
}; };
DeviceIcon.propTypes = { DeviceIcon.propTypes = {

Loading…
Cancel
Save