-
Notifications
You must be signed in to change notification settings - Fork 16
feat: sphinx dark theme #1146
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
feat: sphinx dark theme #1146
Conversation
Thanks, @danielhe4rt. It looks suitable for my untrained eye, but I would like a professional designer to review it. |
@tzach just to be clear: Nextur is a Senior UX/UI. I think we need a professional front-end to review it. Also I'll test with the main ScyllaDB documentation and see if I missed something. He got some cool ideas but I didn't risked to implement since I'm not a front-end :p I'll ask some FE folks to check the merge request too. |
src/css/main.scss
Outdated
body { | ||
@apply dark:bg-surface-base dark:bg-gradient-to-tl dark:from-gradient-start dark:to-gradient-end; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before and after body, is alright have two lines?
src/css/components/_labels.scss
Outdated
} | ||
|
||
&--caution { | ||
background-color: $color-background-label-caution; | ||
@apply dark:border-[#FFAB00EB] dark:bg-[#FFAB006B]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is alright two lines?
src/css/components/_footer.scss
Outdated
|
||
img { | ||
@apply dark:scylla-icon-svg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this one. I'll fix it later, thanks!
src/css/base/_index.scss
Outdated
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary lines
src/css/base/_reset.scss
Outdated
code { | ||
@apply py-0.5 px-2 border-8 dark:text-typography-titlelink dark:bg-navigation-base bg-[#f7f8f9] !important; | ||
} | ||
|
||
.highlight pre { | ||
@apply dark:bg-navigation-base dark:text-typography-title !important; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently !important
tags should be escaped as per preprocessors docs
code { | |
@apply py-0.5 px-2 border-8 dark:text-typography-titlelink dark:bg-navigation-base bg-[#f7f8f9] !important; | |
} | |
.highlight pre { | |
@apply dark:bg-navigation-base dark:text-typography-title !important; | |
} | |
code { | |
@apply py-0.5 px-2 border-8 dark:text-typography-titlelink dark:bg-navigation-base bg-[#f7f8f9] #{!important}; | |
} | |
.highlight pre { | |
@apply dark:bg-navigation-base dark:text-typography-title #{!important}; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are plenty other places where this is used, if it is to be fixed those should be found, I won't pin point them as it may be unnecessary.
src/css/components/_header.scss
Outdated
.dark-theme-toggle { | ||
@apply dark:text-white text-black p-2 dark:bg-navigation-base bg-gray-200 rounded focus:outline-none; | ||
display: flex; | ||
flex-direction: row; | ||
margin-right: 12px | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not commit all to tailwind?
.dark-theme-toggle { | |
@apply dark:text-white text-black p-2 dark:bg-navigation-base bg-gray-200 rounded focus:outline-none; | |
display: flex; | |
flex-direction: row; | |
margin-right: 12px | |
} | |
.dark-theme-toggle { | |
@apply flex flex-row mr-3 dark:text-white text-black p-2 dark:bg-navigation-base bg-gray-200 rounded focus:outline-none; | |
} |
sphinx_scylladb_theme/side-nav.html
Outdated
@@ -1,4 +1,4 @@ | |||
<div id="side-nav" class="side-nav custom-scroll-bar" data-closable data-toggler=".show"> | |||
<div id="side-nav" class="side-nav @apply dark:bg-navigation-base custom-scroll-bar" data-closable data-toggler=".show"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div id="side-nav" class="side-nav @apply dark:bg-navigation-base custom-scroll-bar" data-closable data-toggler=".show"> | |
<div id="side-nav" class="side-nav dark:bg-navigation-base custom-scroll-bar" data-closable data-toggler=".show"> |
I don't think you need @apply
here since you're already on a "class"
src/js/dark-theme.js
Outdated
el.addEventListener('click', () => { | ||
if (document.documentElement.classList.contains('dark')) { | ||
document.documentElement.classList.remove('dark'); | ||
localStorage.setItem('dark-mode', 'false'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small tip, but it should be easier to handle values using json stringify and json parse
localStorage.setItem('dark-mode', 'false'); | |
localStorage.setItem('dark-mode', JSON.stringify(false)); |
src/js/dark-theme.js
Outdated
toggle(darkModeTogleEl, 'flex') | ||
} else { | ||
document.documentElement.classList.add('dark'); | ||
localStorage.setItem('dark-mode', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localStorage.setItem('dark-mode', 'true'); | |
localStorage.setItem('dark-mode', JSON.stringify(true)); |
src/js/dark-theme.js
Outdated
} | ||
|
||
|
||
if (localStorage.getItem('dark-mode') === 'false') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (localStorage.getItem('dark-mode') === 'false') { | |
if (!JSON.parse(localStorage.getItem('dark-mode'))) { |
src/js/dark-theme.js
Outdated
@@ -0,0 +1,41 @@ | |||
if (localStorage.getItem('dark-mode') === 'true') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (localStorage.getItem('dark-mode') === 'true') { | |
if (JSON.parse(localStorage.getItem('dark-mode'))) { |
Thanks @danielhe4rt! The theme currently uses Foundation Framework. Do we need to load Tailwind and have two CSS frameworks just for this feature? Note that the theme already defines all colors in _colors.scss. I was thinking a better approach would be to change SCSS variables to standard CSS variables and define two color schemas as follows: :root {
--color-black: #000;
--color-white: #ffffff;
--color-background-footer: var(--color-white);
(...)
}
.dark-mode {
--color-background-footer: var(--color-black);
(...)
} Similar to what you did on https://github.com/scylladb/sphinx-scylladb-theme/pull/1146/files#diff-a37591e286af1d6159d657820ec36c4a9df2696a4ac603893c33e5601a7a6c2c, but controlling and overriding all the colors from there, not just: Then, we can load the dark theme class conditionally to the tag once we click the toggle button. This way, we have control over colors in just one file, we don't have to edit every CSS class, and we don't need Tailwind at all. |
Hi @danielhe4rt, Thanks for opening this PR. We definitely need a dark theme for the docs.
In short, I fully agree with the approach suggested by @dgarcia360 above. Could you update this PR or open a new one to apply his suggestions? |
Hey @dgarcia360 and @annastuchlik. I have no problem to only use one framework into it. However IMHO it will be way easier to maintain a TailwindCSS project... There's too much hardcoded width and heights in the current project in a way that in bigger screens it would be a problem. With TailwindCSS this wouldn't be an issue for each component. But I'm not a Front-end Developer, I'm just a curious person with a developer stack and a dream LOL... In each case, I'll try to implement the color scheme like @dgarcia360 suggested, but I still gonna run a fork for a project that I'm working on with @timkoopmans using TailwindCSS. |
@kwiato please take a look |
replaced by #1164 |
Hi @danielhe4rt
We can always switch frameworks if there are clear benefits. If you think it's a better approach, consider creating a new issue with a proposal. It would be helpful to see a comparison of pros and cons, as well as an outline of what changes would be needed to understand the impact.
I'm not sure how this relates to the dark mode, could you please elaborate? Bigger screens can always be handled with media queries. Switching to TailwindCSS won't automatically fix having fixed widths and heights (it's only a wrapper on top of CSS), it will depend on the implementation.
Thanks! Let's continue with the revision in the next PR. |
Hi @dgarcia360 Thanks for the info - I didn't realize we were using foundation for the scylladb sphinx theme. FWIW I don't have a strong preference for any theme, be it tailwind, foundation or material (which seems to be scylladb cloud for example). I do think it would be a good idea to start aligning subdomains a little more in terms of theming, but will let the new UI/UX person (Rafal) take lead on that. In the short term, if I wanted to introduce a simple card component e.g. Does the current scylladb sphinx theme support native UI components of foundation e.g. https://get.foundation/sites/docs/card.html Or do we have to roll our own CSS/HTML? What would be the best way to work within the current implementation of our framework? |
@timkoopmans consider using the topic box directive: https://sphinx-theme.scylladb.com/stable/examples/topic-box.html#topic-box |
I did see topic box. Question is do we implement full set of foundation UI elements or is it a subset? |
Hey folks!
After some hours hacking into the Sphinx, I managed to add dark theme by adding TailwindCSS.
Motivation
Since I'm working mostly at night in these past days, my sight get tired faster than during the day by the fact of the screen brightness + white theme. So I've decided to implement this to make it an option not only for me, but for the other users that probably are looking for this feature.
This PoC/Concept was designed by @nexturhe4rt (cheers).
Here I simply applied the colors and enhance a couple of css mostly in the navigation.
I'd like to hear some feedbacks on that!
PoC/Concept
Actual Implementation
Transition gif

Hero/Landing

Content page

Mobile Toggle:
