Skip to content

Commit 8597f18

Browse files
authored
fix(site): document search box adapts to the dark theme. (#3046)
* fix(site): docsearch的暗黑适配 * fix(chart): fix charts-docs in dark mode * fix(site): add html selector before .dark
1 parent c89f744 commit 8597f18

File tree

11 files changed

+46
-21
lines changed

11 files changed

+46
-21
lines changed

examples/sites/src/assets/custom-block.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ body {
8484
--color-danger-title: #900;
8585
}
8686
}
87-
.dark {
87+
html.dark {
8888
.markdown-body {
8989
--color-tip-fg: #d3d5d6;
9090
--color-tip-bg: #24292f;

examples/sites/src/assets/custom-markdown.css

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
/* 以下为 github-markdown-css 包的预制颜色,根据暗色主题再修改 */
7-
.dark .markdown-body {
7+
html.dark .markdown-body {
88
color-scheme: dark;
99
--color-prettylights-syntax-comment: #8b949e;
1010
--color-prettylights-syntax-constant: #79c0ff;
@@ -99,22 +99,22 @@ body .markdown-body {
9999
text-shadow: none !important;
100100
}
101101

102-
.dark.dark .markdown-body {
102+
html.dark.dark .markdown-body {
103103
background-color: #000;
104104
}
105105

106-
.dark.dark .markdown-body pre {
106+
html.dark.dark .markdown-body pre {
107107
background-color: #1a1a1a;
108108
}
109109

110-
.dark.dark .markdown-body code {
110+
html.dark.dark .markdown-body code {
111111
color: var(--tv-color-text);
112112
}
113113

114-
.dark.dark .markdown-body code .token.operator {
114+
html.dark.dark .markdown-body code .token.operator {
115115
background-color: transparent;
116116
}
117117

118-
.dark.dark .markdown-body code .hljs-string {
118+
html.dark.dark .markdown-body code .hljs-string {
119119
color: #6f42c1;
120120
}

examples/sites/src/style.css

+20
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ strong {
7474
color: #969faf;
7575
}
7676

77+
/** docsearch 的暗黑模式 */
78+
html.dark {
79+
--docsearch-text-color: #f5f6f7;
80+
--docsearch-container-background: rgba(9, 10, 17, 0.8);
81+
--docsearch-modal-background: #15172a;
82+
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
83+
--docsearch-searchbox-background: #090a11;
84+
--docsearch-searchbox-focus-background: #000;
85+
--docsearch-hit-color: #bec3c9;
86+
--docsearch-hit-shadow: none;
87+
--docsearch-hit-background: #090a11;
88+
--docsearch-key-gradient: linear-gradient(-26.5deg, #565872, #31355b);
89+
--docsearch-key-shadow: inset 0 -2px 0 0 #282d55, inset 0 0 1px 1px #51577d, 0 2px 2px 0 rgba(3, 4, 9, 0.3);
90+
--docsearch-key-pressed-shadow: inset 0 -2px 0 0 #282d55, inset 0 0 1px 1px #51577d, 0 1px 1px 0 #0304094d;
91+
--docsearch-footer-background: #1e2136;
92+
--docsearch-footer-shadow: inset 0 1px 0 0 rgba(73, 76, 106, 0.5), 0 -4px 8px 0 rgba(0, 0, 0, 0.2);
93+
--docsearch-logo-color: #fff;
94+
--docsearch-muted-color: #7f8497;
95+
}
96+
7797
:root {
7898
--docsearch-primary-color: #1476ff;
7999
--docsearch-searchbox-background: #f5f5f5;

examples/sites/src/views/components-doc/common.vue

+1
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ defineExpose({ loadPage })
513513
justify-content: space-between;
514514
align-items: flex-start;
515515
column-gap: 16px;
516+
overflow: auto;
516517
}
517518
518519
.cmp-container {

examples/sites/src/views/components-doc/components/api-docs.vue

+9-5
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ defineExpose({ jumpToApi })
184184
color: var(--primary);
185185
border: 1px solid var(--primary);
186186
}
187-
.dark .api-groupname-tag {
188-
color: var(--tv-color-text-secondary);
189-
background-color: var(--tv-color-bg-header);
190-
border: none;
191-
}
187+
192188
.api-table-box {
193189
overflow-x: auto;
194190
width: 100%;
@@ -231,3 +227,11 @@ defineExpose({ jumpToApi })
231227
}
232228
}
233229
</style>
230+
231+
<style lang="less">
232+
html.dark .api-groupname-tag {
233+
color: var(--tv-color-text-secondary);
234+
background-color: var(--tv-color-bg-header);
235+
border: none;
236+
}
237+
</style>

examples/sites/src/views/components-doc/components/demo.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,12 @@ onBeforeUnmount(() => {
398398
</style>
399399

400400
<style lang="less">
401-
.dark .pc-demo-container.pc-demo-container {
401+
html.dark .pc-demo-container.pc-demo-container {
402402
background-color: #1a1a1a;
403403
border: none;
404404
}
405405
406-
.dark .demo-content.demo-content .demo-desc {
406+
html.dark .demo-content.demo-content .demo-desc {
407407
color: #b3b3b3;
408408
}
409409
</style>

examples/sites/src/views/components-doc/components/float-settings.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export default defineComponent({
275275
margin-right: 0;
276276
}
277277
}
278-
.dark .settings-btn {
278+
html.dark .settings-btn {
279279
background-color: var(--tv-color-bg-dark);
280280
}
281281
@@ -363,7 +363,7 @@ export default defineComponent({
363363
border-radius: 12px;
364364
background-color: var(--tv-color-bg);
365365
}
366-
.dark .tiny-popover.tiny-popper.theme-settings-popover {
366+
html.dark .tiny-popover.tiny-popper.theme-settings-popover {
367367
background-color: var(--tv-color-bg-dark);
368368
}
369369

examples/sites/src/views/components-doc/components/header.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const mdContent = computed(() =>
7070
</style>
7171

7272
<style lang="less">
73-
.dark .docs-header {
73+
html.dark .docs-header {
7474
background-color: #1a1a1a;
7575
7676
.markdown-top-body {

examples/sites/src/views/layout/layout.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export default defineComponent({
394394
}
395395
}
396396
397-
.dark #layoutSider {
397+
html.dark #layoutSider {
398398
border-right: 1px solid #1a1a1a; // 没有常用变量
399399
}
400400

examples/sites/src/views/overview.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export default defineComponent({
214214
}
215215
}
216216
217-
.dark .component-card {
217+
html.dark .component-card {
218218
&:hover {
219219
box-shadow: 1px 1px 6px 6px rgba(255, 255, 255, 0.08);
220220
}
@@ -229,7 +229,7 @@ export default defineComponent({
229229
width: 24.25%;
230230
}
231231
232-
.dark .overview-card-container {
232+
html.dark .overview-card-container {
233233
background-color: var(--tv-color-bg-dark);
234234
}
235235

packages/theme/src/checkbox/vars.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
// 复选框选中禁用背景色
4747
--tv-Checkbox-checked-disabled-bg-color: var(--tv-color-icon-checked-disabled);
4848
// 复选框选中禁用边框色
49-
--tv-Checkbox-checked-disabled-border-color: var(--tv-color-bg-disabled-control-unactive)
49+
--tv-Checkbox-checked-disabled-border-color: var(--tv-color-bg-disabled-control-unactive);
5050
}

0 commit comments

Comments
 (0)