Skip to content

Commit

Permalink
Added close button for toast (ToolJet#3821)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavinvenkatachalam authored Aug 24, 2022
1 parent 4199001 commit 11c9451
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ResetPassword } from '@/ResetPassword';
import { ManageSSO } from '@/ManageSSO';
import { ManageOrgVars } from '@/ManageOrgVars';
import { lt } from 'semver';
import { Toaster } from 'react-hot-toast';
import Toast from '@/_ui/Toast';
import { RealtimeEditor } from '@/Editor/RealtimeEditor';
import { Editor } from '@/Editor/Editor';
import { RedirectSso } from '@/RedirectSso/RedirectSso';
Expand Down Expand Up @@ -76,6 +76,7 @@ class App extends React.Component {

if (darkMode) {
toastOptions = {
className: 'toast-dark-mode',
style: {
borderRadius: '10px',
background: '#333',
Expand Down Expand Up @@ -259,7 +260,7 @@ class App extends React.Component {
/>
</div>
</Router>
<Toaster toastOptions={toastOptions} />
<Toast toastOptions={toastOptions} />
</>
);
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/_styles/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5034,6 +5034,12 @@ div#driver-page-overlay {
}
}

.toast-dark-mode {
.btn-close {
filter: brightness(0) invert(1);
}
}

.editor .editor-sidebar .inspector .form-control-plaintext {
padding: 2px 4px;
}
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/_ui/Toast/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { toast, Toaster, ToastBar } from 'react-hot-toast';

const Toast = ({ toastOptions }) => {
return (
<Toaster toastOptions={toastOptions}>
{(t) => (
<ToastBar toast={t}>
{({ icon, message }) => (
<>
{icon}
{message}
<button className="btn-close" onClick={() => toast.dismiss(t.id)} />
</>
)}
</ToastBar>
)}
</Toaster>
);
};

export default Toast;

0 comments on commit 11c9451

Please sign in to comment.