-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Dark color scheme #152
Comments
We do. 😄 Integrated, but optional behind a config toggle, would indeed make sense. Or even something purely JS-based that shows a light switch on the client side for the user to switch at will. 🤔 💡 I won't be able to work on this shortly, so further discussion / PR welcome! |
Or, if the way of a config tunable, a dict of preferred style colors would empower the user more. Something like: # config.mako:
bright_color_theme = dict(foreground='black',
background='white',
link='...',
...)
dark_color_theme = ...
color_theme = bright_color_theme # Default |
An even better idea is to provide a basic set of easily overridable colors in CSS variables (e.g. in pdoc/templates/colors.css) like it's currently for highlighting color: Lines 6 to 8 in cd84fb3
Lines 184 to 186 in cd84fb3
|
Hello, I was also looking for dark theme for pdoc3, can you please tell what fields am i supposed to modify in css file? |
@xcodz-dot it's not available yet. There's just the idea to separate colors hard-coded all over css.mako into another file colors.css (or maybe theme.css), with CSS variables defined on the :root pseudo-class. That new file then needs to be included in the html.mako template: Lines 389 to 392 in aef1917
This sounds good enough in principle, but I think it's going to prove a breaking change for anyone who's customized their html.mako (but not css.mako). Lines 5 to 8 in aef1917
In either case, someone needs to figure it out, and I'd appreciate a PR. |
So the thing I have ended up with is to copy the default |
Ok, so looks like I have pretty much achieved a dark theme. I tested that theme on pdoc documentation. but there are somethings like warnings, todo, notes, etc... that i have to change color of, so is there something like Btw here is the progress by far (90% done): |
I'd rather first have a solid mechanism for customizing the color theme. We can bundle some themes after the feature spreads and matures. Till then, having the user provide |
that will be good if they use template-dir but what I meant is that In other words, It's still up to you. I will still be happy to contribute my added themes. Also, here is a alternative to
Now in second case we can identify and resolve the path to the selected theme and I will be complete with dark theme by 3 days or most probably earlier. |
Looks like my theme is complete and ready for use, also it's more like black theme so i will also try making a greyish dark theme |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jappi00 It's likewise not as grave as you're having it. See #310. 😅 @xcodz-dot I'm not a huge fan of populous CLI switches that sooner or later nobody has proper count of (cf. |
|
By the way here is the almost final theme: I changed scroll bar color and changed the color of code between back ticks. Also the location of the theme that i am working on is here |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
so my last word is that i am gonna do nothing more than hosting a simple github repository with my template because the codebase is too complex for me. |
Indeed, plugin support would be a heavy and questionably-worthwhile undertaking. At this stage still, extracting CSS colors into a separate overridable colors.css, as above, seems the most reasonable course of action. |
and yes that's what i did. so i guess i will soon host the repo for the dark theme. I have some work to do currently |
Well here is another dark mode css.mako generated with coolors: I do also have a suggestion: create a new repo |
From what I'm reading, it seems to me like this needs a little bit of fleshing out requirements-wise. I am tempted to give it a whack, but even if someone else decides to, might be nice to have these things listed in one space. Edit: I am obligated to disclose that this is all selfish, as I am starting to introduce code-based self-documentation at work for our legacy Python projects, so this could go hand-in-hand with requirements I have thought up. Edit #2: Decided to do some preliminary work around this, will do a PR once in a workable state. I still want to use this for myself, but in case this is good enough to act as a fully fledged theme support feature for pdoc that'd be even cooler. Requirements
ConsiderationsDark Mode support:It seems like currently the CSS files are split up by "platform", I.E. mobile, desktop and print (although print is the odd one out here). I (personally) feel like there is no need for this at all, and the base style should just be one CSS file utilising an import of CSS vars (either from a preceding stylesheet or from the same one). I would also carefully re-group component-scope declarations in order to position them for the inevitable: :root {
--bg-primary: #fff;
--fc-primary: #000;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-primary: #000;
--fc-primary: #fff;
}
}
body {
background-color: var(--bg-primary);
color: var(--fc-primary);
} What's great about this approach is that we can leverage
<%def name="make_colors()">
<%
# Name, default, dark mode
css_colors = [
("--bg-primary", "#FFF", "#000"),
("--bc-primary", "#000", "#FFF")
]
default = [f"\n\t{c[0]}: {c[1]};" for c in css_colors]
dark = [f"\n\t\t{c[0]}: {c[2]};" for c in css_colors]
vardef = (
f"\n:root {{{ ''.join(default) }\n}}"
+ f"\n@media (prefers-color-scheme: dark) {{"
+ f"\n\t:root {{{ ''.join(dark) }\n}}"
+ f"\n}}"
)
%>
${ vardef }
</%def>
## Minify removed for output testing..
<%def name="desktop()">
${make_colors()}
...
<style media="screen and (min-width: 700px)">
:root {
--bg-primary: #FFF;
--bc-primary: #000;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-primary: #000;
--bc-primary: #FFF;
}
}
@media screen and (min-width: 700px) {
... This means that these color variables could be config(or file)-driven allowing drop-in replacements for the sake of theming. Or you could have override files which Mako could diff between them and the default config to only apply variables that are included and leave un-overridden ones as default. I think this could be a clean approach, albeit it would require a small rewrite to the Non-breaking changesHonestly, this it tough, because frankly if people are editing the For those who did not touch the css source, nothing changes. Any variations introduced in-html are frankly outside that context and are brittle by default. Say the use of inline styles - it's neither recommended (unless done via some automated and robust means) nor is it something that fosters compatibility. It's not necessarily easy for me to suggest people "suck it up" in this case, so maybe a note around moving custom components and styles out of templates and into the CSS file would be enough of a nudge. ThemingWith the change proposed/detailed above, I believe theming would become trivial. In-fact you could even provide a small pre-rendered "generator" SPA which would give users a nice UI around color changes which reflect how they will appear in the UI. Sort of like Bootstrap Magic, but incredibly scaled down for the purposes of function over form and small bundle size. It's just an idea, but would greatly extend support for theming. In closingI am unsure if I have missed any obvious points, but so far from what I have looked at, this could be a nice way to introduce dark mode and theming to PDOC, and hopefully not mess stuff up too much retroactively. |
An update from my side - I have got a preliminary working dark mode and easier theming support (See gifs below for demo of this). I retained all of the original styling of The color info was moved out of ChangesThe way I've implemented this is that it is driven via
## ...
hljs_style_tuple = ('github', 'atom-one-dark') ## Replaces `hljs_style`
## ...
css_theme = 'default' The The The template structure has changed thusly: templates/
|__themes/
| |__custom.mako
| |__default.mako
|_ config.mako
|_ ... Each theme is it's own file and contains the following structure:
<%!
from pdoc.html_helpers import minify_css
colors = [
("--bg-highlight-color", "#FFEE99", "#3E4951"),
("--bg-default", "#FFFFFF", "#22282D"),
## ...
]
default = [f"{color[0]}: {color[1]};" for color in colors]
dark = [f"{color[0]}: {color[2]};" for color in colors]
root_light = f":root[data-theme='theme-light'] {{{''.join(default)}}}"
root_dark = f":root[data-theme='theme-dark'] {{{''.join(dark)}}}"
root_light_auto = f"@media (prefers-color-scheme: light) {{ :root[data-theme='theme-light'] {{{''.join(default)}}} }}"
root_dark_auto = f"@media (prefers-color-scheme: dark) {{ :root[data-theme='theme-dark'] {{{''.join(dark)}}} }}"
color_variables = f"{root_light}{root_dark}{root_light_auto}{root_dark_auto}"
%>
<%def name="style()" filter="minify_css">
${color_variables}
</%def> The css template also changed to now contain styling sans the color values and instead relies on the provided vars from the theme file. Which keeps the structure completely intact, but allows easy theming. All someone has to do is copy the Left to implement
Demo |
Hope your work will be merged soon 🙏 |
@pm5k Is dark mode still something that might show up? It looks great |
As far as I am concerned, I do not think this is happening anytime soon, you can use my theme here if you would like to. You can copy the folder to where you run the commands and while generating the docs with the pdoc command just add this flag: |
Hey,
I think we all love Darkmodes. What about pdoc? I think a default integrated Darkmode would be great! What do you think about something like this? Thank you for this awesome package!
The text was updated successfully, but these errors were encountered: