File tree 2 files changed +50
-8
lines changed
2 files changed +50
-8
lines changed Original file line number Diff line number Diff line change 1
1
import Github from '@uiw/react-shields/esm/github' ;
2
2
import Npm from '@uiw/react-shields/esm/npm' ;
3
+ import { useState } from 'react' ;
3
4
import styled from 'styled-components' ;
5
+ import MarkdownPreview from '@uiw/react-markdown-preview' ;
4
6
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 `
6
47
text-align: center;
7
48
padding-top: 30px;
8
49
` ;
9
50
10
- const App = ( ) => {
51
+ export const Footer = ( ) => {
11
52
return (
12
- < Footer >
53
+ < FooterWrapper >
13
54
< Github user = "uiwjs" repo = "react-markdown-preview" >
14
55
< Github . Social type = "forks" href = "https://github.com/uiwjs/react-markdown-preview" />
15
56
< Github . Social type = "stars" href = "https://github.com/uiwjs/react-markdown-preview/stargazers" />
@@ -20,8 +61,6 @@ const App = () => {
20
61
packageName = "react-markdown-preview"
21
62
href = "https://www.npmjs.com/package/@uiw/react-markdown-preview"
22
63
/>
23
- </ Footer >
64
+ </ FooterWrapper >
24
65
) ;
25
66
} ;
26
-
27
- export default App ;
Original file line number Diff line number Diff line change 1
1
import { createRoot } from 'react-dom/client' ;
2
2
import MarkdownPreviewExample from '@uiw/react-markdown-preview-example' ;
3
3
import data from '@uiw/react-markdown-preview/README.md' ;
4
- import Example from './App' ;
4
+ import { Footer , Example } from './App' ;
5
5
6
6
const container = document . getElementById ( 'root' ) ;
7
7
const root = createRoot ( container ! ) ;
@@ -20,6 +20,9 @@ root.render(
20
20
version = { `v${ VERSION } ` }
21
21
>
22
22
< MarkdownPreviewExample . Github href = "https://github.com/uiwjs/react-markdown-preview" />
23
- < Example />
23
+ < MarkdownPreviewExample . Example >
24
+ < Example />
25
+ </ MarkdownPreviewExample . Example >
26
+ < Footer />
24
27
</ MarkdownPreviewExample > ,
25
28
) ;
You can’t perform that action at this time.
0 commit comments