From 5300df4bb40ff3ccd8b7c1703711d107e214f28f Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 21 Dec 2023 23:38:36 +1100 Subject: [PATCH] General UI changes --- .../src/components/app-bar/FeaturePicker.tsx | 37 +++++--- client/src/components/generic/Select.tsx | 29 ++++--- .../components/inspector/EventInspector.tsx | 2 +- client/src/pages/DebugPage.tsx | 11 ++- client/src/pages/Page.tsx | 2 +- client/src/pages/index.tsx | 87 ++++++++++++------- client/src/slices/view.ts | 20 ++++- client/src/theme.tsx | 15 +++- 8 files changed, 141 insertions(+), 62 deletions(-) diff --git a/client/src/components/app-bar/FeaturePicker.tsx b/client/src/components/app-bar/FeaturePicker.tsx index cfeb93fa..95a28d57 100644 --- a/client/src/components/app-bar/FeaturePicker.tsx +++ b/client/src/components/app-bar/FeaturePicker.tsx @@ -1,20 +1,23 @@ -import { ButtonProps, Typography as Type } from "@mui/material"; +import { Box, ButtonProps, Typography as Type, useTheme } from "@mui/material"; import { Select } from "components/generic/Select"; -import { Space } from "components/generic/Space"; import { find, map, startCase } from "lodash"; import { FeatureDescriptor } from "protocol/FeatureQuery"; -import { ReactNode } from "react"; +import { ReactElement, ReactNode, cloneElement } from "react"; +import { AccentColor, getShade } from "theme"; import { FeaturePickerButton } from "./FeaturePickerButton"; +import { Flex } from "components/generic/Flex"; +import { Space } from "components/generic/Space"; export type Props = { label?: string; value?: string; onChange?: (key: string) => void; - items?: FeatureDescriptor[]; + items?: (FeatureDescriptor & { icon?: ReactNode; color?: AccentColor })[]; icon?: ReactNode; showArrow?: boolean; disabled?: boolean; ButtonProps?: ButtonProps; + itemOrientation?: "vertical" | "horizontal"; }; export function FeaturePicker({ @@ -26,7 +29,18 @@ export function FeaturePicker({ showArrow, disabled, ButtonProps, + itemOrientation = "horizontal", }: Props) { + const { palette } = useTheme(); + + const getIcon = (icon: ReactNode, color?: AccentColor) => + icon && + cloneElement(icon as ReactElement, { + sx: { + color: color ? getShade(color, palette.mode) : "primary.main", + }, + }); + const selected = find(items, { id: value }); return (