Skip to content

Commit e0eceb7

Browse files
committed
Add dark mode support to Airflow documentation site
Upgrade Docsy theme from v0.2.0 to v0.12.0 and implement Bootstrap 5 dark mode. Core Changes: - Enable showLightDarkModeMenu in config.toml - Add theme toggle component to navbar (light/dark/auto modes) - Store user preference in localStorage - Respect prefers-color-scheme media query Styling Implementation: - Use Bootstrap 5 CSS variables (--bs-body-color, --bs-secondary-bg, etc.) for all UI elements - Style navbar, header, sidebar, tables, admonitions, and forms for dark mode - Add Pygments-generated GitHub Dark theme for code syntax highlighting in Sphinx docs - Adapt confetti animation to dynamically set background based on theme - Ensure proper semantic colors for all admonition types (note, warning, error, hint, etc.) Technical Details: - Added $td-sidebar-tree-root-color variable (required by Docsy v0.2.0+) - Added $font-awesome-font-name variable (required by Docsy v0.6.0+) - Added .-bg-orange utility class (required by Docsy v0.6.0+) - Created pygments/_dark.scss (generated via: pygmentize -S github-dark) - Use hooks/body-end.html for webpack scripts (proper Docsy pattern) - Add dark mode support to Sphinx theme (header.html, layout.html) - Update .gitignore to exclude site/public/ directory Fixed Issues: - Confetti animation now visible with transparent header background - Sidebar links readable in dark mode (increased contrast) - All admonition types (including seealso) properly colored - Logo text white in dark mode - Navbar and header backgrounds adapt to theme Architecture: - Removed baseof.html override, use Docsy hooks instead - Follow Docsy best practices for customization - Use CSS variables for maintainability Testing: - Verified dark mode toggle works on all pages - Confirmed confetti animation adapts to theme changes - Tested all admonition types in light and dark modes - Verified code syntax highlighting in Sphinx documentation
1 parent b53c62f commit e0eceb7

File tree

20 files changed

+864
-119
lines changed

20 files changed

+864
-119
lines changed

landing-pages/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist/
33
site/data/webpack.json
44
resources/
55
site/static/_gen/
6+
site/public/

landing-pages/site/assets/scss/_colors.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $colors: (
3333
greyish-brown: #51504f
3434
);
3535

36-
// Background color utility class for Docsy theme compatibility
36+
// Background color utility class required by Docsy v0.6.0+ theme
3737
.-bg-orange {
38-
background-color: #FFA630; // Using $secondary color
38+
background-color: #FFA630; // Using $secondary color value
3939
}

landing-pages/site/assets/scss/_header.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
position: relative;
2323
margin: 123px -20px 0;
2424
min-height: calc(100vh - 123px);
25+
// background-color is handled by the canvas animation which draws white/dark background
26+
transition: background-color 0.3s ease;
2527
}
2628

2729
#header-canvas {
@@ -119,3 +121,22 @@
119121
}
120122
}
121123
}
124+
125+
// Dark mode styles
126+
[data-bs-theme="dark"] {
127+
#header {
128+
// background-color handled by canvas animation
129+
}
130+
131+
#header-canvas {
132+
.text-area {
133+
&--header {
134+
color: rgba(255, 255, 255, 0.95);
135+
}
136+
137+
&--subheader {
138+
color: rgba(255, 255, 255, 0.75);
139+
}
140+
}
141+
}
142+
}

landing-pages/site/assets/scss/_navbar.scss

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
border-bottom: solid 1px map-get($colors, very-light-pink);
2929
z-index: 32;
3030
padding: 30px 60px;
31+
transition: background-color 0.3s ease, border-color 0.3s ease;
3132

3233
&__menu-container {
3334
flex-grow: 1;
@@ -50,6 +51,7 @@
5051
margin-right: 30px;
5152
position: relative;
5253
width: fit-content;
54+
transition: color 0.3s ease;
5355

5456
&::before, &::after {
5557
content: "";
@@ -74,6 +76,43 @@
7476
&--box-shadow {
7577
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .12);
7678
}
79+
80+
// Theme toggle styling
81+
&__theme-toggle {
82+
display: inline-flex;
83+
align-items: center;
84+
position: relative;
85+
86+
.btn {
87+
padding: 0.25rem 0.5rem;
88+
font-size: 0.875rem;
89+
border: none;
90+
background: none;
91+
92+
svg {
93+
width: 1rem;
94+
height: 1rem;
95+
}
96+
}
97+
98+
.dropdown-menu {
99+
font-size: 0.8125rem;
100+
min-width: 7rem;
101+
padding: 0.25rem 0;
102+
left: 0 !important;
103+
right: auto !important;
104+
105+
.dropdown-item {
106+
padding: 0.375rem 0.75rem;
107+
font-size: 0.8125rem;
108+
109+
svg {
110+
width: 0.875rem;
111+
height: 0.875rem;
112+
}
113+
}
114+
}
115+
}
77116
}
78117

79118
@media (max-width: $tablet) {
@@ -154,3 +193,31 @@
154193
}
155194
}
156195
}
196+
197+
// Dark mode styles
198+
[data-bs-theme="dark"] {
199+
.navbar {
200+
background-color: #1a1a1a;
201+
border-bottom-color: #333;
202+
203+
&__text-link {
204+
color: rgba(255, 255, 255, 0.85);
205+
206+
&:hover, &.active {
207+
color: rgba(255, 255, 255, 1);
208+
}
209+
}
210+
211+
// Make logo text (Apache Airflow) white in dark mode
212+
&__icon-container {
213+
svg path[fill="#51504f"] {
214+
fill: rgba(255, 255, 255, 0.95);
215+
}
216+
}
217+
218+
// Also handle mobile drawer background
219+
&__drawer {
220+
background-color: #1a1a1a;
221+
}
222+
}
223+
}

landing-pages/site/assets/scss/_rating.scss

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,44 @@
3131
cursor: pointer;
3232
margin-right: 13px;
3333

34+
&:hover, &:hover ~ & {
35+
svg {
36+
path {
37+
fill: #017cee;
38+
stroke: none;
39+
}
40+
}
41+
}
42+
3443
svg {
3544
path {
3645
fill: none;
3746
stroke: #51504f;
3847
}
3948
}
49+
}
50+
51+
// Dark mode styles
52+
[data-bs-theme="dark"] {
53+
.rating-container {
54+
p {
55+
color: rgba(255, 255, 255, 0.85);
56+
}
57+
}
58+
59+
.rate-star {
60+
&:hover, &:hover ~ & {
61+
svg {
62+
path {
63+
fill: #68d2fe;
64+
stroke: none;
65+
}
66+
}
67+
}
4068

41-
&:hover, &:hover ~ & {
4269
svg {
4370
path {
44-
fill: #017cee;
45-
stroke: none;
71+
stroke: rgba(255, 255, 255, 0.75);
4672
}
4773
}
4874
}

landing-pages/site/assets/scss/_roadmap.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,8 @@
288288
}
289289
}
290290
}
291+
292+
// Dark mode styles for roadmap page
293+
[data-bs-theme="dark"] .roadmap .td-sidebar {
294+
background-color: #2d2d2d !important;
295+
}

0 commit comments

Comments
 (0)