Skip to content

Commit 61fb904

Browse files
committed
Various code view improvements
1 parent bc92478 commit 61fb904

File tree

7 files changed

+38
-22
lines changed

7 files changed

+38
-22
lines changed

web_src/css/base.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ a.ui.active.label:hover {
14201420
padding-left: 10px;
14211421
padding-right: 10px;
14221422
text-align: right !important;
1423-
color: var(--color-text-light-1);
1423+
color: var(--color-text-light-2);
14241424
width: 1%;
14251425
font-family: var(--fonts-monospace);
14261426
}
@@ -1478,8 +1478,8 @@ a.ui.active.label:hover {
14781478
padding-left: 5px;
14791479
}
14801480

1481-
.lines-code.active,
1482-
.lines-code .active {
1481+
.file-view tr.active,
1482+
.file-view tr.active .lines-code {
14831483
background: var(--color-active-line) !important;
14841484
}
14851485

web_src/css/modules/message.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,15 @@
100100
color: var(--color-warning-text);
101101
border-color: var(--color-warning-border);
102102
}
103+
104+
.ui.message > .close.icon {
105+
cursor: pointer;
106+
position: absolute;
107+
top: 9px;
108+
right: 9px;
109+
opacity: .7;
110+
}
111+
112+
.ui.message > .close.icon:hover {
113+
opacity: 1;
114+
}

web_src/css/repo.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,6 @@
16121612

16131613
.repository .diff-file-box .file-body.file-code .lines-num {
16141614
text-align: right;
1615-
color: var(--color-text-light);
16161615
width: 1%;
16171616
min-width: 50px;
16181617
}

web_src/css/repo/linebutton.css

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
}
44

55
.code-line-button {
6-
background-color: var(--color-menu);
7-
color: var(--color-text-light);
86
border: 1px solid var(--color-secondary);
97
border-radius: var(--border-radius);
10-
padding: 1px 10px;
8+
padding: 1px 4px !important;
119
position: absolute;
1210
font-family: var(--fonts-regular);
1311
left: 0;
14-
transform: translateX(-50%);
12+
transform: translateX(calc(-50% + 6px));
1513
cursor: pointer;
1614
}
1715

1816
.code-line-button:hover {
19-
color: var(--color-primary);
17+
background: var(--color-secondary) !important;
2018
}

web_src/css/themes/theme-gitea-dark.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
--color-body: #1c1f25;
184184
--color-box-header: #1a1d1f;
185185
--color-box-body: #14171a;
186-
--color-box-body-highlight: #121517;
186+
--color-box-body-highlight: #1c2227;
187187
--color-text-dark: #f8f8f9;
188188
--color-text: #d1d5d8;
189189
--color-text-light: #bdc3c7;
@@ -208,11 +208,11 @@
208208
--color-markup-table-row: #e8e8ff06;
209209
--color-markup-code-block: #e8e8ff16;
210210
--color-button: #151a1e;
211-
--color-code-bg: #191d20;
211+
--color-code-bg: #101315;
212212
--color-code-sidebar-bg: #1b1f22;
213213
--color-shadow: #00001758;
214-
--color-secondary-bg: #2f3135;
215-
--color-expand-button: #414348;
214+
--color-secondary-bg: #2f3138;
215+
--color-expand-button: #2b353e;
216216
--color-placeholder-text: var(--color-text-light-3);
217217
--color-editor-line-highlight: var(--color-primary-light-5);
218218
--color-project-board-bg: var(--color-secondary-light-2);
@@ -233,7 +233,7 @@
233233
--color-label-active-bg: #73828eff;
234234
--color-accent: var(--color-primary-light-1);
235235
--color-small-accent: var(--color-primary-light-5);
236-
--color-active-line: #534d1b;
236+
--color-active-line: #39301e;
237237
--color-overlay-backdrop: #080808c0;
238238
accent-color: var(--color-accent);
239239
color-scheme: dark;

web_src/css/themes/theme-gitea-light.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
--color-body: #ffffff;
184184
--color-box-header: #f1f3f5;
185185
--color-box-body: #ffffff;
186-
--color-box-body-highlight: #f4faff;
186+
--color-box-body-highlight: #ecf5fd;
187187
--color-text-dark: #01050a;
188188
--color-text: #181c21;
189189
--color-text-light: #30363b;
@@ -212,7 +212,7 @@
212212
--color-code-sidebar-bg: #f2f5f8;
213213
--color-shadow: #00001726;
214214
--color-secondary-bg: #f2f5f8;
215-
--color-expand-button: #d8efff;
215+
--color-expand-button: #cfe8fa;
216216
--color-placeholder-text: var(--color-text-light-3);
217217
--color-editor-line-highlight: var(--color-primary-light-6);
218218
--color-project-board-bg: var(--color-secondary-light-4);

web_src/js/features/repo-code.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function changeHash(hash) {
1717
}
1818

1919
function selectRange($list, $select, $from) {
20-
$list.removeClass('active');
20+
$list.closest('tr').removeClass('active');
2121

2222
// add hashchange to permalink
2323
const $refInNewIssue = $('a.ref-in-new-issue');
@@ -69,7 +69,9 @@ function selectRange($list, $select, $from) {
6969
for (let i = a; i <= b; i++) {
7070
classes.push(`[rel=L${i}]`);
7171
}
72-
$list.filter(classes.join(',')).addClass('active');
72+
$list.filter(classes.join(',')).each(function () {
73+
$(this).closest('tr').addClass('active');
74+
});
7375
changeHash(`#L${a}-L${b}`);
7476

7577
updateIssueHref(`L${a}-L${b}`);
@@ -78,7 +80,7 @@ function selectRange($list, $select, $from) {
7880
return;
7981
}
8082
}
81-
$select.addClass('active');
83+
$select.closest('tr').addClass('active');
8284
changeHash(`#${$select.attr('rel')}`);
8385

8486
updateIssueHref($select.attr('rel'));
@@ -96,10 +98,10 @@ function showLineButton() {
9698
}
9799

98100
// find active row and add button
99-
const tr = document.querySelector('.code-view td.lines-code.active').closest('tr');
101+
const tr = document.querySelector('.code-view tr.active .lines-code').closest('tr');
100102
const td = tr.querySelector('td');
101103
const btn = document.createElement('button');
102-
btn.classList.add('code-line-button');
104+
btn.classList.add('code-line-button', 'ui', 'basic', 'button');
103105
btn.innerHTML = svg('octicon-kebab-horizontal');
104106
td.prepend(btn);
105107

@@ -130,7 +132,12 @@ export function initRepoCodeView() {
130132
} else {
131133
$list = $('.code-view td.lines-code');
132134
}
133-
selectRange($list, $list.filter(`[rel=${$select.attr('id')}]`), (e.shiftKey ? $list.filter('.active').eq(0) : null));
135+
const $sel = $list.filter(`[rel=${$select.attr('id')}]`);
136+
let $from = null;
137+
if (e.shiftKey) {
138+
$from = $list.closest('tr').filter('.active').children('.lines-code').eq(0);
139+
}
140+
selectRange($list, $sel, $from);
134141

135142
if (window.getSelection) {
136143
window.getSelection().removeAllRanges();

0 commit comments

Comments
 (0)