gh-137634: Modernizing calendar.HTMLCalendar for HTML Output#137635
gh-137634: Modernizing calendar.HTMLCalendar for HTML Output#137635hugovk merged 5 commits intopython:mainfrom
calendar.HTMLCalendar for HTML Output#137635Conversation
|
What problem does this solve? This PR changes the default theme to dark and hardcodes some colors -- what is the reason? Could not you just use a custom stylesheet? |
|
We provide basic dark mode support for the HTML generated by module. In 3.14 and 3.15 we've already added this feature for In this case, the loading order ensures that Regarding The hardcoded colors could potentially be changed, but this would make the code longer :root {
--background-color-dark: #121212;
--text-color-dark: #e0e0e0;
--border-color-dark: #444;
}
@media (prefers-color-scheme: dark) {
body { background-color: var(--background-color-dark); color: var(--text-color-dark); }
table.year, table.month, td, th { border-color: var(--border-color-dark); }
} |
|
I do not think we should hardcode any colors. This will simply lead to problems in the future when custom stylesheets becomes dependent on these values and they will be changed again. This also makes the HTML code longer. If you need calendar in dark mode, just create a custom stylesheet. |
|
Thank you for the suggestion. I will add them this weekend. Also, do you think it should support dark mode? 👀 |
|
I think dark mode would be useful, but can it be done without hardcoding colours? |
|
should light mode take precedent here? Would it be better to switch to |
|
Searching GitHub:
I don't notice any flash, but it's with a local |





We don't need to worry about css overwriting the user's css in dark mode, I moved the to the bottom of style, and users can override them according to css priority
Removed
cellpadding="0" cellspacing="0"they are deprecated:https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/cellPadding
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/cellSpacing
CC: @hugovk
calendar.HTMLCalendarfor HTML Output #137634📚 Documentation preview 📚: https://cpython-previews--137635.org.readthedocs.build/