mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
Fixed animation loading
This commit is contained in:
parent
88a94ec06e
commit
a4d88fb919
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { Component } from 'react';
|
||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
@ -82,38 +82,54 @@ const Dot = styled.div`
|
|||||||
height: 10px;
|
height: 10px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const DeviceHeader = ({
|
class DeviceHeader extends Component {
|
||||||
disabled = false,
|
constructor(props) {
|
||||||
handleOpen,
|
super(props);
|
||||||
status,
|
this.state = {
|
||||||
label,
|
clicked: false,
|
||||||
deviceCount,
|
};
|
||||||
isOpen = false,
|
}
|
||||||
trezorModel,
|
|
||||||
}) => (
|
handleClick() {
|
||||||
<Wrapper>
|
this.setState({ clicked: true });
|
||||||
<ClickWrapper onClick={!disabled ? handleOpen : null}>
|
if (!this.props.disabled) {
|
||||||
<ImageWrapper>
|
this.props.handleOpen();
|
||||||
<Dot color={getStatusColor(status)} />
|
}
|
||||||
<TrezorImage status={status} model={trezorModel} />
|
}
|
||||||
</ImageWrapper>
|
|
||||||
<LabelWrapper>
|
render() {
|
||||||
<Name>{label}</Name>
|
console.log('cananitem', this.state.clicked);
|
||||||
<Status>{getStatusName(status)}</Status>
|
const {
|
||||||
</LabelWrapper>
|
status, label, deviceCount, isOpen, trezorModel,
|
||||||
<IconWrapper>
|
} = this.props;
|
||||||
{deviceCount > 1 && <Counter>{deviceCount}</Counter>}
|
return (
|
||||||
<Icon
|
<Wrapper>
|
||||||
isOpen={isOpen}
|
<ClickWrapper onClick={() => this.handleClick()}>
|
||||||
size={25}
|
<ImageWrapper>
|
||||||
color={colors.TEXT_SECONDARY}
|
<Dot color={getStatusColor(status)} />
|
||||||
icon={icons.ARROW_DOWN}
|
<TrezorImage status={status} model={trezorModel} />
|
||||||
rotateOnActive
|
</ImageWrapper>
|
||||||
/>
|
<LabelWrapper>
|
||||||
</IconWrapper>
|
<Name>{label}</Name>
|
||||||
</ClickWrapper>
|
<Status>{getStatusName(status)}</Status>
|
||||||
</Wrapper>
|
</LabelWrapper>
|
||||||
);
|
<IconWrapper>
|
||||||
|
{deviceCount > 1 && <Counter>{deviceCount}</Counter>}
|
||||||
|
<Icon
|
||||||
|
canAnimate={this.state.clicked === true}
|
||||||
|
isActive={isOpen}
|
||||||
|
size={25}
|
||||||
|
color={colors.TEXT_SECONDARY}
|
||||||
|
icon={icons.ARROW_DOWN}
|
||||||
|
rotateOnActive
|
||||||
|
/>
|
||||||
|
</IconWrapper>
|
||||||
|
</ClickWrapper>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DeviceHeader.propTypes = {
|
DeviceHeader.propTypes = {
|
||||||
deviceCount: PropTypes.number,
|
deviceCount: PropTypes.number,
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import styled, { css, keyframes } from 'styled-components';
|
import styled, { keyframes } from 'styled-components';
|
||||||
|
|
||||||
const rotate180up = keyframes`
|
const rotate180up = keyframes`
|
||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
@ -16,50 +15,41 @@ const rotate180down = keyframes`
|
|||||||
from {
|
from {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const SvgWrapper = styled.svg`
|
const SvgWrapper = styled.svg`
|
||||||
animation: ${props => (props.isActive ? rotate180up : rotate180down)} 0.2s linear 1 forwards;
|
animation: ${props => (props.canAnimate ? (props.isActive ? rotate180up : rotate180down) : null)} 0.2s linear 1 forwards;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Path = styled.path``;
|
const Path = styled.path``;
|
||||||
|
|
||||||
const Icon = ({
|
const Icon = ({
|
||||||
icon, size = 32, color = 'black', isActive = false,
|
icon, size = 32, color = 'black', isActive, canAnimate,
|
||||||
}) => {
|
}) => (
|
||||||
const styles = {
|
<SvgWrapper
|
||||||
svg: {
|
canAnimate={canAnimate}
|
||||||
|
isActive={isActive}
|
||||||
|
style={{
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
verticalAlign: 'middle',
|
verticalAlign: 'middle',
|
||||||
},
|
}}
|
||||||
path: {
|
width={`${size}`}
|
||||||
fill: color,
|
height={`${size}`}
|
||||||
},
|
viewBox="0 0 1024 1024"
|
||||||
};
|
>
|
||||||
|
<Path
|
||||||
return (
|
isActive={isActive}
|
||||||
<SvgWrapper
|
style={{ fill: color }}
|
||||||
isOpen={isOpen}
|
d={icon}
|
||||||
style={styles.svg}
|
/>
|
||||||
width={`${size}`}
|
</SvgWrapper>
|
||||||
height={`${size}`}
|
);
|
||||||
viewBox="0 0 1024 1024"
|
|
||||||
>
|
|
||||||
<Path
|
|
||||||
isActive={isActive}
|
|
||||||
style={styles.path}
|
|
||||||
d={icon}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</SvgWrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Icon.propTypes = {
|
Icon.propTypes = {
|
||||||
|
canAnimate: PropTypes.bool,
|
||||||
icon: PropTypes.string.isRequired,
|
icon: PropTypes.string.isRequired,
|
||||||
size: PropTypes.number,
|
size: PropTypes.number,
|
||||||
isActive: PropTypes.bool,
|
isActive: PropTypes.bool,
|
||||||
|
@ -64,7 +64,7 @@ export const DeviceSelect = (props: Props) => {
|
|||||||
handleOpen={handleOpen}
|
handleOpen={handleOpen}
|
||||||
label={selected.instanceLabel}
|
label={selected.instanceLabel}
|
||||||
status={getStatus(selected)}
|
status={getStatus(selected)}
|
||||||
deviceCount={deviceCount}
|
deviceCount={devices.length}
|
||||||
isOpen={props.deviceDropdownOpened}
|
isOpen={props.deviceDropdownOpened}
|
||||||
trezorModel={getVersion(selected)}
|
trezorModel={getVersion(selected)}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user