Skip to content

Commit 51cfe0e

Browse files
authored
Remove CSS has selector and improve various styles (#26891)
Replace #26850 Major changes: 1. Remove all `has` selectors, it is still not supported by firefox. Actually there could be some more general and clearer approaches 2. Remove `two-toggle-buttons`, the `.ui.buttons` just works well 3. Rewrite the `.ui.buttons` border styles, see the screenshots 4. Remove the "fine-tuning" paddings from the the flex children, they could layout themselves well. ![image](https://github.com/go-gitea/gitea/assets/2114189/a32ed6f3-60f7-43d5-9492-62c45d2397f6) ![image](https://github.com/go-gitea/gitea/assets/2114189/5cb173c5-c942-4237-8cb4-2697220b3f06) ![image](https://github.com/go-gitea/gitea/assets/2114189/8a1c12b3-a632-48ff-b1a7-a01a4417f821) ![image](https://github.com/go-gitea/gitea/assets/2114189/46bde1bd-9113-4231-965d-6ec9076f6a3b)
1 parent a38cf86 commit 51cfe0e

File tree

5 files changed

+38
-39
lines changed

5 files changed

+38
-39
lines changed

templates/devtest/gitea-ui.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@
7979
</div>
8080
</div>
8181

82+
<div>
83+
<h1>Buttons</h1>
84+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button">2</button><button class="ui button">3</button></div>
85+
<div class="ui buttons"><button class="ui button active">1</button><button class="ui button">2</button><button class="ui button">3</button></div>
86+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button active">2</button><button class="ui button">3</button></div>
87+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button">2</button><button class="ui button active">3</button></div>
88+
</div>
89+
8290
<div>
8391
<h1>Tooltip</h1>
8492
<div><span data-tooltip-content="test tooltip">text with tooltip</span></div>

templates/repo/view_file.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121
<div class="file-header-right file-actions gt-df gt-ac gt-fw">
2222
{{if .HasSourceRenderedToggle}}
23-
<div class="ui compact icon buttons two-toggle-buttons">
23+
<div class="ui compact icon buttons">
2424
<a href="{{$.Link}}?display=source" class="ui mini basic button {{if .IsDisplayingSource}}active{{end}}" data-tooltip-content="{{.locale.Tr "repo.file_view_source"}}">{{svg "octicon-code" 15}}</a>
2525
<a href="{{$.Link}}" class="ui mini basic button {{if .IsDisplayingRendered}}active{{end}}" data-tooltip-content="{{.locale.Tr "repo.file_view_rendered"}}">{{svg "octicon-file" 15}}</a>
2626
</div>

web_src/css/base.css

+10-14
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,10 @@ a.label,
485485
border-color: var(--color-primary);
486486
}
487487

488-
.ui.action.input .button {
488+
.ui.action.input .ui.ui.button {
489489
border-color: var(--color-input-border);
490+
padding-top: 0; /* the ".action.input" is "flex + stretch", so let the buttons layout themselves */
491+
padding-bottom: 0;
490492
}
491493

492494
/* currently used for search bar dropdowns in repo search and explore code */
@@ -2015,25 +2017,19 @@ a.ui.basic.label:hover {
20152017
border-color: var(--color-secondary);
20162018
}
20172019

2018-
.ui.attached.header .right .button {
2019-
padding: 8px 10px;
2020-
font-weight: var(--font-weight-normal);
2021-
}
2022-
2023-
/* reduce height of buttons with dropdown icon */
2024-
.ui.attached.header .right .button:has(.dropdown.icon) {
2025-
padding-top: 7px;
2026-
padding-bottom: 7px;
2027-
}
2028-
20292020
/* fix misaligned right buttons on box headers */
2030-
.ui.attached.header .right:not(.dropdown) {
2021+
.ui.attached.header > .ui.right {
20312022
position: absolute;
20322023
right: 0.78571429rem;
20332024
top: 0;
20342025
bottom: 0;
20352026
display: flex;
2036-
align-items: center;
2027+
}
2028+
2029+
.ui.attached.header > .ui.right > .button,
2030+
.ui.attached.header > .ui.right > .dropdown > .button {
2031+
padding: 8px 10px;
2032+
font-weight: var(--font-weight-normal);
20372033
}
20382034

20392035
/* if a .top.attached.header is followed by a .segment, add some margin */

web_src/css/modules/button.css

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* this contains override styles for buttons and related elements */
22

3+
/* these styles changed the Fomantic UI's rules, Fomantic UI expects only "basic" buttons have borders */
34
.ui.button,
45
.ui.button:focus {
56
background: var(--color-button);
@@ -52,26 +53,29 @@ a.btn:hover {
5253
color: inherit;
5354
}
5455

55-
/* other button styles */
56+
/* By default, Fomantic UI doesn't support "bordered" buttons group, but Gitea would like to use it.
57+
And the default buttons always have borders now (not the same as Fomantic UI's default buttons, see above).
58+
It needs some tricks to tweak the left/right borders with active state */
5659

57-
.ui.buttons .button:first-child {
58-
border-left: 1px solid var(--color-light-border);
60+
.ui.buttons .button {
61+
border-right: none;
5962
}
6063

61-
.ui.buttons .button:first-child:has(+ .button.active) {
62-
border-right: none !important;
64+
.ui.buttons .button:first-child {
65+
border-left: 1px solid var(--color-light-border);
6366
}
6467

65-
.ui.buttons .button + .button:not(.active) {
66-
border-left: none;
68+
.ui.buttons .button:last-child {
69+
border-right: 1px solid var(--color-light-border);
6770
}
6871

69-
.two-toggle-buttons .button:not(.active):first-of-type {
70-
border-right: none;
72+
.ui.buttons .button.active {
73+
border-left: 1px solid var(--color-light-border);
74+
border-right: 1px solid var(--color-light-border);
7175
}
7276

73-
.two-toggle-buttons .button.active:last-of-type {
74-
border-left: 1px solid var(--color-light-border);
77+
.ui.buttons .button.active + .button {
78+
border-left: none;
7579
}
7680

7781
.ui.labeled.button.disabled > .button,

web_src/css/repo.css

+4-13
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@
437437
justify-content: center;
438438
}
439439

440-
.pdf-content:has(.pdf-fallback-button) {
441-
height: 100px;
440+
.pdf-content .pdf-fallback-button {
441+
margin: 50px auto;
442442
}
443443

444444
.repository.file.list .non-diff-file-content .plain-text {
@@ -1054,11 +1054,6 @@
10541054
margin: 0;
10551055
}
10561056

1057-
/* fix fomantic's border-radius via :first-child with hidden elements */
1058-
.collapsible-comment-box:has(.gt-hidden) {
1059-
border-radius: var(--border-radius) !important;
1060-
}
1061-
10621057
.repository.view.issue .comment-list .code-comment .comment-header {
10631058
background: transparent;
10641059
border-bottom: 0 !important;
@@ -1637,14 +1632,10 @@
16371632
}
16381633

16391634
.repository .diff-box .header:not(.resolved-placeholder) .button {
1640-
padding: 8px 12px;
1635+
padding: 0 12px;
16411636
flex: 0 0 auto;
16421637
margin-right: 0;
1643-
}
1644-
1645-
.repository .diff-box .header:not(.resolved-placeholder) .button:has(svg) {
1646-
padding-top: 6px;
1647-
padding-bottom: 6px;
1638+
height: 30px;
16481639
}
16491640

16501641
.repository .diff-box .resolved-placeholder {

0 commit comments

Comments
 (0)