From de29a3de87de86b884ce82bb3d2e6d96bc12cd8a Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 10:06:16 +0000 Subject: [PATCH 01/26] Replaced default html button with MUI Button --- src/ui/widgets/ActionButton/actionButton.tsx | 79 +++++++------------- 1 file changed, 29 insertions(+), 50 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 7e5dfe7..7648174 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -18,6 +18,9 @@ import { Font } from "../../../types/font"; import { Border, BorderStyle } from "../../../types/border"; import { MacroContext } from "../../../types/macros"; import { ExitFileContext, FileContext } from "../../../misc/fileContext"; +import { Button } from "@mui/material"; +import { ThemeProvider } from "@mui/material"; +import { defaultColours } from "../../../colourscheme"; export interface ActionButtonProps { text: string; @@ -32,44 +35,6 @@ export interface ActionButtonProps { visible?: boolean; } -export const ActionButtonComponent = ( - props: ActionButtonProps -): JSX.Element => { - const style = commonCss(props); - if (props.disabled) { - style["cursor"] = "not-allowed"; - } - style["whiteSpace"] = "normal"; - // Use default button style if no border defined. - if (props.border?.style === BorderStyle.None) { - style["borderStyle"] = undefined; - style["borderWidth"] = undefined; - style["borderColor"] = undefined; - style["padding"] = "0"; - } - return ( - - ); -}; - const ActionButtonPropType = { text: StringPropOpt, actions: ActionsPropType, @@ -104,18 +69,32 @@ export const ActionButtonWidget = ( ); } return ( - + + + ); }; From 9cd6af8036fef9006e1286cf7c4e0e51cc6d187c Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 10:54:08 +0000 Subject: [PATCH 02/26] Added border and disabled settings --- src/ui/widgets/ActionButton/actionButton.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 7648174..0608ad7 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -1,6 +1,6 @@ import React, { useContext } from "react"; import { WidgetActions, executeActions } from "../widgetActions"; -import { commonCss, Widget } from "../widget"; +import { Widget } from "../widget"; import { PVComponent, PVWidgetPropType } from "../widgetProps"; import classes from "./actionButton.module.css"; import { registerWidget } from "../register"; @@ -15,7 +15,7 @@ import { } from "../propTypes"; import { Color } from "../../../types/color"; import { Font } from "../../../types/font"; -import { Border, BorderStyle } from "../../../types/border"; +import { Border } from "../../../types/border"; import { MacroContext } from "../../../types/macros"; import { ExitFileContext, FileContext } from "../../../misc/fileContext"; import { Button } from "@mui/material"; @@ -43,7 +43,8 @@ const ActionButtonPropType = { foregroundColor: ColorPropOpt, font: FontPropOpt, border: BorderPropOpt, - visible: BoolPropOpt + visible: BoolPropOpt, + disabled: BoolPropOpt }; const ActionButtonWidgetProps = { @@ -72,12 +73,14 @@ export const ActionButtonWidget = ( From 82addef4c216e4d8ec59852f3a3fc19f974c299b Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 11:04:07 +0000 Subject: [PATCH 03/26] Updated file for prettier --- src/ui/widgets/ActionButton/actionButton.tsx | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 0608ad7..484bc28 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -75,27 +75,27 @@ export const ActionButtonWidget = ( variant="contained" disabled={props.disabled} sx={{ - height: "100%", - width: "100%", - fontFamily: props.font?.css() ?? "", - color: props.foregroundColor?.toString() ?? defaultColours.palette.primary.contrastText, - backgroundColor: props.backgroundColor?.toString() ?? defaultColours.palette.primary.main, - border: props.border?.css() ?? "" - }} + height: "100%", + width: "100%", + fontFamily: props.font?.css() ?? "", + color: props.foregroundColor?.toString() ?? defaultColours.palette.primary.contrastText, + backgroundColor: props.backgroundColor?.toString() ?? defaultColours.palette.primary.main, + border: props.border?.css() ?? "" + }} onClick={onClick} > - {props.image !== undefined ? ( -
- {props.image} -
{props.text}
-
- ) : ( - props.text ?? "" - )} + {props.image !== undefined ? ( +
+ {props.image} +
{props.text}
+
+ ) : ( + (props.text ?? "") + )} ); From d2468d957292dcde3ff43dcc70e24a7a001d957d Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 11:14:04 +0000 Subject: [PATCH 04/26] Prettier again --- src/ui/widgets/ActionButton/actionButton.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 484bc28..6442e21 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -18,8 +18,8 @@ import { Font } from "../../../types/font"; import { Border } from "../../../types/border"; import { MacroContext } from "../../../types/macros"; import { ExitFileContext, FileContext } from "../../../misc/fileContext"; -import { Button } from "@mui/material"; -import { ThemeProvider } from "@mui/material"; +import { Button, ThemeProvider} from "@mui/material"; + import { defaultColours } from "../../../colourscheme"; export interface ActionButtonProps { @@ -78,10 +78,12 @@ export const ActionButtonWidget = ( height: "100%", width: "100%", fontFamily: props.font?.css() ?? "", - color: props.foregroundColor?.toString() ?? defaultColours.palette.primary.contrastText, - backgroundColor: props.backgroundColor?.toString() ?? defaultColours.palette.primary.main, - border: props.border?.css() ?? "" - }} + color: props.foregroundColor?.toString() ?? + defaultColours.palette.primary.contrastText, + backgroundColor: props.backgroundColor?.toString() ?? + defaultColours.palette.primary.main, + border: props.border?.css() ?? "" + }} onClick={onClick} > {props.image !== undefined ? ( From b855c7498613fa9128eb6f833ed9773901411687 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 11:19:11 +0000 Subject: [PATCH 05/26] Prettier still --- src/ui/widgets/ActionButton/actionButton.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 6442e21..aafe169 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -18,7 +18,7 @@ import { Font } from "../../../types/font"; import { Border } from "../../../types/border"; import { MacroContext } from "../../../types/macros"; import { ExitFileContext, FileContext } from "../../../misc/fileContext"; -import { Button, ThemeProvider} from "@mui/material"; +import { Button, ThemeProvider } from "@mui/material"; import { defaultColours } from "../../../colourscheme"; @@ -78,10 +78,12 @@ export const ActionButtonWidget = ( height: "100%", width: "100%", fontFamily: props.font?.css() ?? "", - color: props.foregroundColor?.toString() ?? - defaultColours.palette.primary.contrastText, - backgroundColor: props.backgroundColor?.toString() ?? - defaultColours.palette.primary.main, + color: + props.foregroundColor?.toString() ?? + defaultColours.palette.primary.contrastText, + backgroundColor: + props.backgroundColor?.toString() ?? + defaultColours.palette.primary.main, border: props.border?.css() ?? "" }} onClick={onClick} From 6f74e874b3a170345c3f2757a9fbdf880b964bae Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 11:22:20 +0000 Subject: [PATCH 06/26] Final time --- src/ui/widgets/ActionButton/actionButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index aafe169..4319994 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -78,10 +78,10 @@ export const ActionButtonWidget = ( height: "100%", width: "100%", fontFamily: props.font?.css() ?? "", - color: + color: props.foregroundColor?.toString() ?? defaultColours.palette.primary.contrastText, - backgroundColor: + backgroundColor: props.backgroundColor?.toString() ?? defaultColours.palette.primary.main, border: props.border?.css() ?? "" From a99f07f7af381a113a0bd4ec89cbf7be252e4238 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 13:03:42 +0000 Subject: [PATCH 07/26] Refactored code to be compatible with tests --- src/ui/widgets/ActionButton/actionButton.tsx | 89 ++++++++++++-------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 4319994..a0825a3 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -11,7 +11,8 @@ import { ColorPropOpt, FontPropOpt, BorderPropOpt, - BoolPropOpt + BoolPropOpt, + FuncPropOpt } from "../propTypes"; import { Color } from "../../../types/color"; import { Font } from "../../../types/font"; @@ -35,6 +36,45 @@ export interface ActionButtonProps { visible?: boolean; } +export const ActionButtonComponent = ( + props: ActionButtonProps +): JSX.Element => { + return ( + + + + ); +}; + const ActionButtonPropType = { text: StringPropOpt, actions: ActionsPropType, @@ -44,7 +84,8 @@ const ActionButtonPropType = { font: FontPropOpt, border: BorderPropOpt, visible: BoolPropOpt, - disabled: BoolPropOpt + disabled: BoolPropOpt, + onClick: FuncPropOpt }; const ActionButtonWidgetProps = { @@ -70,38 +111,18 @@ export const ActionButtonWidget = ( ); } return ( - - - + ); }; From 8a3a0ee7dd3317b06171df33ce43c3734c013dda Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 13:10:08 +0000 Subject: [PATCH 08/26] Updated test snapshot --- .../__snapshots__/actionButton.test.tsx.snap | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap index a3ad453..bab6900 100644 --- a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap +++ b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap @@ -2,26 +2,22 @@ exports[` > it matches the snapshot 1`] = ` `; From b9e8cd3f25f44ac2571f5fcd997d7e7fa1044128 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 24 Mar 2025 13:13:16 +0000 Subject: [PATCH 09/26] Fixed error in snapshot --- .../ActionButton/__snapshots__/actionButton.test.tsx.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap index bab6900..fda1ae0 100644 --- a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap +++ b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap @@ -19,5 +19,7 @@ exports[` > it matches the snapshot 1`] = ` onTouchStart={[Function]} tabIndex={0} type="button" +> + hello `; From e1ef730658c01bdfa48107cf7773bbd64095dd30 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 31 Mar 2025 08:56:26 +0100 Subject: [PATCH 10/26] Corrected the default grey colour --- src/colourscheme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colourscheme.ts b/src/colourscheme.ts index a9b8332..a50def5 100644 --- a/src/colourscheme.ts +++ b/src/colourscheme.ts @@ -3,7 +3,7 @@ import { createTheme } from "@mui/material/styles"; export const defaultColours = createTheme({ palette: { primary: { - main: "#C0C0C0", + main: "#D2D2D2", // light: currently calculated automatically by MUI // dark: currently calculated automatically by MUI contrastText: "#FFFFFF" From e66311671b3bced08dd4e0715c7d4051fd3d1725 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 31 Mar 2025 08:58:37 +0100 Subject: [PATCH 11/26] Corrected the default text colour --- src/colourscheme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colourscheme.ts b/src/colourscheme.ts index a50def5..d899df1 100644 --- a/src/colourscheme.ts +++ b/src/colourscheme.ts @@ -6,7 +6,7 @@ export const defaultColours = createTheme({ main: "#D2D2D2", // light: currently calculated automatically by MUI // dark: currently calculated automatically by MUI - contrastText: "#FFFFFF" + contrastText: "#000000" } }, typography: { From c098291919c1b91307cb30f9155ddda646d080c0 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 31 Mar 2025 09:18:16 +0100 Subject: [PATCH 12/26] Added settings to change cursor when button is disabled --- src/ui/widgets/ActionButton/actionButton.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index a0825a3..6f0133c 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -54,7 +54,11 @@ export const ActionButtonComponent = ( backgroundColor: props.backgroundColor?.toString() ?? defaultColours.palette.primary.main, - border: props.border?.css() ?? "" + border: props.border?.css() ?? "", + ".Mui-disabled &": { + pointerEvents: "unset", + cursor: "not-allowed" + } }} onClick={props.onClick} > From 7418adfcda05895ea36f6b177ef8a940ceffaccd Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Mon, 31 Mar 2025 13:42:48 +0100 Subject: [PATCH 13/26] Tidied the colour prop declarations --- src/ui/widgets/ActionButton/actionButton.tsx | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 6f0133c..1da9f00 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -25,11 +25,11 @@ import { defaultColours } from "../../../colourscheme"; export interface ActionButtonProps { text: string; - disabled?: boolean; + enabled?: boolean; onClick: (event: React.MouseEvent) => void; image?: string; - backgroundColor?: Color; - foregroundColor?: Color; + backgroundColor?: Color | string; + foregroundColor?: Color | string; border?: Border; font?: Font; actions?: WidgetActions; @@ -39,21 +39,25 @@ export interface ActionButtonProps { export const ActionButtonComponent = ( props: ActionButtonProps ): JSX.Element => { + const { + enabled = true, + foregroundColor = defaultColours.palette.primary.contrastText, + backgroundColor = defaultColours.palette.primary.main + } = props; return ( @@ -100,7 +121,9 @@ const ActionButtonPropType = { border: BorderPropOpt, visible: BoolPropOpt, enabled: BoolPropOpt, - onClick: FuncPropOpt + onClick: FuncPropOpt, + transparent: BoolPropOpt, + rotationStep: FloatPropOpt }; const ActionButtonWidgetProps = { @@ -137,6 +160,8 @@ export const ActionButtonWidget = ( border={props.border} actions={props.actions as WidgetActions} visible={props.visible} + transparent={props.transparent} + rotationStep={props.rotationStep} /> ); }; From 8e80b07ac78811cfaf176f9b4d4125260eb22f7f Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Wed, 2 Apr 2025 09:53:06 +0100 Subject: [PATCH 18/26] Moved ThemeProvider to embeddedDisplay --- src/ui/widgets/ActionButton/actionButton.tsx | 103 +++++++++--------- .../EmbeddedDisplay/embeddedDisplay.tsx | 4 +- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index 4914a06..ab00d53 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -20,7 +20,7 @@ import { Font } from "../../../types/font"; import { Border } from "../../../types/border"; import { MacroContext } from "../../../types/macros"; import { ExitFileContext, FileContext } from "../../../misc/fileContext"; -import { Button, ThemeProvider } from "@mui/material"; +import { Button } from "@mui/material"; import { diamondTheme } from "../../../diamondTheme"; @@ -56,58 +56,57 @@ export const ActionButtonComponent = ( const border = props.border?.css() ?? null; return ( - - - + transform: `rotation(${rotationStep * -90}deg)`.toString(), + whiteSpace: "nowrap", + textOverflow: "ellipsis" + }} + > + {props.text ?? ""} + + )} + ); }; diff --git a/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx b/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx index 66df195..807b1b4 100644 --- a/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx +++ b/src/ui/widgets/EmbeddedDisplay/embeddedDisplay.tsx @@ -24,6 +24,8 @@ import { GroupBoxComponent } from "../GroupBox/groupBox"; import { useOpiFile } from "./useOpiFile"; import { useId } from "react-id-generator"; import { getOptionalValue, trimFromString } from "../utils"; +import { ThemeProvider } from "@mui/material"; +import { diamondTheme } from "../../../diamondTheme"; const RESIZE_STRINGS = [ "scroll-widget", @@ -209,7 +211,7 @@ export const EmbeddedDisplay = ( return ( - {component} + {component} ); From 9705ea95f259cbed46c7349c49dd8d1dbcbe55dd Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Wed, 2 Apr 2025 10:29:06 +0100 Subject: [PATCH 19/26] Updated the snapshot --- .../__snapshots__/actionButton.test.tsx.snap | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap index fda1ae0..c6599ac 100644 --- a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap +++ b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap @@ -2,7 +2,7 @@ exports[` > it matches the snapshot 1`] = ` `; From 1c86e3579ee7837f580004ae6eb50ea468542122 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Wed, 2 Apr 2025 15:19:46 +0100 Subject: [PATCH 20/26] Changed it so that button variant is "text" when transparent, otherwise it's "contained" --- src/ui/widgets/ActionButton/actionButton.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx index ab00d53..ad66b8e 100644 --- a/src/ui/widgets/ActionButton/actionButton.tsx +++ b/src/ui/widgets/ActionButton/actionButton.tsx @@ -29,8 +29,8 @@ export interface ActionButtonProps { enabled?: boolean; onClick: (event: React.MouseEvent) => void; image?: string; - backgroundColor?: Color | string; - foregroundColor?: Color | string; + backgroundColor?: Color; + foregroundColor?: Color; border?: Border; font?: Font; actions?: WidgetActions; @@ -57,7 +57,7 @@ export const ActionButtonComponent = ( return (