sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.

Home Page:https://sanic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dark mode / custom CSS for Sanic's own output

Tronic opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

Sanic currently creates error pages and assuming that PR #2662 is merged will be producing file listings with bright white background.

The Internet is moving to dark mode, with more or less all sites implementing dark background via @media (prefers-color-scheme: dark) if not as the only option. The bright white hurts eyes on modern screens that often output 200 nits of bright light for it, and many are used to working in all-dark-background environments, coders too often in all-dark rooms.

Describe the solution you'd like

Sanic generates its output from Python source code where the CSS is included as a string. Adding the media selector for automatic dark mode would be simple, or if minimalism is preferred, Sanic could even only implement a dark mode (but it is more polite to implement both so that users' browsers choose the one matching their desktop preference).

However, there is legitimate use for applications and enterprises using Sanic wanting to customize the pages further such that even the errors at least to a degree agree with their general visual style. This would be far harder to implement. Fetching the CSS as an extra file on an error page would be a bad idea, so basically Sanic would instead need to load those strings from some external source (e.g. during server startup).

I am opening this issue for discussion on the matter, that would work as a basis for a PR to come.

Additional context

No response

I am not so concerned about customization. If someone wants to customize the error pages, we already provide an api for that. I am not opposed to dark mode alternatives though. Our CSS is already very minimal.

Dark mode was implemented.