Skip to content

Commit a0cec4d

Browse files
authored
Merge pull request #56 from GustavoKatel/showUrlOnLinkHover
Show url when mouse enters a link
2 parents eae93c0 + 4c3aee0 commit a0cec4d

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

src/components/services/content/ServiceWebview.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Webview from 'react-electron-web-view';
66
import classnames from 'classnames';
77

88
import ServiceModel from '../../../models/Service';
9+
import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl';
910

1011
@observer
1112
export default class ServiceWebview extends Component {
@@ -20,6 +21,8 @@ export default class ServiceWebview extends Component {
2021

2122
state = {
2223
forceRepaint: false,
24+
targetUrl: '',
25+
statusBarVisible: false,
2326
};
2427

2528
componentDidMount() {
@@ -33,6 +36,17 @@ export default class ServiceWebview extends Component {
3336
});
3437
}
3538

39+
updateTargetUrl = (event) => {
40+
let visible = true;
41+
if (event.url === '' || event.url === '#') {
42+
visible = false;
43+
}
44+
this.setState({
45+
targetUrl: event.url,
46+
statusBarVisible: visible,
47+
});
48+
}
49+
3650
webview = null;
3751

3852
render() {
@@ -47,6 +61,13 @@ export default class ServiceWebview extends Component {
4761
'services__webview--force-repaint': this.state.forceRepaint,
4862
});
4963

64+
let statusBar = null;
65+
if (this.state.statusBarVisible) {
66+
statusBar = (
67+
<StatusBarTargetUrl position="bottom" text={this.state.targetUrl} />
68+
);
69+
}
70+
5071
return (
5172
<div className={webviewClasses}>
5273
<Webview
@@ -62,11 +83,14 @@ export default class ServiceWebview extends Component {
6283
webview: this.webview.view,
6384
})}
6485

86+
onUpdateTargetUrl={this.updateTargetUrl}
87+
6588
useragent={service.userAgent}
6689

6790
disablewebsecurity
6891
allowpopups
6992
/>
93+
{statusBar}
7094
</div>
7195
);
7296
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { observer } from 'mobx-react';
4+
import classnames from 'classnames';
5+
6+
@observer
7+
export default class StatusBarTargetUrl extends Component {
8+
static propTypes = {
9+
// eslint-disable-next-line
10+
className: PropTypes.string,
11+
position: PropTypes.string,
12+
text: PropTypes.string,
13+
};
14+
15+
static defaultProps = {
16+
className: '',
17+
position: 'bottom',
18+
text: '',
19+
};
20+
21+
render() {
22+
const {
23+
className,
24+
position,
25+
text,
26+
} = this.props;
27+
28+
return (
29+
<div
30+
className={classnames({
31+
'status-bar-target-url': true,
32+
[`status-bar-target-url--${position}`]: true,
33+
[`${className}`]: true,
34+
})}
35+
>
36+
<div className="status-bar-target-url__content">
37+
{text}
38+
</div>
39+
</div>
40+
);
41+
}
42+
}

src/styles/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $mdi-font-path: '../node_modules/mdi/fonts';
2020
@import './auth.scss';
2121
@import './tooltip.scss';
2222
@import './info-bar.scss';
23+
@import './status-bar-target-url.scss';
2324
@import './animations.scss';
2425
@import './infobox.scss';
2526
@import './badge.scss';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@import './config.scss';
2+
3+
.status-bar-target-url {
4+
// width: 100%;
5+
height: auto;
6+
background: $theme-gray-lighter;
7+
padding: 2px 20px 2px 10px;
8+
position: absolute;
9+
// z-index: 100;
10+
box-shadow: 0 0 8px rgba(black, 0.2);
11+
12+
color: $theme-gray-dark;
13+
14+
.status-bar-target-url__content {
15+
height: auto;
16+
17+
.mdi {
18+
margin-right: 5px;
19+
}
20+
}
21+
22+
&.status-bar-target-url--bottom {
23+
order: 10;
24+
bottom: 0;
25+
border-top-right-radius: 5px;
26+
}
27+
28+
&.status-bar-target-url--top {
29+
order: 10;
30+
top: 0;
31+
border-bottom-right-radius: 5px;
32+
}
33+
}

0 commit comments

Comments
 (0)