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

Up usehooks ts #707

Merged
merged 9 commits into from
Feb 14, 2024
Merged

Up usehooks ts #707

merged 9 commits into from
Feb 14, 2024

Conversation

technophile-04
Copy link
Collaborator

Description

Updated all the usehooks-ts package, it seems that useDarkMode is (broken still)*.

I tried both our custom useDarkMode and useDarkMode from usehooks-ts.

For some strange reason it borken on my arc browser but it works fine Chrome! :(

Screen.Recording.2024-02-08.at.12.02.12.AM.mov

I think one of the main reason might be both rely on useMediaQueryHook which relies on (prefers-color-scheme: dark) as I read few discussions it might be the case even though user OS is set to light, some browser extension or browser itself can force (prefers-color-scheme) to be dark or light

Would love it if others could test, will try to dig more on this also please feel free to suggest any other approaches to handle it 🙌

Also a question :

What if we use some alternate approaches to handle theme ? Which will handle both flickering of theme on initial render (when dark mode is choosen) and also handle this theme switch logic ?

It seems people tend to use:

  1. next-theme
  2. cookie approachs ( 1 & 2 ),
  3. inserting script tag approach

@Pabl0cks
Copy link
Collaborator

Pabl0cks commented Feb 7, 2024

Nice job @technophile-04, digging so fast into the problem, documenting it and trying this approach 🙌

Would love it if others could test, will try to dig more on this also please feel free to suggest any other approaches to handle it 🙌

Here are the results of my first tests in Chrome and Firefox (both working equal for me):

  • With OS (Windows) in dark mode:
    • Turning ON Light mode in SE-2, without contracts deployed, Debug tab works fine. Disconnect+Connect wallet turns it to Dark
    • Turning ON Light mode in SE-2, with contracts deployed, Debug tab and Disconnect+Connect wallet turns it to Dark mode
  • With OS (Windows) in light mode:
    • Everything works fine, SE-2 Light does not change to Dark on any action and vice versa.

@technophile-04
Copy link
Collaborator Author

With OS (Windows) in dark mode

Yeah !, really weird happens with me too

Thanks @Pabl0cks for the really nice testing and reproduction as always !!!


After debugging a lot for useDarkMode nothing works properly even tried tinkering with custom useDarkMode but no luck :(, but would love if someone could give a shot !

Create #712 with next-themes, I think its worth giving a control to the library since it handles most of the cases very nicely (like flickering, etc too).

At the beginning, I thought it's not worth using the whole library just to handle the theme but digging a bit deep in the NextJS context I think its worth using due to all the caveats present, and handling them ourselves properly might be a pain.

@technophile-04
Copy link
Collaborator Author

Tysm all, Merging this 🙌!

@technophile-04 technophile-04 merged commit 2d98105 into main Feb 14, 2024
1 check passed
@technophile-04 technophile-04 deleted the up-usehooks-ts branch February 14, 2024 13:09
@github-actions github-actions bot mentioned this pull request Feb 15, 2024
kmjones1979 added a commit that referenced this pull request Feb 15, 2024
* Add Optimism Sepolia config (#711)

* Use arbitrumSepolia instead of Goerli (#716)

* up rainbowkit version to 1.3.5 (#719)

* removing lock file

* use next-themes to handle theme and update usehooks-ts (#707)

* Feat: Better complex struct inputs (#702)

* improve debug struct UI (#726)

* add basic example to show connected address (#721)

---------

Co-authored-by: winnsterx <46658657+winnsterx@users.noreply.github.com>
Co-authored-by: Shiv Bhonde | shivbhonde.eth <shivbhonde04@gmail.com>
Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>
@technophile-04 technophile-04 mentioned this pull request Aug 30, 2024
2 tasks
lukaw3d added a commit to oasisprotocol/abi-playground that referenced this pull request Sep 6, 2024
Removed useDarkMode leftovers after c1e7ca0.
Related to scaffold-eth/scaffold-eth-2#707.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants