From b03b1ff1ac50d00dede8047d7be68eace89b4371 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Thu, 27 Mar 2025 09:36:46 +0000 Subject: [PATCH 01/13] Replaced div with MUI Typography --- src/ui/widgets/Label/label.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui/widgets/Label/label.tsx b/src/ui/widgets/Label/label.tsx index 64be7186..2dc1de14 100644 --- a/src/ui/widgets/Label/label.tsx +++ b/src/ui/widgets/Label/label.tsx @@ -15,6 +15,8 @@ import { FloatPropOpt, MacrosPropOpt } from "../propTypes"; +import { Typography, ThemeProvider } from "@mui/material"; +import { defaultColours } from "../../../colourscheme"; const LabelProps = { macros: MacrosPropOpt, @@ -53,7 +55,6 @@ export const LabelComponent = ( rotationAngle, wrapWords } = props; - const className = props.className ?? `Label ${classes.Label}`; // Since display is "flex", use "flex-start" and "flex-end" to align // the content. let alignment = "center"; @@ -93,9 +94,20 @@ export const LabelComponent = ( // Simple component to display text - defaults to black text and dark grey background return ( -
- {text} -
+ + + {text} + + ); }; From dbbe3c6f55bde866661046c60b8829820a3416b2 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Thu, 27 Mar 2025 10:42:51 +0000 Subject: [PATCH 02/13] Added styling props to Typography --- src/ui/widgets/Label/label.tsx | 49 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/ui/widgets/Label/label.tsx b/src/ui/widgets/Label/label.tsx index 2dc1de14..b0db73ad 100644 --- a/src/ui/widgets/Label/label.tsx +++ b/src/ui/widgets/Label/label.tsx @@ -1,7 +1,6 @@ -import React, { CSSProperties } from "react"; +import React from "react"; -import classes from "./label.module.css"; -import { Widget, commonCss } from "../widget"; +import { Widget } from "../widget"; import { WidgetPropType } from "../widgetProps"; import { registerWidget } from "../register"; import { @@ -43,11 +42,9 @@ export const LabelComponent = ( props: InferWidgetProps ): JSX.Element => { // Default labels to transparent. - const editedProps = { - ...props, - transparent: props.transparent ?? true - }; - const style: CSSProperties = commonCss(editedProps); + + const transparent = props.transparent ?? true; + const { textAlign = "left", textAlignV = "top", @@ -60,49 +57,45 @@ export const LabelComponent = ( let alignment = "center"; if (textAlign === "left") { alignment = "flex-start"; - if (wrapWords) { - style["textAlign"] = "left"; - } } else if (textAlign === "right") { alignment = "flex-end"; - if (wrapWords) { - style["textAlign"] = "right"; - } - } else { - if (wrapWords) { - style["textAlign"] = "center"; - } } - style["justifyContent"] = alignment; - style["cursor"] = "default"; + let alignmentV = "center"; if (textAlignV === "top") { alignmentV = "flex-start"; } else if (textAlignV === "bottom") { alignmentV = "flex-end"; } - style["alignItems"] = alignmentV; + let transform = undefined; if (rotationAngle) { transform = `rotate(${rotationAngle}deg)`; } - if (wrapWords) { - style["wordBreak"] = "break-word"; - style["whiteSpace"] = "break-spaces"; - } - // Simple component to display text - defaults to black text and dark grey background return ( {text} From ece0b0e80cdb6f7c4b30eec6f69a2250f5f02797 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Thu, 27 Mar 2025 10:56:27 +0000 Subject: [PATCH 03/13] Updated the tests for label --- .../Label/__snapshots__/label.test.tsx.snap | 11 ++++----- src/ui/widgets/Label/label.test.tsx | 24 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/ui/widgets/Label/__snapshots__/label.test.tsx.snap b/src/ui/widgets/Label/__snapshots__/label.test.tsx.snap index 0f776d0e..0710eb3a 100644 --- a/src/ui/widgets/Label/__snapshots__/label.test.tsx.snap +++ b/src/ui/widgets/Label/__snapshots__/label.test.tsx.snap @@ -2,13 +2,10 @@ exports[`