Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit f52e290

Browse files
Kerumenrakannimer
authored andcommitted
feat(gatsby-theme-docz): add a config to hide the dark mode switch
(#1205)
1 parent b8c9afb commit f52e290

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

core/gatsby-theme-docz/src/components/Header/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { Logo } from '../Logo'
88

99
export const Header = props => {
1010
const { onOpen } = props
11-
const config = useConfig()
11+
const {
12+
repository,
13+
themeConfig: { showDarkModeSwitch },
14+
} = useConfig()
1215
const { edit = true, ...doc } = useCurrentDoc()
1316
const [colorMode, setColorMode] = useColorMode()
1417

@@ -17,7 +20,7 @@ export const Header = props => {
1720
}
1821

1922
return (
20-
<div sx={styles.wrapper} data-testid={'header'}>
23+
<div sx={styles.wrapper} data-testid="header">
2124
<Box sx={styles.menuIcon}>
2225
<button sx={styles.menuButton} onClick={onOpen}>
2326
<Menu size={25} />
@@ -26,10 +29,10 @@ export const Header = props => {
2629
<div sx={styles.innerContainer}>
2730
<Logo />
2831
<Flex>
29-
{config.repository && (
32+
{repository && (
3033
<Box sx={{ mr: 2 }}>
3134
<a
32-
href={config.repository}
35+
href={repository}
3336
sx={styles.headerButton}
3437
target="_blank"
3538
rel="noopener noreferrer"
@@ -38,9 +41,11 @@ export const Header = props => {
3841
</a>
3942
</Box>
4043
)}
41-
<button sx={styles.headerButton} onClick={toggleColorMode}>
42-
<Sun size={15} />
43-
</button>
44+
{showDarkModeSwitch && (
45+
<button sx={styles.headerButton} onClick={toggleColorMode}>
46+
<Sun size={15} />
47+
</button>
48+
)}
4449
</Flex>
4550
{edit && doc.link && (
4651
<a

core/gatsby-theme-docz/src/components/Header/styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export const wrapper = {
1111
export const innerContainer = {
1212
...mixins.centerAlign,
1313
px: 4,
14-
py: '24px',
1514
position: 'relative',
1615
justifyContent: 'space-between',
16+
height: 80,
1717
}
1818

1919
export const menuIcon = {

core/gatsby-theme-docz/src/theme/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default merge(typography, {
1414
showLiveError: true,
1515
showLivePreview: true,
1616
showPlaygroundEditor: true,
17+
showDarkModeSwitch: true,
1718
colors: {
1819
...modes.light,
1920
modes: {

0 commit comments

Comments
 (0)