Skip to content

Commit df14b1c

Browse files
committed
feat: support dark-mode style.
1 parent 9d12672 commit df14b1c

File tree

10 files changed

+273
-142
lines changed

10 files changed

+273
-142
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
]
4242
},
4343
"dependencies": {
44-
"@uiw/react-markdown-preview": "~3.5.1",
44+
"@uiw/react-markdown-preview": "~4.0.3",
4545
"codemirror": "~5.65.2"
4646
},
4747
"devDependencies": {
@@ -53,6 +53,7 @@
5353
"@types/react-dom": "~17.0.13",
5454
"@uiw/react-github-corners": "~1.5.3",
5555
"@uiw/reset.css": "~1.0.6",
56+
"@wcj/dark-mode": "~1.0.10",
5657
"compile-less-cli": "~1.8.11",
5758
"kkt": "~7.1.5",
5859
"prettier": "~2.5.1",

src/commands/preview.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ type Options = {
77
container?: HTMLDivElement | null;
88
containerEditor?: HTMLDivElement | null;
99
editor?: CodeMirror.Editor;
10-
}
10+
};
1111

12-
const Preview: React.FC<{ command: ICommand, editorProps: IMarkdownEditor & Options }> = (props) => {
13-
const { editorProps: { preview, containerEditor } } = props;
12+
const Preview: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & Options }> = (props) => {
13+
const {
14+
editorProps: { preview, containerEditor },
15+
} = props;
1416
const [visible, setVisible] = useState(props.editorProps.visible);
1517
useEffect(() => {
1618
setVisible(props.editorProps.visible);
@@ -23,40 +25,39 @@ const Preview: React.FC<{ command: ICommand, editorProps: IMarkdownEditor & Opti
2325
if (preview && visible) {
2426
preview.style.width = '50%';
2527
preview.style.overflow = 'auto';
26-
preview.style.borderLeft = '1px solid #dfdfe0';
28+
preview.style.borderLeft = '1px solid var(--color-border-muted)';
2729
preview.style.padding = '20px';
2830
if (containerEditor) {
29-
containerEditor.style.width = '50%'
31+
containerEditor.style.width = '50%';
3032
}
3133
} else if (preview) {
3234
preview.style.width = '0%';
3335
preview.style.overflow = 'hidden';
3436
preview.style.borderLeft = '0px';
3537
preview.style.padding = '0';
3638
if (containerEditor) {
37-
containerEditor.style.width = '100%'
39+
containerEditor.style.width = '100%';
3840
}
3941
}
4042
}, [preview, containerEditor, visible]);
4143

4244
return (
43-
<button
44-
onClick={() => setVisible(!visible)}
45-
type="button"
46-
className={visible ? 'active' : ''}
47-
>
45+
<button onClick={() => setVisible(!visible)} type="button" className={visible ? 'active' : ''}>
4846
{props.command.icon}
4947
</button>
50-
)
51-
}
48+
);
49+
};
5250

5351
export const preview: ICommand = {
5452
name: 'preview',
5553
keyCommand: 'preview',
5654
button: (command, props, opts) => <Preview command={command} editorProps={{ ...props, ...opts }} />,
5755
icon: (
5856
<svg width="16" height="16" viewBox="0 0 32 32">
59-
<path fill="currentColor" d="M0 16c3.037-5.864 9.058-9.802 16-9.802s12.963 3.938 15.953 9.703l0.047 0.1c-3.037 5.864-9.058 9.802-16 9.802s-12.963-3.938-15.953-9.703l-0.047-0.1zM16 22.531c3.607 0 6.531-2.924 6.531-6.531s-2.924-6.531-6.531-6.531v0c-3.607 0-6.531 2.924-6.531 6.531s2.924 6.531 6.531 6.531v0zM16 19.265c-1.804 0-3.265-1.461-3.265-3.265s1.461-3.265 3.265-3.265v0c1.804 0 3.265 1.461 3.265 3.265s-1.461 3.265-3.265 3.265v0z" />
57+
<path
58+
fill="currentColor"
59+
d="M0 16c3.037-5.864 9.058-9.802 16-9.802s12.963 3.938 15.953 9.703l0.047 0.1c-3.037 5.864-9.058 9.802-16 9.802s-12.963-3.938-15.953-9.703l-0.047-0.1zM16 22.531c3.607 0 6.531-2.924 6.531-6.531s-2.924-6.531-6.531-6.531v0c-3.607 0-6.531 2.924-6.531 6.531s2.924 6.531 6.531 6.531v0zM16 19.265c-1.804 0-3.265-1.461-3.265-3.265s1.461-3.265 3.265-3.265v0c1.804 0 3.265 1.461 3.265 3.265s-1.461 3.265-3.265 3.265v0z"
60+
/>
6061
</svg>
6162
),
62-
};
63+
};

0 commit comments

Comments
 (0)