Skip to content

Commit

Permalink
feat(Alert): add succes intent
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvanhoutte committed Nov 12, 2020
1 parent cbd71ee commit 1c9ab9b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
18 changes: 16 additions & 2 deletions src/components/Alert/Alert.module.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
.alert {
padding: 14.5px 18px;
background-color: var(--color-error-light);
display: flex;
align-items: center;
border-radius: var(--border-radius-small);
}

.alert.alertError {
background-color: var(--color-error-light);
}

.alert.alertSuccess {
background-color: var(--color-success-light);
}

.message {
display: inline-block;
}

svg.icon {
margin-right: 10px;
color: var(--color-error);
height: 16px;
width: 16px;
}

svg.icon.iconSuccess {
color: var(--color-success);
}

svg.icon.iconError {
color: var(--color-error);
}
17 changes: 14 additions & 3 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { AlertCircle } from 'react-feather';
import { AlertCircle, CheckCircle } from 'react-feather';
import classNames from 'classnames';

import cssReset from '../../css-reset.module.css';
Expand All @@ -14,11 +14,22 @@ interface Props {
}

const Alert: React.FC<Props> = ({ intent = 'error', message, className }: Props) => {
const mergedClassNames = classNames(cssReset.ventura, styles.alert, className);
const mergedClassNames = classNames(
cssReset.ventura,
styles.alert,
{
[styles.alertError]: intent === 'error',
[styles.alertSuccess]: intent === 'success',
},
className,
);

return (
<div className={mergedClassNames}>
{intent === 'error' && <AlertCircle className={styles.icon} />}
{intent === 'error' && <AlertCircle className={classNames(styles.icon, styles.iconError)} />}
{intent === 'success' && (
<CheckCircle className={classNames(styles.icon, styles.iconSuccess)} />
)}
<span className={styles.message}>{message}</span>
</div>
);
Expand Down
9 changes: 6 additions & 3 deletions src/components/Toaster/Toaster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ Toaster allow you to display status messages.
### Basic usage

<Playground>
<Button onClick={(event) => {
toaster.error('Error toaster')}
}>Click me</Button>
<Button onClick={(event) => {
toaster.error('Error toaster')}
}>Click me</Button>
<Button onClick={(event) => {
toaster.success('Success toaster')}
}>Click me</Button>
</Playground>
4 changes: 4 additions & 0 deletions src/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
--color-neutral-8: #2e2e2e;
--color-neutral-9: #000000;

--color-success-1: #e1f5e3;
--color-success-2:#5cc767;
--color-error-1: #ffe2e2;
--color-error-2: #eb3737;
}
Expand All @@ -31,6 +33,8 @@
--color-secondary-font: var(--color-neutral-8);
--color-secondary-hover: var(--color-neutral-2);

--color-success: var(--color-success-2);
--color-success-light: var(--color-success-1);
--color-error: var(--color-error-2);
--color-error-light: var(--color-error-1);

Expand Down

0 comments on commit 1c9ab9b

Please sign in to comment.