Skip to content

Commit 483bab0

Browse files
committed
use data-toggled attribute and improve transition
1 parent 228eb7b commit 483bab0

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

templates/repo/pulls/status.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Template Attributes:
77
*/}}
88

99
{{if .CommitStatus}}
10-
<div class="{{if .IsPopup}}tippy-commit-status{{else}}pr-commit-status{{end}}">
10+
<div class="{{if .IsPopup}}tippy-commit-status{{else}}pr-commit-status{{end}}"{{if not .IsPopup}} data-toggled="true"{{end}}>
1111
<div class="ui attached header top">
1212
{{if eq .CommitStatus.State "pending"}}
1313
{{ctx.Locale.Tr "repo.pulls.status_checking"}}

web_src/css/repo.css

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,19 +3078,20 @@ tbody.commit-list {
30783078
padding: 0 !important;
30793079
max-height: 231px;
30803080
overflow-x: hidden;
3081-
transition: max-height 0.2s;
3082-
border-bottom: 0 !important;
3081+
transition: max-height .2s;
3082+
border-bottom: none !important;
30833083
}
30843084

3085-
.pr-commit-status.hide {
3086-
border-bottom: 0 !important;
3085+
.pr-commit-status[data-toggled="false"] {
3086+
border-bottom: none !important;
30873087
}
30883088

3089-
.pr-commit-status.hide .ui.attached.header {
3090-
border-bottom: none !important;
3089+
.pr-commit-status[data-toggled="false"] .ui.attached.header {
3090+
transition-delay: .2s;
3091+
border-bottom-width: 0 !important;
30913092
}
30923093

3093-
.pr-commit-status.hide .commit-status-list {
3094+
.pr-commit-status[data-toggled="false"] .commit-status-list {
30943095
max-height: 0;
30953096
}
30963097

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
export function initRepoPullRequestCommitStatus() {
22
const btn = document.querySelector('.hide-all-checks');
3-
const prCommitStatus = document.querySelector('.pr-commit-status');
43
if (!btn) return;
4+
55
btn.addEventListener('click', () => {
6-
if (prCommitStatus.classList.contains('hide')) {
7-
btn.textContent = btn.getAttribute('data-hide-all');
8-
} else {
9-
btn.textContent = btn.getAttribute('data-show-all');
10-
}
11-
prCommitStatus.classList.toggle('hide');
6+
const prCommitStatus = document.querySelector('.pr-commit-status');
7+
const toggled = prCommitStatus.getAttribute('data-toggled') === 'true';
8+
btn.textContent = btn.getAttribute(toggled ? 'data-hide-all' : 'data-show-all');
9+
prCommitStatus.setAttribute('data-toggled', String(!toggled));
1210
});
1311
}

0 commit comments

Comments
 (0)