From 41ad0c00c002c7f382d047ba7a80e7a8b52fa706 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Fri, 23 Sep 2022 00:41:37 +1000 Subject: [PATCH] Add disclosure to widgets --- src/components/Card.tsx | 2 +- src/components/Dropdown.tsx | 39 ++++++++++ src/components/Widgets/BatteryWidget.tsx | 29 +++++--- src/components/Widgets/ConfiguringWidget.tsx | 78 ++++++++++---------- src/components/Widgets/NodeInfoWidget.tsx | 36 +++++---- src/components/Widgets/PeersWidget.tsx | 17 +++-- src/components/Widgets/PositionWidget.tsx | 18 ++--- 7 files changed, 137 insertions(+), 82 deletions(-) create mode 100644 src/components/Dropdown.tsx diff --git a/src/components/Card.tsx b/src/components/Card.tsx index e653756d..e43f7b84 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -7,7 +7,7 @@ export const Card = ({ }: JSX.IntrinsicElements["div"]): JSX.Element => { return (
{ + return ( + + {({ open }) => ( + <> + +
+
{icon}
+ {title} +
+
+ {open ? ( + + ) : ( + + )} +
+
+ {children} + + )} +
+ ); +}; diff --git a/src/components/Widgets/BatteryWidget.tsx b/src/components/Widgets/BatteryWidget.tsx index 3a631004..a2ad7238 100644 --- a/src/components/Widgets/BatteryWidget.tsx +++ b/src/components/Widgets/BatteryWidget.tsx @@ -1,8 +1,10 @@ import type React from "react"; -import { BoltIcon } from "@heroicons/react/24/outline"; +import { Battery100Icon, BoltIcon } from "@heroicons/react/24/outline"; import { Card } from "../Card.js"; +import { Dropdown } from "../Dropdown.js"; +import { Mono } from "../Mono.js"; export interface BatteryWidgetProps { batteryLevel: number; @@ -14,17 +16,22 @@ export const BatteryWidget = ({ voltage, }: BatteryWidgetProps): JSX.Element => { return ( - -
- -
-
-
- Power + + }> +
+
+ +
+ + {batteryLevel} + % + + + {voltage} + v +
- {batteryLevel} - {voltage} -
+ ); }; diff --git a/src/components/Widgets/ConfiguringWidget.tsx b/src/components/Widgets/ConfiguringWidget.tsx index ba148182..a8a65e79 100644 --- a/src/components/Widgets/ConfiguringWidget.tsx +++ b/src/components/Widgets/ConfiguringWidget.tsx @@ -1,9 +1,11 @@ import React, { useEffect } from "react"; import { useDevice } from "@core/providers/useDevice.js"; +import { AdjustmentsHorizontalIcon } from "@heroicons/react/24/outline"; import { Button } from "../Button.js"; import { Card } from "../Card.js"; +import { Dropdown } from "../Dropdown.js"; export const ConfiguringWidget = (): JSX.Element => { const { @@ -36,43 +38,45 @@ export const ConfiguringWidget = (): JSX.Element => { return ( -
- Power -
-
-
    - - - - - -
- -
+ } + > +
+
    + + + + + +
+ +
+
); }; diff --git a/src/components/Widgets/NodeInfoWidget.tsx b/src/components/Widgets/NodeInfoWidget.tsx index f3e376a3..3d5beb59 100644 --- a/src/components/Widgets/NodeInfoWidget.tsx +++ b/src/components/Widgets/NodeInfoWidget.tsx @@ -1,8 +1,10 @@ import type React from "react"; +import { InformationCircleIcon } from "@heroicons/react/24/outline"; import type { Protobuf } from "@meshtastic/meshtasticjs"; import { Card } from "../Card.js"; +import { Dropdown } from "../Dropdown.js"; export interface NodeInfoWidgetProps { hardware: Protobuf.MyNodeInfo; @@ -13,26 +15,28 @@ export const NodeInfoWidget = ({ }: NodeInfoWidgetProps): JSX.Element => { return ( -
- Information -
-
-
+ } + > +
+
+
+
Firmware version
+
+ {hardware.firmwareVersion} +
+
+
-
Firmware version
-
- {hardware.firmwareVersion} +
Bitrate
+
+ {hardware.bitrate.toFixed(2)} + bps
-
-
-
Bitrate
-
- {hardware.bitrate.toFixed(2)} - bps -
-
+
); }; diff --git a/src/components/Widgets/PeersWidget.tsx b/src/components/Widgets/PeersWidget.tsx index 0b7af404..eca85aa1 100644 --- a/src/components/Widgets/PeersWidget.tsx +++ b/src/components/Widgets/PeersWidget.tsx @@ -3,10 +3,14 @@ import type React from "react"; import { base16 } from "rfc4648"; import { Hashicon } from "@emeraldpay/hashicon-react"; -import { EllipsisHorizontalCircleIcon } from "@heroicons/react/24/outline"; +import { + EllipsisHorizontalCircleIcon, + UserGroupIcon, +} from "@heroicons/react/24/outline"; import type { Protobuf } from "@meshtastic/meshtasticjs"; import { Card } from "../Card.js"; +import { Dropdown } from "../Dropdown.js"; import { IconButton } from "../IconButton.js"; import { Mono } from "../Mono.js"; @@ -16,12 +20,9 @@ export interface PeersWidgetProps { export const PeersWidget = ({ peers }: PeersWidgetProps): JSX.Element => { return ( - -
-
- Peers -
-
+ + }> +
{peers.map((peer) => (
{
))}
-
+ ); }; diff --git a/src/components/Widgets/PositionWidget.tsx b/src/components/Widgets/PositionWidget.tsx index 9dd520e2..3686aa22 100644 --- a/src/components/Widgets/PositionWidget.tsx +++ b/src/components/Widgets/PositionWidget.tsx @@ -3,6 +3,7 @@ import type React from "react"; import { MapPinIcon } from "@heroicons/react/24/outline"; import { Card } from "../Card.js"; +import { Dropdown } from "../Dropdown.js"; export interface PositionWidgetProps { grid: string; @@ -10,16 +11,15 @@ export interface PositionWidgetProps { export const PositionWidget = ({ grid }: PositionWidgetProps): JSX.Element => { return ( - -
- -
-
-
- Position + + }> +
+
+ +
+ {grid}
- {grid} -
+ ); };