stephenneale / seng371-group16

Contains Group 16's work for SENG371 A02 - Group 16, Spring 2023
0 stars 1 forks source link

Implement dark mode #58

Closed matt-lebl closed 1 year ago

matt-lebl commented 1 year ago

a.k.a. dim mode

Frontend

Add a button that switches the page style to a dark mode, with light text on dark background.

Backend

Add one POST endpoint to set dark or light mode, and a GET endpoint to check what's currently set.

stephenneale commented 1 year ago

After some brainstorming, I think I know how I'm gonna go about this. Could you add a "dark mode" endpoint to the rest API that either returns 0 or 1? This will be toggled by the button to switch between light and dark mode, and depending on what the endpoint returns I can generate the appropriate HTML.

matt-lebl commented 1 year ago

@stephenneale Sounds reasonable enough! So if I'm understanding correctly, we'll need one POST endpoint to set dark or light mode, and a GET endpoint to check what's currently set?

stephenneale commented 1 year ago

@stephenneale Sounds reasonable enough! So if I'm understanding correctly, we'll need one POST endpoint to set dark or light mode, and a GET endpoint to check what's currently set?

Yeah that'd work perfect :)

matt-lebl commented 1 year ago

On to you, @stephenneale ! 😃

matt-lebl commented 1 year ago

Well I should probably explain 😂

New endpoint: /darkmode. Submitting a GET to this endpoint will return a JSON response:

{
    "enabled": false
}

In this case indicating that dark mode is off. This operation doesn't toggle, only returns the state of the flag.

To change the flag, submit a POST request to the same endpoint with the same format as the GET response. So a POST that looks like this:

{
    "enabled": true
}

…will cause subsequent GETs to return

{
    "enabled": true
}

Let me know if you have any questions/notes!

matt-lebl commented 1 year ago

(in retrospect PUT would have likely been the more appropriate verb but we out here)

stephenneale commented 1 year ago

Everything's working as intended after my implementation found here, let me know what you think!