Skip to content

feat: Theme Plugin Loading#1524

Merged
bmingles merged 42 commits intodeephaven:mainfrom
bmingles:1504-theme-plugin-loader
Oct 5, 2023
Merged

feat: Theme Plugin Loading#1524
bmingles merged 42 commits intodeephaven:mainfrom
bmingles:1504-theme-plugin-loader

Conversation

@bmingles
Copy link
Copy Markdown
Contributor

@bmingles bmingles commented Sep 18, 2023

  • First pass at base theme variables theme_default_dark.scss and theme_default_light.scss
  • Swapped a few places --dh-background-color. This is only consumed in a few places and is set to the original #1a171a color in theme_default_dark, so shouldn't result in any display changes by default.
  • Loading custom themes from a new ThemePlugin type. 2 sample themes can be found in this DRAFT PR: DRAFT: Sample ThemePlugins deephaven-plugins#65

Testing

Setup Theme Plugins Locally

  • Checkout the draft plugins PR: DRAFT: Sample ThemePlugins deephaven-plugins#65
  • Configure docker-compose for Community to load from checked out plugins directory
    e.g
    START_OPTS=-Xmx4g -Ddeephaven.jsPlugins.resourceBase=/plugin-dev and map a volume /Users/jdoe/code/deephaven-plugins/plugins:/plugin-dev
  • docker-compose up (note, this has to be restarted any time plugins config changes)

Run web ui locally

  • On initial load
    • Nothing should look different in the UI. Inspect the div id="root" element.
    • Its first child should be <style data-theme-key="default-dark">...
    • Inspect the <body> el. There should be some --dh-color-xxx CSS variables loaded in the inspector.
    • In "Application" dev tools tab there should be an entry in localStorage deephaven.themeCache
      {"themeKey":"default-dark","preloadStyleContent":":root{--dh-accent-color:#4c7dee;--dh-background-color:#1a171a}"}
  • Switch default theme
    • In console run: localStorage.setItem('deephaven.themeCache', '{"themeKey":"default-light"}') and reload page
      Note: On the first page refresh, there will be a moment where the background shows the previously applied theme. Refreshing the page again should show the right color the entire time. This is due to how we are setting things via the console but won't be an issue once users can select themes from the UI.
    • UI should show white background in title bar (it won't look good, just proving we can switch color)
    • Its first child should be <style data-theme-key="default-light">...
    • Inspect the <body> el. There should be some --dh-color-xxx CSS variables loaded in the inspector.
    • In "Application" dev tools tab there should be an entry in localStorage deephaven.themeCache
      {"themeKey":"default-light","preloadStyleContent":":root{--dh-accent-color:#4c7dee;--dh-background-color:#fdfdfd}"}
    • Repeat, but this time run: localStorage.setItem('deephaven.themeCache', '{"themeKey":"default-dark"}') and reload page. Should see things go back to initial load state
  • Load custom themes
    There should be 4 custom themes provided by the plugins repo. They can be selected via the following:
    • localStorage.setItem('deephaven.themeCache', '{"themeKey":"theme-multi-example_acme-dark"}')
    • localStorage.setItem('deephaven.themeCache', '{"themeKey":"theme-multi-example_acme-light"}')
    • localStorage.setItem('deephaven.themeCache', '{"themeKey":"theme-multi-example_acme-cool"}')
    • localStorage.setItem('deephaven.themeCache', '{"themeKey":"theme-single-example_single-dark"}')
    • These should produce similar results as the default ones, except:
      • There should be 2 style tags under the div id="root". The first will be either the dark or light base theme. The 2nd will correspond to the custom theme variables
      • Inspecting the body element should show additional :root { ... } css variables for the custom theme just above the base theme variables
      • localStorage should contain an entry like: {"themeKey":"theme-multi-example_acme-light","preloadStyleContent":":root{--dh-accent-color:#4c7dee;--dh-background-color:#fdfdfd}"} corresponding to the current theme.
      • Reloading the page should keep the same styling

resolves #1530

@bmingles bmingles force-pushed the 1504-theme-plugin-loader branch from 30e890e to 135d2ba Compare September 20, 2023 18:28
@bmingles bmingles changed the title Theme Plugin Loading feat: Theme Plugin Loading Sep 20, 2023
@bmingles bmingles marked this pull request as ready for review September 20, 2023 20:45
@bmingles bmingles mentioned this pull request Sep 25, 2023
13 tasks
Comment thread packages/app-utils/src/components/PluginsBootstrap.tsx Outdated
Comment thread packages/code-studio/src/index.tsx Outdated
Comment thread packages/components/src/theme/ThemeCache.ts Outdated
@bmingles bmingles force-pushed the 1504-theme-plugin-loader branch 3 times, most recently from 66ec40b to 64d4db6 Compare September 25, 2023 21:15
@bmingles bmingles requested a review from mofojed September 25, 2023 21:17
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 25, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (a273e64) 46.36% compared to head (2d9d2fa) 46.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1524      +/-   ##
==========================================
- Coverage   46.36%   46.32%   -0.04%     
==========================================
  Files         564      569       +5     
  Lines       35787    35877      +90     
  Branches     8959     8982      +23     
==========================================
+ Hits        16591    16620      +29     
- Misses      19144    19205      +61     
  Partials       52       52              
Flag Coverage Δ
unit 46.32% <90.42%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/app-utils/src/components/AppBootstrap.tsx 87.50% <ø> (ø)
...ckages/app-utils/src/components/ThemeBootstrap.tsx 100.00% <100.00%> (ø)
packages/app-utils/src/components/usePlugins.ts 0.00% <ø> (ø)
packages/components/src/EditableItemList.tsx 94.87% <ø> (ø)
packages/components/src/theme/ThemeModel.ts 100.00% <100.00%> (ø)
packages/components/src/theme/ThemeProvider.tsx 100.00% <100.00%> (ø)
packages/components/src/theme/ThemeUtils.ts 100.00% <100.00%> (ø)
packages/components/src/theme/useTheme.ts 100.00% <100.00%> (ø)
packages/plugin/src/PluginTypes.ts 45.00% <100.00%> (+6.11%) ⬆️
packages/utils/src/Asserts.ts 100.00% <100.00%> (ø)
... and 2 more

... and 20 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread packages/components/src/theme/useInitializeThemeContextValue.ts Outdated
Comment thread packages/plugin/src/PluginTypes.ts Outdated
Comment thread packages/components/src/theme/ThemeUtils.ts Outdated
Comment thread packages/app-utils/src/plugins/PluginUtils.tsx Outdated
Comment thread packages/app-utils/src/plugins/PluginUtils.tsx Outdated
Comment thread packages/components/src/theme/ThemeUtils.ts
Comment thread packages/components/src/theme/ThemeUtils.ts
Comment thread packages/components/src/theme/ThemeUtils.ts
Comment thread packages/components/src/theme/ThemeUtils.ts Outdated
Comment thread packages/app-utils/src/components/ThemeBootstrap.tsx Outdated
@bmingles bmingles force-pushed the 1504-theme-plugin-loader branch 2 times, most recently from 17c6085 to 93b5184 Compare September 28, 2023 15:56
@bmingles bmingles force-pushed the 1504-theme-plugin-loader branch from dec7d96 to 0e24329 Compare September 28, 2023 20:09
@bmingles bmingles requested a review from mattrunyon September 29, 2023 17:03
@bmingles bmingles linked an issue Oct 3, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@mattrunyon mattrunyon left a comment

Choose a reason for hiding this comment

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

Looking good. Just 1 tiny thing and a suggestion

Comment thread packages/components/src/theme/ThemeProvider.tsx Outdated
Comment thread packages/components/src/theme/ThemeProvider.test.tsx
@bmingles bmingles requested a review from mattrunyon October 3, 2023 20:20
@bmingles bmingles requested a review from mattrunyon October 5, 2023 12:51
@bmingles bmingles merged commit a9541b1 into deephaven:main Oct 5, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2023
@bmingles bmingles deleted the 1504-theme-plugin-loader branch October 5, 2023 22:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mechanism for loading default + custom themes from plugins Theming - Theme Provider

3 participants