-
Notifications
You must be signed in to change notification settings - Fork 1
Generalise use of themes #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalise use of themes #117
Conversation
abigailalexander
left a comment
There was a problem hiding this 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}> |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
|
The issue with passing the theme from a client was on my end, that all works fine :) |
c80519b
into
80-update-widgets-to-use-mui-base
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
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.