-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add toast notifications for experiment save success and error h…
…andling
- Loading branch information
1 parent
255ebe8
commit 471ae3d
Showing
5 changed files
with
111 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
backend/experiment/templates/form/experiment-form/src/components/Toast.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Toast as ToastType } from '../utils/store'; | ||
|
||
interface ToastProps { | ||
toast: ToastType; | ||
} | ||
|
||
export const Toast: React.FC<ToastProps> = ({ toast }) => { | ||
const bgColorClass = { | ||
info: 'bg-gray-800', | ||
warning: 'bg-yellow-600', | ||
error: 'bg-red-600' | ||
}[toast.level]; | ||
|
||
return ( | ||
<div className={`fixed bottom-4 right-4 ${bgColorClass} text-white px-6 py-3 rounded-lg shadow-lg transition-all duration-300 ease-in-out`}> | ||
<p>{toast.message}</p> | ||
</div> | ||
); | ||
}; |
14 changes: 14 additions & 0 deletions
14
backend/experiment/templates/form/experiment-form/src/components/Toasts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useBoundStore } from '../utils/store'; | ||
import { Toast } from './Toast'; | ||
|
||
export const Toasts: React.FC = () => { | ||
const toasts = useBoundStore((state) => state.toasts); | ||
|
||
return ( | ||
<div className="fixed bottom-4 right-4 flex flex-col gap-2"> | ||
{toasts.map((toast, index) => ( | ||
<Toast key={index} toast={toast} /> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters