From 9941d9b18217e05f69547985a170234ee84c39f5 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 17 May 2020 09:55:35 -0700 Subject: save comp --- frontend/src/components/PasteInfo.js | 73 +++++++++++++++++++++---------- frontend/src/components/ViewPaste.js | 3 ++ frontend/src/components/renderers/Code.js | 6 +-- 3 files changed, 55 insertions(+), 27 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/PasteInfo.js b/frontend/src/components/PasteInfo.js index ea4981c..b63eedb 100644 --- a/frontend/src/components/PasteInfo.js +++ b/frontend/src/components/PasteInfo.js @@ -2,6 +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"; const Bold = styled.span` font-weight: 700 @@ -9,14 +10,13 @@ const Bold = styled.span` const StyledDiv = styled.div` display: inline-block; + margin: 2em 0; ` const Button = styled.button` - margin-left: 0 !important; -` - -const ButtonRow = styled.div` - display: inline; + margin-right: 0 !important; + margin-left: 2em !important; + height: calc(16px + 1.6em + 2px); ` const SpacedText = styled.span` @@ -32,38 +32,63 @@ const Flex = styled.div` const PasteInfo = (props) => { const history = useHistory(); - const redir = () => { + const redirRaw = () => { const redirUrl = `/raw/${props.hash}` history.push(redirUrl); } + const redirRender = () => { + const redirUrl = `/render/${props.hash}` + history.push(redirUrl); + } + + const renderable = () => { + if (props.lang === 'latex') { + return ( + + ); + } + } + return (
+ + + {renderable()} - - - - language: {props.lang} - - - expires: {props.expiry} - - - {props.err} - - + + language: {props.lang} + + + expires: {props.expiry} + + + {props.err} +
); diff --git a/frontend/src/components/ViewPaste.js b/frontend/src/components/ViewPaste.js index 81d78f3..914f94c 100644 --- a/frontend/src/components/ViewPaste.js +++ b/frontend/src/components/ViewPaste.js @@ -29,6 +29,7 @@ class ViewPaste extends React.Component { this.validatePass = this.validatePass.bind(this); this.ErrorLabel = React.createRef(); this.PasswordModal = React.createRef(); + this.componentRef = React.createRef(); } handleChange(event) { @@ -89,12 +90,14 @@ class ViewPaste extends React.Component { content={this.state.content} lang={this.state.language} theme={this.state.theme} + ref={this.componentRef} id="pasteInput" /> } expiry={this.state.expiry} /> diff --git a/frontend/src/components/renderers/Code.js b/frontend/src/components/renderers/Code.js index a024bb7..cfb43ab 100644 --- a/frontend/src/components/renderers/Code.js +++ b/frontend/src/components/renderers/Code.js @@ -39,9 +39,9 @@ const RelPositioning = styled.div` position: relative; ` -const CodeRenderer = (props) => { +const CodeRenderer = React.forwardRef((props, ref) => { return ( - + { ); -}; +}); export default CodeRenderer \ No newline at end of file -- cgit v1.2.3 From 25fe7f39fd65a160ce5dd3f9fc0e5f3773631306 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 17 May 2020 11:12:23 -0700 Subject: fix export not being right size --- frontend/src/components/renderers/Code.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/renderers/Code.js b/frontend/src/components/renderers/Code.js index cfb43ab..3d84adb 100644 --- a/frontend/src/components/renderers/Code.js +++ b/frontend/src/components/renderers/Code.js @@ -1,5 +1,4 @@ import React from 'react'; -import styled from 'styled-components' import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'; import { atomOneLight, ascetic, atomOneDark, dracula, ocean } from 'react-syntax-highlighter/dist/esm/styles/hljs'; @@ -35,21 +34,24 @@ export const LANGS = Object.freeze({ 'yaml': 'yaml' }) -const RelPositioning = styled.div` - position: relative; -` - const CodeRenderer = React.forwardRef((props, ref) => { + + const Pre = (props) => { + return ( +
+        );
+    }
+
     return (
-        
-            
-                {props.content}
-            
-        
+        
+            {props.content}
+        
     );
 });
 
-- 
cgit v1.2.3