Skip to content

Commit 76af4fd

Browse files
authored
Merge pull request #155 from smacker/review_visual_design
Port visual design of review page
2 parents e952dd5 + ed7efa8 commit 76af4fd

File tree

7 files changed

+211
-22
lines changed

7 files changed

+211
-22
lines changed

src/components/Experiment/Diff.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Diff extends PureComponent {
1919

2020
render() {
2121
const { diffString, leftLoc, rightLoc, className } = this.props;
22+
const showLoc = leftLoc && rightLoc;
2223
const diffHTML = Diff2Html.getPrettyHtml(diffString, {
2324
inputFormat: 'diff',
2425
outputFormat: 'side-by-side',
@@ -29,12 +30,14 @@ class Diff extends PureComponent {
2930
});
3031
return (
3132
<div className={`diff ${className}`}>
32-
<div className="diff__locs">
33-
<div className="diff__loc left">{leftLoc} lines of code</div>
34-
<div className="diff__loc right">{rightLoc} lines of code</div>
35-
</div>
33+
{showLoc && (
34+
<div className="diff__locs">
35+
<div className="diff__loc left">{leftLoc} lines of code</div>
36+
<div className="diff__loc right">{rightLoc} lines of code</div>
37+
</div>
38+
)}
3639
<div
37-
className="diff__content"
40+
className={`diff__content ${showLoc ? '_with-loc' : ''}`}
3841
dangerouslySetInnerHTML={{ __html: diffHTML }}
3942
/>
4043
</div>

src/components/Experiment/Diff.less

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
margin-bottom: -5px;
2020
}
2121

22+
.d2h-diff-tbody {
23+
background: #fff;
24+
}
25+
2226
.diff {
2327
// there is a bug in Chrome if I use flex here location div gets 0px height
2428
// but I can't reproduce it on simpler example
@@ -43,7 +47,9 @@
4347
}
4448

4549
&__content {
46-
padding-top: 20px;
4750
height: 100%;
4851
}
52+
&__content._with-loc {
53+
padding-top: 20px;
54+
}
4955
}

src/components/Review/FeaturesTable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react';
22
import { Table } from 'react-bootstrap';
33
import './FeaturesTable.less';
44

5-
function FeaturesTable({ title, features }) {
5+
function FeaturesTable({ title, features, bsStyle }) {
66
return (
7-
<Table striped bordered condensed hover className="features-table">
7+
<Table condensed className={`features-table ${bsStyle}`}>
88
<thead>
99
<tr>
1010
<th className="features-table__th-number" />
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,66 @@
1+
@import '../../../node_modules/bootstrap/less/variables.less';
2+
13
.features-table {
24
&__cell-name {
35
max-width: 600px;
46
overflow: hidden;
57
}
8+
9+
th,
10+
td {
11+
border: 1px solid transparent !important;
12+
}
13+
14+
thead {
15+
background: @gray-darker;
16+
17+
th {
18+
color: @gray-lighter;
19+
font-weight: 300;
20+
font-size: 10px;
21+
text-transform: uppercase;
22+
letter-spacing: 1px;
23+
}
24+
25+
th:nth-child(3),
26+
th:nth-child(4) {
27+
text-align: right;
28+
color: @gray-light;
29+
}
30+
}
31+
32+
tbody {
33+
tr {
34+
background: @gray-darker;
35+
}
36+
37+
tr:nth-of-type(odd) {
38+
background-color: @gray-dark;
39+
}
40+
41+
td:nth-child(1) {
42+
color: @gray;
43+
text-align: center;
44+
}
45+
46+
td:nth-child(2) {
47+
color: @brand-success;
48+
letter-spacing: 1px;
49+
font-weight: 300;
50+
}
51+
52+
td:nth-child(3),
53+
td:nth-child(4) {
54+
color: @gray-lighter;
55+
text-align: right;
56+
}
57+
}
58+
59+
&.danger {
60+
tbody {
61+
td:nth-child(2) {
62+
color: @brand-danger;
63+
}
64+
}
65+
}
666
}

src/components/Review/Results.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ class Results extends Component {
3030
return (
3131
<Grid fluid className="review-results">
3232
<Row className="review-results__info">
33-
<Col xs={4}>
33+
<Col xs={12} className="review-results__info-col">
3434
<FormGroup>
3535
<Radio
3636
inline
3737
value="most"
3838
checked={this.state.mode === 'most'}
3939
onChange={this.onModeChange}
40+
className={this.state.mode === 'most' ? '_checked' : ''}
4041
>
41-
Most similar & disimilar Features
42+
Most similar & dissimilar Features
4243
</Radio>{' '}
4344
<Radio
4445
inline
4546
value="full"
4647
checked={this.state.mode === 'full'}
4748
onChange={this.onModeChange}
49+
className={this.state.mode === 'full' ? '_checked' : ''}
4850
>
4951
Full Output
5052
</Radio>
5153
</FormGroup>
52-
</Col>
53-
<Col xs={4} className="text-right">
54-
Users Annotations: <b>{annotations.yes || 0} Similar</b> &{' '}
55-
<b>{annotations.no || 0} Disimilar</b>
56-
</Col>
57-
<Col xs={4}>
54+
<div className="review-results__stats">
55+
Users Annotations: <b>{annotations.yes || 0} Similar</b> &{' '}
56+
<b>{annotations.no || 0} Dissimilar</b>
57+
</div>
5858
<div className="review-results__score">
5959
Similarity Score: {score}
6060
</div>
@@ -71,8 +71,9 @@ class Results extends Component {
7171
features={mostSimilarFeatures}
7272
/>
7373
<FeaturesTable
74-
title="Most Disimilar Features"
74+
title="Most Dissimilar Features"
7575
features={leastSimilarFeatures}
76+
bsStyle="danger"
7677
/>
7778
</React.Fragment>
7879
) : (

src/components/Review/Results.less

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
11
@import '../../../node_modules/bootstrap/less/variables.less';
22

33
.review-results {
4-
//height: 100%;
54
flex: 1;
65
display: flex;
76
flex-direction: column;
87

98
&__info {
109
flex: 0 0;
1110
padding-top: 10px;
11+
margin: 0 -30px 20px;
12+
}
13+
14+
&__info-col {
15+
display: flex;
16+
justify-content: space-between;
17+
align-items: center;
18+
}
19+
20+
.form-group {
21+
margin: 0;
22+
}
23+
24+
&__stats {
25+
flex: 1;
26+
27+
padding: 0 36px;
28+
29+
text-align: right;
30+
color: @gray-lighter;
31+
font-weight: 300;
32+
font-size: 11px;
33+
text-transform: uppercase;
34+
letter-spacing: 1px;
35+
36+
b {
37+
white-space: nowrap;
38+
}
1239
}
1340

1441
&__score {
15-
margin-top: -10px;
16-
padding: 10px 20px;
17-
background: @gray-lighter;
42+
padding: 10px 36px;
43+
color: @brand-success;
44+
font-weight: 400;
45+
font-size: 11px;
46+
text-transform: uppercase;
47+
letter-spacing: 1px;
48+
background: @gray-dark;
1849
}
1950

2051
&__main {
@@ -65,4 +96,82 @@
6596
margin-bottom: 0;
6697
}
6798
}
99+
100+
// bootstrap style overrides
101+
.radio-inline {
102+
color: @gray-lighter;
103+
position: relative;
104+
padding-left: 32px;
105+
cursor: pointer;
106+
line-height: 23px;
107+
display: inline-block;
108+
font-size: 12px;
109+
text-transform: uppercase;
110+
letter-spacing: 1px;
111+
font-weight: 300;
112+
margin-right: 16px;
113+
114+
input {
115+
position: absolute;
116+
left: -9999px;
117+
}
118+
119+
&:before {
120+
content: '';
121+
position: absolute;
122+
left: 0;
123+
top: 0;
124+
width: 22px;
125+
height: 22px;
126+
background: @gray-dark;
127+
border-radius: 100%;
128+
}
129+
130+
&._checked:after {
131+
content: '';
132+
width: 8px;
133+
height: 8px;
134+
background: @brand-info;
135+
position: absolute;
136+
top: 7px;
137+
left: 7px;
138+
border-radius: 100%;
139+
transition: all 0.2s ease;
140+
}
141+
142+
&:last-child {
143+
margin-right: 0;
144+
}
145+
}
146+
147+
.nav-tabs {
148+
border-bottom: 1px solid transparent;
149+
}
150+
151+
.nav-tabs > li > a,
152+
.nav-tabs > li > a:hover,
153+
.nav-tabs > li > a:focus {
154+
background: @gray-dark;
155+
color: @gray-lighter;
156+
border: none;
157+
border-radius: 0;
158+
font-size: 12px;
159+
text-transform: uppercase;
160+
letter-spacing: 1px;
161+
font-weight: 300;
162+
padding: 12px 26px;
163+
margin-right: 6px;
164+
165+
&:hover {
166+
color: @brand-info;
167+
}
168+
}
169+
170+
.nav-tabs > li.active > a,
171+
.nav-tabs > li.active > a:hover,
172+
.nav-tabs > li.active > a:focus {
173+
background: @gray-darker;
174+
color: @brand-info;
175+
padding: 12px 40px;
176+
}
68177
}

src/pages/Review.less

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
height: 100%;
55
display: flex;
66
flex-direction: column;
7+
background: @gray;
78

89
.navbar {
910
flex: 0;
@@ -59,6 +60,8 @@
5960
}
6061

6162
&__diff {
63+
flex: 1;
64+
6265
margin-bottom: 10px;
6366
}
6467

@@ -67,10 +70,15 @@
6770
position: relative;
6871
flex: 0 0 auto;
6972
display: block;
73+
7074
border-top: 1px solid @gray;
7175
border-bottom: 1px solid @gray;
7276
margin-bottom: 10px;
73-
color: @gray;
77+
padding: 2px 0;
78+
79+
color: @brand-info;
80+
background: @gray-darker;
81+
7482
cursor: row-resize;
7583

7684
&:before {
@@ -86,5 +94,7 @@
8694

8795
min-width: 0;
8896
min-height: 0;
97+
98+
background: @gray;
8999
}
90100
}

0 commit comments

Comments
 (0)