-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTutorialDialog.tsx
More file actions
100 lines (99 loc) · 2.42 KB
/
TutorialDialog.tsx
File metadata and controls
100 lines (99 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { useState, type Dispatch, type SetStateAction } from "react";
import { type TutorialDialogSteps } from "@/types/Tutorial";
import {
Dialog,
DialogTitle,
DialogContent,
DialogActions,
Typography,
IconButton,
} from "@mui/material";
import CloseIcon from "@mui/icons-material/Close";
import CommonButton from "./CommonButton";
export default function TutorialDialog({
open,
setOpen,
tutorialDialogSteps,
}: {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
tutorialDialogSteps: TutorialDialogSteps;
}): JSX.Element {
const [selectedStep, setSelectedStep] = useState<number>(0);
function closeDialog(): void {
setOpen(false);
setSelectedStep(0);
}
return (
<Dialog
open={open}
onClose={() => {
closeDialog();
}}
scroll="paper"
fullWidth
maxWidth={false}
PaperProps={{
sx: {
height: "100%",
},
}}
>
<DialogTitle m={0} p={2}>
<Typography
variant="h4"
component="div"
color="inherit"
sx={{ fontWeight: "bold" }}
>
{tutorialDialogSteps[selectedStep].title}
</Typography>
<IconButton
sx={{ position: "absolute", right: 8, top: 8 }}
onClick={() => {
closeDialog();
}}
>
<CloseIcon />
</IconButton>
</DialogTitle>
<DialogContent dividers>
{tutorialDialogSteps[selectedStep].content}
</DialogContent>
<DialogActions>
<CommonButton
variant="outlined"
disabled={selectedStep === 0}
onClick={() => {
if (selectedStep > 0) {
setSelectedStep(selectedStep - 1);
}
}}
>
前へ
</CommonButton>
<CommonButton
variant="outlined"
disabled={selectedStep === tutorialDialogSteps.length - 1}
onClick={() => {
if (selectedStep < tutorialDialogSteps.length - 1) {
setSelectedStep(selectedStep + 1);
}
}}
>
次へ
</CommonButton>
{selectedStep === tutorialDialogSteps.length - 1 && (
<CommonButton
variant="contained"
onClick={() => {
closeDialog();
}}
>
はじめる
</CommonButton>
)}
</DialogActions>
</Dialog>
);
}