Skip to content

Commit c6e2093

Browse files
authored
Clean up "file-view" related styles (#34558)
Move "file-view" and "code-view" related styles to their own file, remove unnecessary `!important`
1 parent 4cb0c64 commit c6e2093

File tree

6 files changed

+73
-77
lines changed

6 files changed

+73
-77
lines changed

web_src/css/base.css

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,6 @@ overflow-menu .ui.label {
815815
display: block;
816816
}
817817

818-
.code-view .lines-num span::after {
819-
cursor: pointer;
820-
}
821-
822818
.lines-type-marker {
823819
vertical-align: top;
824820
white-space: nowrap;
@@ -855,39 +851,13 @@ overflow-menu .ui.label {
855851
.lines-escape {
856852
width: 0;
857853
white-space: nowrap;
854+
padding: 0;
858855
}
859856

860857
.lines-code {
861858
padding-left: 5px;
862859
}
863860

864-
.file-view tr.active {
865-
color: inherit !important;
866-
background: inherit !important;
867-
}
868-
869-
.file-view tr.active .lines-num,
870-
.file-view tr.active .lines-code {
871-
background: var(--color-highlight-bg) !important;
872-
}
873-
874-
.file-view tr.active:last-of-type .lines-code {
875-
border-bottom-right-radius: var(--border-radius);
876-
}
877-
878-
.file-view tr.active .lines-num {
879-
position: relative;
880-
}
881-
882-
.file-view tr.active .lines-num::before {
883-
content: "";
884-
position: absolute;
885-
left: 0;
886-
width: 2px;
887-
height: 100%;
888-
background: var(--color-highlight-fg);
889-
}
890-
891861
.code-inner {
892862
font: 12px var(--fonts-monospace);
893863
white-space: pre-wrap;
@@ -938,28 +908,19 @@ overflow-menu .ui.label {
938908
margin-right: 4px;
939909
}
940910

941-
.top-line-blame {
911+
tr.top-line-blame {
942912
border-top: 1px solid var(--color-secondary);
943913
}
944914

945-
.code-view tr.top-line-blame:first-of-type {
946-
border-top: none;
915+
tr.top-line-blame:first-of-type {
916+
border-top: none; /* merge code lines belonging to the same commit into one block */
947917
}
948918

949919
.lines-code .bottom-line,
950920
.lines-commit .bottom-line {
951921
border-bottom: 1px solid var(--color-secondary);
952922
}
953923

954-
.code-view {
955-
background: var(--color-code-bg);
956-
border-radius: var(--border-radius);
957-
}
958-
959-
.code-view table {
960-
width: 100%;
961-
}
962-
963924
.migrate .svg.gitea-git {
964925
color: var(--color-git);
965926
}

web_src/css/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
@import "./repo/issue-label.css";
6363
@import "./repo/issue-list.css";
6464
@import "./repo/list-header.css";
65-
@import "./repo/linebutton.css";
65+
@import "./repo/file-view.css";
6666
@import "./repo/wiki.css";
6767
@import "./repo/header.css";
6868
@import "./repo/home.css";

web_src/css/markup/content.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,18 @@
309309
box-sizing: initial;
310310
}
311311

312+
.file-view.markup {
313+
padding: 1em 2em;
314+
}
315+
316+
.file-view.markup:has(.file-not-rendered-prompt) {
317+
padding: 0; /* let the file-not-rendered-prompt layout itself */
318+
}
319+
312320
/* this background ensures images can break <hr>. We can only do this on
313321
cases where the background is known and not transparent. */
314-
.markup.file-view img,
315-
.markup.file-view video,
322+
.file-view.markup img,
323+
.file-view.markup video,
316324
.comment-body .markup img, /* regular comment */
317325
.comment-body .markup video,
318326
.comment-content .markup img, /* code comment */

web_src/css/repo.css

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,21 +1238,6 @@ td .commit-summary {
12381238
white-space: nowrap;
12391239
}
12401240

1241-
.file-view.markup {
1242-
padding: 1em 2em;
1243-
}
1244-
1245-
.file-view.markup:has(.file-not-rendered-prompt) {
1246-
padding: 0; /* let the file-not-rendered-prompt layout itself */
1247-
}
1248-
1249-
.file-not-rendered-prompt {
1250-
padding: 1rem;
1251-
text-align: center;
1252-
font-size: 1rem !important; /* use consistent styles for various containers (code, markup, etc) */
1253-
line-height: var(--line-height-default) !important; /* same as above */
1254-
}
1255-
12561241
.repository .activity-header {
12571242
display: flex;
12581243
justify-content: space-between;

web_src/css/repo/file-view.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.file-view tr.active {
2+
background: var(--color-highlight-bg);
3+
}
4+
5+
.file-view tr.active:last-of-type .lines-code {
6+
border-bottom-right-radius: var(--border-radius);
7+
}
8+
9+
.file-view tr.active .lines-num {
10+
position: relative;
11+
}
12+
13+
.file-view tr.active .lines-num::before {
14+
content: "";
15+
position: absolute;
16+
left: 0;
17+
width: 2px;
18+
height: 100%;
19+
background: var(--color-highlight-fg);
20+
}
21+
22+
.file-view .file-not-rendered-prompt {
23+
padding: 1rem;
24+
text-align: center;
25+
font-size: 1rem !important; /* use consistent styles for various containers (code, markup, etc) */
26+
line-height: var(--line-height-default) !important; /* same as above */
27+
}
28+
29+
/* ".code-view" is always used with ".file-view", to show the code of a file */
30+
.file-view.code-view {
31+
background: var(--color-code-bg);
32+
border-radius: var(--border-radius);
33+
}
34+
35+
.file-view.code-view table {
36+
width: 100%;
37+
}
38+
39+
.file-view.code-view .lines-num span::after {
40+
cursor: pointer;
41+
}
42+
43+
.file-view.code-view .lines-num:hover {
44+
color: var(--color-text-dark);
45+
}
46+
47+
.file-view.code-view .ui.button.code-line-button {
48+
border: 1px solid var(--color-secondary);
49+
padding: 1px 4px;
50+
margin: 0;
51+
min-height: 0;
52+
position: absolute;
53+
left: 6px;
54+
}
55+
56+
.file-view.code-view .ui.button.code-line-button:hover {
57+
background: var(--color-secondary);
58+
}

web_src/css/repo/linebutton.css

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)