Skip to content

Commit d4cddf4

Browse files
committed
website: update markdown preview.
1 parent 50a450f commit d4cddf4

File tree

4 files changed

+38
-128
lines changed

4 files changed

+38
-128
lines changed

www/package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88
"map": "source-map-explorer build/static/js/*.js --html build/website-result.html"
99
},
1010
"dependencies": {
11-
"@uiw/react-back-to-top": "1.2.3",
11+
"@uiw/react-markdown-preview-example": "1.1.0",
1212
"@uiw/react-color-colorful": "^1.3.1",
13-
"@uiw/react-github-corners": "^1.5.15",
1413
"@uiw/react-json-view": "1.8.0",
15-
"@uiw/react-markdown-preview": "^4.1.0",
16-
"@wcj/dark-mode": "^1.0.13",
1714
"react": "^18.2.0",
18-
"react-code-preview-layout": "^3.0.1",
19-
"react-dom": "^18.2.0",
20-
"styled-components": "^6.0.0"
15+
"react-dom": "^18.2.0"
2116
},
2217
"devDependencies": {
2318
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",

www/src/App.tsx

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,44 @@
11
import { useState } from 'react';
2-
import GitHubCorners from '@uiw/react-github-corners';
32
import styled, { css } from 'styled-components';
4-
import BackToUp from '@uiw/react-back-to-top';
53
import { Example } from './example/default';
6-
import MarkdownPreview from './Markdown';
74
import { ExampleEditor } from './example/editor';
85

9-
const Header = styled.header`
10-
padding: 2rem 0;
11-
text-align: center;
12-
h1 {
13-
font-weight: 900;
14-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif,
15-
'Apple Color Emoji', 'Segoe UI Emoji';
16-
}
17-
`;
18-
19-
const SupVersion = styled.sup`
20-
font-weight: 200;
21-
font-size: 0.78rem;
22-
margin-left: 0.5em;
23-
margin-top: -0.3em;
24-
position: absolute;
25-
`;
26-
276
const ExampleWrapper = styled.div`
287
max-width: 530px;
298
margin: 0 auto;
309
padding-bottom: 3rem;
3110
`;
3211

33-
const Wrappper = styled.div`
34-
padding-bottom: 5rem;
35-
`;
36-
3712
const TabItem = styled.div`
3813
padding-bottom: 10px;
3914
`;
4015

41-
const Button = styled.button<{ $active: boolean; }>`
16+
const Button = styled.button<{ $active: boolean }>`
4217
background: transparent;
4318
border: 0;
4419
cursor: pointer;
4520
border-radius: 3px;
46-
${({ $active }) => $active && css`
47-
background-color: var(--tabs-bg, #bce0ff);
48-
`}
21+
${({ $active }) =>
22+
$active &&
23+
css`
24+
background-color: var(--tabs-bg, #bce0ff);
25+
`}
4926
`;
5027

5128
export default function App() {
5229
const [tabs, setTabs] = useState<'preview' | 'editor'>('preview');
5330
return (
54-
<Wrappper>
55-
<GitHubCorners fixed target="__blank" zIndex={10} href="https://github.com/uiwjs/react-json-view" />
56-
<Header>
57-
<h1>
58-
JSON View for React<SupVersion>v{VERSION}</SupVersion>
59-
</h1>
60-
</Header>
61-
<ExampleWrapper>
62-
<TabItem>
63-
<Button $active={tabs === 'preview'} onClick={() => setTabs('preview')}>Preview</Button>
64-
<Button $active={tabs === 'editor'} onClick={() => setTabs('editor')}>Editor</Button>
65-
</TabItem>
66-
{tabs === 'preview' && <Example />}
67-
{tabs === 'editor' && <ExampleEditor />}
68-
</ExampleWrapper>
69-
<MarkdownPreview />
70-
<BackToUp>Top</BackToUp>
71-
</Wrappper>
31+
<ExampleWrapper>
32+
<TabItem>
33+
<Button $active={tabs === 'preview'} onClick={() => setTabs('preview')}>
34+
Preview
35+
</Button>
36+
<Button $active={tabs === 'editor'} onClick={() => setTabs('editor')}>
37+
Editor
38+
</Button>
39+
</TabItem>
40+
{tabs === 'preview' && <Example />}
41+
{tabs === 'editor' && <ExampleEditor />}
42+
</ExampleWrapper>
7243
);
7344
}

www/src/Markdown.tsx

Lines changed: 0 additions & 62 deletions
This file was deleted.

www/src/index.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
22
import { createRoot } from 'react-dom/client';
33
import { createGlobalStyle } from 'styled-components';
4-
import '@wcj/dark-mode';
4+
import data from '@uiw/react-json-view/README.md';
5+
import MarkdownPreviewExample from '@uiw/react-markdown-preview-example';
56
import App from './App';
67

7-
export const GlobalStyle = createGlobalStyle<any>`
8+
export const GlobalStyle = createGlobalStyle`
89
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
910
--tabs-bg: #5f5f5f;
1011
}
@@ -21,17 +22,22 @@ export const GlobalStyle = createGlobalStyle<any>`
2122
}
2223
`;
2324

25+
const Github = MarkdownPreviewExample.Github;
26+
const Example = MarkdownPreviewExample.Example;
27+
2428
const container = document.getElementById('root');
2529
const root = createRoot(container!);
2630
root.render(
27-
<React.Fragment>
28-
<dark-mode
29-
permanent
30-
dark="Dark"
31-
light="Light"
32-
style={{ position: 'fixed', top: 8, left: 12, zIndex: 99, fontSize: 32 }}
33-
/>
34-
<GlobalStyle />
35-
<App />
36-
</React.Fragment>,
31+
<MarkdownPreviewExample
32+
source={data.source}
33+
components={data.components}
34+
data={data.data}
35+
title="JSON View for React"
36+
version={`v${VERSION}`}
37+
>
38+
<Github href="https://github.com/uiwjs/react-markdown-preview-example" />
39+
<Example>
40+
<App />
41+
</Example>
42+
</MarkdownPreviewExample>,
3743
);

0 commit comments

Comments
 (0)