|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import { |
4 | | - Button, |
5 | | - Dialog, |
6 | | - DialogActions, |
7 | | - DialogContent, |
8 | | - DialogContentText, |
9 | | - DialogTitle, |
10 | | -} from "@mui/material"; |
11 | 3 | import { type ReactNode, createContext, useContext, useState } from "react"; |
12 | 4 |
|
13 | 5 | export type Alert = { |
@@ -49,27 +41,34 @@ export const AlertProvider = ({ children }: AlertProviderProps) => { |
49 | 41 | <AlertContext.Provider value={{ showAlert }}> |
50 | 42 | {children} |
51 | 43 | {alertProps && ( |
52 | | - <Dialog |
53 | | - open={true} |
| 44 | + // https://daisyui.com/components/modal/#method-1-using-dialog-element-recommended |
| 45 | + // TODO: 挙動を修正 (外をクリックしたり ESC を押したときに閉じるようにする) |
| 46 | + <dialog |
| 47 | + id="alert-dialog" |
| 48 | + className="modal modal-open" |
54 | 49 | onClose={handleClose} |
55 | | - aria-labelledby="alert-dialog-title" |
56 | | - aria-describedby="alert-dialog-description" |
57 | 50 | > |
58 | | - <DialogTitle id="alert-dialog-title"> |
59 | | - {alertProps.AlertMessage} |
60 | | - </DialogTitle> |
61 | | - <DialogContent> |
62 | | - <DialogContentText id="alert-dialog-description"> |
63 | | - {alertProps.subAlertMessage} |
64 | | - </DialogContentText> |
65 | | - </DialogContent> |
66 | | - <DialogActions> |
67 | | - <Button onClick={handleYesClick} autoFocus sx={{ color: "red" }}> |
68 | | - {alertProps.yesMessage} |
69 | | - </Button> |
70 | | - <Button onClick={handleClose}>キャンセル</Button> |
71 | | - </DialogActions> |
72 | | - </Dialog> |
| 51 | + <div className="modal-box"> |
| 52 | + <h3 className="font-bold text-lg">{alertProps.AlertMessage}</h3> |
| 53 | + <p className="py-4">{alertProps.subAlertMessage}</p> |
| 54 | + <div className="modal-action"> |
| 55 | + <form method="dialog"> |
| 56 | + <div className="flex gap-3"> |
| 57 | + <button |
| 58 | + type="button" |
| 59 | + className="btn text-red-500" |
| 60 | + onClick={handleYesClick} |
| 61 | + > |
| 62 | + {alertProps.yesMessage} |
| 63 | + </button> |
| 64 | + <button type="button" className="btn" onClick={handleClose}> |
| 65 | + キャンセル |
| 66 | + </button> |
| 67 | + </div> |
| 68 | + </form> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + </dialog> |
73 | 72 | )} |
74 | 73 | </AlertContext.Provider> |
75 | 74 | ); |
|
0 commit comments