-
Notifications
You must be signed in to change notification settings - Fork 26
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: Dark theme implementation for Sway Playground #83
Conversation
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.
Thank you for the contribution! This is looking really good. I have a few initial comments and I will dig in deeper on Monday.
In Dark Mode, I think all buttons other than compile should have a light gray color for the text rather than green. This highlights the compile button, which is the primary button on the page. It might look better for the compile button to have green text with a dark backrgound. I will experiment with it and test it out soon.
Thank you again!
I noticed also that the theme button disappears when the "interact" drawer is open. Edit: It is also missing in mobile view. You might need to put it in App.tsx rather than in the action toolbar to make sure it's above everything. |
… removed redunndant import.
Hey there, I'm really glad that you've reviewed my PR and liked my dark theme, thank you! I've made some changes you've commented on and waiting for your reply regarding dark theme buttons styling. I tried some of the variants you've suggested and in the video, I also tried the text to be green on hover. OnHoverGreen.mp4 |
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.
You might also want to look into MUI ThemeProvider since the app uses MUI extensively.
https://mui.com/material-ui/customization/dark-mode/
Here's an example of toggling the mode: https://mui.com/material-ui/customization/dark-mode/#toggling-color-mode
Actually using useFuelTheme
is probably better. Here's an example in the documentation site:
https://github.com/FuelLabs/docs-hub/blame/e159d2edc4b4e4494904ac0b96e2b8591a414e97/src/hooks/useTheme.tsx
Thank you for all the comments/suggestions I've read them all,will make changes during weekends and come back with an updated version! |
Good day! I think I've made all the changes you mentioned, tried to stick to black/white styling that time but if some colors need to be changed - I'll change them. In |
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.
As a heads up, I'm adding linting and formatting to CI.
You can copy the changes from package.json in this PR to run the lint + formatter scripts on this code, or wait until that PR is merged and merge from master to run them. There might be merge conflicts but they'll be simple things like changing '
s to "
s
npm run lint
and npm run format
Thank you for an update, woking on the changes 🫡 |
Good day, I hope I didn't miss anything. Now it is looking way better than in my first commit)).Is there anything else I should change? |
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.
Thanks for the quick turnaround. I left a couple more nits/questions, then I think it's ready to go 🚀
I made some small changes, as you suggested. Regarding dividers in dark mode, I could create a custom |
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.
Sorry, I had a couple more comments from Friday that I forgot to post. I will go ahead and commit them if I can and then approve. Thanks for your hard work on this PR!
Thank you so much, it was a please for me! |
Closes #45
Videos may be a bit laggy as my PC is not quite powerful:)
Intro
Hey there, I've done a Dark Theme for Sway Playground by creating
themeContext
and then just made other components to know about the current state oftheme
.A bit below I'll explain all my steps in details, just wanted to say that I really want to have this working so I'm open for making changes and enhancing the implementation of the dark theme.Implementation explanation
I think I'll start with explaining how I set up a
theme
and then I'll go through the components I've edited.themeContext.ts
Using React context API I created a
context
.It has a theme property (it has 2 states - light or dark), andsetTheme
- to set a theme (on page load or on SwitchThemeButton click).Also created
useThemeContext
hook so we can make sure theme has been set up properly and with it we will be accessing theme and setTheme.SwitchThemeButton.tsx
The main functionality just a simple switch theme button, that sets the theme to an opposite one once clicked.
Other code is styling (sets a Moon Icon when the dark theme is set and a Sun Icon when the light theme is set).
App.tsx
For some reason on github, it shows my changes kinda wrong.
The changes you see below is everything I've done in
App.tsx
:And wrapped my entire app with Theme Provider so all my components are aware of the current
theme
state:Finally, depending on theme set the background color of our main div:
background: theme==='light' ? '#F1F1F1': 'black',
Copyable.tsx
Imported custom
useThemeContext
hook with which accessed currenttheme
state:const theme = useThemeContext().theme;
div
andContentCopyIcon
.SecondaryButton.tsx
Button
.shared.tsx
Created a
BorderColor
function which depending on a theme will changeStyledBorder
color.DarkThemeStyling
- this is styling for dropdowns and inputs for dark theme,ExampleDropdown.tsx & ToolchainDropdown.tsx
Imported DarkThemeStyling
Created a
dropdownStyling
which depending on the theme state will use styling fromshared.tsx
or will return nothing (default styling will be applied). And this styling we will pass tosx
ofFormControl
.Added MenuProps and removed background styling from Select components for styling purposes.
LogView.tsx
LogView
.SolidityEditor.tsx & SwayEditor.tsx & ComplexParameterInput.tsx
Imported another editor theme from AceEditor -
tomorrow_night_bright
With useMemo depending on the theme's current state set
themeStyle
to tomorrow_night_bright | chromeIn the AceEditor component assign the theme:
theme={themeStyle}
DryrunSwitch.tsx
Switch
andtext
close to it.FunctionCallAccordion.tsx
Accordion
,ExpandMoreIcon
, andFormLabel
.FunctionParameters.tsx
I decided to create a custom TableCellComponent to avoid passing the same changes over and over again.
Replaced
TableCellComponent
instead ofTableCell
, but in the place of parameters input leftTableCell
to be able to input our parameters.FunctionToolbar.tsx
InteractionDrawer.tsx
ParameterInput.tsx
ResponceCard.tsx
ActionTollbar.tsx
1.Using useEffect hook on page load we check the system preferences of the user and set the theme state to user preferences.
{!isMobile && <SwitchThemeButton />}
- check if we are not in the mobile version then we should be able to seeSwitchThemeButton
.That is pretty much it.If something needs to be refactored or changed, will be glad to make edits <3
bandicam.2024-05-12.15-40-49-539.mp4
Phone.Sway.Playground.MP4