Skip to content

Commit

Permalink
feat(*): added toast
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Mar 21, 2022
1 parent 8384ce2 commit bce44a5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Components/Toast/Toast.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

.Toast {
background: white;
border-left: 1rem solid #8a8a8a;
border-radius: 0.5rem;
box-shadow: 0.125rem 0.125rem 0.25rem rgba(0, 0, 0, 0.25);
display: flex;
font-family: Helvetica;
justify-content: space-between;
padding: 1rem;
margin: 1rem auto;
width: 25rem;
}

.Toast--success {
border-color: #008554;
}

.Toast--warning {
border-color: #FFC627;
}

.Toast--error {
border-color: #D14229;
}

.Toast__message-category {
font-weight: bold;
font-size: 1.25rem;
margin-bottom: 0.5rem;
margin-top: 0;
text-transform: capitalize;
}

.Toast__message-text {
margin-bottom: 0;
}

.Toast__button {
background: transparent;
border: none;
font-family: inherit;
font-size: inherit;
margin-left: 1rem;
opacity: 0.5;
padding: 0;
}
Run Pen

Resources
44 changes: 44 additions & 0 deletions src/Components/Toast/Toast.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import './Toast.css'
const toasts = [
{
category: "success",
message: "Right on! Your account has been updated."
},
{
category: "warning",
message: "Hmmm. Something doesn't look right."
},
{
category: "error",
message: "Uh oh! Something went terribly wrong!"
}
];

function Toast(props) {
return (
<div className={`Toast Toast--${props.category}`}>
<main className="Toast__message">
<header className="Toast__message-category">{props.category}</header>
<p className="Toast__message-text">{props.message}</p>
</main>
<button className="Toast__button" type="button" onClick={() => props.dismiss(props.id)}>
Dismiss
</button>
</div>
);
}

// class App extends React.Component {
// render() {
// return (
// <div>
// {toasts.map((toast, i) => (
// <Toast category={toast.category} key={i} message={toast.message} />
// ))}
// </div>
// );
// }
// }

export default Toast;

0 comments on commit bce44a5

Please sign in to comment.