diff --git a/app/packages/components/src/components/ThemeProvider/index.tsx b/app/packages/components/src/components/ThemeProvider/index.tsx index e4a99b5ba5..79a48aaab6 100644 --- a/app/packages/components/src/components/ThemeProvider/index.tsx +++ b/app/packages/components/src/components/ThemeProvider/index.tsx @@ -49,6 +49,7 @@ let theme = extendMuiTheme({ viewBarButtons: "hsl(200, 0%, 100%)", inactiveTab: "hsl(200, 0%, 90%)", popup: "hsl(200, 0%, 95%)", + field: "hsl(200, 0%, 95%)", }, divider: "hsl(200, 0%, 80%)", dividerDisabled: "hsl(200, 0%, 85%)", @@ -123,6 +124,7 @@ let theme = extendMuiTheme({ inactiveTab: "hsl(200, 0%, 18%)", paper: "hsl(200, 0%, 10%)", popup: "hsl(200, 0%, 20%)", + field: "hsl(200, 0%, 20%, 0.3)", }, divider: "hsl(200, 0%, 20%)", dividerDisabled: "hsl(200, 0%, 15%)", diff --git a/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx b/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx index 8ff2fa35d0..f5d637da1d 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx @@ -4,9 +4,10 @@ import { usePanelId } from "@fiftyone/spaces"; import { isNullish } from "@fiftyone/utilities"; import { Box, ButtonProps, Typography } from "@mui/material"; import React from "react"; -import { getComponentProps } from "../utils"; +import { getComponentProps, getColorByCode } from "../utils"; import { ViewPropsType } from "../utils/types"; import Button from "./Button"; +import TooltipProvider from "./TooltipProvider"; export default function ButtonView(props: ViewPropsType) { const { schema, path } = props; @@ -20,6 +21,7 @@ export default function ButtonView(props: ViewPropsType) { operator, params = {}, prompt, + title, } = view; const panelId = usePanelId(); const handleClick = usePanelEvent(); @@ -35,25 +37,31 @@ export default function ButtonView(props: ViewPropsType) { return ( - + + + ); } function getButtonProps(props: ViewPropsType): ButtonProps { - const { label, variant } = props.schema.view; + const { label, variant, color } = props.schema.view; const baseProps: ButtonProps = getCommonProps(props); if (isNullish(label)) { baseProps.sx["& .MuiButton-startIcon"] = { mr: 0, ml: 0 }; @@ -66,10 +74,21 @@ function getButtonProps(props: ViewPropsType): ButtonProps { } if (variant === "square") { baseProps.sx.borderRadius = "3px 3px 0 0"; - baseProps.sx.backgroundColor = (theme) => theme.palette.neutral.softBg; + baseProps.sx.backgroundColor = (theme) => theme.palette.background.field; baseProps.sx.borderBottom = "1px solid"; + baseProps.sx.paddingBottom = "5px"; baseProps.sx.borderColor = (theme) => theme.palette.primary.main; } + if (variant === "outlined") { + baseProps.sx.p = "5px"; + } + if ((variant === "square" || variant === "outlined") && isNullish(color)) { + const borderColor = + "rgba(var(--fo-palette-common-onBackgroundChannel) / 0.23)"; + baseProps.sx.borderColor = borderColor; + baseProps.sx.borderBottomColor = borderColor; + } + return baseProps; } @@ -95,10 +114,7 @@ function getCommonProps(props: ViewPropsType): ButtonProps { function getColor(props: ViewPropsType) { const color = props.schema.view.color; if (color) { - if (color === "primary") return (theme) => theme.palette.text.primary; - if (color === "secondary") return (theme) => theme.palette.text.secondary; - if (color === "orange") return (theme) => theme.palette.primary.main; - return color; + return getColorByCode(color); } const variant = getVariant(props); return (theme) => { diff --git a/app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx b/app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx index acda73f920..4caadbd7f3 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/ContainerizedComponent.tsx @@ -1,6 +1,11 @@ import { Box, Paper, PaperProps } from "@mui/material"; import React, { PropsWithChildren } from "react"; -import { isCompositeView, overlayToSx } from "../utils"; +import { + getMarginSx, + getPaddingSx, + isCompositeView, + overlayToSx, +} from "../utils"; import { ViewPropsType } from "../utils/types"; export default function ContainerizedComponent(props: ContainerizedComponent) { @@ -29,9 +34,16 @@ export default function ContainerizedComponent(props: ContainerizedComponent) { } function PaperContainer(props: PaperContainerProps) { - const { elevation = 1, children, ...paperProps } = props; + const { elevation = 1, children, rounded = true, ...paperProps } = props; + const roundedSx = rounded ? {} : { borderRadius: 0 }; + const paddingSx = getPaddingSx(props); + const marginSx = getMarginSx(props); return ( - + {children} ); @@ -45,4 +57,6 @@ const containersByName = { PaperContainer, OutlinedContainer }; type ContainerizedComponent = PropsWithChildren; -type PaperContainerProps = PropsWithChildren; +type PaperContainerProps = PropsWithChildren< + PaperProps & { rounded?: boolean } +>; diff --git a/app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx b/app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx index ec352aca95..00597c0631 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/DropdownView.tsx @@ -1,12 +1,12 @@ import { MenuItem, Select } from "@mui/material"; -import React from "react"; +import React, { useState } from "react"; import { useKey } from "../hooks"; -import { getComponentProps } from "../utils"; +import { getComponentProps, getFieldSx } from "../utils"; import autoFocus from "../utils/auto-focus"; +import { ViewPropsType } from "../utils/types"; import AlertView from "./AlertView"; import ChoiceMenuItemBody from "./ChoiceMenuItemBody"; import FieldWrapper from "./FieldWrapper"; -import { ViewPropsType } from "../utils/types"; const MULTI_SELECT_TYPES = ["string", "array"]; @@ -19,11 +19,14 @@ export default function DropdownView(props: ViewPropsType) { placeholder = "", separator = ",", readOnly, - condensed, + compact, label, description, + color, + variant, } = view; const [key, setUserChanged] = useKey(path, schema, data, true); + const [selected, setSelected] = useState(false); if (multiSelect && !MULTI_SELECT_TYPES.includes(type)) return ( @@ -53,10 +56,22 @@ export default function DropdownView(props: ViewPropsType) { labels[choice.value] = choice.label; return labels; }, {}); - const { MenuProps = {}, ...selectProps } = getComponentProps(props, "select"); + const { MenuProps = {}, ...selectProps } = getComponentProps( + props, + "select", + { + sx: { + ".MuiSelect-select": { + padding: "0.45rem 2rem 0.45rem 1rem", + opacity: selected ? 1 : 0.5, + }, + ...getFieldSx({ color, variant }), + }, + } + ); return ( - +