Skip to content

Commit 0386f6a

Browse files
committed
Add copy button on builder view
1 parent ef625c7 commit 0386f6a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

frontend/src/components/Builder.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
88
import './Builder.scss';
99
import DynamicTextInput from './common/DynamicTextInput';
1010
import PermissionInput from './common/PermissionInput';
11+
import CopyToClipboard from 'react-copy-to-clipboard';
12+
import ToastMaker from 'toastmaker';
1113

1214
class Builder extends Component {
1315
state = {
@@ -163,9 +165,18 @@ class Builder extends Component {
163165
<div className="header" ref={this.headerDiv}>
164166
<div className="text">
165167
<code>
166-
{generatedCommand != null && (<span>{generatedCommand}</span>)}
168+
{generatedCommand != null && <span>{generatedCommand}</span>}
167169
</code>
168170
</div>
171+
<CopyToClipboard text={generatedCommand}>
172+
<button className="copy" onClick={(e) => ToastMaker("Copied!")}>
173+
<span className="copy-icon" title="copy">
174+
<FontAwesomeIcon icon="copy" color="white" size="lg" />
175+
</span><br />
176+
<span className="copy-label">COPY</span>
177+
</button>
178+
</CopyToClipboard>
179+
169180
</div>
170181

171182
<div className="content" ref={this.contentDiv}>

frontend/src/components/Builder.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $builder-header-min-height: 50px;
44
$header-padding-vertical: 5px;
55
$checkbox-size: 30px;
66
$form-bottom-button-spacing: 15px;
7+
$command-copy-button-width: 50px;
78

89
.builder {
910
> .header {
@@ -16,12 +17,32 @@ $form-bottom-button-spacing: 15px;
1617
min-height: $builder-header-min-height;
1718
min-width: auto;
1819
padding: $header-padding-vertical 10px;
20+
padding-right: $command-copy-button-width;
1921
position: fixed;
2022
text-align: center;
2123
width: 100%;
2224
z-index: 100;
2325
.text {
2426
width: 100%;
27+
user-select: none;
28+
}
29+
button.copy {
30+
background-color: $color-primary;
31+
border: none;
32+
border-left: 1px solid lighten($color-primary, 50%);
33+
outline: none;
34+
position: absolute;
35+
right: 0;
36+
height: 100%;
37+
width: $command-copy-button-width;
38+
cursor: pointer;
39+
.copy-icon {
40+
padding: 2px;
41+
}
42+
.copy-label {
43+
font-size: xx-small;
44+
color: white;
45+
}
2546
}
2647
}
2748
> .content {

0 commit comments

Comments
 (0)