feat: Dynamic theme selection#1511
Conversation
| result[key] = | ||
| typeof value === 'string' | ||
| ? value.replace(CSS_PROPERTY_NAME_REGEX, (_match, propertyName) => | ||
| getComputedStyle(targetElement ?? document.body).getPropertyValue( |
There was a problem hiding this comment.
check my draft PR for converting rgba to hex with alpha, as that's needed for monaco.
There was a problem hiding this comment.
ah yes. I saw that. This is mostly just to show case "where" we would hook the replacement into Iris, but yeah needs to be built out more.
|
|
||
| logInit(); | ||
|
|
||
| initializeTheme(); |
There was a problem hiding this comment.
We might want to inline and call this function in a script tag in the actual html , that way there's no flash of the wrong theme before react loads/initializes.
There was a problem hiding this comment.
I'm fine with that. Are you actually seeing a flash?
| <link rel="icon" href="%VITE_FAVICON%" /> | ||
| <title>Deephaven</title> | ||
| <link rel="stylesheet" href="/default_theme.css" /> | ||
| <link rel="stylesheet" href="/custom_theme.css" /> |
There was a problem hiding this comment.
Is this more of a POC or intended implementation of how custom themes would be loaded?
It's probably preferable that they are split into separate files, and then loaded dynamically, such that theme files can be created and shared individually.
There was a problem hiding this comment.
I imagine the default themes would actually live in the codebase not in public. Those could be split up however.
For the custom ones, it's easiest to just have 1 file and statically load it. I could see the benefit of splitting them up, would just have to see how hard it is to determine the full list before our app code has actually loaded
|
Closing this in favor of #1524 |
1 similar comment
|
Closing this in favor of #1524 |
Draft PR showing dynamic theme selection.
--dh-base-themeto inherit from a default themeThis includes a few minimal changes to
BaseStyleSheet.scss,goldenlayout-dark-theme.scss, andIrisGridTheme.tsto prove they can consume the theme variables.NOTES:
dh-xxxxones.To see it work, you can set the theme key in local storage in the console and then refresh the page. You should see different css classes get attached to the body based on the theme key:
#1504