Skip to content

Commit 0f0adae

Browse files
committed
AlertDialog を実装
1 parent c48eb85 commit 0f0adae

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

web/components/common/alert/AlertProvider.tsx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
"use client";
22

3-
import {
4-
Button,
5-
Dialog,
6-
DialogActions,
7-
DialogContent,
8-
DialogContentText,
9-
DialogTitle,
10-
} from "@mui/material";
113
import { type ReactNode, createContext, useContext, useState } from "react";
124

135
export type Alert = {
@@ -49,27 +41,34 @@ export const AlertProvider = ({ children }: AlertProviderProps) => {
4941
<AlertContext.Provider value={{ showAlert }}>
5042
{children}
5143
{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"
5449
onClose={handleClose}
55-
aria-labelledby="alert-dialog-title"
56-
aria-describedby="alert-dialog-description"
5750
>
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>
7372
)}
7473
</AlertContext.Provider>
7574
);

web/tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default {
1818
"base-100": "#ffffff",
1919

2020
"--rounded-btn": "0.25rem",
21+
"--rounded-box": "0.25rem",
2122
},
2223
},
2324
],

0 commit comments

Comments
 (0)