rgerum / unofficial-duolingo-stories

This project brings the official Duolingo Stories to new languages, translated by a community effort.
https://duostories.org
135 stars 28 forks source link

Dark Mode Button Not Showed on Avatar Hover in Light Mode #245

Closed PaoloDiBello closed 10 months ago

PaoloDiBello commented 10 months ago

Steps to Reproduce:

  1. Login to the application.
  2. Upon login, ensure that the app is in light mode. (which should be always the case I assume)
  3. Hover over the avatar located at the top right corner.

Expected Behavior:

When hovering over the avatar in light mode, there should be a button for switching to dark mode.

Actual Behavior:

Instead of the dark mode button, the light mode button is being displayed upon hovering over the avatar in light mode.

Screenshot

image

Suggestions

In /src/components/login/loggedinbutton.jsx you could change

function useDarkLight() {
  const [activeTheme, setActiveTheme] = useState(
-    typeof document !== "undefined" ? document.body.dataset.theme : undefined,
+    typeof document !== "undefined" ? document.body.dataset.theme : "light",
  );
const inactiveTheme = activeTheme === "light" ? "dark" : "light";

Without those changes activeTheme could also be undefined.

 const inactiveTheme = activeTheme === undefined ? "dark" : "light"; // "light"

// so...
 toggle("light")

// and...
 {controls.value === "light" ? "Dark Mode" : "Light Mode"}  // controls.value is undefiend so "Light Mode" is shown 

A light Mode button with toggle("light"), and all this while the Light Mode is already on.

PaoloDiBello commented 10 months ago

image

The state is still undefined at the very beginning and it only changes when I click on the button, were the changes released to production? @rgerum

rgerum commented 10 months ago

The changes are first hosted on beta.duostories.org Are you able to run and test the website locally or are you doing the changes blind? I did not test your pull request, the code change looked resonable to I just had it merged.

rgerum commented 10 months ago

I hope the recent commit should now work 0572937 as seen on beta.duostories.org

PaoloDiBello commented 10 months ago

@rgerum yes, I confirm that it works now.