Skip to content

Commit 8282985

Browse files
fix: add inactive ViewInBrowser icon
1 parent 9ebb091 commit 8282985

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

lib/static/components/icons/view-in-browser.js renamed to lib/static/components/icons/view-in-browser/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import PropTypes from 'prop-types';
55
import url from 'url';
66
import classNames from 'classnames';
77

8-
import * as actions from '../../modules/actions';
8+
import * as actions from '../../../modules/actions';
9+
10+
import './index.styl';
911

1012
class ViewInBrowser extends Component {
1113
static propTypes = {
1214
resultId: PropTypes.string.isRequired,
1315
extendClassNames: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
1416
// from store
15-
suiteUrl: PropTypes.string.isRequired,
16-
parsedHost: PropTypes.object.isRequired
17+
suiteUrl: PropTypes.string,
18+
parsedHost: PropTypes.object
1719
}
1820

1921
onViewInBrowser = (e) => {
@@ -31,18 +33,23 @@ class ViewInBrowser extends Component {
3133
render() {
3234
const {suiteUrl, parsedHost, extendClassNames} = this.props;
3335
const className = classNames(
34-
'button custom-icon custom-icon_view-in-browser',
36+
'fa view-in-browser',
37+
suiteUrl ? 'fa-eye view-in-browser_active' : 'fa-eye-slash view-in-browser_disabled',
3538
extendClassNames
3639
);
3740

41+
if (!suiteUrl) {
42+
return <i className={className} aria-hidden="true" />;
43+
}
44+
3845
return (
3946
<a
4047
className={className}
4148
href={this._buildUrl(suiteUrl, parsedHost)}
4249
onClick={this.onViewInBrowser}
4350
title="view in browser"
44-
target="_blank">
45-
</a>
51+
target="_blank"
52+
/>
4653
);
4754
}
4855
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.view-in-browser {
2+
display: inline-block;
3+
width: 16px;
4+
height: 19px;
5+
vertical-align: middle;
6+
margin-left: 4px;
7+
margin-right: 0;
8+
padding: 0 2px;
9+
border: none;
10+
color: black;
11+
opacity: 0.3;
12+
13+
&:visited {
14+
color: black;
15+
}
16+
17+
&:active,
18+
&:hover {
19+
&.view-in-browser_active {
20+
opacity: 1;
21+
cursor: pointer;
22+
}
23+
24+
&.view-in-browser_disabled {
25+
cursor: default;
26+
}
27+
}
28+
}

lib/static/styles.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,6 @@ details[open] > .details__summary:before {
447447
margin-left: 4px;
448448
}
449449

450-
.custom-icon_view-in-browser:before {
451-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath transform='scale(0.027,-0.027) translate(0,-448)' d=' M569.354 216.369C512.969 312.051 407.81 376 288 376C168.14 376 63.004 312.006 6.646 216.369A47.999 47.999 0 0 1 6.646 167.63C63.031 71.949 168.19 8 288 8C407.86 8 512.996 71.994 569.354 167.631A47.997 47.997 0 0 1 569.354 216.369zM288 56C212.838 56 152 116.827 152 192C152 267.1620000000001 212.826 328 288 328C363.1620000000001 328 424 267.174 424 192C424 116.838 363.174 56 288 56zM392 192C392 134.562 345.438 88 288 88S184 134.562 184 192C184 209.708 188.431 226.379 196.236 240.973L196.235 240.941C196.235 217.29 215.408 198.118 239.059 198.118S281.883 217.291 281.883 240.941C281.883 264.592 262.71 283.765 239.059 283.765L239.027 283.764C253.621 291.569 270.292 296 288 296C345.438 296 392 249.438 392 192z'/%3E%3C/svg%3E");
452-
}
453-
454450
.custom-icon_copy-to-clipboard:before {
455451
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath transform='scale(0.027,-0.027) translate(0,-448)' d=' M464 448H144C117.49 448 96 426.51 96 400V352H48C21.49 352 0 330.51 0 304V-16C0 -42.51 21.49 -64 48 -64H368C394.51 -64 416 -42.51 416 -16V32H464C490.51 32 512 53.49 512 80V400C512 426.51 490.51 448 464 448zM362 -16H54A6 6 0 0 0 48 -10V298A6 6 0 0 0 54 304H96V80C96 53.49 117.49 32 144 32H368V-10A6 6 0 0 0 362 -16zM458 80H150A6 6 0 0 0 144 86V394A6 6 0 0 0 150 400H458A6 6 0 0 0 464 394V86A6 6 0 0 0 458 80z'/%3E%3C/svg%3E");
456452
}

0 commit comments

Comments
 (0)