summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-11-02 23:49:02 +0900
committerGitHub <noreply@github.com>2023-11-02 14:49:02 +0000
commitdcb648ee71853073d54e8a6e107b764212ede58e (patch)
treec36b409ccd001f2dcbae5f60d7fda35661068a43 /web_src
parent0ba4ecc3bd8443f0d3a834530a44e0c1334554b7 (diff)
downloadgitea-dcb648ee71853073d54e8a6e107b764212ede58e.tar.gz
gitea-dcb648ee71853073d54e8a6e107b764212ede58e.zip
Add `Hide/Show all checks` button to commit status check (#26284)
Step one for a GitHub like commit status check ui: ![image](https://github.com/go-gitea/gitea/assets/18380374/22953b88-1f91-4d19-bc57-ad92d33fa11f) ![image](https://github.com/go-gitea/gitea/assets/18380374/78572a49-c9b0-472b-86a8-8293197e807b) ![image](https://github.com/go-gitea/gitea/assets/18380374/bc5c8d1c-2ab5-4b03-b8c6-20c34b86d856) Step two: ![image](https://github.com/go-gitea/gitea/assets/18380374/938b359e-8823-4192-b82d-55fa40b986fd) ![image](https://github.com/go-gitea/gitea/assets/18380374/2de5bb8f-40f5-462a-8d6d-bac13a32bc2a) The design now will list all commit status checks which takes too much space. This is a pre-improve for #26247 --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/css/modules/tippy.css57
-rw-r--r--web_src/css/repo.css38
-rw-r--r--web_src/js/features/repo-commit.js1
-rw-r--r--web_src/js/features/repo-issue-pr-status.js12
-rw-r--r--web_src/js/features/repo-legacy.js2
-rw-r--r--web_src/js/modules/tippy.js2
6 files changed, 73 insertions, 39 deletions
diff --git a/web_src/css/modules/tippy.css b/web_src/css/modules/tippy.css
index fe32597280..45feab7574 100644
--- a/web_src/css/modules/tippy.css
+++ b/web_src/css/modules/tippy.css
@@ -6,7 +6,7 @@
}
[data-tippy-root] {
- max-width: calc(100vw - 10px);
+ max-width: calc(100vw - 32px);
}
.tippy-box {
@@ -18,37 +18,59 @@
font-size: 1rem;
}
+.tippy-content {
+ position: relative;
+ padding: 1rem; /* if you need different padding, use different data-theme */
+ z-index: 1;
+}
+
+/* tooltip theme for text tooltips */
+
.tippy-box[data-theme="tooltip"] {
background-color: var(--color-tooltip-bg);
color: var(--color-tooltip-text);
border: none;
}
+.tippy-box[data-theme="tooltip"] .tippy-content {
+ padding: 0.5rem 1rem;
+}
+
+.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
+.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
+ fill: var(--color-tooltip-bg);
+}
+
+/* menu theme for .ui.menu */
+
.tippy-box[data-theme="menu"] {
background-color: var(--color-menu);
color: var(--color-text);
}
-.tippy-box[data-theme="form-fetch-error"] {
- border-color: var(--color-error-border);
- background-color: var(--color-error-bg);
- color: var(--color-error-text);
+.tippy-box[data-theme="menu"] .tippy-content {
+ padding: 0;
}
-.tippy-content {
- position: relative;
- padding: 1rem;
- z-index: 1;
+.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
+ fill: var(--color-menu);
}
-.tippy-box[data-theme="tooltip"] .tippy-content {
- padding: 0.5rem 1rem;
-}
+/* box-with-header theme to look like .ui.attached.segment. can contain .ui.attached.header */
-.tippy-box[data-theme="menu"] .tippy-content {
+.tippy-box[data-theme="box-with-header"] .tippy-content {
+ background: var(--color-box-body);
padding: 0;
}
+.tippy-box[data-theme="box-with-header"][data-placement^="top"] .tippy-svg-arrow-inner {
+ fill: var(--color-box-body);
+}
+
+.tippy-box[data-theme="box-with-header"][data-placement^="bottom"] .tippy-svg-arrow-inner {
+ fill: var(--color-box-header);
+}
+
.tippy-box[data-placement^="top"] > .tippy-svg-arrow {
bottom: 0;
}
@@ -107,12 +129,3 @@
.tippy-svg-arrow-inner {
fill: var(--color-body);
}
-
-.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
-.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
- fill: var(--color-tooltip-bg);
-}
-
-.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
- fill: var(--color-menu);
-}
diff --git a/web_src/css/repo.css b/web_src/css/repo.css
index b17917c246..e4995d4229 100644
--- a/web_src/css/repo.css
+++ b/web_src/css/repo.css
@@ -3074,43 +3074,49 @@ tbody.commit-list {
}
}
-.pr-status {
- padding: 0 !important; /* To clear fomantic's padding on .ui.segment elements */
- display: flex;
- align-items: center;
+.commit-status-header {
+ border: none !important; /* reset the default ".ui.attached.header" styles, to use the outer border */
+ margin: 0 !important;
}
-.pr-status .commit-status {
- margin: 1em;
- flex-shrink: 0;
+.commit-status-list {
+ max-height: 195px; /* fit exactly 4 items */
+ overflow-x: hidden;
+ transition: max-height .2s;
}
-.pr-status .status-context {
+.commit-status-item {
+ padding: 14px 10px !important;
display: flex;
- justify-content: space-between;
- width: 100%;
+ gap: 8px;
+ align-items: center;
+ border-top: 1px solid var(--color-secondary);
+}
+
+.commit-status-item .commit-status {
+ flex-shrink: 0;
}
-.pr-status .status-context > span {
- padding: 1em 0;
+.commit-status-item .status-context {
+ color: var(--color-text);
+ flex: 1;
}
-.pr-status .status-details {
+.commit-status-item .status-details {
display: flex;
- padding-right: 0.5em;
align-items: center;
justify-content: flex-end;
}
@media (max-width: 767.98px) {
- .pr-status .status-details {
+ .commit-status-item .status-details {
flex-direction: column;
align-items: flex-end;
justify-content: center;
}
}
-.pr-status .status-details > span {
+.commit-status-item .status-details > span {
padding-right: 0.5em; /* To match the alignment with the "required" label */
}
diff --git a/web_src/js/features/repo-commit.js b/web_src/js/features/repo-commit.js
index 7240bf398a..76b34d2077 100644
--- a/web_src/js/features/repo-commit.js
+++ b/web_src/js/features/repo-commit.js
@@ -66,6 +66,7 @@ export function initCommitStatuses() {
placement: top ? 'top-start' : 'bottom-start',
interactive: true,
role: 'dialog',
+ theme: 'box-with-header',
});
});
}
diff --git a/web_src/js/features/repo-issue-pr-status.js b/web_src/js/features/repo-issue-pr-status.js
new file mode 100644
index 0000000000..3010615706
--- /dev/null
+++ b/web_src/js/features/repo-issue-pr-status.js
@@ -0,0 +1,12 @@
+export function initRepoPullRequestCommitStatus() {
+ for (const btn of document.querySelectorAll('.commit-status-hide-checks')) {
+ const panel = btn.closest('.commit-status-panel');
+ const list = panel.querySelector('.commit-status-list');
+ btn.addEventListener('click', () => {
+ list.style.maxHeight = list.style.maxHeight ? '' : '0px'; // toggle
+ list.style.overflow = 'hidden'; // hide scrollbar when hiding
+ btn.textContent = btn.getAttribute(list.style.maxHeight ? 'data-show-all' : 'data-hide-all');
+ });
+ list.addEventListener('animationend', () => list.style.overflow = '');
+ }
+}
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index 0aacc6ee85..8b3b7b5c12 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -20,6 +20,7 @@ import {initCommentContent, initMarkupContent} from '../markup/content.js';
import {initCompReactionSelector} from './comp/ReactionSelector.js';
import {initRepoSettingBranches} from './repo-settings.js';
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.js';
+import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
import {hideElem, showElem} from '../utils/dom.js';
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
import {attachRefIssueContextPopup} from './contextpopup.js';
@@ -546,6 +547,7 @@ export function initRepository() {
initCompReactionSelector($(document));
initRepoPullRequestMergeForm();
+ initRepoPullRequestCommitStatus();
}
// Pull request
diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js
index ec7ee2141f..d27908962f 100644
--- a/web_src/js/modules/tippy.js
+++ b/web_src/js/modules/tippy.js
@@ -34,7 +34,7 @@ export function createTippy(target, opts = {}) {
},
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
- theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
+ theme: other.role || 'menu', // CSS theme, either "tooltip", "menu" or "box-with-header"
plugins: [followCursor],
...other,
});