Skip to content

Commit c9aa906

Browse files
authored
Fix various UI problems (#34243)
Also fix #34242
1 parent eda6d65 commit c9aa906

File tree

12 files changed

+43
-59
lines changed

12 files changed

+43
-59
lines changed

templates/repo/diff/conversation.tmpl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
{{$referenceUrl := printf "%s#%s" $.Issue.Link $comment.HashTag}}
99
<div class="conversation-holder" data-path="{{$comment.TreePath}}" data-side="{{if lt $comment.Line 0}}left{{else}}right{{end}}" data-idx="{{$comment.UnsignedLine}}">
1010
{{if $resolved}}
11-
<div class="ui attached header resolved-placeholder tw-flex tw-items-center tw-justify-between">
12-
<div class="ui grey text tw-flex tw-items-center tw-flex-wrap tw-gap-1">
13-
{{svg "octicon-check" 16 "icon tw-mr-1"}}
11+
<div class="resolved-placeholder">
12+
<div class="flex-text-block tw-flex-wrap grey text">
13+
{{svg "octicon-check"}}
1414
<b>{{$resolveDoer.Name}}</b> {{ctx.Locale.Tr "repo.issues.review.resolved_by"}}
1515
{{if $invalid}}
1616
<!--
@@ -22,14 +22,12 @@
2222
</a>
2323
{{end}}
2424
</div>
25-
<div class="tw-flex tw-items-center tw-gap-2">
26-
<button id="show-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="ui tiny labeled button show-outdated tw-flex tw-items-center">
27-
{{svg "octicon-unfold" 16 "tw-mr-2"}}
28-
{{ctx.Locale.Tr "repo.issues.review.show_resolved"}}
25+
<div class="flex-text-block">
26+
<button id="show-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="btn tiny show-outdated">
27+
{{svg "octicon-unfold" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.issues.review.show_resolved"}}
2928
</button>
30-
<button id="hide-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="ui tiny labeled button hide-outdated tw-flex tw-items-center tw-hidden">
31-
{{svg "octicon-fold" 16 "tw-mr-2"}}
32-
{{ctx.Locale.Tr "repo.issues.review.hide_resolved"}}
29+
<button id="hide-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="btn tiny hide-outdated tw-hidden">
30+
{{svg "octicon-fold" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.issues.review.hide_resolved"}}
3331
</button>
3432
</div>
3533
</div>

templates/repo/issue/view_content/conversation.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
</div>
1818
<div>
1919
{{if or $invalid $resolved}}
20-
<button id="show-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="{{if not $resolved}}tw-hidden {{end}}ui compact labeled button show-outdated tw-flex tw-items-center">
20+
<button id="show-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="{{if not $resolved}}tw-hidden{{end}} btn tiny show-outdated">
2121
{{svg "octicon-unfold" 16 "tw-mr-2"}}
2222
{{if $resolved}}
2323
{{ctx.Locale.Tr "repo.issues.review.show_resolved"}}
2424
{{else}}
2525
{{ctx.Locale.Tr "repo.issues.review.show_outdated"}}
2626
{{end}}
2727
</button>
28-
<button id="hide-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="{{if $resolved}}tw-hidden {{end}}ui compact labeled button hide-outdated tw-flex tw-items-center">
28+
<button id="hide-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="{{if $resolved}}tw-hidden {{end}} btn tiny hide-outdated">
2929
{{svg "octicon-fold" 16 "tw-mr-2"}}
3030
{{if $resolved}}
3131
{{ctx.Locale.Tr "repo.issues.review.hide_resolved"}}

templates/repo/wiki/revision.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
{{template "repo/header" .}}
44
{{$title := .title}}
55
<div class="ui container">
6-
<div class="ui stackable grid">
7-
<div class="ui eight wide column">
8-
<div class="ui header">
9-
<a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.back_to_wiki"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}">{{if .revision}}<span>{{.revision}}</span> {{end}}{{svg "octicon-home"}}</a>
6+
<div class="ui dividing header flex-text-block tw-flex-wrap tw-justify-between">
7+
<div class="flex-text-block">
8+
<a class="ui basic button tw-px-3" title="{{ctx.Locale.Tr "repo.wiki.back_to_wiki"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}">{{svg "octicon-home"}}</a>
9+
<div class="tw-flex-1 gt-ellipsis">
1010
{{$title}}
11-
<div class="ui sub header tw-break-anywhere">
11+
<div class="ui sub header gt-ellipsis">
1212
{{$timeSince := DateUtils.TimeSince .Author.When}}
1313
{{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}}
1414
</div>
1515
</div>
1616
</div>
17-
<div class="ui eight wide column tw-text-right">
17+
<div>
1818
{{template "repo/clone_panel" .}}
1919
</div>
2020
</div>

templates/repo/wiki/view.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<div class="ui dividing header">
3434
<div class="flex-text-block tw-flex-wrap tw-justify-end">
3535
<div class="flex-text-block tw-flex-1 tw-min-w-[300px]">
36-
<a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.file_revision"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_revision" >{{if .CommitCount}}<span>{{.CommitCount}}</span> {{end}}{{svg "octicon-history"}}</a>
36+
<a class="ui basic button tw-px-3 tw-gap-3" title="{{ctx.Locale.Tr "repo.wiki.file_revision"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_revision" >{{if .CommitCount}}<span>{{.CommitCount}}</span> {{end}}{{svg "octicon-history"}}</a>
3737
<div class="tw-flex-1 gt-ellipsis">
3838
{{$title}}
3939
<div class="ui sub header gt-ellipsis">

web_src/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ progress::-moz-progress-bar {
224224
}
225225

226226
.unselectable,
227+
.btn,
227228
.button,
228229
.lines-num,
229230
.lines-commit,

web_src/css/markup/content.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -529,20 +529,6 @@
529529
margin: 0 0.25em;
530530
}
531531

532-
.file-revisions-btn {
533-
display: block;
534-
float: left;
535-
margin-bottom: 2px !important;
536-
padding: 11px !important;
537-
margin-right: 10px !important;
538-
}
539-
540-
.file-revisions-btn i {
541-
-webkit-touch-callout: none;
542-
-webkit-user-select: none;
543-
user-select: none;
544-
}
545-
546532
.markup-content-iframe {
547533
display: block;
548534
border: none;

web_src/css/modules/button.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ a.btn:hover {
352352
color: inherit;
353353
}
354354

355+
.btn.tiny {
356+
font-size: 12px;
357+
}
358+
359+
.btn.small {
360+
font-size: 13px;
361+
}
362+
355363
/* By default, Fomantic UI doesn't support "bordered" buttons group, but Gitea would like to use it.
356364
And the default buttons always have borders now (not the same as Fomantic UI's default buttons, see above).
357365
It needs some tricks to tweak the left/right borders with active state */

web_src/css/modules/tippy.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
}
9393

9494
.tippy-box[data-theme="menu"] .item:focus {
95+
background: var(--color-hover);
96+
}
97+
98+
.tippy-box[data-theme="menu"] .item.active {
9599
background: var(--color-active);
96100
}
97101

web_src/css/repo.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,12 +1784,12 @@ tbody.commit-list {
17841784
.resolved-placeholder {
17851785
display: flex;
17861786
align-items: center;
1787-
font-size: 14px !important;
1788-
padding: 8px !important;
1789-
font-weight: var(--font-weight-normal) !important;
1790-
border: 1px solid var(--color-secondary) !important;
1791-
border-radius: var(--border-radius) !important;
1792-
margin: 4px !important;
1787+
justify-content: space-between;
1788+
margin: 4px;
1789+
padding: 8px;
1790+
border: 1px solid var(--color-secondary);
1791+
border-radius: var(--border-radius);
1792+
background: var(--color-box-header);
17931793
}
17941794

17951795
.resolved-placeholder + .comment-code-cloud {

web_src/css/review.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
.show-outdated,
2-
.hide-outdated {
3-
-webkit-touch-callout: none;
4-
-webkit-user-select: none;
5-
user-select: none;
6-
margin-right: 0 !important;
7-
}
8-
91
.ui.button.add-code-comment {
102
padding: 2px;
113
position: absolute;
@@ -59,11 +51,6 @@
5951
margin-bottom: 0.5em;
6052
}
6153

62-
.show-outdated:hover,
63-
.hide-outdated:hover {
64-
text-decoration: underline;
65-
}
66-
6754
.comment-code-cloud {
6855
padding: 0.5rem 1rem !important;
6956
position: relative;

web_src/js/features/repo-code.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {svg} from '../svg.ts';
22
import {createTippy} from '../modules/tippy.ts';
3-
import {clippie} from 'clippie';
43
import {toAbsoluteUrl} from '../utils.ts';
54
import {addDelegatedEventListener} from '../utils/dom.ts';
65

@@ -43,7 +42,8 @@ function selectRange(range: string): Element {
4342
if (!copyPermalink) return;
4443
let link = copyPermalink.getAttribute('data-url');
4544
link = `${link.replace(/#L\d+$|#L\d+-L\d+$/, '')}#${anchor}`;
46-
copyPermalink.setAttribute('data-url', link);
45+
copyPermalink.setAttribute('data-clipboard-text', link);
46+
copyPermalink.setAttribute('data-clipboard-text-type', 'url');
4747
};
4848

4949
const rangeFields = range ? range.split('-') : [];
@@ -138,8 +138,4 @@ export function initRepoCodeView() {
138138
};
139139
onHashChange();
140140
window.addEventListener('hashchange', onHashChange);
141-
142-
addDelegatedEventListener(document, 'click', '.copy-line-permalink', (el) => {
143-
clippie(toAbsoluteUrl(el.getAttribute('data-url')));
144-
});
145141
}

web_src/js/utils/dom.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ export function querySingleVisibleElem<T extends HTMLElement>(parent: Element, s
360360
export function addDelegatedEventListener<T extends HTMLElement, E extends Event>(parent: Node, type: string, selector: string, listener: (elem: T, e: E) => Promisable<void>, options?: boolean | AddEventListenerOptions) {
361361
parent.addEventListener(type, (e: Event) => {
362362
const elem = (e.target as HTMLElement).closest(selector);
363-
if (!elem || !parent.contains(elem)) return;
363+
// It strictly checks "parent contains the target elem" to avoid side effects of selector running on outside the parent.
364+
// Keep in mind that the elem could have been removed from parent by other event handlers before this event handler is called.
365+
// For example: tippy popup item, the tippy popup could be hidden and removed from DOM before this.
366+
// It is caller's responsibility make sure the elem is still in parent's DOM when this event handler is called.
367+
if (!elem || (parent !== document && !parent.contains(elem))) return;
364368
listener(elem as T, e as E);
365369
}, options);
366370
}

0 commit comments

Comments
 (0)