From 1f1b57e4b4af3cd648ac95dd48bafa827a6b24d9 Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 9 Jan 2023 15:52:50 +0100 Subject: [PATCH] Using a dialog for confirm delete alert. --- src/components/alert/Alert.tsx | 33 +++++++++++++++++ src/components/alert/index.ts | 1 + src/components/dialog/Dialog.tsx | 38 +++++++++++--------- src/components/trk/TrkViewer.tsx | 61 ++++++++++++++++---------------- 4 files changed, 86 insertions(+), 47 deletions(-) create mode 100644 src/components/alert/Alert.tsx create mode 100644 src/components/alert/index.ts diff --git a/src/components/alert/Alert.tsx b/src/components/alert/Alert.tsx new file mode 100644 index 0000000..7e6c6a6 --- /dev/null +++ b/src/components/alert/Alert.tsx @@ -0,0 +1,33 @@ +import { Component, JSXElement } from 'solid-js'; + +import { Alert as MuiAlert } from '@suid/material'; +import { AlertColor } from '@suid/material/Alert'; +import Dialog from '../dialog'; + +interface Props { + open: boolean; + closeHandler: (event: any, reason?: string) => void; + severity?: AlertColor; + icon?: JSXElement; + action?: JSXElement; + children?: JSXElement; +} + +const Alert: Component = ({ + open, + closeHandler, + severity, + icon, + action, + children, +}) => { + return ( + + + {children} + + + ); +}; + +export default Alert; diff --git a/src/components/alert/index.ts b/src/components/alert/index.ts new file mode 100644 index 0000000..becaea7 --- /dev/null +++ b/src/components/alert/index.ts @@ -0,0 +1 @@ +export { default } from './Alert'; diff --git a/src/components/dialog/Dialog.tsx b/src/components/dialog/Dialog.tsx index 77bf896..c764fc6 100644 --- a/src/components/dialog/Dialog.tsx +++ b/src/components/dialog/Dialog.tsx @@ -1,4 +1,4 @@ -import { Component, JSXElement } from 'solid-js'; +import { Component, JSXElement, Show } from 'solid-js'; import { Dialog as MuiDialog, DialogContent, @@ -10,7 +10,8 @@ import CloseIcon from '@suid/icons-material/Close'; const Dialog: Component<{ open: boolean; fullScreen?: boolean; - title: JSXElement; + maxWidth?: boolean; + title?: JSXElement; closeHandler: (event: any, reason?: string) => void; children: JSXElement; }> = (props) => { @@ -21,24 +22,27 @@ const Dialog: Component<{ PaperProps={{ sx: { minWidth: '300px' } }} fullScreen={props.fullScreen} > - - - - - {props.title} - + + + + + + {props.title} + + {props.children} diff --git a/src/components/trk/TrkViewer.tsx b/src/components/trk/TrkViewer.tsx index 21eb44f..ee5d963 100644 --- a/src/components/trk/TrkViewer.tsx +++ b/src/components/trk/TrkViewer.tsx @@ -3,10 +3,11 @@ import { peekCachedSignal } from '../../workers/cached-signals'; import Tree from '../tree'; import TrkIcon from '../../icons/human-footprints-svgrepo-com.svg?component-solid'; import { TrksegViewer } from '../trkseg'; -import { Alert, Button, IconButton } from '@suid/material'; +import { Button, IconButton } from '@suid/material'; import DeleteIcon from '@suid/icons-material/Delete'; import QuestionMarkIcon from '@suid/icons-material/QuestionMark'; import dispatch from '../../workers/dispatcher-main'; +import Alert from '../alert'; interface Props { trkId: string; @@ -64,7 +65,7 @@ const TrkViewer: Component = ({ trkId, restrictToHierarchy }) => {
- +
@@ -82,34 +83,34 @@ const TrkViewer: Component = ({ trkId, restrictToHierarchy }) => { } /> - - } - action={ - <> - - - - } - > - Delete this track ? - - + } + action={ + <> + + + + } + > + Delete this track ? + ); };