Skip to content
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

feat(dep-graph): add dark mode #8712

Merged
merged 3 commits into from Mar 31, 2022
Merged

feat(dep-graph): add dark mode #8712

merged 3 commits into from Mar 31, 2022

Conversation

Lcarv20
Copy link
Contributor

@Lcarv20 Lcarv20 commented Jan 26, 2022

Current Behavior

Currently there is no possibility to use different themes.

Expected Behavior

Users can toggle between dark and light themes, or select to dynamically follow the system setting.

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Jan 26, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/ESeNUyZ6EqM79aUizTSWdCXpx9ig
✅ Preview: https://nx-dev-git-fork-lcarv20-dark-mode-changes-nrwl.vercel.app

[Deployment for 6a72952 canceled]

@nx-cloud
Copy link

nx-cloud bot commented Jan 26, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6a72952. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@philipjfulcher
Copy link
Collaborator

Please update your PR title to match our commit guidelines, something like "feat(dep-graph): add dark mode"

@philipjfulcher
Copy link
Collaborator

This is a good start and takes care of changing our React components to dark mode. I'll work with our designer to determine some colors that fit the Nrwl color palette.

One more thing we need to figure out is passing the dark mode setting to the graph to be able to alter the colors there. The graph is powered by a library called Cytoscape which uses a canvas to render the graph. So it won't accept our CSS rules to change colors, but it does accept a very similar syntax for styles. You can find the existing styles for nodes and edges in dep-graph/client/src/app/styles-graph.

The style rules accept a function as a setter. So for example, right now the background color on allNodes is set using backgroundColor: NrwlPalette.white. This could be changed to a function like backgroundColor: () => isDarkMode ? NrwlDarkPalette.white : NrwlPalette.white so based on the current theme, it can switch between the color from two different palettes. You can probably use one of the existing function you have for selecting the correct class in React here.

Let me know if that is a good enough starting off point.

@Lcarv20 Lcarv20 changed the title Dark mode changes feat(dep-graph): add dark mode Feb 1, 2022
@Lcarv20
Copy link
Contributor Author

Lcarv20 commented Feb 3, 2022

Hey @philipjfulcher, thanks for the hint. I did something like you mention in the previous comment, however the instances do not update dynamically, and the nodes, edges and arrows will only update after you hover. I didn't quite yet figure a way to dynamically update those. Also, I added my own colour scheme but you can always update them easily, or if you have a pallet in mind just tell me and I can make those changes.

@philipjfulcher
Copy link
Collaborator

@Lcarv20 - I pushed up a commit that should refresh the colors on the graph immediately. I also rebased on master to get the latest changes in and ran a format, which I'm hoping should clean-up the e2e failures.

Copy link
Contributor

@johannesschobel johannesschobel left a comment

Choose a reason for hiding this comment

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

found a few typos that should be corrected

dep-graph/client/jest.config.js Show resolved Hide resolved
Lcarv20 and others added 3 commits March 30, 2022 20:52
Squash commits:

feat(dep-graph): Updating tailwind config file.

As of version 3.0 higher tailwind jit mode is default. Instead of purge is now content and as dark mode will be added as class.

feat(dep-graph): Enabling toggable dark mode.

As darkmode (tailwind.congig.json) is set as class, we need to add the script to the head tag on index.html.
see: https://tailwindcss.com/docs/dark-mode

feat(dep-graph): Adding theme Initializer and creating support functions

All functions related to theme changing and initialization are located on the theme-resolver.tsx
The themeInit function will run when page is loaded and apply add class to the <html> tag as dark or light accordignly. Theme resolver applies the changes and keeps localstorage and <html class> in sync.

feat(dep-graph): Adding theme panel

The pannel allows users to switch themes. Currently it only changes the html class and localstorage.

feat(dep-graph): Creating tailwind dark colors pallete

The current colors remain as light. The dark colors are an attempt to contrast the light ones.

feat(dep-graph): Adding additional styles to sidebar

feat(dep-graph): Define styling presets for darkmode to allow consistent and concise classNames.

feat(dep-graph): Apply dark styling classes to sidebar

feat(dep-graph): Added dark mode styles to the debugger

feat(dep-graph): Added Color to tailwind config and adjusting imports.

feat(dep-graph): Created theme tracker

feat(dep-graph): Added dark classes to graph container

feat(dep-graph): Adjusted some edge styles for better UX. Added dynamic selection of colors according to the current theme.

feat(dep-graph):  Added transition when switching themes.

feat(dep-graph): Readded auto roation for implicit label and dynamic background.

feat(dep-graph): Assigned generic types to selectDynbamically, and added new color to the pallete.

feat(dep-graph): Added dynamic styles for theming.

feat(dep-graph): Added mock for matchMedia. Tests will fail otherwise.

feat(dep-graph): Added styles to tippy.

feat(dep-graph): Moved theme related functions to theme-resolver file

feat(dep-graph): Implement dark mode on tooltips.

feat(dep-graph): re-evaluate graph colors on theme change

cleanup(dep-graph): Removed duplicate style

chore(dep-graph): Testing theme preferences

Adding test cases for theme initialization, and the ability to change.

cleanup(dep-graph): removing repeated style classes

Fixed issue with webpack plugin (#8231)

feat(npm): resolved issue with live reload failing

Fixed the issue with live reload when adding scripts in project.json

Closes #8230

chore(repo): update nx to 13.10.0-beta.1 (#9407)

feat(dep-graph): re-evaluate graph colors on theme change

fix(dep-graph): use theme background color in image download
@philipjfulcher philipjfulcher merged commit c86618e into nrwl:master Mar 31, 2022
sidmonta pushed a commit to sidmonta/nx that referenced this pull request Apr 2, 2022
* feat(dep-graph): add dark mode

Squashed commits:

feat(dep-graph): Updating tailwind config file.

As of version 3.0 higher tailwind jit mode is default. Instead of purge is now content and as dark mode will be added as class.

feat(dep-graph): Enabling toggable dark mode.

As darkmode (tailwind.congig.json) is set as class, we need to add the script to the head tag on index.html.
see: https://tailwindcss.com/docs/dark-mode

feat(dep-graph): Adding theme Initializer and creating support functions

All functions related to theme changing and initialization are located on the theme-resolver.tsx
The themeInit function will run when page is loaded and apply add class to the <html> tag as dark or light accordignly. Theme resolver applies the changes and keeps localstorage and <html class> in sync.

feat(dep-graph): Adding theme panel

The pannel allows users to switch themes. Currently it only changes the html class and localstorage.

feat(dep-graph): Creating tailwind dark colors pallete

The current colors remain as light. The dark colors are an attempt to contrast the light ones.

feat(dep-graph): Adding additional styles to sidebar

feat(dep-graph): Define styling presets for darkmode to allow consistent and concise classNames.

feat(dep-graph): Apply dark styling classes to sidebar

feat(dep-graph): Added dark mode styles to the debugger

feat(dep-graph): Added Color to tailwind config and adjusting imports.

feat(dep-graph): Created theme tracker

feat(dep-graph): Added dark classes to graph container

feat(dep-graph): Adjusted some edge styles for better UX. Added dynamic selection of colors according to the current theme.

feat(dep-graph):  Added transition when switching themes.

feat(dep-graph): Readded auto roation for implicit label and dynamic background.

feat(dep-graph): Assigned generic types to selectDynbamically, and added new color to the pallete.

feat(dep-graph): Added dynamic styles for theming.

feat(dep-graph): Added mock for matchMedia. Tests will fail otherwise.

feat(dep-graph): Added styles to tippy.

feat(dep-graph): Moved theme related functions to theme-resolver file

feat(dep-graph): Implement dark mode on tooltips.

feat(dep-graph): re-evaluate graph colors on theme change

cleanup(dep-graph): Removed duplicate style

chore(dep-graph): Testing theme preferences

Adding test cases for theme initialization, and the ability to change.

cleanup(dep-graph): removing repeated style classes

Fixed issue with webpack plugin (nrwl#8231)

feat(npm): resolved issue with live reload failing

Fixed the issue with live reload when adding scripts in project.json

Closes nrwl#8230

chore(repo): update nx to 13.10.0-beta.1 (nrwl#9407)

feat(dep-graph): re-evaluate graph colors on theme change

fix(dep-graph): use theme background color in image download

* fix(dep-graph): change dark mode styles

* cleanup(dep-graph): cleanup e2e tests and naming

Co-authored-by: Philip Fulcher <philip@nrwl.io>
@Lcarv20 Lcarv20 deleted the dark-mode-changes branch April 3, 2022 19:49
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
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.

None yet

3 participants