Skip to content

feat: Theming - Bootstrap#1603

Merged
bmingles merged 74 commits intodeephaven:mainfrom
bmingles:1540-theming-bootstrap
Dec 8, 2023
Merged

feat: Theming - Bootstrap#1603
bmingles merged 74 commits intodeephaven:mainfrom
bmingles:1540-theming-bootstrap

Conversation

@bmingles
Copy link
Copy Markdown
Contributor

@bmingles bmingles commented Oct 30, 2023

  • Updated bootstrap styles to pull from theme variables and added some mixin overrides

NOTE I copy / pasted all of the original Bootstrap mixins (packages/components/scss/bootstrap_override_* in their own commit to make the diff easier for customizations I made. Should be able to see the diff here: https://github.com/bmingles/web-client-ui/compare/7ce4875ef065075c920f2e70b3462a77215b6d5e..bmingles:1540-theming-bootstrap

BREAKING CHANGE: Bootstrap color variables are now predominantly hsl based. SCSS will need to be updated accordingly. Theme providers are needed to load themes.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 30, 2023

Codecov Report

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

Comparison is base (5e2be64) 46.62% compared to head (79f46a6) 46.71%.
Report is 3 commits behind head on main.

Files Patch % Lines
...ackages/components/src/RandomAreaPlotAnimation.tsx 0.00% 22 Missing ⚠️
...ackages/code-studio/src/styleguide/ThemeColors.tsx 0.00% 9 Missing ⚠️
packages/code-studio/src/styleguide/colorUtils.ts 27.27% 8 Missing ⚠️
packages/code-studio/src/styleguide/hooks.ts 85.00% 3 Missing ⚠️
packages/code-studio/src/styleguide/Swatch.tsx 83.33% 2 Missing ⚠️
...kages/code-studio/src/styleguide/GotoTopButton.tsx 50.00% 1 Missing ⚠️
packages/utils/src/ColorUtils.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1603      +/-   ##
==========================================
+ Coverage   46.62%   46.71%   +0.09%     
==========================================
  Files         602      606       +4     
  Lines       36726    36769      +43     
  Branches     9208     9231      +23     
==========================================
+ Hits        17122    17176      +54     
+ Misses      19552    19541      -11     
  Partials       52       52              
Flag Coverage Δ
unit 46.71% <52.08%> (+0.09%) ⬆️

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

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

@bmingles bmingles force-pushed the 1540-theming-bootstrap branch 4 times, most recently from 02ced7a to ba444f7 Compare November 7, 2023 21:43
@bmingles bmingles marked this pull request as ready for review November 8, 2023 20:36
@bmingles bmingles requested review from dsmmcken and mofojed November 8, 2023 20:36
Comment thread packages/components/scss/bootstrap_imports.scss Outdated
Comment thread packages/components/scss/bootstrap_override_functions.scss Outdated
Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Two things I noticed while testing:

  • The animation on login screen (RandomAreaPlotAnimation) doesn't display anymore, it's just a black screen.
  • The first time I ran this, the loading circle was black... I think because I switched from main to this branch? Can't seem to reproduce it with an incognito window or by re-opening the same thing, so probably not a big deal but thought I'd mention it.

Comment thread packages/components/scss/BaseStyleSheet.scss
Comment thread packages/components/scss/BaseStyleSheet.scss
Comment thread packages/code-studio/src/styleguide/colorUtils.ts Outdated
Comment thread packages/components/scss/bootstrap_imports.scss Outdated
Comment thread packages/golden-layout/scss/goldenlayout-dark-theme.scss
Comment thread packages/components/scss/BaseStyleSheet.scss Outdated
@bmingles bmingles requested a review from mofojed December 6, 2023 20:07
Comment thread packages/code-studio/src/main/AppMainContainer.scss
Comment thread packages/code-studio/src/settings/SettingsMenu.scss
Comment thread packages/code-studio/src/styleguide/Alerts.tsx
Comment thread packages/code-studio/src/styleguide/Colors.tsx Outdated
Comment thread packages/code-studio/src/styleguide/colorUtils.ts Outdated
Comment thread packages/components/scss/bootstrap_imports.scss Outdated
Comment thread packages/components/scss/bootstrap_overrides.scss
Comment thread packages/components/src/RandomAreaPlotAnimation.tsx Outdated
Comment thread packages/components/src/theme/theme-dark/theme-dark-components.css Outdated
Comment thread packages/components/src/theme/ThemeUtils.ts Outdated
@mofojed
Copy link
Copy Markdown
Member

mofojed commented Dec 7, 2023

For the most part good, just the 404 link to bootstrap.scss and some minor cleanup suggestions to take a look at.

@bmingles bmingles requested a review from mofojed December 7, 2023 22:58
Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Should cleanup the normalizeCssColor, other comments are suggestions.

Comment thread packages/code-studio/src/styleguide/Swatch.tsx Outdated
Comment thread packages/components/scss/bootstrap_imports.scss Outdated
Comment on lines +12 to +17
| '--dh-color-login-form-bg'
| '--dh-color-login-status-message'
| '--dh-color-random-area-plot-animation-fg-fill'
| '--dh-color-random-area-plot-animation-fg-stroke'
| '--dh-color-random-area-plot-animation-bg'
| '--dh-color-random-area-plot-animation-grid'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This smells to me. ThemeModel to me shouldn't have any specific things for login or random-area-plot-animation in my mind; rather login/random area plot should be pulling from generic values; e.g. instead of login-form-bg, should just be form-bg and that's what we use for all forms; login-status-message should just be status-message; random-area-plot-animation-fg-fill should just be using accent-bg, etc. Just seems like we're not doing the right abstraction here.
Then getRandomAreaPlotAnimationThemeColors() would be a utility method within the RandomPlotAnimation rather than from the ThemeModel itself, which should just provide the generic colors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds like @dsmmcken is saying the form colors should be specific to the form, so the issue here may be that the ThemeModel should not be responsible to specify these. I think these may not actually be required in the preload in DHC at all but will be needed for DHE, so I probably need to augment the preload to allow the app to specify additional vars. Then ThemeModel won't have to own these.

The other suggestions make sense. I'll change those as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This turned out to be more involved than I want to include in this PR. I created #1679 to address it.

Comment thread packages/utils/src/ColorUtils.ts Outdated
@bmingles bmingles requested a review from mofojed December 8, 2023 17:41
Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

One suggestion for cleanup

Comment on lines +45 to +49
const [themeColors, setThemeColors] = useState<ThemeColors | null>(null);

useEffect(() => {
setThemeColors(getRandomAreaPlotAnimationThemeColors());
}, [activeThemes]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should just memoize themeColors, then you don't need checks for null on themeColors, e.g.:

  const themeColors = useMemo(getRandomAreaPlotAnimationThemeColors, [
    activeThemes,
  ]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most of the places that depend on resolving css vars need to go in an effect so that the latest data is available to the DOM right after a theme selection change.

I'm not 100% sure, but I believe this happens because ThemeProvider renders style tags dynamically which would be in the same render as when useMemo gets calculated vs useEffect would fire after the DOM has actually updated the colors that are needed for the resolve.

For this particular example, it's easiest to see in the styleguide. When I tried useMemo and change the theme, the change trails behind till the next render

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a clarifying comment to the effect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay - as we discussed in our meeting it would be nice if we pulled this logic up to the ThemeProvider so we don't need to do this pattern in so many places (here, ChartThemeProvider, IrisGridThemeProvider, etc).
So in ThemeProvider, the value it provides to the ThemeContext.Provider is only set after a useLayoutEffect occurs in the ThemeProvider. Then any child can just do useActiveThemes (or maybe a useThemeColors type of hook?) and just get the active colours without needed to add their own useLayoutEffect
Can be a follow up ticket.

@bmingles bmingles requested a review from mofojed December 8, 2023 18:59
mofojed
mofojed previously approved these changes Dec 8, 2023
@bmingles bmingles merged commit 88bcae0 into deephaven:main Dec 8, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 8, 2023
@bmingles bmingles deleted the 1540-theming-bootstrap branch December 8, 2023 21:54
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.

3 participants