Skip to content

Commit 59b4782

Browse files
ffxingyuefeng
authored andcommitted
docs: 优化文档预览
1 parent bb01a70 commit 59b4782

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

website/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@babel/plugin-syntax-jsx": "^7.18.6",
2525
"@babel/preset-react": "^7.18.6",
2626
"@uiw/icons": "2.5.3",
27-
"@uiw/react-back-to-top": "^1.2.1",
2827
"@uiw/react-markdown-preview": "^4.1.6",
2928
"@validator.tool/hook": "2.2.4",
3029
"@wcj/dark-mode": "^1.0.15",

website/src/component/Preview/index.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import MarkdownPreview from '@uiw/react-markdown-preview';
22
import styled from 'styled-components';
3-
import BackToUp from '@uiw/react-back-to-top';
3+
import { BackTop, Circle, Icon } from 'uiw';
44
import { getMetaId, isMeta, getURLParameters } from 'markdown-react-code-preview-loader';
55
import CodeLayout from 'react-code-preview-layout';
66
import { useRef } from 'react';
77

8-
const Warpper = styled.div`
8+
const Wrapper = styled.div`
99
width: 100%;
1010
height: 100%;
1111
overflow: auto;
1212
.w-rcpl-preview {
1313
white-space: normal;
1414
}
15+
display: flex;
16+
justify-content: center;
1517
`;
1618

1719
const Markdown = styled(MarkdownPreview)`
18-
padding: 50px 30px 120px 30px;
20+
padding: 50px 50px 120px 50px;
1921
max-width: 1024px;
2022
`;
2123

@@ -35,7 +37,7 @@ const getBooleanValue = (param, field, defaultValue) => {
3537
const Preview = (mdData) => {
3638
const $dom = useRef(null);
3739
return (
38-
<Warpper ref={$dom}>
40+
<Wrapper ref={$dom}>
3941
<Markdown
4042
disableCopy={true}
4143
source={mdData.source}
@@ -80,10 +82,17 @@ const Preview = (mdData) => {
8082
},
8183
}}
8284
/>
83-
<BackToUp element={$dom.current} style={{ float: 'right' }}>
84-
Top
85-
</BackToUp>
86-
</Warpper>
85+
<BackTop speed={500}>
86+
{({ percent, scrollToTop }) => (
87+
<Circle
88+
width={50}
89+
onClick={() => scrollToTop()}
90+
format={() => <Icon type="arrow-up" />}
91+
percent={percent}
92+
></Circle>
93+
)}
94+
</BackTop>
95+
</Wrapper>
8796
);
8897
};
8998
export default Preview;

0 commit comments

Comments
 (0)