/* @flow */ import React, { PureComponent } from 'react'; import styled, { keyframes } from 'styled-components'; import TrezorConnect from 'trezor-connect'; import l10nCommonMessages from 'views/common.messages'; import { Button, P, H5, Link, icons, colors } from 'trezor-ui-components'; import { PULSATE } from 'config/animations'; import { FONT_SIZE, FONT_WEIGHT, SCREEN_SIZE } from 'config/variables'; import CaseImage from 'images/macbook.png'; import { FormattedMessage } from 'react-intl'; import l10nMessages from './index.messages'; type Props = { deviceLabel: string, showWebUsb: boolean, showDisconnect: boolean, }; const StyledConnectDevice = styled.div` padding: 0px 48px; `; const Title = styled.div` margin-top: 60px; max-width: 800px; text-align: center; `; const Wrapper = styled.div` display: flex; align-items: center; margin: 0 auto; padding: 36px 0; justify-content: center; @media screen and (max-width: ${SCREEN_SIZE.SM}) { align-content: center; flex-direction: column; } `; const ConnectTrezorWrapper = styled.div` position: relative; top: 1px; margin: 15px 15px 0px 15px; animation: ${PULSATE} 1.3s ease-out infinite; color: ${colors.GREEN_PRIMARY}; font-size: ${FONT_SIZE.BIG}; font-weight: ${FONT_WEIGHT.MEDIUM}; `; const StyledP = styled(P)` line-height: auto; margin: 15px 15px 0px 15px; `; const StyledButton = styled(Button)` margin: 15px 15px 5px 15px; `; const Image = styled.img` width: 100%; max-width: 850px; height: auto; margin: auto; background-repeat: no-repeat; background-position: center 0px; background-size: contain; `; const Footer = styled.div` margin-bottom: 32px; `; const FooterText = styled.span` margin-right: 4px; `; const StyledLink = styled(Link)` font-size: ${FONT_SIZE.BIG}; `; class ConnectDevice extends PureComponent { 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() { return ( <H5 claim> <FormattedMessage {...l10nMessages.TR_THE_PRIVATE_BANK_IN_YOUR_HANDS} /> </H5> <P> <FormattedMessage {...l10nMessages.TR_TREZOR_WALLET_IS_AN_EASY_DASH} /> </P> {this.props.showDisconnect && ( )} {!this.props.showDisconnect && ( {this.getTrezorDeviceImage()} )} {this.props.showWebUsb && !this.props.showDisconnect && ( )} ); } } export default ConnectDevice;