forked from Foundry376/Mailspring
-
Notifications
You must be signed in to change notification settings - Fork 14
/
share-button.tsx
94 lines (87 loc) · 2.38 KB
/
share-button.tsx
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
91
92
93
94
import React from 'react';
import { clipboard } from 'electron';
import { localized, MailspringAPIRequest } from 'mailspring-exports';
import { RetinaImg } from 'mailspring-component-kit';
function buildShareHTML(htmlEl, styleEl) {
return `
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="author" content="Mailspring">
<title>Mailspring Activity</title>
<style type="text/css">
body {
font-family: sans-serif;
font-size: 14px;
margin: 40px auto;
max-width: 1000px;
}
.hidden-on-web {
display: none !important;
}
</style>
${styleEl.outerHTML}
</head>
<body>
${htmlEl.outerHTML}
<script>
Array.from(document.querySelectorAll('.visible')).forEach((el) => {
el.classList.remove('visible');
setTimeout(() => {
el.classList.add('visible');
}, 250);
});
</script>
</body>
</html>
`;
}
export default class ShareButton extends React.Component<{}, { link: string; loading: boolean }> {
_mounted: boolean = false;
_linkEl: HTMLInputElement;
constructor(props) {
super(props);
this.state = {
loading: false,
link: null,
};
}
componentDidMount() {
this._mounted = true;
}
componentWillUnmount() {
this._mounted = false;
}
_onShareReport = async () => {};
render() {
return (
<div style={{ display: 'flex' }}>
{/* <div className="btn" onClick={this._onShareReport} style={{ minWidth: 150 }}>
{localized('Share this Report')}
{this.state.loading && (
<RetinaImg
name="inline-loading-spinner.gif"
mode={RetinaImg.Mode.ContentDark}
style={{ width: 14, height: 14, marginLeft: 10 }}
/>
)}
</div>
{this.state.link && (
<div>
<input
ref={el => (this._linkEl = el)}
type="url"
value={this.state.link}
style={{ width: 300, marginLeft: 10 }}
readOnly
/>
<div className="copy-to-clipboard" onClick={() => clipboard.writeText(this.state.link)}>
<RetinaImg name="icon-copytoclipboard.png" mode={RetinaImg.Mode.ContentIsMask} />
</div>
</div>
)} */}
</div>
);
}
}