Closed matt-lebl closed 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.
@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 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 :)
On to you, @stephenneale ! 😃
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!
(in retrospect PUT would have likely been the more appropriate verb but we out here)
Everything's working as intended after my implementation found here, let me know what you think!
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.