diff options
| author | jackyzha0 <[email protected]> | 2021-03-06 14:44:15 -0800 |
|---|---|---|
| committer | jackyzha0 <[email protected]> | 2021-03-06 14:44:15 -0800 |
| commit | e9a7416fabbbb0155c09ee86e7843a4d87e0c118 (patch) | |
| tree | 4243141cd2f151c65a0b4a8d34213b762aeef516 /frontend/src/components/renderers/Code.js | |
| parent | code input style finalizations (diff) | |
| download | ctrl-v-e9a7416fabbbb0155c09ee86e7843a4d87e0c118.tar.xz ctrl-v-e9a7416fabbbb0155c09ee86e7843a4d87e0c118.zip | |
code renderer virtualization, better visuals
Diffstat (limited to 'frontend/src/components/renderers/Code.js')
| -rw-r--r-- | frontend/src/components/renderers/Code.js | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/frontend/src/components/renderers/Code.js b/frontend/src/components/renderers/Code.js index 9243532..d110f79 100644 --- a/frontend/src/components/renderers/Code.js +++ b/frontend/src/components/renderers/Code.js @@ -1,8 +1,9 @@ import React from 'react'; import SyntaxHighlighter from 'react-syntax-highlighter'; +import virtualizedRenderer from 'react-syntax-highlighter-virtualized-renderer'; import { atomOneLight, ascetic, atomOneDark, dracula, ocean } from 'react-syntax-highlighter/dist/esm/styles/hljs'; import styled from 'styled-components' -import {Rounded} from "../Form/mixins"; +import {Border, CodeLike, DropShadow, Hover, Rounded} from "../Form/mixins"; export const THEMES = Object.freeze({ 'atom': atomOneLight, @@ -19,19 +20,17 @@ export const LANGS = Object.freeze({ }) export const StyledPre = styled.pre` - width: 100%; - font-size: 14px; - line-height: 1.2em; - padding: calc(0.8em - 1px) !important; + ${Rounded}; + ${Border}; + ${DropShadow}; + width: calc(100%); + padding: calc(0.6em - 1px) !important; margin: 1.7em 0; - background: none !important; position: relative; - ${Rounded} outline: none; - border: 1px solid #565656 !important; & code { - font-family: JetBrains Mono !important; + ${CodeLike} } & code:first-child:not(:only-of-type) { @@ -51,18 +50,15 @@ export const Highlighter = ({language, lineNumbers, theme, pre = StyledPre, chil const CodeRenderer = React.forwardRef((props, ref) => { const Pre = (props) => <StyledPre {...props} ref={ref} /> - return ( - <div className="lt-shadow"> - <Highlighter - lineNumbers={true} - language={props.lang} - theme={props.theme} - pre={Pre} - > - {props.content} - </Highlighter> - </div> - ); + return (<Highlighter + lineNumbers={true} + language={props.lang} + theme={props.theme} + renderer={virtualizedRenderer()} + pre={Pre} + > + {props.content} + </Highlighter>) }); export default CodeRenderer
\ No newline at end of file |