Skip to content

Commit c445a85

Browse files
authored
Improve repo button row layout (#30668)
Since there is now a second `<input>` in the repo buttons, we can make a better-looking layout with no empty space, except on mobile. Also I fixed one bug with focus border on clone panel. ## Large <img width="1163" alt="Screenshot 2024-04-23 at 22 25 22" src="https://github.com/go-gitea/gitea/assets/115237/8135a572-aa67-4672-ad49-b76b06890b52"> ## Medium <img width="870" alt="Screenshot 2024-04-23 at 22 25 34" src="https://github.com/go-gitea/gitea/assets/115237/9e93f61c-3315-4a78-8328-8cefad5b50fa"> ## Mobile <img width="416" alt="Screenshot 2024-04-23 at 22 25 52" src="https://github.com/go-gitea/gitea/assets/115237/859e341f-807a-48e6-8bcf-31715963216c">
1 parent e67fbe4 commit c445a85

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

templates/repo/clone_buttons.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
SSH
1010
</button>
1111
{{end}}
12-
<input id="repo-clone-url" size="20" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
12+
<input id="repo-clone-url" size="10" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
1313
<button class="ui small icon button" id="clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{ctx.Locale.Tr "copy_url"}}">
1414
{{svg "octicon-copy" 14}}
1515
</button>

templates/repo/home.tmpl

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{{$l := Eval $n "-" 1}}
4747
{{$isHomepage := (eq $n 0)}}
4848
<div class="repo-button-row">
49-
<div class="tw-flex tw-items-center tw-flex-wrap tw-gap-y-2">
49+
<div class="repo-button-row-left">
5050
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}}
5151
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
5252
{{$cmpBranch := ""}}
@@ -66,7 +66,7 @@
6666
{{end}}
6767

6868
{{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}}
69-
<button class="ui dropdown basic compact jump button tw-mr-1"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
69+
<button class="ui dropdown basic compact jump button"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
7070
{{ctx.Locale.Tr "repo.editor.add_file"}}
7171
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
7272
<div class="menu">
@@ -93,9 +93,9 @@
9393
{{if $isHomepage}}
9494
{{/* only show the "code search" on the repo home page, it only does global search,
9595
so do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) */}}
96-
<form class="ignore-dirty" action="{{.RepoLink}}/search" method="get">
97-
<div class="ui small action input">
98-
<input name="q" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
96+
<form class="ignore-dirty tw-flex tw-flex-1" action="{{.RepoLink}}/search" method="get">
97+
<div class="ui small action input tw-flex-1">
98+
<input name="q" size="10" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
9999
{{template "shared/search/button"}}
100100
</div>
101101
</form>
@@ -113,7 +113,7 @@
113113
</span>
114114
{{end}}
115115
</div>
116-
<div class="tw-flex tw-items-center">
116+
<div class="repo-button-row-right">
117117
<!-- Only show clone panel in repository home page -->
118118
{{if $isHomepage}}
119119
<div class="clone-panel ui action tiny input">

web_src/css/modules/input.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
.ui.action.input:not([class*="left action"]) > input:focus + .ui.dropdown.selection:hover,
189189
.ui.action.input:not([class*="left action"]) > input:focus + .button,
190190
.ui.action.input:not([class*="left action"]) > input:focus + .button:hover,
191-
.ui.action.input:not([class*="left action"]) > input:focus + .icon + .button,
192-
.ui.action.input:not([class*="left action"]) > input:focus + .icon + .button:hover {
191+
.ui.action.input:not([class*="left action"]) > input:focus + i.icon + .button,
192+
.ui.action.input:not([class*="left action"]) > input:focus + i.icon + .button:hover {
193193
border-left-color: var(--color-primary);
194194
}
195195
.ui.action.input:not([class*="left action"]) > input:focus {

web_src/css/repo.css

+43-10
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,22 @@
128128
margin-bottom: 12px;
129129
}
130130

131-
.repository .clone-panel #repo-clone-url {
132-
width: 320px;
133-
border-radius: 0;
131+
.repository .clone-panel {
132+
display: flex;
133+
flex: 1;
134134
}
135135

136-
@media (max-width: 991.98px) {
137-
.repository .clone-panel #repo-clone-url {
138-
width: 200px;
139-
}
136+
.repository.wiki .clone-panel {
137+
flex: 0;
138+
}
139+
140+
.repository.wiki .clone-panel input {
141+
width: 20ch;
142+
}
143+
144+
.repository .clone-panel #repo-clone-url {
145+
border-radius: 0;
146+
flex: 1;
140147
}
141148

142149
.repository .ui.action.input.clone-panel > button + button,
@@ -2229,17 +2236,37 @@ td .commit-summary {
22292236
}
22302237

22312238
.repo-button-row {
2232-
margin: 10px 0;
2239+
margin: 8px 0;
22332240
display: flex;
22342241
align-items: center;
2235-
gap: 0.5em;
2236-
flex-wrap: wrap;
2242+
gap: 8px;
22372243
justify-content: space-between;
22382244
}
22392245

2246+
.repo-button-row-left,
2247+
.repo-button-row-right {
2248+
display: flex;
2249+
flex: 1;
2250+
align-items: center;
2251+
gap: 0.5rem;
2252+
}
2253+
2254+
.repo-button-row-right {
2255+
justify-content: flex-end;
2256+
}
2257+
2258+
@media (max-width: 991px) {
2259+
.repository:not(.wiki) .repo-button-row {
2260+
flex-direction: column;
2261+
align-items: stretch;
2262+
}
2263+
}
2264+
22402265
.repo-button-row .button {
22412266
padding: 6px 10px !important;
22422267
height: 30px;
2268+
flex-shrink: 0;
2269+
margin: 0;
22432270
}
22442271

22452272
.repo-button-row .button.dropdown:not(.icon) {
@@ -2250,6 +2277,12 @@ td .commit-summary {
22502277
height: 30px;
22512278
}
22522279

2280+
@media (max-width: 600px) {
2281+
.repo-button-row-left {
2282+
flex-wrap: wrap;
2283+
}
2284+
}
2285+
22532286
tbody.commit-list {
22542287
vertical-align: baseline;
22552288
}

0 commit comments

Comments
 (0)