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 #178

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

How to test

You can simply toggle the theme change button

fixes #165

GMishx commented 2 years ago

Thank you for your contribution @d-e-v-esh , to answer your question

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.

The plan is to allow multiple themes for use to choose from. Currently there are only light and dark themes available but there can be more in future. Therefore, we do not have the value as boolean ATM.

d-e-v-esh commented 2 years ago

@GMishx Thanks for the clarification. šŸ‘

GMishx commented 2 years ago

@Shruti3004 @sjha2048 can on of you please review this PR and merge it?

d-e-v-esh commented 2 years ago

I deleted the repo by mistake, I'll create another PR and link it here. šŸ‘

d-e-v-esh commented 2 years ago

Refer to #205 for the open PR.