Skip to content

Commit 905e224

Browse files
Fix/dark mode ui/ux (#565)
* Fix mobile layout for Algolia search modal * Fix text wrap in search modal at certain screen widths * Dark Mode: Fix parts of the background on search results page * Dark Mode: Improve general experience, contrast, backgrounds, buttons, etc.
1 parent c157fad commit 905e224

7 files changed

Lines changed: 111 additions & 4 deletions

File tree

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ const config = {
218218
logo: {
219219
alt: 'Netwrix Logo',
220220
src: 'branding/Netwrix_Logo_Dark.svg',
221-
srcDark: 'branding/Netwrix_Logo_Light.svg',
221+
srcDark: 'branding/logo-light.svg',
222222
href: '/',
223223
},
224224
items: [

src/components/CommunityHighlights/styles.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@
105105
border-color: var(--ifm-color-emphasis-200);
106106
}
107107

108+
[data-theme='dark'] .featuredLabel {
109+
background: linear-gradient(45deg, #8d1f1f, #835b00);
110+
color: #fff;
111+
}
112+
108113
.featuredCard::before {
109114
content: '';
110115
position: absolute;

src/pages/index.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@
234234
background: var(--ifm-background-color);
235235
}
236236

237+
[data-theme='dark'] .stats {
238+
background: linear-gradient(135deg, #003c6c 0%, #005a9e 100%);
239+
}
240+
237241
/* Responsive */
238242
@media screen and (max-width: 996px) {
239243
.heroBanner {

src/theme/ColorModeToggle/index.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import useIsBrowser from '@docusaurus/useIsBrowser';
4+
import {translate} from '@docusaurus/Translate';
5+
import IconDarkMode from '@theme/Icon/DarkMode';
6+
import IconLightMode from '@theme/Icon/LightMode';
7+
import styles from './styles.module.css';
8+
9+
/**
10+
* Swizzled ColorModeToggle.
11+
*
12+
* Docusaurus default shows the current-mode icon (sun in light, moon in dark).
13+
* This version shows the target-mode icon instead:
14+
* - Light mode → moon ("switch to dark")
15+
* - Dark mode → sun ("switch to light")
16+
*/
17+
export default function ColorModeToggle({className, buttonClassName, value, onChange}) {
18+
const isBrowser = useIsBrowser();
19+
const title = translate(
20+
{
21+
message: 'Switch between dark and light mode (currently {mode})',
22+
id: 'theme.colorToggle.ariaLabel',
23+
description: 'The ARIA label for the navbar color mode toggle',
24+
},
25+
{
26+
mode:
27+
value === 'dark'
28+
? translate({
29+
message: 'dark mode',
30+
id: 'theme.colorToggle.ariaLabel.mode.dark',
31+
description: 'The name for the dark color mode',
32+
})
33+
: translate({
34+
message: 'light mode',
35+
id: 'theme.colorToggle.ariaLabel.mode.light',
36+
description: 'The name for the light color mode',
37+
}),
38+
},
39+
);
40+
41+
return (
42+
<div className={clsx(styles.toggle, className)}>
43+
<button
44+
className={clsx('clean-btn', buttonClassName, styles.toggleButton, {
45+
[styles.toggleButtonDisabled]: !isBrowser,
46+
})}
47+
type="button"
48+
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
49+
disabled={!isBrowser}
50+
title={title}
51+
aria-label={title}
52+
aria-live="polite">
53+
{/* Moon shown in light mode → "click to switch to dark" */}
54+
<IconDarkMode className={clsx(styles.icon, styles.lightModeIcon)} />
55+
{/* Sun shown in dark mode → "click to switch to light" */}
56+
<IconLightMode className={clsx(styles.icon, styles.darkModeIcon)} />
57+
</button>
58+
</div>
59+
);
60+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.toggle {
2+
display: flex;
3+
align-items: center;
4+
}
5+
6+
.toggleButton {
7+
display: flex;
8+
overflow: hidden;
9+
}
10+
11+
.toggleButtonDisabled {
12+
cursor: not-allowed;
13+
}
14+
15+
.icon {
16+
width: 1.4rem;
17+
height: 1.4rem;
18+
}
19+
20+
/* Moon (lightModeIcon) visible in light mode */
21+
.lightModeIcon {
22+
display: block;
23+
}
24+
25+
/* Sun (darkModeIcon) hidden in light mode */
26+
.darkModeIcon {
27+
display: none;
28+
}
29+
30+
[data-theme='dark'] .lightModeIcon {
31+
display: none;
32+
}
33+
34+
[data-theme='dark'] .darkModeIcon {
35+
display: block;
36+
}

src/theme/SearchBar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function MultiSelectDropdown({label, options, selectedValues, onChange, placehol
390390
padding: '8px 12px',
391391
cursor: 'pointer',
392392
fontSize: '14px',
393-
background: isSelected ? 'var(--docsearch-hit-active-color)' : 'transparent',
393+
background: 'transparent',
394394
}}
395395
onMouseEnter={(e) => {
396396
if (!isSelected) {

src/theme/SearchPage/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ function SearchPageContent() {
683683
position: 'sticky',
684684
top: 'var(--ifm-navbar-height)',
685685
zIndex: 10,
686-
backgroundColor: 'var(--ifm-navbar-background-color)',
686+
backgroundColor: 'var(--ifm-background-color)',
687687
paddingTop: '16px',
688688
paddingBottom: '12px',
689689
}}>
@@ -708,6 +708,8 @@ function SearchPageContent() {
708708
fontSize: '16px',
709709
borderRadius: '8px',
710710
border: '2px solid var(--ifm-color-emphasis-300)',
711+
background: 'var(--ifm-background-color)',
712+
color: 'var(--ifm-font-color-base)',
711713
marginBottom: '0',
712714
transition: 'border-color 0.2s',
713715
}}
@@ -852,7 +854,7 @@ function SearchPageContent() {
852854
flexDirection: 'column',
853855
paddingTop: '16px',
854856
paddingBottom: '16px',
855-
backgroundColor: 'var(--ifm-navbar-background-color)',
857+
backgroundColor: 'var(--ifm-background-color)',
856858
}}>
857859
<MultiSelect
858860
label="Products"

0 commit comments

Comments
 (0)