|
| 1 | +import * as React from "react" |
| 2 | +import Button from "@mui/material/Button" |
| 3 | +import Dialog from "@mui/material/Dialog" |
| 4 | +import DialogActions from "@mui/material/DialogActions" |
| 5 | +import DialogContent from "@mui/material/DialogContent" |
| 6 | +import DialogTitle from "@mui/material/DialogTitle" |
| 7 | +import Box from "@mui/material/Box" |
| 8 | +import Typography from "@mui/material/Typography" |
| 9 | +import { useTranslation } from "react-i18next" |
| 10 | + |
| 11 | +export const ShortcutsDialog = ({ open, handleClose }) => { |
| 12 | + const { t } = useTranslation() |
| 13 | + |
| 14 | + const shortcuts = [ |
| 15 | + { key: "Ctrl + Shift + B", action: t("helptext_boundingbox") }, |
| 16 | + { key: "Ctrl + Shift + Z", action: t("helptext_zoom") }, |
| 17 | + { key: "Ctrl + Shift + P", action: t("helptext_polypolygon") }, |
| 18 | + { key: "Ctrl + Shift + C", action: t("helptext_circle") }, |
| 19 | + { key: "↑", action: t("short_key_up") }, // Up arrow key for navigation |
| 20 | + { key: "↓", action: t("short_key_down") }, // Down arrow key for navigation |
| 21 | + ] |
| 22 | + |
| 23 | + return ( |
| 24 | + <Dialog |
| 25 | + open={open} |
| 26 | + onClose={handleClose} |
| 27 | + aria-labelledby="shortcuts-dialog-title" |
| 28 | + aria-describedby="shortcuts-dialog-description" |
| 29 | + data-testid="shortcuts-dialog" |
| 30 | + fullWidth |
| 31 | + maxWidth="sm" |
| 32 | + PaperProps={{ |
| 33 | + style: { |
| 34 | + minHeight: "40vh", |
| 35 | + maxHeight: "80vh", |
| 36 | + padding: "20px", |
| 37 | + }, |
| 38 | + }} |
| 39 | + > |
| 40 | + <DialogTitle id="shortcuts-dialog-title" data-testid="shortcuts-dialog-title"> |
| 41 | + {t("Keyboard Shortcuts")} |
| 42 | + </DialogTitle> |
| 43 | + <DialogContent data-testid="shortcuts-dialog-content"> |
| 44 | + <Box display="flex" flexDirection="column" gap={2}> |
| 45 | + {shortcuts.map((shortcut, index) => ( |
| 46 | + <Box |
| 47 | + key={index} |
| 48 | + display="flex" |
| 49 | + justifyContent="space-between" |
| 50 | + alignItems="center" |
| 51 | + px={1} |
| 52 | + > |
| 53 | + <Typography variant="body1" data-testid={`shortcut-key-${index}`}> |
| 54 | + {shortcut.key} |
| 55 | + </Typography> |
| 56 | + <Typography variant="body2" data-testid={`shortcut-action-${index}`}> |
| 57 | + {shortcut.action} |
| 58 | + </Typography> |
| 59 | + </Box> |
| 60 | + ))} |
| 61 | + </Box> |
| 62 | + </DialogContent> |
| 63 | + <DialogActions data-testid="shortcuts-dialog-actions"> |
| 64 | + <Button onClick={handleClose} data-testid="close-button"> |
| 65 | + {t("Close")} |
| 66 | + </Button> |
| 67 | + </DialogActions> |
| 68 | + </Dialog> |
| 69 | + ) |
| 70 | +} |
| 71 | + |
| 72 | +export default ShortcutsDialog |
0 commit comments