blob: bab7e2350181ec7a637b6b962e35746c35afc1d8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
import React from 'react';
import styled from 'styled-components'
import { useHistory } from 'react-router-dom';
import { ThemeInput } from './Inputs'
import { exportComponentAsPNG } from "react-component-export-image";
const Bold = styled.span`
font-weight: 700
`
const StyledDiv = styled.div`
display: inline-block;
margin: 2em 0;
`
const Button = styled.button`
margin-right: 0 !important;
margin-left: 2em !important;
height: calc(16px + 1.6em);
margin-top: 1.6em !important;
`
const SpacedText = styled.span`
margin-right: 1em;
`
const Flex = styled.div`
float: right;
display: flex;
flex-direction: row;
transform: translateY(0.2em);
`
const PasteInfo = (props) => {
const history = useHistory();
const redirRaw = () => {
const redirUrl = `/raw/${props.hash}`
history.push(redirUrl);
}
const renderable = () => {
const buttonTxt = props.isRenderMode ? 'text' : 'render'
if (props.lang === 'latex' || props.lang === 'markdown') {
return (
<Button
className="lt-shadow lt-hover"
type="button"
onClick={props.toggleRenderCallback}>
{buttonTxt}
</Button>
);
}
}
return (
<div>
<Flex>
<Button
className="lt-shadow lt-hover"
type="button"
onClick={redirRaw}>
view raw
</Button>
<Button
className="lt-shadow lt-hover"
type="button"
onClick={() => exportComponentAsPNG(props.compref, `paste-${props.hash}.png`)}>
save png
</Button>
{renderable()}
<ThemeInput
value={props.theme}
onChange={props.onChange}
id="themeInput" />
</Flex>
<StyledDiv>
<SpacedText>
<Bold>language: </Bold>{props.lang}
</SpacedText>
<SpacedText>
<Bold>expires: </Bold>{props.expiry}
</SpacedText>
</StyledDiv>
<br />
{props.err}
</div>
);
}
export default PasteInfo
|