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 CSS body classes for each page #1767

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dmadison
Copy link

This PR adds classes to the body element for each individual page, so that it's easier to style pages differently:

Title (en) Route Class
WiFiManager / home
Config ESP /wifi wifi
Credentials saved /wifisave wifi
Info /info info
Setup /param param
Setup saved /paramsave param
Restart /restart restart
Exit /exit exit
Close /close close
Erase /erase erase
Update /update update
options /u update

This is accomplished by modifying the getHTTPHead() function to add an optional String argument for classes to add, and a set of constant class strings in the wm_consts header. The class strings are then invoked in each respective route "handle" function when the head is generated.

I did not add separate classes for the "saved" pages, as that seemed excessive. But I'm happy to go in and add them if you think it would be beneficial.

This change does not break the current API and should add minimal overhead.

Note that the additional function argument for getHTTPHead() includes a default argument for backwards compatibility with the API.
Allows easy styling of each page
Trying to avoid confusion between the class for the root level and the CSS ":root" pseudo-class
Avoids an extra space if a body class is set, but an empty string is passed to the function
@tablatronix tablatronix added enhancement Feature Request 🕸️ HTTP HTTP Related issue labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature Request 🕸️ HTTP HTTP Related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants