Separate animations

pull/8/head
Vladimir Volek 6 years ago
parent a2d7916d9f
commit 39de4ad932

@ -2,6 +2,7 @@ import React from 'react';
import styled, { css, keyframes } from 'styled-components'; import styled, { css, keyframes } from 'styled-components';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Paragraph from 'components/Paragraph'; import Paragraph from 'components/Paragraph';
import { DASH, GREEN_COLOR } from 'config/animations';
import colors from 'config/colors'; import colors from 'config/colors';
const Wrapper = styled.div` const Wrapper = styled.div`
@ -21,36 +22,6 @@ const SvgWrapper = styled.svg`
transform-origin: center center; transform-origin: center center;
`; `;
const animationDash = keyframes`
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124;
}
`;
const animationColor = keyframes`
100%, 0% {
stroke: ${colors.GREEN_PRIMARY};
}
40% {
stroke: ${colors.GREEN_PRIMARY};
}
66% {
stroke: ${colors.GREEN_SECONDARY};
}
80%, 90% {
stroke: ${colors.GREEN_TERTIARY};
}
`;
const CircleWrapper = styled.circle` const CircleWrapper = styled.circle`
${props => props.isRoute && css` ${props => props.isRoute && css`
stroke: ${colors.GRAY_LIGHT}; stroke: ${colors.GRAY_LIGHT};
@ -59,7 +30,7 @@ const CircleWrapper = styled.circle`
${props => props.isPath && css` ${props => props.isPath && css`
stroke-dasharray: 1, 200; stroke-dasharray: 1, 200;
stroke-dashoffset: 0; stroke-dashoffset: 0;
animation: ${animationDash} 1.5s ease-in-out infinite, ${animationColor} 6s ease-in-out infinite; animation: ${DASH} 1.5s ease-in-out infinite, ${GREEN_COLOR} 6s ease-in-out infinite;
stroke-linecap: round; stroke-linecap: round;
`}; `};
`; `;

@ -0,0 +1,42 @@
import { keyframes } from 'styled-components';
import colors from 'config/colors';
export const ROTATE_180_UP = keyframes`
from { transform: rotate(0deg) }
to { transform: rotate(180deg) }
`;
export const ROTATE_180_DOWN = keyframes`
from { transform: rotate(180deg) }
to { transform: rotate(0deg) }
`;
export const DASH = keyframes`
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124;
}
`;
export const GREEN_COLOR = keyframes`
100%, 0% {
stroke: ${colors.GREEN_PRIMARY};
}
40% {
stroke: ${colors.GREEN_PRIMARY};
}
66% {
stroke: ${colors.GREEN_SECONDARY};
}
80%, 90% {
stroke: ${colors.GREEN_TERTIARY};
}
`;

@ -150,53 +150,35 @@ export class DeviceDropdown extends Component<Props> {
if (!a.instance || !b.instance) return -1; if (!a.instance || !b.instance) return -1;
return a.instance > b.instance ? 1 : -1; return a.instance > b.instance ? 1 : -1;
}; };
const deviceList = devices.sort(sortByInstance).map((dev, index) => {
if (dev === selected) return null;
let deviceStatus: string = 'Connected';
let css: string = 'device item';
if (dev.type === 'unacquired' || (dev.features && dev.status === 'occupied')) {
deviceStatus = 'Used in other window';
css += ' unacquired';
} else if (dev.type === 'unreadable') {
deviceStatus = 'Connected';
css += ' connected';
} else if (!dev.connected) {
deviceStatus = 'Disconnected';
css += ' disconnected';
} else if (!dev.available) {
deviceStatus = 'Unavailable';
css += ' unavailable';
}
if (dev.features && dev.features.major_version > 1) {
css += ' trezor-t';
}
return ( const deviceList = devices.sort(sortByInstance)
<DeviceHeader .map((dev, index) => {
onClickWrapper={() => this.props.onSelectDevice(dev)} if (dev === selected) return null;
onClickIcon={() => this.onDeviceMenuClick({ type: 'forget', label: '' }, dev)} return (
icon={( <DeviceHeader
<IconClick onClick={(event) => { key={`${dev.instanceLabel}`}
event.stopPropagation(); onClickWrapper={() => this.props.onSelectDevice(dev)}
event.preventDefault(); onClickIcon={() => this.onDeviceMenuClick({ type: 'forget', label: '' }, dev)}
this.onDeviceMenuClick({ type: 'forget', label: '' }, dev); icon={(
}} <IconClick onClick={(event) => {
> event.stopPropagation();
<Icon event.preventDefault();
icon={icons.EJECT} this.onDeviceMenuClick({ type: 'forget', label: '' }, dev);
size={25} }}
color={colors.TEXT_SECONDARY} >
/> <Icon
</IconClick> icon={icons.EJECT}
)} size={25}
label={dev.instanceLabel} color={colors.TEXT_SECONDARY}
status={getStatus(dev)} />
trezorModel={getVersion(dev)} </IconClick>
/> )}
); label={dev.instanceLabel}
}); status={getStatus(dev)}
trezorModel={getVersion(dev)}
/>
);
});
return ( return (
<Wrapper> <Wrapper>

Loading…
Cancel
Save