Skip to content

Commit ed0bf28

Browse files
authored
Restyle "show more context" buttons (#280)
* normalize text by sorting lines * change link color, remove underlines * getting close to something * css arrows * hollow triangles * expand tabs * more reviewable style * push it in * not bad * adjust show more color too * cleanup
1 parent 02290f7 commit ed0bf28

2 files changed

Lines changed: 60 additions & 13 deletions

File tree

ts/codediff/SkipRow.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,29 @@ export function SkipRow(props: SkipRowProps) {
2424
};
2525
const arrows =
2626
numRows <= expandLines ? (
27-
<span className="skip" title={`show ${numRows} skipped lines`} onClick={showAll}>
27+
<span className="skip right" title={`show ${numRows} skipped lines`} onClick={showAll}>
2828
2929
</span>
3030
) : (
3131
<>
3232
<span
33-
className="skip expand-up"
33+
className="skip right expand-up"
3434
title={`show ${expandLines} more lines above`}
3535
onClick={() => {
3636
onShowMore(range, -expandLines);
3737
}}>
38-
38+
∨ EXPAND
3939
</span>
4040
<span
41-
className="skip expand-down"
41+
className="skip right expand-down"
4242
title={`show ${expandLines} more lines below`}
4343
onClick={() => {
4444
onShowMore(range, expandLines);
4545
}}>
46-
46+
∧ EXPAND
4747
</span>
4848
</>
4949
);
50-
const showMore = (
51-
<a href="#" onClick={showAll}>
52-
Show {numRows} more lines
53-
</a>
54-
);
5550
const headerHTML = header ? <span className="hunk-header">{header}</span> : '';
5651

5752
const rowRef = React.useRef<HTMLTableRowElement>(null);
@@ -63,9 +58,11 @@ export function SkipRow(props: SkipRowProps) {
6358
return (
6459
<tr ref={rowRef} className={'skip-row' + (isSelected ? ` selected` : '')}>
6560
<td colSpan={4} className="skip code">
66-
<span className="arrows-left">{arrows}</span>
67-
{showMore} {headerHTML}
68-
<span className="arrows-right">{arrows}</span>
61+
{arrows}
62+
<a href="#" onClick={showAll} className="show-more">
63+
↕ Show {numRows} more lines
64+
</a>{' '}
65+
{headerHTML}
6966
</td>
7067
</tr>
7168
);

webdiff/static/codediff.js/codediff.css

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,53 @@ span.skip {
154154
-ms-user-select: text;
155155
user-select: text;
156156
}
157+
158+
a, a:visited {
159+
text-decoration: none;
160+
color: #00a;
161+
}
162+
163+
tr.skip-row {
164+
position: relative;
165+
line-height: 1.5em;
166+
}
167+
.skip.right {
168+
position: absolute;
169+
}
170+
.skip.right {
171+
right: 32px;
172+
}
173+
.skip.expand-up, .skip.expand-down {
174+
font-size: 12px;
175+
font-family: Inconsolata, Consolas, "Liberation Mono", Menlo, Courier, monospace;
176+
color: #aaa;
177+
background: #fff;
178+
border: 1px solid #e8e8e8;
179+
padding: 0px 5px;
180+
cursor: pointer;
181+
white-space: nowrap;
182+
display: inline-block;
183+
line-height: 1.3;
184+
letter-spacing: 0.04em;
185+
}
186+
.skip.expand-up:hover, .skip.expand-down:hover {
187+
background: #f5f5f5;
188+
color: #888;
189+
border-color: #ccc;
190+
}
191+
/* tab hangs down from the row above: no top border, rounded bottom corners */
192+
.skip.expand-up {
193+
top: 0;
194+
border-top: none;
195+
border-radius: 0 0 4px 4px;
196+
}
197+
/* tab sticks up from the row below: no bottom border, rounded top corners */
198+
.skip.expand-down {
199+
bottom: 0;
200+
border-bottom: none;
201+
border-radius: 4px 4px 0 0;
202+
}
203+
204+
a.show-more {
205+
color: #888;
206+
}

0 commit comments

Comments
 (0)