Skip to content

Commit 5383257

Browse files
committed
Merge remote-tracking branch 'origin/improvements/tooltips' into dev
2 parents b0209f2 + 9ba3cf9 commit 5383257

File tree

6 files changed

+31
-50
lines changed

6 files changed

+31
-50
lines changed
Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,26 @@
1-
/* eslint-disable react/prop-types */
2-
import React, { useState } from 'react';
3-
import styles from './index.styl';
4-
5-
/*
6-
Custom Tooltip Component
7-
Content Prop: String to be displayed when hovered
8-
Disabled Prop: Varibale to set css display: none;
9-
Location Prop: Where tooltip should be displayed(See css file)
10-
*/
11-
12-
const Tooltip = (props) => {
13-
let disabled = props.disabled;
14-
let timeout;
15-
const [active, setActive] = useState(false);
16-
17-
const showTip = () => {
18-
timeout = setTimeout(() => {
19-
setActive(true);
20-
}, props.delay || 1000);
21-
};
22-
23-
const hideTip = () => {
24-
clearInterval(timeout);
25-
setActive(false);
26-
};
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Tooltip as MainToolTip } from 'app/components/Tooltip';
274

5+
const Tooltip = ({ location, content, disabled, children }) => {
286
return (
29-
<div
30-
className={styles.TooltipWrapper}
31-
// When to show the tooltip
32-
onMouseEnter={showTip}
33-
onMouseLeave={hideTip}
7+
<MainToolTip
8+
content={content}
9+
placement={location === 'default' ? 'bottom' : location}
10+
enterDelay={1000}
11+
disabled={disabled}
3412
>
35-
{props.children}
36-
{active && (
37-
<div className={disabled ? styles.disabled : styles[`${props.location}`]}>
38-
{props.content}
39-
</div>
40-
)}
41-
</div>
13+
<div>
14+
{children}
15+
</div>
16+
</MainToolTip>
4217
);
4318
};
4419

20+
Tooltip.propTypes = {
21+
location: PropTypes.string,
22+
content: PropTypes.string || PropTypes.node,
23+
disabled: PropTypes.bool,
24+
};
25+
4526
export default Tooltip;

src/app/containers/Firmware/Firmware.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ class Firmware extends PureComponent {
615615
Export Settings
616616
</ToolModalButton>
617617
</TooltipCustom>
618-
<TooltipCustom content="Restore the settings for your current Machine profile" location="default">
618+
<TooltipCustom content="Restore the settings for your current machine profile" location="default">
619619
<ToolModalButton
620620
onClick={this.restoreSettings}
621621
icon="fas fa-undo"

src/app/containers/Preferences/GeneralSettings.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const GeneralSettings = ({ active, state, actions }) => {
6060
<div className={styles.halfContainer}>
6161
<Fieldset legend="Connection">
6262
<TooltipCustom content="Machine must be disconnected to change this value" location="top" disabled={!baudRateDisabled}>
63-
<TooltipCustom content="Baudrate specifies how fast data is sent over a serial line." location="bottom">
63+
<TooltipCustom content="Baudrate specifies how fast data is sent over a serial line." location="default">
6464
<div className={baudRateDisabled ? styles.disabled : styles.addMargin}>
6565
<Baudrates baudrate={state.baudrate} onChange={(option) => actions.general.setBaudrate(option)} />
6666
<br />
@@ -106,7 +106,7 @@ const GeneralSettings = ({ active, state, actions }) => {
106106
</TooltipCustom>
107107
</div>
108108
<div style={{ marginBottom: '10px' }}>
109-
<TooltipCustom content="gSender will warn you on file load if any errorous commands are found in your file" location="default">
109+
<TooltipCustom content="gSender will warn you on file load if any invalid commands are found" location="default">
110110
<ToggleSwitch
111111
label="Warn if file contains invalid G-Code"
112112
checked={state.showWarning}
@@ -116,7 +116,7 @@ const GeneralSettings = ({ active, state, actions }) => {
116116
</TooltipCustom>
117117
</div>
118118
<div style={{ marginBottom: '10px' }}>
119-
<TooltipCustom content="gSender will warn you while running if any errorous commands are found in your file" location="default">
119+
<TooltipCustom content="gSender will warn you while running if any invalid commands are found" location="default">
120120
<ToggleSwitch
121121
label="Warn if invalid line detected during job"
122122
checked={state.showLineWarnings}

src/app/containers/Preferences/Keybindings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export default class Keybindings extends Component {
160160

161161
{ showEditModal && (
162162
<Modal onClose={closeModal} size="md" style={{ padding: '1rem 1rem 2rem', backgroundColor: '#d1d5db' }}>
163-
<h2 style={{ textAlign: 'center', marginBottom: '1rem' }}>Edit Shortcut</h2>
163+
<h3 style={{ textAlign: 'center', marginBottom: '1rem' }}>Edit Shortcut</h3>
164164

165165
<EditArea
166166
shortcut={currentShortcut}

src/app/containers/Preferences/MachineProfiles/Options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export default class Options extends Component {
224224
<div className={styles['machine-options-section']}>
225225
<div className={styles['general-area-item']}>
226226
<h4 className={styles['settings-subtitle']}>Presets</h4>
227-
<TooltipCustom content="gSender comes pre-loaded with many Cnc machine presets" location="default">
227+
<TooltipCustom content="gSender comes pre-loaded with many CNC machine presets" location="default">
228228
<Select
229229
className={styles['machine-options-select']}
230230
value={{ label: label }}

src/app/widgets/Axes/DisplayPanel.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ class DisplayPanel extends PureComponent {
10671067
}}
10681068
>
10691069
<Tooltip
1070-
placement="bottom"
1070+
placement="default"
10711071
content={i18n._('Zero Out Machine')}
10721072
disabled={!canZeroOutMachine}
10731073
hideOnClick
@@ -1082,7 +1082,7 @@ class DisplayPanel extends PureComponent {
10821082
}}
10831083
>
10841084
<Tooltip
1085-
placement="bottom"
1085+
placement="default"
10861086
content={i18n._('Home Machine')}
10871087
disabled={!canHomeMachine}
10881088
hideOnClick
@@ -1121,7 +1121,7 @@ class DisplayPanel extends PureComponent {
11211121
}}
11221122
>
11231123
<Tooltip
1124-
placement="bottom"
1124+
placement="default"
11251125
content={i18n._('Move Backward')}
11261126
disabled={!canMoveBackward}
11271127
hideOnClick
@@ -1137,7 +1137,7 @@ class DisplayPanel extends PureComponent {
11371137
}}
11381138
>
11391139
<Tooltip
1140-
placement="bottom"
1140+
placement="default"
11411141
content={i18n._('Move Forward')}
11421142
disabled={!canMoveForward}
11431143
hideOnClick
@@ -1152,7 +1152,7 @@ class DisplayPanel extends PureComponent {
11521152
}}
11531153
>
11541154
<Tooltip
1155-
placement="bottom"
1155+
placement="default"
11561156
content={i18n._('Zero Out Work Offsets')}
11571157
disabled={!canZeroOutWorkOffsets}
11581158
hideOnClick
@@ -1166,7 +1166,7 @@ class DisplayPanel extends PureComponent {
11661166
onClick={this.showPositionInput(axis)}
11671167
>
11681168
<Tooltip
1169-
placement="bottom"
1169+
placement="default"
11701170
content={i18n._('Set Work Offsets')}
11711171
disabled={!canModifyWorkPosition}
11721172
hideOnClick

0 commit comments

Comments
 (0)