From cacda7aa8ba59fd2f2a9fd6f025857adaf212aa5 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Sat, 27 Aug 2022 23:05:56 +1000 Subject: [PATCH] Dialog replacement --- src/components/Dialog/HelpDialog.tsx | 15 +++--- src/components/Dialog/PeersDialog.tsx | 27 ++--------- src/components/Dialog/QRDialog.tsx | 16 ++++--- src/components/Dialog/RegionDialog.tsx | 5 +- src/components/Dialog/index.tsx | 63 ++++++++++++++++++++++++++ src/components/layout/AppLayout.tsx | 2 +- 6 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 src/components/Dialog/index.tsx diff --git a/src/components/Dialog/HelpDialog.tsx b/src/components/Dialog/HelpDialog.tsx index 87cb2dff..a7aa3808 100644 --- a/src/components/Dialog/HelpDialog.tsx +++ b/src/components/Dialog/HelpDialog.tsx @@ -1,8 +1,9 @@ import type React from "react"; -import { CogIcon, Dialog, Text } from "evergreen-ui"; +import { CogIcon, CrossIcon, IconButton, Text } from "evergreen-ui"; import { TabbedContent, TabType } from "../layout/page/TabbedContent.js"; +import { Dialog } from "./index.js"; export interface HelpDialogProps { isOpen: boolean; @@ -32,13 +33,11 @@ export const HelpDialog = ({ isOpen, close }: HelpDialogProps): JSX.Element => { ]; return ( - - + + ]} + /> ); }; diff --git a/src/components/Dialog/PeersDialog.tsx b/src/components/Dialog/PeersDialog.tsx index a4b9cfc1..e54e201c 100644 --- a/src/components/Dialog/PeersDialog.tsx +++ b/src/components/Dialog/PeersDialog.tsx @@ -1,7 +1,6 @@ import type React from "react"; import { - Dialog, HelperManagementIcon, IconButton, majorScale, @@ -16,6 +15,8 @@ import { useDevice } from "@core/providers/useDevice.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { Protobuf } from "@meshtastic/meshtasticjs"; +import { Dialog } from "./index.js"; + export interface PeersDialogProps { isOpen: boolean; close: () => void; @@ -29,13 +30,7 @@ export const PeersDialog = ({ useDevice(); return ( - + @@ -126,22 +121,6 @@ export const PeersDialog = ({ ))}
- {/* - - {node.data.user?.longName} - {node.metrics.airUtilTx} - {node.metrics.} - {node.metrics.channelUtilization} - {node.metrics.} - {node.data.} - */}
); }; diff --git a/src/components/Dialog/QRDialog.tsx b/src/components/Dialog/QRDialog.tsx index 0c11b5b3..ff724985 100644 --- a/src/components/Dialog/QRDialog.tsx +++ b/src/components/Dialog/QRDialog.tsx @@ -5,7 +5,6 @@ import { fromByteArray } from "base64-js"; import { Checkbox, ClipboardIcon, - Dialog, FormField, IconButton, majorScale, @@ -17,6 +16,8 @@ import { QRCode } from "react-qrcode-logo"; import { Protobuf } from "@meshtastic/meshtasticjs"; +import { Dialog } from "./index.js"; + export interface QRDialogProps { isOpen: boolean; close: () => void; @@ -53,12 +54,13 @@ export const QRDialog = ({ }, [channels, selectedChannels, loraConfig]); return ( - + // + { }); return ( - +
void; + title?: string; + background?: boolean; + width?: number; + children: React.ReactNode; +} + +export const Dialog = ({ + isOpen, + close, + title, + background, + width, + children, +}: DialogProps): JSX.Element => { + return ( + + + {background && ( + + {title} + + + )} + + {children} + + + ); +}; diff --git a/src/components/layout/AppLayout.tsx b/src/components/layout/AppLayout.tsx index b5eac1ae..ca93b9ff 100644 --- a/src/components/layout/AppLayout.tsx +++ b/src/components/layout/AppLayout.tsx @@ -31,7 +31,7 @@ export const AppLayout = ({ children }: AppLayoutProps): JSX.Element => { minHeight="100vh" >
- + {devices.length ? ( devices.map((device) => (