Skip to content

Commit a59dbd4

Browse files
authored
chore: respect theme in code snippets (microsoft#842)
1 parent 8adea13 commit a59dbd4

File tree

6 files changed

+194
-7
lines changed

6 files changed

+194
-7
lines changed

dotnet/docusaurus.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ module.exports = {
5555
respectPrefersColorScheme: true,
5656
},
5757
prism: {
58-
theme: require('prism-react-renderer/themes/dracula'),
58+
theme: require('./src/config/prismLight'),
59+
darkTheme: require('./src/config/prismDark'),
5960
additionalLanguages: ['csharp', 'bash', 'batch', 'powershell'],
6061
},
6162
navbar: {

java/docusaurus.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ module.exports = {
5555
respectPrefersColorScheme: true,
5656
},
5757
prism: {
58-
theme: require('prism-react-renderer/themes/dracula'),
59-
additionalLanguages: ['java', 'bash', 'batch', 'powershell', 'csharp'],
58+
theme: require('./src/config/prismLight'),
59+
darkTheme: require('./src/config/prismDark'),
60+
additionalLanguages: ['java', 'bash', 'batch', 'powershell'],
6061
},
6162
navbar: {
6263
title: "Playwright for Java",

nodejs/docusaurus.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ module.exports = {
5555
respectPrefersColorScheme: true,
5656
},
5757
prism: {
58-
theme: require('prism-react-renderer/themes/dracula'),
59-
additionalLanguages: ['bash', 'batch', 'powershell', 'csharp'],
58+
theme: require('./src/config/prismLight'),
59+
darkTheme: require('./src/config/prismDark'),
60+
additionalLanguages: ['bash', 'batch', 'powershell'],
6061
},
6162
navbar: {
6263
title: "Playwright",

python/docusaurus.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ module.exports = {
5555
respectPrefersColorScheme: true,
5656
},
5757
prism: {
58-
theme: require('prism-react-renderer/themes/dracula'),
59-
additionalLanguages: ['python', 'bash', 'batch', 'powershell', 'csharp'],
58+
theme: require('./src/config/prismLight'),
59+
darkTheme: require('./src/config/prismDark'),
60+
additionalLanguages: ['python', 'bash', 'batch', 'powershell'],
6061
},
6162
navbar: {
6263
title: "Playwright for Python",

src/config/prismDark.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// https://github.com/facebook/docusaurus/blob/main/website/src/utils/prismDark.mjs
9+
10+
const darkTheme = require('prism-react-renderer/themes/vsDark/index.cjs.js');
11+
12+
module.exports = {
13+
plain: {
14+
color: '#D4D4D4',
15+
backgroundColor: '#212121',
16+
},
17+
styles: [
18+
...darkTheme.styles,
19+
{
20+
types: ['title'],
21+
style: {
22+
color: '#569CD6',
23+
fontWeight: 'bold',
24+
},
25+
},
26+
{
27+
types: ['property', 'parameter'],
28+
style: {
29+
color: '#9CDCFE',
30+
},
31+
},
32+
{
33+
types: ['script'],
34+
style: {
35+
color: '#D4D4D4',
36+
},
37+
},
38+
{
39+
types: ['boolean', 'arrow', 'atrule', 'tag'],
40+
style: {
41+
color: '#569CD6',
42+
},
43+
},
44+
{
45+
types: ['number', 'color', 'unit'],
46+
style: {
47+
color: '#B5CEA8',
48+
},
49+
},
50+
{
51+
types: ['font-matter'],
52+
style: {
53+
color: '#CE9178',
54+
},
55+
},
56+
{
57+
types: ['keyword', 'rule'],
58+
style: {
59+
color: '#C586C0',
60+
},
61+
},
62+
{
63+
types: ['regex'],
64+
style: {
65+
color: '#D16969',
66+
},
67+
},
68+
{
69+
types: ['maybe-class-name'],
70+
style: {
71+
color: '#4EC9B0',
72+
},
73+
},
74+
{
75+
types: ['constant'],
76+
style: {
77+
color: '#4FC1FF',
78+
},
79+
},
80+
],
81+
};

src/config/prismLight.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// https://github.com/facebook/docusaurus/blob/main/website/src/utils/prismLight.mjs
9+
10+
const lightTheme = require('prism-react-renderer/themes/github/index.cjs.js');
11+
12+
module.exports = {
13+
...lightTheme,
14+
styles: [
15+
...lightTheme.styles,
16+
{
17+
types: ['title'],
18+
style: {
19+
color: '#0550AE',
20+
fontWeight: 'bold',
21+
},
22+
},
23+
{
24+
types: ['parameter'],
25+
style: {
26+
color: '#953800',
27+
},
28+
},
29+
{
30+
types: ['boolean', 'rule', 'color', 'number', 'constant', 'property'],
31+
style: {
32+
color: '#005CC5',
33+
},
34+
},
35+
{
36+
types: ['atrule', 'tag'],
37+
style: {
38+
color: '#22863A',
39+
},
40+
},
41+
{
42+
types: ['script'],
43+
style: {
44+
color: '#24292E',
45+
},
46+
},
47+
{
48+
types: ['operator', 'unit', 'rule'],
49+
style: {
50+
color: '#D73A49',
51+
},
52+
},
53+
{
54+
types: ['font-matter', 'string', 'attr-value'],
55+
style: {
56+
color: '#C6105F',
57+
},
58+
},
59+
{
60+
types: ['class-name'],
61+
style: {
62+
color: '#116329',
63+
},
64+
},
65+
{
66+
types: ['attr-name'],
67+
style: {
68+
color: '#0550AE',
69+
},
70+
},
71+
{
72+
types: ['keyword'],
73+
style: {
74+
color: '#CF222E',
75+
},
76+
},
77+
{
78+
types: ['function'],
79+
style: {
80+
color: '#8250DF',
81+
},
82+
},
83+
{
84+
types: ['selector'],
85+
style: {
86+
color: '#6F42C1',
87+
},
88+
},
89+
{
90+
types: ['variable'],
91+
style: {
92+
color: '#E36209',
93+
},
94+
},
95+
{
96+
types: ['comment'],
97+
style: {
98+
color: '#6B6B6B',
99+
},
100+
},
101+
],
102+
};

0 commit comments

Comments
 (0)