Skip to content

Commit 29c00eb

Browse files
Gustedlunnysilverwind
authored
Improve code comment review on mobile (#21461)
- Fix placement of avatar image, this was not placed in the `comment-header-left` and add CSS to cover the limiting of width+height of avatar for code-review comment on "Files changed" page. This fixes the big noticeable avatar issue. - Apply `margin-bottom` to the "next" button, so it's consistent with the "previous" button. - Make sure the "next"/"previous" start at `flex-start` on mobile and not off-screen at `flex-end`. As well force them to have `flex: 1` so they won't overflow on x-asis. This also requires the `width: 100%` for the `.ui.buttons` div. - Resolves #20074 ### Before <details><img width="512" src="https://user-images.githubusercontent.com/25481501/195952930-09560cad-419f-43a3-a8a4-a4166c117994.jpg"></details> ### After <details><img width="512" src="https://user-images.githubusercontent.com/25481501/197340081-0365dfa8-4344-46b4-8702-a40c778c073f.jpg"></details> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: silverwind <[email protected]>
1 parent 06a7ed4 commit 29c00eb

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

templates/repo/diff/conversation.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{{template "repo/diff/comments" dict "root" $ "comments" .comments}}
2727
</ui>
2828
</div>
29-
<div class="df je ac fw mt-3">
29+
<div class="df je js-small ac fw mt-3">
3030
<div class="ui buttons mr-2">
3131
<button class="ui icon tiny basic button previous-conversation">
3232
{{svg "octicon-arrow-up" 12 "icon"}} {{$.locale.Tr "repo.issues.previous"}}

templates/repo/diff/section_split.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<td class="lines-num"></td>
102102
<td class="lines-escape"></td>
103103
<td class="lines-type-marker"></td>
104-
<td class="add-comment-left">
104+
<td class="add-comment-left" colspan="4">
105105
{{if gt (len $line.Comments) 0}}
106106
{{if eq $line.GetCommentSide "previous"}}
107107
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
@@ -116,7 +116,7 @@
116116
<td class="lines-num"></td>
117117
<td class="lines-escape"></td>
118118
<td class="lines-type-marker"></td>
119-
<td class="add-comment-right">
119+
<td class="add-comment-right" colspan="4">
120120
{{if eq $line.GetCommentSide "proposed"}}
121121
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
122122
{{end}}
@@ -133,7 +133,7 @@
133133
<td class="lines-num"></td>
134134
<td class="lines-escape"></td>
135135
<td class="lines-type-marker"></td>
136-
<td class="add-comment-left">
136+
<td class="add-comment-left" colspan="4">
137137
{{if gt (len $line.Comments) 0}}
138138
{{if eq $line.GetCommentSide "previous"}}
139139
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
@@ -143,7 +143,7 @@
143143
<td class="lines-num"></td>
144144
<td class="lines-escape"></td>
145145
<td class="lines-type-marker"></td>
146-
<td class="add-comment-right">
146+
<td class="add-comment-right" colspan="4">
147147
{{if eq $line.GetCommentSide "proposed"}}
148148
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
149149
{{end}}

templates/repo/diff/section_unified.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{{if gt (len $line.Comments) 0}}
4747
<tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}">
4848
<td colspan="3" class="lines-num"></td>
49-
<td class="add-comment-left add-comment-right" colspan="2">
49+
<td class="add-comment-left add-comment-right" colspan="5">
5050
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
5151
</td>
5252
</tr>

web_src/js/features/repo-issue.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,16 @@ export function initRepoPullRequestReview() {
513513
<td class="lines-num"></td>
514514
<td class="lines-escape"></td>
515515
<td class="lines-type-marker"></td>
516-
<td class="add-comment-left"></td>
516+
<td class="add-comment-left" colspan="4"></td>
517517
<td class="lines-num"></td>
518518
<td class="lines-escape"></td>
519519
<td class="lines-type-marker"></td>
520-
<td class="add-comment-right"></td>
520+
<td class="add-comment-right" colspan="4"></td>
521521
` : `
522522
<td class="lines-num"></td>
523523
<td class="lines-num"></td>
524524
<td class="lines-escape"></td>
525-
<td class="add-comment-left add-comment-right" colspan="2"></td>
525+
<td class="add-comment-left add-comment-right" colspan="5"></td>
526526
`}
527527
</tr>`);
528528
tr.after(ntr);

web_src/less/_repository.less

+5-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,10 @@
11261126
.comment-content {
11271127
margin-left: 36px;
11281128
}
1129+
}
11291130

1131+
.code-comment,
1132+
.comment {
11301133
img.avatar {
11311134
width: 28px;
11321135
height: 28px;
@@ -3266,7 +3269,8 @@ td.blob-excerpt {
32663269
background: var(--color-diff-inactive);
32673270
}
32683271

3269-
.code-diff-split tbody tr td:nth-child(5) {
3272+
.code-diff-split tbody tr td:nth-child(5),
3273+
.code-diff-split tbody tr td.add-comment-right {
32703274
border-left: 1px solid var(--color-secondary);
32713275
}
32723276

web_src/less/_review.less

+29-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
}
4949
}
5050

51+
.add-comment .lines-num,
52+
.add-comment .lines-escape,
53+
.add-comment .lines-type-marker {
54+
display: none;
55+
}
56+
5157
.show-outdated,
5258
.hide-outdated {
5359
&:extend(.unselectable);
@@ -59,11 +65,13 @@
5965
}
6066

6167
.comment-code-cloud {
62-
padding: .5rem !important;
68+
padding: .5rem 1rem !important;
6369
position: relative;
6470
margin: 0 auto;
71+
max-width: 1000px;
6572

6673
@media @mediaSm {
74+
max-width: auto;
6775
padding: .75rem !important;
6876

6977
.code-comment-buttons {
@@ -73,13 +81,22 @@
7381
width: 100%;
7482
}
7583
}
84+
85+
.ui.buttons {
86+
width: 100%;
87+
margin: 0 !important;
88+
89+
.button {
90+
flex: 1;
91+
}
92+
}
7693
}
7794

7895
.comments .comment {
79-
margin: 0;
96+
padding: 0;
8097

8198
@media @mediaSm {
82-
padding: 0;
99+
display: flex;
83100

84101
.comment-header-right.actions .ui.basic.label {
85102
display: none;
@@ -90,6 +107,10 @@
90107
float: none;
91108
margin: 0 .5rem 0 0;
92109
flex-shrink: 0;
110+
111+
~ .content {
112+
margin-left: 1em;
113+
}
93114
}
94115

95116
img.avatar {
@@ -100,6 +121,10 @@
100121
margin-left: 0 !important;
101122
}
102123

124+
.comment-container {
125+
width: 100%;
126+
}
127+
103128
&.code-comment {
104129
padding: 0 0 .5rem !important;
105130
}
@@ -166,10 +191,7 @@
166191
.button {
167192
width: 100%;
168193
margin: 0 !important;
169-
170-
&:not(:last-child) {
171-
margin-bottom: .75rem !important;
172-
}
194+
margin-bottom: .75rem !important;
173195
}
174196
}
175197
}

web_src/less/helpers.less

+1
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,5 @@
175175
@media @mediaSm {
176176
.db-small { display: block !important; }
177177
.w-100-small { width: 100% !important; }
178+
.js-small { justify-content: flex-start !important; }
178179
}

0 commit comments

Comments
 (0)