Skip to content

Commit 3ff46ed

Browse files
authored
Get closer to theme inside of code blocks shown on no experiments data screen (#2988)
1 parent 62ebb3a commit 3ff46ed

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

webview/src/shared/components/codeBlock/CodeBlock.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,45 @@ export interface CodeBlockProps {
99
inline?: boolean
1010
}
1111

12+
const editorBackground = 'var(--vscode-textCodeBlock-background)'
13+
const editorForeground = 'var(--vscode-editor-foreground)'
14+
const tokenHighlight = 'var(--vscode-editorInfo-foreground)'
15+
16+
const approximateTheme = {
17+
plain: {
18+
backgroundColor: editorBackground,
19+
color: editorForeground
20+
},
21+
styles: [
22+
{
23+
style: {
24+
color: tokenHighlight
25+
},
26+
types: [
27+
'char',
28+
'function',
29+
'keyword',
30+
'operator',
31+
'punctuation',
32+
'string',
33+
'variable'
34+
]
35+
}
36+
]
37+
}
38+
1239
export const CodeBlock: React.FC<CodeBlockProps> = ({
1340
language,
1441
children,
1542
inline
1643
}) => {
1744
return (
18-
<Highlight {...defaultProps} code={children} language={language}>
45+
<Highlight
46+
{...defaultProps}
47+
code={children}
48+
language={language}
49+
theme={approximateTheme}
50+
>
1951
{({ className, style, tokens, getLineProps, getTokenProps }) => (
2052
<pre
2153
className={cx(className, styles.codeBlock, {

0 commit comments

Comments
 (0)