Skip to content

Conversation

@NatLeung96
Copy link
Collaborator

Currently, the widgets have hard-coded default styling. In this branch, these default styles have been replaced with theme variables that the user can provide using MUI's ThemeProvider. If the user doesn't provide a theme, it will just use MUI's default theme. One issue is that the EmbeddedDisplay widget is unable to read the theme provided by ThemeProvider and therefore all of its child widgets won't inherit the theme. To circumvent this issue, a theme prop has been added to the EmbeddedDisplay widget which it can re-inject using a ThemeProvider wrapped around its child widgets.

Copy link
Collaborator

@abigailalexander abigailalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me, two things I noted:

  • As I mentioned in a comment, we probably want a default Phoebus theme rather than the default MUI theme
  • Currently, I can't seem to pass a theme to EmbeddedDisplay in Daedalus to overwrite the default. It gives this error: Property 'containerQueries' is missing in type 'import("daedalus/node_modules/@mui/material/styles/createTheme").Theme' but required in type 'import("/cs-web-lib/node_modules/@mui/material/styles/createThemeNoVars").Theme'.ts(2741) cssContainerQueries.d.ts(10, 5): 'containerQueries' is declared here.

Have you tested passing a custom theme to EmbeddedDisplay and did it work for you?

<ThemeProvider theme={diamondTheme}>{component}</ThemeProvider>
</GroupBoxComponent>
</MacroContext.Provider>
<ThemeProvider theme={props.theme ?? theme}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using the default MUI theme here if the client application doesn't pass one in, we should use a "default" theme we have created that has Phoebus defaults. So the diamondTheme you previously created (which contains Phoebus defaults for font and colours etc) could be used (but perhaps renamed to phoebusTheme or defaultTheme).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be a much more sensible idea.

@abigailalexander
Copy link
Collaborator

The issue with passing the theme from a client was on my end, that all works fine :)

@NatLeung96 NatLeung96 merged commit c80519b into 80-update-widgets-to-use-mui-base May 20, 2025
2 checks passed
@NatLeung96 NatLeung96 deleted the generalise-use-of-themes branch May 20, 2025 12:07
NatLeung96 added a commit that referenced this pull request May 20, 2025
* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default
NatLeung96 added a commit that referenced this pull request May 20, 2025
* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Fixed widget rotation

* Updated border styling to match phoebus and added rounded corners

* Corrected offsets for 90 and -90 deg rotations

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshots
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Fixed widget rotation

* Updated border styling to match phoebus and added rounded corners

* Corrected offsets for 90 and -90 deg rotations

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshots
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Updated the rotation for readback widget

* Updated rotation for actionbutton

* Removed commented out props

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshot

* Update label borders and rotation (#119)

* Fixed widget rotation

* Updated border styling to match phoebus and added rounded corners

* Corrected offsets for 90 and -90 deg rotations

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshots

* Added a function for calculating width, height, and transform for rotated widgets

* Implemented the new calculateRotationTransform function
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Fixed widget rotation

* Updated border styling to match phoebus and added rounded corners

* Corrected offsets for 90 and -90 deg rotations

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshots
NatLeung96 added a commit that referenced this pull request May 22, 2025
* Updated the rotation for readback widget

* Updated rotation for actionbutton

* Removed commented out props

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshot

* Update label borders and rotation (#119)

* Fixed widget rotation

* Updated border styling to match phoebus and added rounded corners

* Corrected offsets for 90 and -90 deg rotations

* Generalise use of themes (#117)

* Removed references to diamondTheme and implemented useTheme hook

* Updated snapshots

* Added theme prop to embeddedDisplay widget

* Renamed diamondTheme to phoebusTheme

* Renamed exported theme to phoebusTheme

* Use phoebusTheme as default instead of the MUI default

* Updated snapshots

* Added a function for calculating width, height, and transform for rotated widgets

* Implemented the new calculateRotationTransform function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants