diff --git a/src/ui/widgets/EmbeddedDisplay/bobParser.ts b/src/ui/widgets/EmbeddedDisplay/bobParser.ts
index 46bc432a..2677c9fc 100644
--- a/src/ui/widgets/EmbeddedDisplay/bobParser.ts
+++ b/src/ui/widgets/EmbeddedDisplay/bobParser.ts
@@ -44,7 +44,7 @@ const BOB_WIDGET_MAPPING: { [key: string]: any } = {
display: "display",
ellipse: "ellipse",
embedded: "embeddedDisplay",
- group: "groupingcontainer",
+ group: "groupbox",
label: "label",
led: "led",
textupdate: "readback",
@@ -377,7 +377,9 @@ export function parseBob(
initialIndex: ["initial_index", bobParseNumber],
showIndex: ["show_index", opiParseBoolean],
fallbackSymbol: ["fallback_symbol", opiParseString],
- rotation: ["rotation", bobParseNumber]
+ rotation: ["rotation", bobParseNumber],
+ styleOpt: ["style", bobParseNumber],
+ lineColor: ["line_color", opiParseColor]
};
const complexParsers = {
diff --git a/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx b/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx
index fcf7b778..66df1954 100644
--- a/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx
+++ b/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx
@@ -208,7 +208,7 @@ export const EmbeddedDisplay = (
if (props.border?.style === BorderStyle.GroupBox) {
return (
-
+
{component}
diff --git a/src/ui/widgets/GroupBox/__snapshots__/groupBox.test.tsx.snap b/src/ui/widgets/GroupBox/__snapshots__/groupBox.test.tsx.snap
index f9a7e92e..e45079a5 100644
--- a/src/ui/widgets/GroupBox/__snapshots__/groupBox.test.tsx.snap
+++ b/src/ui/widgets/GroupBox/__snapshots__/groupBox.test.tsx.snap
@@ -1,38 +1,73 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-exports[` > it matches the snapshot 1`] = `
-
+exports[`
snapshots > it matches the snapshot for Group Box style 1`] = `
+
+
+`;
+
+exports[`
snapshots > it matches the snapshot for Line style 1`] = `
+
+
+
+`;
+
+exports[`
snapshots > it matches the snapshot for Title Bar style 1`] = `
+
-
+ style="width: 100%; height: 100%; position: absolute; padding: 0px; box-sizing: border-box;"
+ >
+
+
+
+`;
+
+exports[` snapshots > it matches the snapshot for no style 1`] = `
+
+
+
`;
diff --git a/src/ui/widgets/GroupBox/groupBox.test.tsx b/src/ui/widgets/GroupBox/groupBox.test.tsx
index 8a556aa9..db0796ab 100644
--- a/src/ui/widgets/GroupBox/groupBox.test.tsx
+++ b/src/ui/widgets/GroupBox/groupBox.test.tsx
@@ -1,19 +1,42 @@
import React from "react";
import { GroupBoxComponent } from "./groupBox";
-import { create } from "react-test-renderer";
import { Color } from "../../../types/color";
import { render } from "@testing-library/react";
-describe("", (): void => {
- test("it matches the snapshot", (): void => {
- const snapshot = create(
-
+describe(" snapshots", (): void => {
+ test("it matches the snapshot for Group Box style", (): void => {
+ const { asFragment } = render(
+
);
- expect(snapshot.toJSON()).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
+ test("it matches the snapshot for Title Bar style", (): void => {
+ const { asFragment } = render(
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+ test("it matches the snapshot for Line style", (): void => {
+ const { asFragment } = render(
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+ test("it matches the snapshot for no style", (): void => {
+ const { asFragment } = render(
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+});
+describe("", (): void => {
test("it renders the title", (): void => {
- const grouping = ;
+ const grouping = ;
const { getByText } = render(grouping);
expect(getByText("Test")).toBeInTheDocument();
});
diff --git a/src/ui/widgets/GroupBox/groupBox.tsx b/src/ui/widgets/GroupBox/groupBox.tsx
index 878be9db..431f7e49 100644
--- a/src/ui/widgets/GroupBox/groupBox.tsx
+++ b/src/ui/widgets/GroupBox/groupBox.tsx
@@ -4,18 +4,33 @@ import { Widget } from "../widget";
import { WidgetPropType } from "../widgetProps";
import { registerWidget } from "../register";
import {
- StringProp,
ChildrenPropOpt,
InferWidgetProps,
ColorPropOpt,
- BoolPropOpt
+ BoolPropOpt,
+ FontPropOpt,
+ IntPropOpt,
+ StringPropOpt
} from "../propTypes";
+import { Font } from "../../../types/font";
+import { Color } from "../../../types/color";
+import Box from "@mui/material/Box";
+
+const INNER_DIV_STYLE: CSSProperties = {
+ position: "relative",
+ overflow: "visible",
+ color: "black"
+};
const GroupBoxProps = {
- name: StringProp,
+ name: StringPropOpt,
children: ChildrenPropOpt,
backgroundColor: ColorPropOpt,
- compat: BoolPropOpt
+ foregroundColor: ColorPropOpt,
+ lineColor: ColorPropOpt,
+ font: FontPropOpt,
+ styleOpt: IntPropOpt,
+ transparent: BoolPropOpt
};
// Widget that renders a group-box style border showing the name prop.
@@ -24,53 +39,80 @@ const GroupBoxProps = {
export const GroupBoxComponent = (
props: InferWidgetProps
): JSX.Element => {
- const { compat = false } = props;
- // Manually render a group-box style border.
- const innerDivStyle: CSSProperties = {
- position: "relative",
- padding: "16px"
+ const {
+ backgroundColor = Color.fromRgba(240, 240, 240),
+ foregroundColor = Color.fromRgba(0, 0, 0),
+ lineColor = Color.fromRgba(0, 0, 0),
+ font = new Font(16),
+ styleOpt = 0,
+ transparent = false
+ } = props;
+
+ const outerDivStyle: CSSProperties = {
+ width: "100%",
+ height: "100%",
+ position: "absolute",
+ padding: "0px",
+ boxSizing: "border-box"
+ };
+
+ const boxStyle: CSSProperties = {
+ width: "100%",
+ height: "100%",
+ padding: "0px",
+ border: "1px solid " + lineColor.toString(),
+ whiteSpace: "nowrap",
+ overflow: "visible",
+ backgroundColor: transparent ? "transparent" : backgroundColor.toString(),
+ color: foregroundColor.toString(),
+ ...font.css()
};
- // Specific styling to match the group boxes in opibuilder.
- if (compat) {
- innerDivStyle.padding = undefined;
- innerDivStyle.top = "16px";
- innerDivStyle.left = "16px";
- innerDivStyle.height = "calc(100% - 32px)";
- innerDivStyle.width = "calc(100% - 32px)";
- innerDivStyle.overflow = "hidden";
+
+ if (styleOpt === 0) {
+ // Typical group box with label
+ outerDivStyle.padding = "10px";
+ outerDivStyle.paddingTop = "0px";
+ boxStyle.paddingLeft = "8px";
+ } else if (styleOpt === 3) {
+ // No groupbox
+ boxStyle.border = "none";
+ }
+
+ let name = "";
+ if (props.name !== undefined) {
+ name = props.name;
}
- // Dimensions match those in the opibuilder groupbox borders.
+
return (
-
-
- {props.name}
-
-
{props.children}
+
+
+ {styleOpt === 1 ? (
+
+ {name}
+
+ ) : (
+ <>>
+ )}
+ {styleOpt === 0 ? : <>>}
+ {props.children}
+
);
};
const GroupBoxWidgetProps = {
...WidgetPropType,
- name: StringProp,
+ ...GroupBoxProps,
+ name: StringPropOpt,
children: ChildrenPropOpt
};