Skip to content

Commit 149fcfe

Browse files
committed
Make the CodeDemo UI look identical to rspress codeblock
1 parent 90f9be8 commit 149fcfe

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

theme/components/code-demo/index.module.scss

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
margin: 2rem auto;
33
max-width: 800px;
44
padding: 1rem;
5+
border-radius: 8px;
6+
overflow: hidden;
57
}
68

79
.filename {
8-
font-family: 'Fira Code', monospace;
10+
font-family: system-ui, -apple-system, sans-serif;
911
font-size: 0.9rem;
10-
color: #d4d4d4;
11-
background-color: #1e1e1e;
12-
padding: 0.5rem 1rem;
12+
color: #666;
13+
background-color: #ecf0f7;
14+
padding: 0.75rem 1.5rem;
1315
border-top-left-radius: 8px;
1416
border-top-right-radius: 8px;
15-
border-bottom: 1px solid #333;
16-
opacity: 0.8;
1717
}
1818

1919
.codeContainer {
20-
background-color: #1e1e1e;
20+
background-color: #f7f8fa;
2121
border-radius: 8px;
2222
border-top-left-radius: 0;
2323
border-top-right-radius: 0;
2424
overflow: auto;
25-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
2625

2726
&:has(+ .filename) {
2827
border-top-left-radius: 0;
@@ -39,7 +38,7 @@
3938
font-family: 'Fira Code', monospace;
4039
font-size: 0.9rem;
4140
line-height: 1.5;
42-
color: #d4d4d4;
41+
color: #333;
4342
display: block;
4443
white-space: pre;
4544
}

theme/components/code-demo/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { type FC } from 'react';
22
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
3-
import { darcula as style } from 'react-syntax-highlighter/dist/esm/styles/prism';
3+
const style = {
4+
'comment': { color: '#8B8B8B' },
5+
'function': { color: '#8B5CF6' },
6+
'string': { color: '#4CAF50' },
7+
'keyword': { color: '#F92672' },
8+
'number': { color: '#FF8B00' }
9+
};
410
import styles from './index.module.scss';
511

612
interface CodeDemoProps {
@@ -17,7 +23,7 @@ const CodeDemo: FC<CodeDemoProps> = ({ code, filename, width = '800px', height,
1723
{filename && <div className={styles.filename}>{filename}</div>}
1824
<div className={styles.codeContainer} style={{ height }}>
1925
<SyntaxHighlighter
20-
language={language}
26+
language="javascript"
2127
style={style}
2228
customStyle={{ margin: 0, padding: '1.5rem', background: 'transparent' }}
2329
codeTagProps={{

0 commit comments

Comments
 (0)