You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/components/Button/index.js

185 lines
4.3 KiB

/* @flow */
import * as React from 'react';
6 years ago
import styled, { css } from 'styled-components';
import PropTypes from 'prop-types';
import colors from 'config/colors';
import { TRANSITION, FONT_WEIGHT, FONT_SIZE } from 'config/variables';
6 years ago
type Props = {
children: React.Node,
className?: string,
onClick?: () => any,
onMouseEnter?: () => void,
onMouseLeave?: () => void,
onFocus?: () => void,
isDisabled?: boolean,
isWhite?: boolean,
isWebUsb?: boolean,
isTransparent?: boolean,
Integration tests (#311) * Add base test env * Add eslint rules for cypress * Add configs and scripts in package json * Added docker file for bridge and emualator * Bridge install progress * Bridge install next step * Add task for integration tests * Fixed deps * Added baseUrl * Added baseUrl fix * Added npx * Added caching for cypress bin * Added path to binary * Install cypress * Finalized dockerfile * Fixed bridge lib path * Fixed path for binary * Adjust script again * Run all the things properly * Try to run the tests * First POC test * First POC test in gitlab * Fixed flow * Fixed gitlab test url, try docker service * export artifacts * Test only integration tests in CI * Test only integration tests in CI 2 * Test only integration tests in CI 3 * Added tests for initialize device * Try to add docker in only one step * Turn on other integration steps * Correct node version * Ignore cache in flow * Run bridge and emulator in debug link mode * Fix param * Try to run new config in CI * init device in docker * Remove docker image after run * Remove amp * Fix path * Artifacts on fail * Artifacts on fail with volume * Artifacts on fail with volume 2 * Install mkdir * Install mkdir again * test * test 2 * test 3 * test 4 * test 5 * test 6 * test 7 * test 8 * test 9 * test 10 * test 11 * test 12 * test 13 * test 14 * test 15 * test 16 * test 17 * Revert "test 17" This reverts commit f3f6c0d6906cdc470aa11ae728b4b61a6b71a732. * test 18 * test 19 * test 20 * test 21 try chrome * test 22 * test 23 * test 24 * test 25 * test 25 try to install chrome again * test 25 try to install chrome again * Added missing deps * Added debug * Install chromium * Install chromium 2 * turn on chromium * turn off debug * turn on debug * fix folder * turn off debug * Fix init device * Add header dashboard test * Bring things back * clean * clean fix * Build image in CI * Added stage step * Added docker image * Added service * Added tests to docker image * Refactor a bit * Correct registry image * Build wallet again * Add test for dashbaord content * new node version, more tests * Remove unused code * typo * Correct snapshots, moved deps to dev, beta disclaimer prop
5 years ago
dataTest?: string
}
6 years ago
const Wrapper = styled.button`
padding: ${props => (props.icon ? '4px 24px 4px 15px' : '11px 24px')};
6 years ago
border-radius: 3px;
font-size: ${FONT_SIZE.BASE};
font-weight: ${FONT_WEIGHT.LIGHT};
6 years ago
cursor: pointer;
background: ${colors.GREEN_PRIMARY};
color: ${colors.WHITE};
border: 0;
6 years ago
&:hover {
background: ${colors.GREEN_SECONDARY};
}
6 years ago
&:active {
background: ${colors.GREEN_TERTIARY};
}
&:focus {
5 years ago
border-color: ${colors.INPUT_FOCUSED_BORDER};
box-shadow: 0 0px 6px 0 ${colors.INPUT_FOCUSED_SHADOW};
}
${props => props.isDisabled && css`
6 years ago
pointer-events: none;
color: ${colors.TEXT_SECONDARY};
background: ${colors.GRAY_LIGHT};
`}
${props => props.isWhite && css`
background: ${colors.WHITE};
color: ${colors.TEXT_SECONDARY};
border: 1px solid ${colors.DIVIDER};
&:focus {
5 years ago
border-color: ${colors.INPUT_FOCUSED_BORDER};
}
&:hover {
color: ${colors.TEXT_PRIMARY};
background: ${colors.DIVIDER};
}
&:active {
color: ${colors.TEXT_PRIMARY};
background: ${colors.DIVIDER};
}
`}
${props => props.isTransparent && css`
background: transparent;
border: 0px;
color: ${colors.TEXT_SECONDARY};
5 years ago
&:focus {
color: ${colors.TEXT_PRIMARY};
box-shadow: none;
}
&:hover,
&:active {
color: ${colors.TEXT_PRIMARY};
background: transparent;
}
`}
${props => props.isWebUsb && css`
position: relative;
padding: 12px 24px 12px 40px;
background: transparent;
color: ${colors.GREEN_PRIMARY};
border: 1px solid ${colors.GREEN_PRIMARY};
transition: ${TRANSITION.HOVER};
&:before,
&:after {
content: '';
position: absolute;
background: ${colors.GREEN_PRIMARY};
top: 0;
bottom: 0;
margin: auto;
transition: ${TRANSITION.HOVER};
}
&:before {
width: 12px;
height: 2px;
left: 18px;
}
&:after {
width: 2px;
height: 12px;
left: 23px;
}
&:hover {
background: ${colors.GREEN_PRIMARY};
color: ${colors.WHITE};
&:before,
&:after {
background: ${colors.WHITE};
}
}
iframe {
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
`}
6 years ago
`;
const Button = ({
children,
className = '',
onClick,
onMouseEnter,
onMouseLeave,
onFocus,
isDisabled = false,
isWhite = false,
isWebUsb = false,
isTransparent = false,
Integration tests (#311) * Add base test env * Add eslint rules for cypress * Add configs and scripts in package json * Added docker file for bridge and emualator * Bridge install progress * Bridge install next step * Add task for integration tests * Fixed deps * Added baseUrl * Added baseUrl fix * Added npx * Added caching for cypress bin * Added path to binary * Install cypress * Finalized dockerfile * Fixed bridge lib path * Fixed path for binary * Adjust script again * Run all the things properly * Try to run the tests * First POC test * First POC test in gitlab * Fixed flow * Fixed gitlab test url, try docker service * export artifacts * Test only integration tests in CI * Test only integration tests in CI 2 * Test only integration tests in CI 3 * Added tests for initialize device * Try to add docker in only one step * Turn on other integration steps * Correct node version * Ignore cache in flow * Run bridge and emulator in debug link mode * Fix param * Try to run new config in CI * init device in docker * Remove docker image after run * Remove amp * Fix path * Artifacts on fail * Artifacts on fail with volume * Artifacts on fail with volume 2 * Install mkdir * Install mkdir again * test * test 2 * test 3 * test 4 * test 5 * test 6 * test 7 * test 8 * test 9 * test 10 * test 11 * test 12 * test 13 * test 14 * test 15 * test 16 * test 17 * Revert "test 17" This reverts commit f3f6c0d6906cdc470aa11ae728b4b61a6b71a732. * test 18 * test 19 * test 20 * test 21 try chrome * test 22 * test 23 * test 24 * test 25 * test 25 try to install chrome again * test 25 try to install chrome again * Added missing deps * Added debug * Install chromium * Install chromium 2 * turn on chromium * turn off debug * turn on debug * fix folder * turn off debug * Fix init device * Add header dashboard test * Bring things back * clean * clean fix * Build image in CI * Added stage step * Added docker image * Added service * Added tests to docker image * Refactor a bit * Correct registry image * Build wallet again * Add test for dashbaord content * new node version, more tests * Remove unused code * typo * Correct snapshots, moved deps to dev, beta disclaimer prop
5 years ago
dataTest,
}: Props) => {
const newClassName = isWebUsb ? `${className} trezor-webusb-button` : className;
return (
<Wrapper
Integration tests (#311) * Add base test env * Add eslint rules for cypress * Add configs and scripts in package json * Added docker file for bridge and emualator * Bridge install progress * Bridge install next step * Add task for integration tests * Fixed deps * Added baseUrl * Added baseUrl fix * Added npx * Added caching for cypress bin * Added path to binary * Install cypress * Finalized dockerfile * Fixed bridge lib path * Fixed path for binary * Adjust script again * Run all the things properly * Try to run the tests * First POC test * First POC test in gitlab * Fixed flow * Fixed gitlab test url, try docker service * export artifacts * Test only integration tests in CI * Test only integration tests in CI 2 * Test only integration tests in CI 3 * Added tests for initialize device * Try to add docker in only one step * Turn on other integration steps * Correct node version * Ignore cache in flow * Run bridge and emulator in debug link mode * Fix param * Try to run new config in CI * init device in docker * Remove docker image after run * Remove amp * Fix path * Artifacts on fail * Artifacts on fail with volume * Artifacts on fail with volume 2 * Install mkdir * Install mkdir again * test * test 2 * test 3 * test 4 * test 5 * test 6 * test 7 * test 8 * test 9 * test 10 * test 11 * test 12 * test 13 * test 14 * test 15 * test 16 * test 17 * Revert "test 17" This reverts commit f3f6c0d6906cdc470aa11ae728b4b61a6b71a732. * test 18 * test 19 * test 20 * test 21 try chrome * test 22 * test 23 * test 24 * test 25 * test 25 try to install chrome again * test 25 try to install chrome again * Added missing deps * Added debug * Install chromium * Install chromium 2 * turn on chromium * turn off debug * turn on debug * fix folder * turn off debug * Fix init device * Add header dashboard test * Bring things back * clean * clean fix * Build image in CI * Added stage step * Added docker image * Added service * Added tests to docker image * Refactor a bit * Correct registry image * Build wallet again * Add test for dashbaord content * new node version, more tests * Remove unused code * typo * Correct snapshots, moved deps to dev, beta disclaimer prop
5 years ago
data-test={dataTest}
className={newClassName}
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
onFocus={onFocus}
isDisabled={isDisabled}
isWhite={isWhite}
isWebUsb={isWebUsb}
isTransparent={isTransparent}
>
{children}
</Wrapper>
);
};
6 years ago
Button.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
6 years ago
onClick: PropTypes.func,
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
onFocus: PropTypes.func,
isDisabled: PropTypes.bool,
isWhite: PropTypes.bool,
isWebUsb: PropTypes.bool,
isTransparent: PropTypes.bool,
Integration tests (#311) * Add base test env * Add eslint rules for cypress * Add configs and scripts in package json * Added docker file for bridge and emualator * Bridge install progress * Bridge install next step * Add task for integration tests * Fixed deps * Added baseUrl * Added baseUrl fix * Added npx * Added caching for cypress bin * Added path to binary * Install cypress * Finalized dockerfile * Fixed bridge lib path * Fixed path for binary * Adjust script again * Run all the things properly * Try to run the tests * First POC test * First POC test in gitlab * Fixed flow * Fixed gitlab test url, try docker service * export artifacts * Test only integration tests in CI * Test only integration tests in CI 2 * Test only integration tests in CI 3 * Added tests for initialize device * Try to add docker in only one step * Turn on other integration steps * Correct node version * Ignore cache in flow * Run bridge and emulator in debug link mode * Fix param * Try to run new config in CI * init device in docker * Remove docker image after run * Remove amp * Fix path * Artifacts on fail * Artifacts on fail with volume * Artifacts on fail with volume 2 * Install mkdir * Install mkdir again * test * test 2 * test 3 * test 4 * test 5 * test 6 * test 7 * test 8 * test 9 * test 10 * test 11 * test 12 * test 13 * test 14 * test 15 * test 16 * test 17 * Revert "test 17" This reverts commit f3f6c0d6906cdc470aa11ae728b4b61a6b71a732. * test 18 * test 19 * test 20 * test 21 try chrome * test 22 * test 23 * test 24 * test 25 * test 25 try to install chrome again * test 25 try to install chrome again * Added missing deps * Added debug * Install chromium * Install chromium 2 * turn on chromium * turn off debug * turn on debug * fix folder * turn off debug * Fix init device * Add header dashboard test * Bring things back * clean * clean fix * Build image in CI * Added stage step * Added docker image * Added service * Added tests to docker image * Refactor a bit * Correct registry image * Build wallet again * Add test for dashbaord content * new node version, more tests * Remove unused code * typo * Correct snapshots, moved deps to dev, beta disclaimer prop
5 years ago
dataTest: PropTypes.string,
6 years ago
};
export default Button;