/* @flow */ import React, { Component } from 'react'; import styled, { keyframes } from 'styled-components'; import TrezorConnect from 'trezor-connect'; import P from 'components/Paragraph'; import Button from 'components/Button'; import { PULSATE } from 'config/animations'; import colors from 'config/colors'; import { FONT_SIZE, FONT_WEIGHT } from 'config/variables'; type Props = { deviceLabel: string, showWebUsb: boolean, showDisconnect: boolean, }; class ConnectDevice extends Component { componentDidMount() { if (this.props.showWebUsb) { TrezorConnect.renderWebUSBButton(); } } componentDidUpdate() { if (this.props.showWebUsb) { TrezorConnect.renderWebUSBButton(); } } getTrezorDeviceImage() { const animationConnect = keyframes` 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-4px) } `; const ImageWrapper = styled.svg` position: absolute; top: -8px; left: -24px; `; const DeviceRect = styled.rect` animation: ${animationConnect} 1.3s ease-out infinite; `; return ( ); } render() { const Wrapper = styled.div` display: flex; justify-content: space-around; align-items: center; width: 400px; margin: 0 auto; padding: 36px 0; `; const ConnectTrezorWrapper = styled.div` position: relative; top: 1px; animation: ${PULSATE} 1.3s ease-out infinite; color: ${colors.GREEN_PRIMARY}; font-size: ${FONT_SIZE.BASE}; font-weight: ${FONT_WEIGHT.BASE}; `; return ( {this.props.showDisconnect && `Unplug "${this.props.deviceLabel}" device`} {!this.props.showDisconnect && ( {this.getTrezorDeviceImage()} Connect TREZOR )} {this.props.showWebUsb && (

and

)}
); } } export default ConnectDevice;