1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-30 19:00:53 +00:00

Separted button and notfication button

This commit is contained in:
Vladimir Volek 2018-08-29 13:54:41 +02:00
parent e1d4faddfc
commit a7726081f2
6 changed files with 156 additions and 134 deletions

View File

@ -29,42 +29,6 @@ const Wrapper = styled.button`
background: ${colors.GRAY_LIGHT}; background: ${colors.GRAY_LIGHT};
`} `}
${props => props.color === 'blue' && css`
background: transparent;
border: 1px solid ${colors.INFO_PRIMARY};
color: ${colors.INFO_PRIMARY};
padding: 12px 58px;
&:hover {
color: ${colors.WHITE};
background: ${colors.INFO_PRIMARY};
}
`}
${props => props.color === 'red' && css`
background: transparent;
border: 1px solid ${colors.ERROR_PRIMARY};
color: ${colors.ERROR_SECONDARY};
padding: 12px 58px;
&:hover {
color: ${colors.WHITE};
background: ${colors.ERROR_PRIMARY};
}
`}
${props => props.color === 'orange' && css`
background: transparent;
border: 1px solid ${colors.WARNING_PRIMARY};
color: ${colors.WARNING_SECONDARY};
padding: 12px 58px;
&:hover {
color: ${colors.WHITE};
background: ${colors.WARNING_PRIMARY};
}
`}
${props => props.color === 'white' && css` ${props => props.color === 'white' && css`
background: ${colors.WHITE}; background: ${colors.WHITE};
color: ${colors.TEXT_SECONDARY}; color: ${colors.TEXT_SECONDARY};

View File

@ -3,7 +3,7 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import styled, { css } from 'styled-components'; import styled, { css } from 'styled-components';
import colors from 'config/colors'; import colors from 'config/colors';
import Button from 'components/Button'; import NotificationButton from 'components/NotificationButton';
import Icon from 'components/Icon'; import Icon from 'components/Icon';
import icons from 'config/icons'; import icons from 'config/icons';
import { FONT_SIZE, FONT_WEIGHT } from 'config/variables'; import { FONT_SIZE, FONT_WEIGHT } from 'config/variables';
@ -55,7 +55,13 @@ const Title = styled.div`
`; `;
const ActionContent = styled.div``; const ActionContent = styled.div``;
const CloseClick = styled.div``;
const CloseClick = styled.div`
position: absolute;
right: 0;
top: 0;
padding: 20px 10px 0 0;
`;
const Message = styled.div` const Message = styled.div`
padding: 5px 0 0 0; padding: 5px 0 0 0;
@ -68,7 +74,7 @@ const IconContent = styled.div`
const StyledIcon = styled(Icon)` const StyledIcon = styled(Icon)`
position: relative; position: relative;
top: -6px; top: -7px;
`; `;
const MessageContent = styled.div``; const MessageContent = styled.div``;
@ -76,28 +82,6 @@ const MessageContent = styled.div``;
export const Notification = (props: NProps): React$Element<string> => { export const Notification = (props: NProps): React$Element<string> => {
const close: Function = typeof props.close === 'function' ? props.close : () => {}; // TODO: add default close action const close: Function = typeof props.close === 'function' ? props.close : () => {}; // TODO: add default close action
const getButtonColor = (type) => {
let color;
switch (type) {
case 'info':
color = 'blue';
break;
case 'error':
color = 'red';
break;
case 'warning':
color = 'orange';
break;
case 'success':
color = 'green';
break;
default:
color = null;
}
return color;
};
const getIconColor = (type) => { const getIconColor = (type) => {
let color; let color;
switch (type) { switch (type) {
@ -125,7 +109,11 @@ export const Notification = (props: NProps): React$Element<string> => {
{props.loading && <Loader size={50} /> } {props.loading && <Loader size={50} /> }
{props.cancelable && ( {props.cancelable && (
<CloseClick onClick={() => close()}> <CloseClick onClick={() => close()}>
<Icon icon={icons.CLOSE} size={25} /> <Icon
color={getIconColor(props.className)}
icon={icons.CLOSE}
size={20}
/>
</CloseClick> </CloseClick>
)} )}
<Body> <Body>
@ -148,9 +136,9 @@ export const Notification = (props: NProps): React$Element<string> => {
<ActionContent> <ActionContent>
{props.actions {props.actions
.map(action => ( .map(action => (
<Button <NotificationButton
key={action.label} key={action.label}
color={getButtonColor(props.className)} type={props.className}
text={action.label} text={action.label}
onClick={() => { close(); action.callback(); }} onClick={() => { close(); action.callback(); }}
/> />

View File

@ -0,0 +1,98 @@
import React from 'react';
import styled, { css } from 'styled-components';
import PropTypes from 'prop-types';
import Icon from 'components/Icon';
import colors from 'config/colors';
import { TRANSITION } from 'config/variables';
const Wrapper = styled.button`
padding: 12px 58px;
border-radius: 3px;
background: transparent;
font-size: 14px;
font-weight: 300;
cursor: pointer;
color: ${colors.WHITE};
border: 0;
transition: ${TRANSITION.HOVER};
${props => props.type === 'info' && css`
border: 1px solid ${colors.INFO_PRIMARY};
color: ${colors.INFO_PRIMARY};
&:hover {
color: ${colors.WHITE};
background: ${colors.INFO_PRIMARY};
}
`}
${props => props.type === 'success' && css`
border: 1px solid ${colors.SUCCESS_PRIMARY};
color: ${colors.SUCCESS_PRIMARY};
&:hover {
color: ${colors.WHITE};
background: ${colors.SUCCESS_PRIMARY};
}
`}
${props => props.type === 'error' && css`
border: 1px solid ${colors.ERROR_PRIMARY};
color: ${colors.ERROR_PRIMARY};
&:hover {
color: ${colors.WHITE};
background: ${colors.ERROR_PRIMARY};
}
`}
${props => props.type === 'warning' && css`
border: 1px solid ${colors.WARNING_PRIMARY};
color: ${colors.WARNING_PRIMARY};
&:hover {
color: ${colors.WHITE};
background: ${colors.WARNING_PRIMARY};
}
`}
`;
const IconWrapper = styled.span`
margin-right: 8px;
`;
const NotificationButton = ({
className, text, icon, onClick = () => { }, type = null,
}) => (
<Wrapper
className={className}
icon={icon}
onClick={onClick}
type={type}
>
{icon && (
<IconWrapper>
<Icon
icon={icon.type}
color={icon.color}
size={icon.size}
/>
</IconWrapper>
)}
{text}
</Wrapper>
);
NotificationButton.propTypes = {
type: PropTypes.string.isRequired,
className: PropTypes.string,
onClick: PropTypes.func,
icon: PropTypes.shape({
type: PropTypes.arrayOf(PropTypes.string).isRequired,
color: PropTypes.string,
size: PropTypes.number,
}),
text: PropTypes.string.isRequired,
};
export default NotificationButton;

View File

@ -11,6 +11,4 @@
@import './receive.less'; @import './receive.less';
@import './summary.less'; @import './summary.less';
@import './notification.less';
@import './inputs.less'; @import './inputs.less';

View File

@ -1,68 +0,0 @@
.notification {
.notification-action button {
padding: 12px 58px;
}
.notification-close {
position: absolute;
top: 8px;
right: 0;
padding: 12px;
color: inherit;
transition: opacity 0.3s;
z-index: 1;
&:after {
.icomoon-close;
}
&:active,
&:hover {
opacity: 0.6;
color: inherit;
}
}
&.success {
.notification-action button {
border: 1px solid @color_success_primary;
color: @color_success_primary;
&:hover {
color: @color_white;
background: @color_success_primary;
}
}
}
&.warning {
.notification-action button {
border: 1px solid @color_warning_primary;
color: @color_warning_primary;
&:hover {
color: @color_white;
background: @color_warning_primary;
}
}
}
&.error {
.notification-close {
color: @color_error_primary;
&:hover {
color: @color_error_primary;
}
}
.notification-action button {
border: 1px solid @color_error_primary;
color: @color_error_primary;
&:hover {
color: @color_white;
background: @color_error_primary;
}
}
}
}

View File

@ -2,6 +2,8 @@ import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Notification } from 'components/Notification';
import { H2 } from 'components/Heading'; import { H2 } from 'components/Heading';
import DashboardImg from 'images/dashboard.png'; import DashboardImg from 'images/dashboard.png';
@ -32,6 +34,46 @@ const P = styled.p`
const Dashboard = () => ( const Dashboard = () => (
<Wrapper> <Wrapper>
<Notification
title="TITLE TITLE TITLE TITLETITLE TITLE"
message="Config files are missing"
className="error"
actions={[{
label: 'Button action',
callback: () => false,
}]}
/>
<Notification
title="TITLE TITLE TITLE TITLETITLE TITLE"
message="Config files are missing"
className="warning"
actions={[{
label: 'Button action',
callback: () => false,
}]}
/>
<Notification
title="TITLE TITLE TITLE TITLETITLE TITLE"
message="Config files are missing"
className="success"
cancelable={false}
actions={[{
label: 'Button action',
callback: () => false,
}]}
/>
<Notification
title="TITLE TITLE TITLE TITLETITLE TITLE"
message="Description hahahah aloglg lfkdlfkdlfk"
className="info"
actions={[{
label: 'Button action',
callback: () => false,
}]}
/>
<StyledH2>Dashboard</StyledH2> <StyledH2>Dashboard</StyledH2>
<Row> <Row>
<H2>Please select your coin</H2> <H2>Please select your coin</H2>