Skip to content

Commit 7aca7bb

Browse files
authored
Docs darkmode hydra (#2179)
Credit goes to @boemekeld - I had to wrap DOM access to document inside of `useState` in order to get rid of docusaurus build errors. --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
2 parents f7702a6 + 1059296 commit 7aca7bb

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

docs/docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const config = {
155155
({
156156
colorMode: {
157157
defaultMode: "light",
158-
disableSwitch: true,
158+
disableSwitch: false,
159159
respectPrefersColorScheme: false,
160160
},
161161
navbar: {

docs/src/css/custom.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@
8787
}
8888

8989
/* For readability concerns, you should choose a lighter palette in dark mode. */
90-
[data-theme="dark"] {
90+
html:not(.plugin-pages)[data-theme="dark"] {
9191
--ifm-color-primary: var(--ifm-color-primary-light);
9292
}
93+
html.plugin-pages[data-theme='dark'] {
94+
--ifm-navbar-link-color: #1c1e21;
95+
}
96+
html.plugin-pages .navColorModeToggle{
97+
display: none;
98+
}
9399

94100
@media (min-width: 768px) {
95101
:root {
@@ -117,7 +123,7 @@ h4 {
117123
line-height: 30px !important;
118124
}
119125

120-
html {
126+
html:not([data-theme='dark']), html.plugin-pages {
121127
@apply text-black;
122128
}
123129

@@ -294,7 +300,7 @@ svg.architecture {
294300
}
295301
}
296302

297-
.navbar__brand:hover {
303+
html.plugin-pages .navbar__brand:hover {
298304
color: #283032;
299305
}
300306

@@ -319,11 +325,17 @@ svg.architecture {
319325
order: 3;
320326
}
321327

328+
.DocSearch-Button {
329+
margin: 0 10px 0 16px !important;
330+
}
322331
.DocSearch-Button .DocSearch-Search-Icon {
323332
color: black !important;
324333
height: 24px !important;
325334
width: 24px;
326335
}
336+
html:not(.plugin-pages)[data-theme='dark'] .DocSearch-Button .DocSearch-Search-Icon {
337+
color: white !important;
338+
}
327339

328340
.DocSearch-Button {
329341
padding: 0 !important;

docs/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function Home() {
1919
<div className="z-index:1000">
2020
<Layout>
2121
<HomepageHero />
22-
<main>
22+
<main className="bg-white">
2323
<Features />
2424
<div className="pageContainer">
2525
<AnimatedText />

docs/src/theme/Logo/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { useState, useEffect } from 'react';
23
import Link from "@docusaurus/Link";
34
import useBaseUrl from "@docusaurus/useBaseUrl";
45
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
@@ -7,9 +8,16 @@ import ThemedImage from "@theme/ThemedImage";
78
import useMediaQuery from "../../hooks/useMediaQuery";
89
import { forPhablet } from "../../../helpers/media-queries";
910
function LogoThemedImage({ logo, alt, imageClassName }) {
11+
12+
const [isHome, setIsHome] = useState(false);
13+
14+
useEffect(() => {
15+
setIsHome(document.documentElement.classList.contains("plugin-pages"));
16+
}, []);
17+
1018
const sources = {
1119
light: useBaseUrl(logo.src),
12-
dark: useBaseUrl(logo.srcDark || logo.src),
20+
dark: useBaseUrl(isHome ? logo.src : logo.srcDark || logo.src),
1321
};
1422
const themedImage = (
1523
<ThemedImage

docs/src/theme/Navbar/Content/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default function NavbarContent() {
6363
right={
6464
<>
6565
<NavbarItems items={rightItems} />
66-
<NavbarColorModeToggle className={styles.colorModeToggle} />
66+
<div class="navColorModeToggle"><NavbarColorModeToggle className={styles.colorModeToggle} /></div>
6767
{!searchBarItem && (
6868
<NavbarSearch>
6969
<SearchBar />

0 commit comments

Comments
 (0)