1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-28 03:08:30 +00:00

Refactored notifications buttons

This commit is contained in:
Vladimir Volek 2018-08-29 11:33:17 +02:00
parent a4720fc2e3
commit 59ce098c92
3 changed files with 60 additions and 16 deletions

View File

@ -41,6 +41,30 @@ const Wrapper = styled.button`
} }
`} `}
${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

@ -76,9 +76,28 @@ const CloseClick = 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 actionButtons = props.actions ? props.actions.map((a, i) => (
<button key={i} onClick={(event) => { close(); a.callback(); }} className="transparent">{ a.label }</button> const getButtonColor = (type) => {
)) : null; 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;
};
return ( return (
<Wrapper type={props.className}> <Wrapper type={props.className}>
@ -92,18 +111,19 @@ export const Notification = (props: NProps): React$Element<string> => {
<H2>{ props.title }</H2> <H2>{ props.title }</H2>
{ props.message && <p dangerouslySetInnerHTML={{ __html: props.message }} /> } { props.message && <p dangerouslySetInnerHTML={{ __html: props.message }} /> }
</Body> </Body>
{ props.actions && props.actions.length > 0 ? ( { props.actions && props.actions.length > 0 && (
<ActionContent> <ActionContent>
{props.actions {props.actions
.map(action => ( .map(action => (
<Button <Button
color={props.className} color={getButtonColor(props.className)}
text={action.label} text={action.label}
onClick={() => { close(); action.callback(); }} onClick={() => { close(); action.callback(); }}
/> />
))} ))}
</ActionContent> </ActionContent>
) : null } )
}
{ props.loading && <Loader size={50} /> } { props.loading && <Loader size={50} /> }
</Wrapper> </Wrapper>

View File

@ -23,16 +23,16 @@
} }
} }
&.info { // &.info {
.notification-action button { // .notification-action button {
border: 1px solid @color_info_primary; // border: 1px solid @color_info_primary;
color: @color_info_primary; // color: @color_info_primary;
&:hover { // &:hover {
color: @color_white; // color: @color_white;
background: @color_info_primary; // background: @color_info_primary;
} // }
} // }
} // }
&.success { &.success {