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

Add darkmode after login #581

Merged
merged 3 commits into from
Feb 10, 2024
Merged

Conversation

T0biii
Copy link
Member

@T0biii T0biii commented Feb 4, 2024

added darkmode but atm only darkmode, no light mode:
i tried this form the Docs:
https://mui.com/material-ui/customization/dark-mode/#system-preference
but it did not work for me

maybe add also a toggle like:
https://mui.com/material-ui/customization/dark-mode/#toggling-color-mode

"/"
image

"/admin/all-devices"
image

"Popup"
image

image

Copy link

mergeable bot commented Feb 4, 2024

Thanks for creating a pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while.

@GoliathLabs
Copy link
Member

A toggle option would be nice. What exactly didn't work out for you?

@T0biii
Copy link
Member Author

T0biii commented Feb 4, 2024

the const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); (MediaQuery) did not seem to work also nothing happend when i pressed the icon(Button) i added
Unfortunately, I also have no idea about TypeScript, which makes debugging difficult for me

@GoliathLabs GoliathLabs changed the title WIP: add darkmod after login WIP: add darkmode after login Feb 4, 2024
@T0biii
Copy link
Member Author

T0biii commented Feb 6, 2024

here are the branche where i tested more stuff:
https://github.com/T0biii/wg-access-server/tree/test-darkmode

@GoliathLabs
Copy link
Member

@T0biii you could try an useEffect call for that.

useEffect(() => {
    setDarkMode(prefersDarkMode);
}, [prefersDarkMode]);

Not the cleanest solution, though. Perhaps @nwaldispuehl has an idea?

@T0biii
Copy link
Member Author

T0biii commented Feb 6, 2024

@T0biii you could try an useEffect call for that.

useEffect(() => {
    setDarkMode(prefersDarkMode);
}, [prefersDarkMode]);

Not the cleanest solution, though. Perhaps @nwaldispuehl has an idea?

i dont know where

@nwaldispuehl
Copy link

I will happily have a look at it in the next days.

- initializing the theme with the OS setting
- adding toggle button in navigation bar
- introducing global state
- keeping user preference in local storage (if different to OS setting)
@nwaldispuehl
Copy link

nwaldispuehl commented Feb 10, 2024

First thanks for the cool feature, @T0biii ! 👍
I idly wished for a dark mode many times.

I allowed myself to just add the missing things:

  • a toggle switch taken 1:1 from the Mui sample as linked above
  • added the light mode, and initializes it depending on the operating system preference
  • storing the preference in the browsers localStorage

Light:
2024-02-09_19-40_1

Dark:
2024-02-09_19-40

@nwaldispuehl nwaldispuehl marked this pull request as ready for review February 10, 2024 20:20
@nwaldispuehl nwaldispuehl requested a review from a team as a code owner February 10, 2024 20:20
@nwaldispuehl nwaldispuehl changed the title WIP: add darkmode after login Add darkmode after login Feb 10, 2024
@T0biii
Copy link
Member Author

T0biii commented Feb 10, 2024

looks very good too me. thank you for taking it on.

@T0biii
Copy link
Member Author

T0biii commented Feb 10, 2024

i only found if you want to delete a device/user from the Admin Page it is not in darkmode

https://github.com/freifunkMUC/wg-access-server/blob/master/website/src/components/Present.tsx

image

@T0biii
Copy link
Member Author

T0biii commented Feb 10, 2024

should fix it
image

@GoliathLabs GoliathLabs merged commit d9636d9 into freifunkMUC:master Feb 10, 2024
10 checks passed
@GoliathLabs
Copy link
Member

Merged. Thank you @T0biii @nwaldispuehl <3

@T0biii T0biii deleted the darkmode-afterlogin branch February 10, 2024 22:22
@T0biii
Copy link
Member Author

T0biii commented Feb 11, 2024

big thanks to @nwaldispuehl for making the important chagnes

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.

3 participants