Skip to content

Commit d03098f

Browse files
Bug fix/miscellaneous improvements (Azure#4206)
* Fix dotnet branding, add button for jumping to first active comment * Improve showdocumentation buttons * Make scrollbars independent between left and right review pane
1 parent 5754795 commit d03098f

File tree

6 files changed

+110
-52
lines changed

6 files changed

+110
-52
lines changed

src/dotnet/APIView/APIViewWeb/Client/css/site.scss

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,18 @@ input[type="search"]::-webkit-search-cancel-button {
192192
#review-left {
193193
max-width: none;
194194
min-width: 10px;
195+
height: auto;
196+
overflow: auto;
197+
max-height: 100vh;
195198
}
196199

197200
#review-right {
198201
max-width: 100%;
199202
min-width: 100px;
200-
overflow-x: auto;
203+
height: auto;
204+
overflow: auto;
201205
padding: 0px;
206+
max-height: 100vh
202207
}
203208
/*---------------------------------------------------------------------*/
204209

@@ -505,21 +510,6 @@ code {
505510
white-space: nowrap;
506511
}
507512

508-
.btn-group {
509-
.btn.active {
510-
border-radius: .25rem !important;
511-
}
512-
513-
.btn:not(.active) {
514-
transform: scaleY(0.9);
515-
}
516-
517-
.btn:hover {
518-
border-radius: .25rem !important;
519-
transform: scaleY(1);
520-
}
521-
}
522-
523513
.btn-primary {
524514
background-color: var(--link-color);
525515
}
@@ -817,7 +807,7 @@ code {
817807
.icon-comments {
818808
cursor: pointer;
819809
position: absolute;
820-
right: 30px;
810+
right: -25px;
821811
}
822812

823813
.icon-chevron-right {
@@ -885,6 +875,9 @@ code {
885875
background: url(/icons/swagger-original.svg) center center no-repeat;
886876
}
887877
/*---------------------------------------------------------------------*/
878+
.invisible {
879+
visibility: hidden;
880+
}
888881

889882
.info-text {
890883
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
@@ -922,36 +915,36 @@ code {
922915
user-select: none;
923916
}
924917

925-
.line-toggle-documentation-button:hover {
926-
transform: scale(1);
927-
}
928-
929918
.line-toggle-documentation-button {
930-
display: inline-block;
931-
width: 21px;
932-
height: 21px;
933-
line-height: 21px;
934-
color: #fff !important;
919+
display: block;
920+
width: 100%;
921+
height: 100%;
935922
text-align: center;
936-
text-indent: 0;
937923
cursor: pointer;
938-
background-color: #0366d6;
939-
border-radius: 3px;
940-
box-shadow: 0 1px 4px rgba(27, 31, 35, .15);
941-
transition: transform .1s ease-in-out;
942-
transform: scale(.8);
943924
user-select: none;
925+
position: relative;
926+
}
927+
928+
.line-toggle-documentation-button svg {
929+
top: 0px;
930+
left: 0px;
931+
}
932+
933+
.line-toggle-documentation-button i {
934+
position: absolute;
935+
top: 25%;
936+
left: 25%;
944937
}
945938

946939
.line-details-button-cell {
947940
width: 22px;
948941
height: 22px;
949942
min-width: 22px;
950943
min-height: 22px;
944+
padding: 0px;
951945
}
952946

953947
.line-details {
954-
border-right: 1px solid;
955948
border-right: 1px solid var(--border-color);
956949
background-color: var(--background-color);
957950
color: darkcyan;
@@ -972,7 +965,7 @@ code {
972965
vertical-align: middle;
973966
}
974967

975-
.line-details td i{
968+
.row-fold-caret i {
976969
position: relative;
977970
left: 6px;
978971
}

src/dotnet/APIView/APIViewWeb/Client/src/comments.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@
190190
highlightCurrentRow(inlineRow);
191191
});
192192

193+
$("#jump-to-first-comment").on("click", function () {
194+
var commentRows = $('.comment-row');
195+
var displayedCommentRows = getDisplayedCommentRows(commentRows, false, true);
196+
$(displayedCommentRows[0])[0].scrollIntoView();
197+
});
198+
193199
function highlightCurrentRow(rowElement: JQuery<HTMLElement> = $()) {
194200
if (location.hash.length < 1) return;
195201
var row = (rowElement.length > 0) ? rowElement : getCodeRow(location.hash.substring(1));
@@ -411,7 +417,7 @@
411417

412418
function ensureMessageIconInDOM() {
413419
if (!MessageIconAddedToDom) {
414-
$(".line-comment-button-cell").append(`<span class="icon icon-comments ` + INVISIBLE + `"><i class="far fa-comment-alt pt-1 pl-1"></i></span>`);
420+
$(".comment-icon-cell").append(`<span class="icon icon-comments ` + INVISIBLE + `"><i class="far fa-comment-alt pt-1 pl-1"></i></span>`);
415421
MessageIconAddedToDom = true;
416422
}
417423
}
@@ -420,9 +426,33 @@
420426
getCodeRow(id).find(SEL_COMMENT_ICON).toggleClass(INVISIBLE, !show);
421427
}
422428

429+
function getDisplayedCommentRows(commentRows: JQuery<HTMLElement>, clearCommentAnchors = false, returnFirst = false) {
430+
var displayedCommentRows: JQuery<HTMLElement>[] = [];
431+
commentRows.each(function (index) {
432+
if (clearCommentAnchors) {
433+
$(this).find('.comment-thread-anchor').removeAttr("id");
434+
$(this).find('.comment-navigation-buttons').empty();
435+
}
436+
437+
if ($(this).hasClass("d-none")) {
438+
return;
439+
}
440+
441+
let commentHolder = $(this).find(".comment-holder").first();
442+
if (commentHolder.hasClass("comments-resolved") && commentHolder.css("display") != "block") {
443+
return;
444+
}
445+
displayedCommentRows.push($(this));
446+
if (returnFirst) {
447+
return false;
448+
}
449+
});
450+
return displayedCommentRows
451+
}
452+
423453
function addCommentThreadNavigation(){
424454
var commentRows = $('.comment-row');
425-
var displayedCommentRows: JQuery<HTMLElement>[] = [];
455+
var displayedCommentRows = getDisplayedCommentRows(commentRows, true, false);
426456

427457
commentRows.each(function (index) {
428458
$(this).find('.comment-thread-anchor').removeAttr("id");

src/dotnet/APIView/APIViewWeb/Client/src/review.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,17 @@ $(() => {
297297
if((e.target as HTMLInputElement).checked) {
298298
// show all documentation
299299
$(".code-line-documentation").removeClass('hidden-row');
300-
$(TOGGLE_DOCUMENTATION).removeClass("icon-chevron-right");
301-
$(TOGGLE_DOCUMENTATION).addClass("icon-chevron-up");
300+
$(TOGGLE_DOCUMENTATION).children('i').removeClass("fa-square-plus");
301+
$(TOGGLE_DOCUMENTATION).children('i').addClass("fa-square-minus");
302+
$(TOGGLE_DOCUMENTATION).children('i').css("color", "darkorange");
303+
$(TOGGLE_DOCUMENTATION).children('svg').removeClass("invisible");
302304
} else {
303305
// hide all documentation
304306
$(".code-line-documentation").addClass("hidden-row");
305-
$(TOGGLE_DOCUMENTATION).removeClass("icon-chevron-up");
306-
$(TOGGLE_DOCUMENTATION).addClass("icon-chevron-right");
307+
$(TOGGLE_DOCUMENTATION).children('i').removeClass("fa-square-minus");
308+
$(TOGGLE_DOCUMENTATION).children('i').addClass("fa-square-plus");
309+
$(TOGGLE_DOCUMENTATION).children('i').css("color", "darkcyan");
310+
$(TOGGLE_DOCUMENTATION).children('svg').addClass("invisible");
307311
}
308312
});
309313

@@ -353,8 +357,16 @@ $(() => {
353357
$(codeLines[documentedBy[i] - 1]).toggleClass("hidden-row");
354358
}
355359

356-
$(this).toggleClass('icon-chevron-right');
357-
$(this).toggleClass('icon-chevron-up');
360+
$(this).children('i').toggleClass('fa-square-minus');
361+
$(this).children('i').toggleClass('fa-square-plus');
362+
if ($(this).children('i').hasClass('fa-square-plus')) {
363+
$(this).children('i').css("color", "darkcyan");
364+
$(this).children('svg').addClass("invisible");
365+
}
366+
else {
367+
$(this).children('i').css("color", "darkorange");
368+
$(this).children('svg').removeClass("invisible");
369+
}
358370

359371
// scroll button to center of screen, so that the line is visible after toggling folding
360372
$(this).get(0).scrollIntoView({ block: "center"});

src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@
5050
@{
5151
var popOverContent = $"<b>{Model.ActiveConversations}</b> active revision threads.<br><b>{Model.TotalActiveConversations}</b> total active threads.<br>"
5252
+ $"<b>Current Revision:</b> <em>{@Model.Revision.DisplayName}</em>";
53-
@if (Model.DiffRevisionId != null)
53+
@if (Model.DiffRevisionId != null)
5454
{
5555
popOverContent += $"<br><b>Current Diff:</b> <em>{@Model.DiffRevision?.DisplayName}</em>";
5656
}
57-
<button type="button" class="btn btn-info btn-sm shadow-sm" data-placement="bottom" data-trigger="focus" data-toggle="popover" data-html="true" data-title="Page Info" data-content="@popOverContent">
58-
<i class="far fa-comment-alt mr-2"></i><span class="badge badge-light">@Model.ActiveConversations / @Model.TotalActiveConversations</span>
59-
</button>
57+
<div class="btn-group btn-group-sm shadow-sm" aria-label="Page Information">
58+
<button type="button" class="btn btn-info" id="jump-to-first-comment">
59+
<i class="far fa-comment-alt"></i>
60+
</button>
61+
<button type="button" class="btn btn-info" data-placement="bottom" data-trigger="focus" data-toggle="popover" data-html="true" data-title="Page Info" data-content="@popOverContent">
62+
<span class="badge badge-light">@Model.ActiveConversations / @Model.TotalActiveConversations</span>
63+
</button>
64+
</div>
6065
}
6166
</div>
6267
<div class="my-1">

src/dotnet/APIView/APIViewWeb/Pages/Assemblies/_CodeLine.cshtml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,22 @@
7171
<td class="line-details">
7272
<table>
7373
<tr>
74-
@if(userPreference.HideLineNumbers == true || Model.CodeLine.IsDocumentation)
74+
@if(userPreference.HideLineNumbers == true)
7575
{
7676
var lineNumberClass = RemoveMultipleSpaces($"line-number d-none {lineClass}");
7777
<td class="@lineNumberClass"><span>@Model.LineNumber</span></td>
7878
}
7979
else
8080
{
8181
var lineNumberClass = RemoveMultipleSpaces($"line-number {lineClass}");
82-
<td class="@lineNumberClass"><span>@Model.LineNumber</span></td>
82+
if (Model.CodeLine.IsDocumentation)
83+
{
84+
<td class="@lineNumberClass invisible"><span></span></td>
85+
}
86+
else
87+
{
88+
<td class="@lineNumberClass"><span>@Model.LineNumber</span></td>
89+
}
8390
}
8491
<td class="@lineDetailsClass comment-icon-cell">
8592
@if (!isRemoved && Model.CodeLine.ElementId != null)
@@ -88,14 +95,25 @@
8895
}
8996
else
9097
{
91-
<a class="line-comment-button" style="visibility: hidden;">+</a> // Added for visual consistency
98+
<a class="line-comment-button invisible">+</a>// Added for visual consistency
9299
}
93100
</td>
94101
<td class="@lineDetailsClass">
95102
@if(Model.DocumentedByLines?.Length > 0)
96103
{
97-
<span class="line-toggle-documentation-button icon-chevron-right" data-documented-by="[@String.Join(",",Model.DocumentedByLines)]">
98-
&nbsp;
104+
<span class="line-toggle-documentation-button" data-documented-by="[@String.Join(",",Model.DocumentedByLines)]">
105+
<svg height='23' width='23' class="invisible">
106+
<line x1='52%' y1='0' x2='52%' y2='30%' style='stroke:rgb(255,140,0);stroke-width:1.2' />
107+
</svg>
108+
<i class="fa-regular fa-square-plus"></i>
109+
</span>
110+
}
111+
@if (Model.CodeLine.IsDocumentation)
112+
{
113+
<span>
114+
<svg height='23' width='23'>
115+
<line x1='52%' y1='0' x2='52%' y2='100%' style='stroke:rgb(255,140,0);stroke-width:1.2' />
116+
</svg>
99117
</span>
100118
}
101119
</td>

src/dotnet/APIView/APIViewWeb/Pages/Shared/_CommentThreadInnerPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343
<li><h4 class="dropdown-header">Create GitHub Issue</h4></li>
4444
<div class="px-4">
45-
<a href="#" class="badge badge-light js-github" data-repo="azure-sdk-for-net" data-repo-language="c#">.Net</a>
45+
<a href="#" class="badge badge-light js-github" data-repo="azure-sdk-for-net" data-repo-language="c#">.NET</a>
4646
<a href="#" class="badge badge-light js-github" data-repo="azure-sdk-for-java" data-repo-language="java">Java</a>
4747
<a href="#" class="badge badge-light js-github" data-repo="azure-sdk-for-python" data-repo-language="python">Python</a>
4848
<a href="#" class="badge badge-light js-github" data-repo="azure-sdk-for-c" data-repo-language="c">C</a>

0 commit comments

Comments
 (0)