Skip to content

Commit a5e07da

Browse files
mkuhlmannlunny
authored andcommitted
Fix diff split view coloring (#553) (#584)
Signed-off-by: Manuel Kuhlmann <manuel@mkuhlmann.org>
1 parent c5f0d4b commit a5e07da

File tree

3 files changed

+48
-45
lines changed

3 files changed

+48
-45
lines changed

Diff for: public/css/index.css

+18-16
Original file line numberDiff line numberDiff line change
@@ -1982,32 +1982,34 @@ footer .ui.language .menu {
19821982
border-right: 1px solid #d4d4d5;
19831983
padding: 0 5px;
19841984
}
1985+
.repository .diff-file-box .code-diff tbody tr td.halfwidth {
1986+
width: 50%;
1987+
}
19851988
.repository .diff-file-box .code-diff tbody tr.tag-code td,
1986-
.repository .diff-file-box .code-diff tbody tr.tag-code pre {
1989+
.repository .diff-file-box .code-diff tbody tr td.tag-code {
19871990
background-color: #F0F0F0 !important;
1988-
border-color: #D2CECE!important;
1989-
padding-top: 4px;
1990-
padding-bottom: 4px;
1991+
border-color: #D2CECE !important;
1992+
padding-top: 8px;
1993+
padding-bottom: 8px;
19911994
}
1992-
.repository .diff-file-box .code-diff tbody tr.tag-code td.halfwidth {
1993-
width: 50%;
1995+
.repository .diff-file-box .code-diff tbody tr.add-code td:nth-child(1),
1996+
.repository .diff-file-box .code-diff tbody tr.add-code td:nth-child(2),
1997+
.repository .diff-file-box .code-diff tbody tr.del-code td:nth-child(3),
1998+
.repository .diff-file-box .code-diff tbody tr.del-code td:nth-child(4) {
1999+
background-color: #fafafa;
19942000
}
1995-
.repository .diff-file-box .code-diff tbody tr.del-code td,
1996-
.repository .diff-file-box .code-diff tbody tr.del-code pre {
2001+
.repository .diff-file-box .code-diff tbody tr.del-code td:nth-child(1),
2002+
.repository .diff-file-box .code-diff tbody tr.del-code td:nth-child(2),
2003+
.repository .diff-file-box .code-diff tbody tr td.del-code {
19972004
background-color: #ffe0e0 !important;
19982005
border-color: #f1c0c0 !important;
19992006
}
2000-
.repository .diff-file-box .code-diff tbody tr.del-code td.halfwidth {
2001-
width: 50%;
2002-
}
2003-
.repository .diff-file-box .code-diff tbody tr.add-code td,
2004-
.repository .diff-file-box .code-diff tbody tr.add-code pre {
2007+
.repository .diff-file-box .code-diff tbody tr.add-code td:nth-child(3),
2008+
.repository .diff-file-box .code-diff tbody tr.add-code td:nth-child(4),
2009+
.repository .diff-file-box .code-diff tbody tr td.add-code {
20052010
background-color: #d6fcd6 !important;
20062011
border-color: #c1e9c1 !important;
20072012
}
2008-
.repository .diff-file-box .code-diff tbody tr.add-code td.halfwidth {
2009-
width: 50%;
2010-
}
20112013
.repository .diff-file-box .code-diff tbody tr .removed-code {
20122014
background-color: #ff9999;
20132015
}

Diff for: public/less/_repository.less

+24-26
Original file line numberDiff line numberDiff line change
@@ -902,44 +902,42 @@
902902
}
903903
tbody {
904904
tr {
905+
td.halfwidth {
906+
width: 50%;
907+
}
905908

906-
&.tag-code {
907-
td, pre {
908-
background-color: #F0F0F0 !important;
909-
border-color: #D2CECE!important;
910-
padding-top: 4px;
911-
padding-bottom: 4px;
912-
}
913-
td.halfwidth {
914-
width: 50%;
915-
}
909+
&.tag-code td, td.tag-code {
910+
background-color: #F0F0F0 !important;
911+
border-color: #D2CECE !important;
912+
padding-top: 8px;
913+
padding-bottom: 8px;
916914
// td.selected-line, td.selected-line pre {
917915
// background-color: #ffffdd !important;
918916
// }
919917
}
918+
920919
// &.same-code {
921920
// td.selected-line, td.selected-line pre {
922921
// background-color: #ffffdd !important;
923922
// }
924923
// }
925-
&.del-code {
926-
td, pre {
927-
background-color: #ffe0e0 !important;
928-
border-color: #f1c0c0 !important;
929-
}
930924

931-
td.halfwidth {
932-
width: 50%;
933-
}
925+
// light gray for empty lines before / after commit
926+
&.add-code td:nth-child(1), &.add-code td:nth-child(2),
927+
&.del-code td:nth-child(3), &.del-code td:nth-child(4) {
928+
background-color: #fafafa;
934929
}
935-
&.add-code {
936-
td, pre {
937-
background-color: #d6fcd6 !important;
938-
border-color: #c1e9c1 !important;
939-
}
940-
td.halfwidth {
941-
width: 50%;
942-
}
930+
931+
&.del-code td:nth-child(1), &.del-code td:nth-child(2),
932+
td.del-code {
933+
background-color: #ffe0e0 !important;
934+
border-color: #f1c0c0 !important;
935+
}
936+
937+
&.add-code td:nth-child(3), &.add-code td:nth-child(4),
938+
td.add-code{
939+
background-color: #d6fcd6 !important;
940+
border-color: #c1e9c1 !important;
943941
}
944942

945943
.removed-code {

Diff for: templates/repo/diff/box.tmpl

+6-3
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,19 @@
133133
{{if .IsSplitStyle}}
134134
<script>
135135
(function() {
136-
$('.add-code').each(function() {
136+
$('tr.add-code').each(function() {
137137
var prev = $(this).prev();
138138
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
139139
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
140140
prev = prev.prev();
141141
}
142-
prev.children().eq(3).html($(this).children().eq(3).html());
143142
prev.children().eq(2).html($(this).children().eq(2).html());
144-
prev.children().eq(3).addClass('add-code');
143+
prev.children().eq(3).html($(this).children().eq(3).html());
144+
145+
prev.children().eq(0).addClass('del-code');
146+
prev.children().eq(1).addClass('del-code');
145147
prev.children().eq(2).addClass('add-code');
148+
prev.children().eq(3).addClass('add-code');
146149
$(this).remove();
147150
}
148151
});

0 commit comments

Comments
 (0)