diff options
| author | jackyzha0 <[email protected]> | 2020-05-23 10:59:31 -0700 |
|---|---|---|
| committer | jackyzha0 <[email protected]> | 2020-05-23 10:59:31 -0700 |
| commit | f4cb08e7a1eaebf3c60506e3a4941c903619c448 (patch) | |
| tree | a29777c693a02ec0b0bd2713979272f3b155e67f /frontend/src | |
| parent | wip render dispatch (diff) | |
| download | ctrl-v-f4cb08e7a1eaebf3c60506e3a4941c903619c448.tar.xz ctrl-v-f4cb08e7a1eaebf3c60506e3a4941c903619c448.zip | |
fix more styling problems
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/components/PasteInfo.js | 4 | ||||
| -rw-r--r-- | frontend/src/components/RenderDispatch.js | 0 | ||||
| -rw-r--r-- | frontend/src/components/ViewPaste.js | 29 | ||||
| -rw-r--r-- | frontend/src/components/renderers/Code.js | 21 | ||||
| -rw-r--r-- | frontend/src/components/renderers/RenderDispatch.js | 29 | ||||
| -rw-r--r-- | frontend/src/css/index.css | 6 |
6 files changed, 61 insertions, 28 deletions
diff --git a/frontend/src/components/PasteInfo.js b/frontend/src/components/PasteInfo.js index 9f0d3bf..0b4188d 100644 --- a/frontend/src/components/PasteInfo.js +++ b/frontend/src/components/PasteInfo.js @@ -2,7 +2,7 @@ import React from 'react'; import styled from 'styled-components' import { useHistory } from 'react-router-dom'; import { ThemeInput } from './Inputs' -import { exportComponentAsJPEG } from "react-component-export-image"; +import { exportComponentAsPNG } from "react-component-export-image"; const Bold = styled.span` font-weight: 700 @@ -63,7 +63,7 @@ const PasteInfo = (props) => { <Button className="lt-shadow lt-hover" type="button" - onClick={() => exportComponentAsJPEG(props.compref, `paste-${props.hash}.png`)}> + onClick={() => exportComponentAsPNG(props.compref, `paste-${props.hash}.png`)}> save png </Button> {renderable()} diff --git a/frontend/src/components/RenderDispatch.js b/frontend/src/components/RenderDispatch.js deleted file mode 100644 index e69de29..0000000 --- a/frontend/src/components/RenderDispatch.js +++ /dev/null diff --git a/frontend/src/components/ViewPaste.js b/frontend/src/components/ViewPaste.js index 00348a5..30fb29e 100644 --- a/frontend/src/components/ViewPaste.js +++ b/frontend/src/components/ViewPaste.js @@ -6,6 +6,7 @@ import PasteInfo from './PasteInfo'; import PasswordModal from './modals/PasswordModal' import { FetchPaste, FetchPasswordPaste } from '../helpers/httpHelper' import { LANGS } from './renderers/Code' +import RenderDispatch from './renderers/RenderDispatch' class ViewPaste extends React.Component { @@ -80,10 +81,23 @@ class ViewPaste extends React.Component { render() { - // var display - // if (this.state.isRenderMode) { - - // } + var display + if (this.state.isRenderMode) { + display = + <RenderDispatch + language={this.state.language} + content={this.state.content} + ref={this.componentRef} + /> + } else { + display = + <CodeRenderer + content={this.state.content} + lang={this.state.language} + theme={this.state.theme} + ref={this.componentRef} + id="pasteInput" /> + } return ( <div> @@ -98,12 +112,7 @@ class ViewPaste extends React.Component { value={this.state.title} id="titleInput" readOnly /> - <CodeRenderer - content={this.state.content} - lang={this.state.language} - theme={this.state.theme} - ref={this.componentRef} - id="pasteInput" /> + {display} <PasteInfo hash={this.props.hash} lang={this.state.language} diff --git a/frontend/src/components/renderers/Code.js b/frontend/src/components/renderers/Code.js index 9e7521b..524ea30 100644 --- a/frontend/src/components/renderers/Code.js +++ b/frontend/src/components/renderers/Code.js @@ -36,19 +36,20 @@ export const LANGS = Object.freeze({ }) const StyledPre = styled.pre` - padding: calc(0.8em - 1px) !important; - margin: 0; -` - -const CodeBlock = styled.div` width: 100%; font-size: 0.8em; min-height: 1.2em; - border-radius: 3px; - border: 1px solid #565656; + border-radius: 3px !important; + border: 1px solid #565656 !important; + padding: calc(0.8em - 1px) !important; outline: none; margin: 1.7em 0; - padding-right: calc(1.6em - 2px); + + & code:first-child { + margin-right: 10px !important; + border-radius: 0 !important; + border-right: 1px solid #11111155 !important; + } ` const CodeRenderer = React.forwardRef((props, ref) => { @@ -60,7 +61,7 @@ const CodeRenderer = React.forwardRef((props, ref) => { } return ( - <CodeBlock className="lt-shadow"> + <div className="lt-shadow"> <SyntaxHighlighter ref={ref} language={props.lang} @@ -69,7 +70,7 @@ const CodeRenderer = React.forwardRef((props, ref) => { PreTag={Pre}> {props.content} </SyntaxHighlighter> - </CodeBlock> + </div> ); }); diff --git a/frontend/src/components/renderers/RenderDispatch.js b/frontend/src/components/renderers/RenderDispatch.js new file mode 100644 index 0000000..892c649 --- /dev/null +++ b/frontend/src/components/renderers/RenderDispatch.js @@ -0,0 +1,29 @@ +import React from 'react'; +import styled from 'styled-components' +import Latex from './Latex' +import CodeRenderer from './Code' + +const LatexWrapper = styled.div` + padding: 2em; +` + +const RenderDispatch = React.forwardRef((props, ref) => { + switch (props.language) { + case 'latex': + return ( + <LatexWrapper ref={ref}> + <Latex + content={props.content} /> + </LatexWrapper>) + default: + return ( + <CodeRenderer + content={props.content} + lang={props.language} + theme={props.theme} + ref={ref} + id="pasteInput" />) + } +}); + +export default RenderDispatch
\ No newline at end of file diff --git a/frontend/src/css/index.css b/frontend/src/css/index.css index 9aa48e1..60b0ca8 100644 --- a/frontend/src/css/index.css +++ b/frontend/src/css/index.css @@ -25,12 +25,6 @@ textarea, input[type=text], input[type=password], .Dropdown-root { margin: 1.7em 0; } -.codeBlock code:first-child { - margin-right: 10px; - border-radius: 0; - border-right: 1px solid #11111155; -} - code, pre { background: #00000000; font-family: 'Roboto Mono', monospace; |