Skip to content

Commit fe2b14d

Browse files
authored
Add dark mode support (#281)
1 parent 3116bd1 commit fe2b14d

File tree

7 files changed

+80
-5
lines changed

7 files changed

+80
-5
lines changed

docusaurus.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const config = {
6767
({
6868
colorMode: {
6969
defaultMode: 'light',
70-
disableSwitch: true,
70+
disableSwitch: false,
71+
respectPrefersColorScheme: true,
7172
},
7273
navbar: {
7374
title: 'Apache Kvrocks',

src/components/HomepageFeatures/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Feature({imgPath,title, description}: FeatureItem) {
5252
<div className={clsx('col col--6')}>
5353
<div className="text--center padding-horiz--md" style={{width:"100%",height:"100%",margin:'30px 0px'}}>
5454
<img className={styles.imgItem} src={imgPath} alt={title}/>
55-
<h3>{title}</h3>
55+
<h3 className={styles.featureTitle}>{title}</h3>
5656
<div className={styles.itemDes}>
5757
<p>{description}</p>
5858
</div>

src/components/HomepageFeatures/styles.module.css

+16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
color:rgba(59, 61, 63, 1)
5151
}
5252

53+
[data-theme='dark'] .blueLine + p {
54+
color:rgba(220, 220, 220, 1);
55+
}
56+
5357
.redisCompatible{
5458
display:flex;
5559
flex-direction:row;
@@ -113,10 +117,22 @@
113117
color:rgba(59, 61, 63, 1);
114118
}
115119

120+
[data-theme='dark'] .itemDes {
121+
color:rgba(220, 220, 220, 1);
122+
}
123+
116124
.itemDes p{
117125
width: 50%;
118126
}
119127

128+
.featureTitle {
129+
color: #333333;
130+
}
131+
132+
[data-theme='dark'] .featureTitle {
133+
color: #ffffff;
134+
}
135+
120136
.container{
121137
margin-left:5%;
122138
width:90%;

src/css/custom.css

+26-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,34 @@
77
/* You can override the default Infima variables here. */
88
:root {
99
--ifm-color-primary: #3071a9;
10+
--ifm-color-primary-dark: #2b6698;
11+
--ifm-color-primary-darker: #295f90;
12+
--ifm-color-primary-darkest: #224e76;
13+
--ifm-color-primary-light: #357cba;
14+
--ifm-color-primary-lighter: #3782c2;
15+
--ifm-color-primary-lightest: #4e93cd;
1016
--ifm-code-font-size: 95%;
1117
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
12-
--ifm-footer-background-color:rgba(115, 150, 233, 0.61);
18+
--ifm-footer-background-color: rgba(115, 150, 233, 0.61);
19+
--ifm-background-color: #ffffff;
20+
--ifm-navbar-background-color: #ffffff;
21+
}
22+
23+
/* Dark mode overrides */
24+
[data-theme='dark'] {
25+
--ifm-color-primary: #4e93cd;
26+
--ifm-color-primary-dark: #3585c6;
27+
--ifm-color-primary-darker: #2f7ebd;
28+
--ifm-color-primary-darkest: #27689c;
29+
--ifm-color-primary-light: #67a1d4;
30+
--ifm-color-primary-lighter: #74a9d8;
31+
--ifm-color-primary-lightest: #99c0e2;
32+
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
33+
--ifm-background-color: #1e2125;
34+
--ifm-navbar-background-color: #1e2125;
35+
--ifm-footer-background-color: rgba(48, 56, 70, 0.8);
36+
--ifm-heading-color: #ffffff;
37+
--ifm-font-color-base: #e3e3e3;
1338
}
1439

1540
.docusaurus-highlight-code-line {

src/pages/index.module.css

+31
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
flex-direction: column;
1414
}
1515

16+
[data-theme='dark'] .heroBanner {
17+
background-image:linear-gradient(to top, rgba(30, 40, 60, 1) , rgba(40, 50, 70, 1));
18+
}
19+
1620
.container{
1721
width:100%;
1822
height:100%;
@@ -25,6 +29,15 @@
2529
width: 40%;
2630
}
2731

32+
/* To make sure the hero title is seen in light mode, add certain styling */
33+
.titles h1 {
34+
color: #333333;
35+
}
36+
37+
[data-theme='dark'] .titles h1 {
38+
color: #ffffff;
39+
}
40+
2841
.image{
2942
width: 40%;
3043
}
@@ -36,6 +49,10 @@
3649
width:80%;
3750
}
3851

52+
[data-theme='dark'] .tagline {
53+
color:rgba(220, 220, 220, 1);
54+
}
55+
3956
@media screen and (max-width: 950px) {
4057
.tagline {
4158
font-size:16px;
@@ -84,12 +101,26 @@
84101
border:1px solid rgba(0, 91, 244, 1);
85102
}
86103

104+
[data-theme='dark'] .buttons a {
105+
background-color:rgba(50, 60, 80, 1);
106+
color:rgba(100, 160, 255, 1);
107+
border:1px solid rgba(100, 160, 255, 1);
108+
box-shadow:0pt 5pt 6pt 1pt rgba(0, 0, 0, 0.3);
109+
}
110+
87111
.buttons a:first-child {
88112
background-color:rgba(40, 117, 243, 1);
89113
box-shadow:0pt 5pt 6pt 1pt rgba(0, 0, 0, 0.16);
90114
color:white
91115
}
92116

117+
[data-theme='dark'] .buttons a:first-child {
118+
background-color:rgba(60, 130, 240, 1);
119+
box-shadow:0pt 5pt 6pt 1pt rgba(0, 0, 0, 0.3);
120+
color:white;
121+
border:1px solid rgba(60, 130, 240, 1);
122+
}
123+
93124
@media screen and (max-width:820px){
94125
.container{
95126
flex-direction: column;

src/pages/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function HomepageHeader() {
1212
<header className={clsx('hero hero--primary', styles.heroBanner)}>
1313
<div className={clsx(styles.container)}>
1414
<div className={clsx(styles.titles)}>
15-
<h1 className="hero__title" style={{color:'black'}}>{siteConfig.title}</h1>
15+
<h1 className="hero__title">{siteConfig.title}</h1>
1616
<div className={clsx('hero__subtitle',styles.tagline)}>{siteConfig.tagline}</div>
1717
</div>
1818
<div className={clsx(styles.image)}>

tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// This file is not used in compilation. It is here just for a nice editor experience.
33
"extends": "@tsconfig/docusaurus/tsconfig.json",
44
"compilerOptions": {
5-
"baseUrl": "."
5+
"baseUrl": ".",
6+
"module": "Node16",
7+
"moduleResolution": "Node16"
68
}
79
}

0 commit comments

Comments
 (0)