aboutsummaryrefslogtreecommitdiff
path: root/web_src
diff options
context:
space:
mode:
authorwxiaoguang2023-02-21 21:36:53 +0800
committerGitHub2023-02-21 21:36:53 +0800
commit1fcf96ad0166420cbdb013365ecae42e3537b42a (patch)
tree98ffceb52a082da7985f97dee42462a1805898f3 /web_src
parent9ebf6424eedce94b1f5ab3ff34b41198e51e36f8 (diff)
Improve PR Review Box UI (#22986)
This PR follows: * #22950 ### Before The Review Box has many problems: * It doesn't work for small screens. * It has an anonying animation which makes the UI laggy. * It uses "custom dropdown menu" which is very difficult to fine tune. * `$().toggle('visible')` is not a correct call * jQuery just accepts any invalid `duration` argument: `$().toggle('anyting')` * The button is not a button. <details> ![image](https://user-images.githubusercontent.com/2114189/219948865-6da3f39c-6fde-4c86-9e42-da5020f3d0c3.png) </details> ### After These problems are fixed, and eliminate many `!important` games. <details> ![image](https://user-images.githubusercontent.com/2114189/219952744-8862fe1a-7ef1-49e4-bf92-2d0c1f104ee4.png) ![image](https://user-images.githubusercontent.com/2114189/219952771-be169a76-45fd-47a8-8f9c-b447d064f4ca.png) ![image](https://user-images.githubusercontent.com/2114189/219952784-3f52e9b7-64ce-4ad1-9553-64c33fb83042.png) </details> And most dropdown icons still looks good: <details> ![image](https://user-images.githubusercontent.com/2114189/219952942-52866a00-e0f9-4af7-8fb5-eb1a8cad1ff3.png) ![image](https://user-images.githubusercontent.com/2114189/219948909-b3bfb844-f84e-4b79-ab1f-382ec66dec31.png) </details> Co-authored-by: delvh <leon@kske.dev>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/common-global.js1
-rw-r--r--web_src/js/features/repo-issue.js10
-rw-r--r--web_src/less/_base.less21
-rw-r--r--web_src/less/_editor.less2
-rw-r--r--web_src/less/_repository.less5
-rw-r--r--web_src/less/_review.less32
6 files changed, 27 insertions, 44 deletions
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index 57a429ed9..4fa694246 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -60,6 +60,7 @@ export function initGlobalEnterQuickSubmit() {
export function initGlobalButtonClickOnEnter() {
$(document).on('keypress', '.ui.button', (e) => {
if (e.keyCode === 13 || e.keyCode === 32) { // enter key or space bar
+ if (e.target.nodeName === 'BUTTON') return; // button already handles space&enter correctly
$(e.target).trigger('click');
e.preventDefault();
}
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 7b8705ad2..4fc8bb5e6 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -470,7 +470,7 @@ export function initRepoPullRequestReview() {
assignMenuAttributes(form.find('.menu'));
});
- const $reviewBox = $('.review-box');
+ const $reviewBox = $('.review-box-panel');
if ($reviewBox.length === 1) {
(async () => {
// the editor's height is too large in some cases, and the panel cannot be scrolled with page now because there is `.repository .diff-detail-box.sticky { position: sticky; }`
@@ -487,12 +487,12 @@ export function initRepoPullRequestReview() {
return;
}
- $('.btn-review').on('click', function (e) {
+ $('.js-btn-review').on('click', function (e) {
e.preventDefault();
- $(this).closest('.dropdown').find('.menu').toggle('visible'); // eslint-disable-line
- }).closest('.dropdown').find('.close').on('click', function (e) {
+ toggleElem($(this).parent().find('.review-box-panel'));
+ }).parent().find('.review-box-panel .close').on('click', function (e) {
e.preventDefault();
- $(this).closest('.menu').toggle('visible'); // eslint-disable-line
+ hideElem($(this).closest('.review-box-panel'));
});
$(document).on('click', 'a.add-code-comment', async function (e) {
diff --git a/web_src/less/_base.less b/web_src/less/_base.less
index fc04df4f9..42b18ed1e 100644
--- a/web_src/less/_base.less
+++ b/web_src/less/_base.less
@@ -2476,24 +2476,13 @@ table th[data-sortt-desc] {
}
}
-/* fix up SVG dropdown triangles because fomantic thinks they are icon fonts */
-/* see https://github.com/go-gitea/gitea/issues/14014 */
-.ui.dropdown > .dropdown.icon,
-.btn-review > .dropdown.icon {
- height: auto !important;
- margin-left: .5rem !important;
- margin-top: -1px !important;
- margin-bottom: -1px !important;
- margin-right: -.5rem !important;
+.ui.dropdown .svg.dropdown.icon,
+.svg.dropdown.icon {
+ margin-top: 0 !important; // reset the "ui.selection.dropdown > .dropdown.icon {margin-top}", for the Issue Dependencies dropdown
+ margin-right: -.5rem !important; // fix up SVG dropdown triangles because Fomantic thinks they are icon fonts
+ height: auto; // reset the ".ui.dropdown > .dropdown.icon {height}", otherwise the icon would be too small
}
-.ui.button.dropdown > .dropdown.icon,
-.btn-review > .dropdown.icon {
- float: right !important;
- @media (max-width: 480px) {
- display: none;
- }
-}
.ui.selection.dropdown > .search.icon,
.ui.selection.dropdown > .delete.icon,
.ui.selection.dropdown > .dropdown.icon {
diff --git a/web_src/less/_editor.less b/web_src/less/_editor.less
index 73e5bda0a..d3f9edeb2 100644
--- a/web_src/less/_editor.less
+++ b/web_src/less/_editor.less
@@ -13,7 +13,7 @@
}
.editor-toolbar {
- opacity: 1 !important;
+ max-width: calc(100vw - 80px);
border-color: var(--color-secondary);
}
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less
index 3bec5f58f..627a5f6c2 100644
--- a/web_src/less/_repository.less
+++ b/web_src/less/_repository.less
@@ -2864,11 +2864,6 @@
margin-top: 10px;
}
-.repo-button-row .dropdown > .dropdown.icon {
- margin-left: .25rem !important;
- margin-right: 0 !important;
-}
-
.wiki .repo-button-row {
margin-bottom: 0;
}
diff --git a/web_src/less/_review.less b/web_src/less/_review.less
index d436bc249..54392151a 100644
--- a/web_src/less/_review.less
+++ b/web_src/less/_review.less
@@ -220,47 +220,45 @@ a.blob-excerpt:hover {
// See the comment of createCommentEasyMDE() for the review editor
// EasyMDE's options can not handle minHeight & maxHeight together correctly, we have to set minHeight in JS code
-#review-box .CodeMirror-scroll {
+.review-box-panel .CodeMirror-scroll {
min-height: 80px;
max-height: calc(100vh - 360px);
}
@media @mediaSm {
- #review-box > .menu {
- > .ui.segment {
- width: 94vw;
- }
-
- .editor-toolbar {
- overflow-x: auto;
- }
- }
-
- #review-box .CodeMirror-scroll {
+ .review-box-panel .CodeMirror-scroll {
max-width: calc(100vw - 70px);
}
}
@media @mediaMd {
- #review-box .CodeMirror-scroll {
+ .review-box-panel .CodeMirror-scroll {
max-width: 700px;
}
}
@media @mediaLg {
- #review-box .CodeMirror-scroll {
+ .review-box-panel .CodeMirror-scroll {
max-width: 800px;
}
}
@media @mediaXl {
- #review-box .CodeMirror-scroll {
+ .review-box-panel .CodeMirror-scroll {
max-width: 900px;
}
}
-.review-box > .segment {
- border: none !important;
+#review-box {
+ position: relative;
+}
+
+.review-box-panel {
+ position: absolute;
+ min-width: max-content;
+ top: 45px;
+ right: -5px;
+ z-index: 2;
}
#review-box .review-comments-counter {