fossology / FOSSologyUI

Repository to hold the new UI framework for FOSSology built with React
https://fossology.github.io/FOSSologyUI/
GNU General Public License v2.0
49 stars 88 forks source link

fix(ui): light and dark mode refresh bug fixed #205

Closed d-e-v-esh closed 2 years ago

d-e-v-esh commented 2 years ago

Signed-off-by: Devesh deves125@gmail.com

Description

This bug was occurring because of a few reasons:

  1. Irregularities in the naming of variables made it confusing to know what a variable actually contains.
  2. useContext hook was implemented incorrectly. The way it was implemented is a very common mistake so it was easy to catch.

Changes

  1. I fixed the useContext implementation.
  2. Removed the line which made the page refresh.

My Suggestion

  1. Since the theme variable can only contain two values (light and dark), can we convert that into a boolean? That would make the logic much simpler.

  2. In the context file, we are exporting a state variable and a setTheme variable which might cause confusion. I think converting the state to a boolean will solve all the confusion. The code seems too complex for such basic logic.

I did not fix the naming convention. I would like to discuss it before changing anything as it could cause confusion. 👍


Screenshot

brave_bohFfjKKy2

Related PR

The original pull request #178 was deleted by mistake that contained some discussion, therefore this is the new PR.

How to test

You can simply toggle the theme change button

fixes #165