Created
November 12, 2021 07:55
-
-
Save davidjbeaver/63caf252ccc97c61be9710e2ec48116e to your computer and use it in GitHub Desktop.
SolidJS Toast Tutorial - types.ts
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
import { For } from "solid-js"; | |
import store from "./store"; | |
import { ToastObject, ToastType } from "./types"; | |
const Toast = () => { | |
return ( | |
<div class="toast-container"> | |
<For each={store.toastStore.toasts}> | |
{(toast: ToastObject) => ( | |
<div class="toast" className={toast.toastType}> | |
<i | |
class="icon" | |
classList={{ | |
"icon-check-circle": toast.toastType === ToastType.Success, | |
"icon-x-circle": toast.toastType === ToastType.Error, | |
"icon-alert-circle": toast.toastType === ToastType.Warning, | |
"icon-info": toast.toastType === ToastType.Info, | |
}} | |
></i> | |
<span>{toast.message}</span> | |
<button onClick={() => store.removeToast(toast.toastId)}>X</button> | |
</div> | |
)} | |
</For> | |
</div> | |
); | |
}; | |
export default Toast |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment