Skip to content

Commit e02b82e

Browse files
committed
Add click-to-confirm buttons and fix color names
1 parent 8b82d23 commit e02b82e

File tree

9 files changed

+59
-27
lines changed

9 files changed

+59
-27
lines changed

src/frontend/common/stylesheet/colors.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $theme-light: #505050;
44
$color-font: #bbbbbb;
55
$color-shadow: rgba(#000000, .2);
66
$color-overlay: rgba(#ffffff, .1);
7+
$color-alert: #f3bd58;
78
$color-selected: #2962ff;
89
$color-patched: #c51162;
910
$color-highlight: #29d;
@@ -15,7 +16,8 @@ $color-highlight: #29d;
1516
colorFont: $color-font;
1617
colorShadow: $color-shadow;
1718
colorOverlay: $color-overlay;
19+
colorAlert: $color-alert;
1820
colorSelected: $color-selected;
19-
colorNotified: $color-patched;
21+
colorPatched: $color-patched;
2022
colorHighlight: $color-highlight;
2123
}

src/frontend/components/Button/index.jsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
11
import React from 'react';
2-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3-
import styles from './stylesheet.scss';
4-
import { classes } from '/common/util';
52
import { Link } from 'react-router-dom';
3+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import faExclamationCircle from '@fortawesome/fontawesome-free-solid/faExclamationCircle';
5+
import { classes } from '/common/util';
6+
import { Ellipsis } from '/components';
7+
import styles from './stylesheet.scss';
68

79
class Button extends React.Component {
10+
constructor(props) {
11+
super(props);
12+
13+
this.state = {
14+
confirming: false,
15+
};
16+
}
17+
818
render() {
9-
const { className, children, onClick, to, href, icon, reverse, selected, disabled, primary, active, ...rest } = this.props;
19+
let { className, children, to, href, onClick, icon, reverse, selected, disabled, primary, active, confirmNeeded, ...rest } = this.props;
20+
const { confirming } = this.state;
21+
22+
if (confirmNeeded) {
23+
if (confirming) {
24+
className = classes(styles.confirming, className);
25+
icon = faExclamationCircle;
26+
children = <Ellipsis key="text">Click to Confirm</Ellipsis>;
27+
} else {
28+
to = null;
29+
href = null;
30+
onClick = () => {
31+
this.setState({ confirming: true });
32+
window.setTimeout(() => {
33+
this.setState({ confirming: false });
34+
}, 2000);
35+
};
36+
}
37+
}
1038

1139
const iconOnly = !children;
1240
const props = {
1341
className: classes(styles.button, reverse && styles.reverse, selected && styles.selected, disabled && styles.disabled, primary && styles.primary, active && styles.active, iconOnly && styles.icon_only, className),
14-
onClick: disabled ? null : onClick,
42+
to: disabled ? null : to,
1543
href: disabled ? null : href,
44+
onClick: disabled ? null : onClick,
1645
children: [
1746
icon && (
1847
typeof icon === 'string' ?
@@ -26,13 +55,9 @@ class Button extends React.Component {
2655
};
2756

2857
return to ? (
29-
<Link to={to} {...props} />
58+
<Link {...props} />
3059
) : href ? (
31-
/^https?:\/\//i.test(href) ? (
32-
<a href={href} rel="noopener" target="_blank" {...props} />
33-
) : (
34-
<a href={href} {...props} />
35-
)
60+
<a rel="noopener" target="_blank" {...props} />
3661
) : (
3762
<div {...props} />
3863
);

src/frontend/components/Button/stylesheet.scss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@
3636
}
3737

3838
&:hover {
39-
background: $color-overlay;
39+
background-color: $color-overlay;
4040
}
4141

4242
&.primary {
4343
&:hover {
44-
background: $color-shadow;
44+
background-color: $color-shadow;
4545

4646
&:active {
4747
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
4848
}
4949
}
5050

5151
&.active {
52-
background: $color-shadow;
52+
background-color: $color-shadow;
5353
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
5454
font-weight: bold;
5555

@@ -60,7 +60,7 @@
6060
}
6161

6262
&.selected {
63-
background: $color-shadow;
63+
background-color: $color-shadow;
6464

6565
&:hover {
6666
color: rgba($color-font, .8);
@@ -69,7 +69,11 @@
6969

7070
&.disabled {
7171
cursor: not-allowed;
72-
background: $color-shadow;
72+
background-color: $color-shadow;
7373
opacity: 0.6;
7474
}
75+
76+
&.confirming {
77+
color: $color-alert;
78+
}
7579
}

src/frontend/components/CodeEditor/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class CodeEditor extends React.Component {
9797
}
9898
<div className={styles.empty}>
9999
<div className={styles.empty} />
100-
<Button className={styles.delete} icon={faTrashAlt} primary onClick={() => onDeleteFile(file)}>
100+
<Button className={styles.delete} icon={faTrashAlt} primary onClick={() => onDeleteFile(file)}
101+
confirmNeeded>
101102
<Ellipsis>Delete File</Ellipsis>
102103
</Button>
103104
</div>

src/frontend/components/CodeEditor/stylesheet.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
min-height: 0 !important;
1515

1616
.current_line_marker {
17-
background: rgba($color-highlight, 0.4);
17+
background-color: rgba($color-highlight, 0.4);
1818
border: 1px solid $color-highlight;
1919
position: absolute;
2020
width: 100% !important;
@@ -24,10 +24,10 @@
2424

2525
@keyframes line_highlight {
2626
from {
27-
background: rgba($color-highlight, 0.1);
27+
background-color: rgba($color-highlight, 0.1);
2828
}
2929
to {
30-
background: rgba($color-highlight, 0.4);
30+
background-color: rgba($color-highlight, 0.4);
3131
}
3232
}
3333
}

src/frontend/components/Header/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Header extends React.Component {
129129
<div className={styles.section}>
130130
<Button icon={faSave} primary disabled={!gistId || this.isGistSaved()}
131131
onClick={() => this.saveGist()}>Save</Button>
132-
<Button icon={faTrashAlt} primary disabled={!gistId} onClick={() => this.deleteGist()}>Delete</Button>
132+
<Button icon={faTrashAlt} primary disabled={!gistId} onClick={() => this.deleteGist()} confirmNeeded>Delete</Button>
133133
<Button icon={faShare} primary disabled={gistId === 'new'} onClick={() => this.shareLink()}>Share</Button>
134134
<Button icon={faExpandArrowsAlt} primary
135135
onClick={() => this.handleClickFullScreen()}>Fullscreen</Button>

src/frontend/components/Header/stylesheet.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
white-space: nowrap;
4444

4545
&:hover {
46-
background: $color-shadow;
46+
background-color: $color-shadow;
4747
}
4848

4949
.range {
@@ -73,7 +73,7 @@
7373
margin-left: -3px;
7474
margin-top: -3px;
7575
appearance: none;
76-
background: $color-font;
76+
background-color: $color-font;
7777
cursor: pointer;
7878
display: block;
7979
position: absolute;

src/frontend/components/ToastContainer/stylesheet.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
&.success {
1919
border-color: rgb(0, 150, 0);
20-
background: rgba(0, 120, 0, .8);
20+
background-color: rgba(0, 120, 0, .8);
2121
}
2222

2323
&.error {
2424
border-color: rgb(150, 0, 0);
25-
background: rgba(120, 0, 0, .8);
25+
background-color: rgba(120, 0, 0, .8);
2626
}
2727
}

src/frontend/core/renderers/ChartRenderer/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ChartRenderer extends Array1DRenderer {
1010
const chartData = {
1111
labels: row.map(col => `${col.value}`),
1212
datasets: [{
13-
backgroundColor: row.map(col => col.patched ? styles.colorNotified : col.selected ? styles.colorSelected : styles.colorFont),
13+
backgroundColor: row.map(col => col.patched ? styles.colorPatched : col.selected ? styles.colorSelected : styles.colorFont),
1414
data: row.map(col => col.value),
1515
}],
1616
};

0 commit comments

Comments
 (0)