Create transient "status bar" to display the hover URL.
Implementation: - <StatusBar> listens to 'update-target-url' and will show/hide itself as needed. - Handled the display of "lbry://" protocol. CSS: - The colors chosen should work on both Light and Dark Theme. - The delay is necessary to avoid blinkies when the mouse is moving around. #4259
This commit is contained in:
parent
5d1d36d4af
commit
ae82b3fc05
4 changed files with 84 additions and 0 deletions
|
@ -164,5 +164,17 @@ export default appState => {
|
||||||
shell.openExternal(url);
|
shell.openExternal(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.webContents.on('update-target-url', (event, url) => {
|
||||||
|
// Change internal links to the lbry protocol. External (https) links should remain unchanged.
|
||||||
|
let dispUrl = url.replace(`http://localhost:${WEBPACK_ELECTRON_PORT}/`, lbryProto);
|
||||||
|
// Non-claims don't need the lbry protocol:
|
||||||
|
if (dispUrl === lbryProto) {
|
||||||
|
dispUrl = 'Home';
|
||||||
|
} else if (dispUrl.startsWith(lbryProto + '$/')) {
|
||||||
|
dispUrl = dispUrl.replace(lbryProto, '/');
|
||||||
|
}
|
||||||
|
window.webContents.send('update-target-url', dispUrl);
|
||||||
|
});
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
};
|
};
|
||||||
|
|
48
ui/component/common/status-bar.jsx
Normal file
48
ui/component/common/status-bar.jsx
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
// @flow
|
||||||
|
import React from 'react';
|
||||||
|
import { ipcRenderer } from 'electron';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
type Props = {};
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
hoverUrl: string,
|
||||||
|
show: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
class StatusBar extends React.PureComponent<Props, State> {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.state = {
|
||||||
|
hoverUrl: '',
|
||||||
|
show: false,
|
||||||
|
};
|
||||||
|
(this: any).handleUrlChange = this.handleUrlChange.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
ipcRenderer.on('update-target-url', this.handleUrlChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
ipcRenderer.removeListener('update-target-url', this.handleUrlChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUrlChange(event: any, url: string) {
|
||||||
|
// We want to retain the previous URL so that it can fade out
|
||||||
|
// without the component collapsing.
|
||||||
|
if (url === '') {
|
||||||
|
this.setState({ show: false });
|
||||||
|
} else {
|
||||||
|
this.setState({ show: true });
|
||||||
|
this.setState({ hoverUrl: url });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { hoverUrl, show } = this.state;
|
||||||
|
return <div className={classnames('status-bar', { visible: show })}>{hoverUrl}</div>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StatusBar;
|
|
@ -44,6 +44,7 @@
|
||||||
@import 'component/snack-bar';
|
@import 'component/snack-bar';
|
||||||
@import 'component/spinner';
|
@import 'component/spinner';
|
||||||
@import 'component/splash';
|
@import 'component/splash';
|
||||||
|
@import 'component/status-bar';
|
||||||
@import 'component/subscriptions';
|
@import 'component/subscriptions';
|
||||||
@import 'component/syntax-highlighter';
|
@import 'component/syntax-highlighter';
|
||||||
@import 'component/table';
|
@import 'component/table';
|
||||||
|
|
23
ui/scss/component/_status-bar.scss
Normal file
23
ui/scss/component/_status-bar.scss
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
.status-bar {
|
||||||
|
background-color: #505050;
|
||||||
|
border: solid 1px #707070;
|
||||||
|
border-bottom-color: #505050;
|
||||||
|
border-left-color: #505050;
|
||||||
|
color: #e0e0e0;
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
font-size: var(--font-small);
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-left: var(--spacing-xsmall);
|
||||||
|
padding-right: var(--spacing-xsmall);
|
||||||
|
border-top-right-radius: var(--spacing-xsmall);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
transition-delay: 400ms;
|
||||||
|
|
||||||
|
&.visible {
|
||||||
|
opacity: 1;
|
||||||
|
transition-delay: 0s;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue