Skip to content

Commit 4113ddc

Browse files
committedJul 23, 2023
website: update example.
1 parent a9a7310 commit 4113ddc

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed
 

‎website/src/App.tsx

+45-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
11
import Github from '@uiw/react-shields/esm/github';
22
import Npm from '@uiw/react-shields/esm/npm';
3+
import { useState } from 'react';
34
import styled from 'styled-components';
5+
import MarkdownPreview from '@uiw/react-markdown-preview';
46

5-
const Footer = styled.footer`
7+
const EditorWrapper = styled.div`
8+
padding-bottom: 10px;
9+
margin: 0 auto;
10+
width: 100%;
11+
textarea {
12+
width: 100%;
13+
min-height: 120px;
14+
min-width: 100%;
15+
padding: 5px;
16+
margin-top: 10px;
17+
box-sizing: border-box;
18+
}
19+
.editor-preview {
20+
border: 1px solid var(--color-border-default);
21+
border-radius: 5px;
22+
margin-top: 10px;
23+
min-height: 60px;
24+
padding: 16px;
25+
}
26+
`;
27+
28+
let val = 1;
29+
30+
export const Example = () => {
31+
const [value, setValue] = useState('');
32+
return (
33+
<EditorWrapper>
34+
<button onClick={() => setValue('# Markdown ' + val++)}>set value</button>
35+
<textarea
36+
placeholder="Please enter the Markdown code!"
37+
value={value}
38+
spellCheck="false"
39+
onChange={(e) => setValue(e.target.value)}
40+
/>
41+
<MarkdownPreview className="editor-preview" source={value} />
42+
</EditorWrapper>
43+
);
44+
};
45+
46+
const FooterWrapper = styled.footer`
647
text-align: center;
748
padding-top: 30px;
849
`;
950

10-
const App = () => {
51+
export const Footer = () => {
1152
return (
12-
<Footer>
53+
<FooterWrapper>
1354
<Github user="uiwjs" repo="react-markdown-preview">
1455
<Github.Social type="forks" href="https://github.com/uiwjs/react-markdown-preview" />
1556
<Github.Social type="stars" href="https://github.com/uiwjs/react-markdown-preview/stargazers" />
@@ -20,8 +61,6 @@ const App = () => {
2061
packageName="react-markdown-preview"
2162
href="https://www.npmjs.com/package/@uiw/react-markdown-preview"
2263
/>
23-
</Footer>
64+
</FooterWrapper>
2465
);
2566
};
26-
27-
export default App;

‎website/src/index.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createRoot } from 'react-dom/client';
22
import MarkdownPreviewExample from '@uiw/react-markdown-preview-example';
33
import data from '@uiw/react-markdown-preview/README.md';
4-
import Example from './App';
4+
import { Footer, Example } from './App';
55

66
const container = document.getElementById('root');
77
const root = createRoot(container!);
@@ -20,6 +20,9 @@ root.render(
2020
version={`v${VERSION}`}
2121
>
2222
<MarkdownPreviewExample.Github href="https://github.com/uiwjs/react-markdown-preview" />
23-
<Example />
23+
<MarkdownPreviewExample.Example>
24+
<Example />
25+
</MarkdownPreviewExample.Example>
26+
<Footer />
2427
</MarkdownPreviewExample>,
2528
);

0 commit comments

Comments
 (0)
Please sign in to comment.