Skip to content

Commit 7a6260f

Browse files
Improve repo search UI (#29767)
1. Introduce a special "flex-items-block" for menu items, to align the dropdown menu items 2. Simplify the "repo search" form 3. Add missing "TopicOnly" search option Screenshots: The old UI items don't align: <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/b965ac00-bad6-4d2f-9103-8841bd940aa5) </details> New UI (doesn't change much, but the items align) <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/a1add892-21dc-423b-90d5-5569faa3dced) ![image](https://github.com/go-gitea/gitea/assets/2114189/fb4040b2-96d8-4fb2-a0ed-760b9881fd86) </details> --------- Co-authored-by: silverwind <[email protected]>
1 parent 0d3ec8e commit 7a6260f

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed

templates/admin/user/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="ui dropdown type jump item">
1616
<span class="text">{{ctx.Locale.Tr "admin.users.list_status_filter.menu_text"}}</span>
1717
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
18-
<div class="menu">
18+
<div class="menu flex-items-menu">
1919
<a class="item j-reset-status-filter">{{ctx.Locale.Tr "admin.users.list_status_filter.reset"}}</a>
2020
<div class="divider"></div>
2121
<label class="item"><input type="radio" name="status_filter[is_admin]" value="1"> {{ctx.Locale.Tr "admin.users.list_status_filter.is_admin"}}</label>

templates/devtest/gitea-ui.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,13 @@
204204

205205
<h2>Dropdown with SVG</h2>
206206
<div>
207-
<div class="ui dropdown" style="border: 1px red dashed" data-tooltip-content="border for demo purpose only">
208-
<span class="text">simple</span>
207+
<div class="ui dropdown tw-border tw-border-red tw-border-dashed" data-tooltip-content="border for demo purpose only">
208+
<span class="text">search-input &amp; flex-item in menu</span>
209209
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
210-
<div class="menu">
210+
<div class="menu flex-items-menu">
211211
<div class="ui icon search input"><i class="icon">{{svg "octicon-search"}}</i><input type="text" value="search input in menu"></div>
212-
<div class="item">item</div>
212+
<div class="item"><input type="radio">item</div>
213+
<div class="item"><input type="radio">item</div>
213214
</div>
214215
</div>
215216
<div class="ui search selection dropdown">

templates/shared/repo_search.tmpl

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
<div class="ui small secondary filter menu">
2-
<form id="repo-search-form" class="ui form ignore-dirty tw-flex-1 tw-flex tw-flex-row tw-gap-x-2 gt-ac">
3-
{{if .Language}}<input hidden name="language" value="{{.Language}}">{{end}}
2+
<form id="repo-search-form" class="ui form ignore-dirty tw-flex-1 tw-flex tw-gap-x-2">
3+
{{if .Language}}<input type="hidden" name="language" value="{{.Language}}">{{end}}
4+
{{if .PageIsExploreRepositories}}<input type="hidden" name="only_show_relevant" value="{{.OnlyShowRelevant}}">{{end}}
5+
{{if .TabName}}<input type="hidden" name="tab" value="{{.TabName}}">{{end}}
6+
{{if .TopicOnly}}<input type="hidden" name="topic" value="{{.TopicOnly}}">{{end}}
47
<div class="ui small fluid action input tw-flex-1">
58
{{template "shared/search/input" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.repo_kind")}}
6-
{{if .PageIsExploreRepositories}}
7-
<input type="hidden" name="only_show_relevant" value="{{.OnlyShowRelevant}}">
8-
{{else if .TabName}}
9-
<input type="hidden" name="tab" value="{{.TabName}}">
10-
{{end}}
119
{{template "shared/search/button"}}
1210
</div>
1311
<!-- Filter -->
14-
<div class="ui small dropdown type jump item tw-mr-0">
15-
<span class="text">
16-
{{ctx.Locale.Tr "filter"}}
17-
</span>
12+
<div class="item ui small dropdown jump">
13+
<span class="text">{{ctx.Locale.Tr "filter"}}</span>
1814
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
19-
<div class="menu">
15+
<div class="menu flex-items-menu">
2016
<label class="item"><input type="radio" name="clear-filter"> {{ctx.Locale.Tr "filter.clear"}}</label>
2117
<div class="divider"></div>
2218
<label class="item"><input type="radio" name="archived" {{if .IsArchived.Value}}checked{{end}} value="1"> {{ctx.Locale.Tr "filter.is_archived"}}</label>
@@ -36,10 +32,8 @@
3632
</div>
3733
</div>
3834
<!-- Sort -->
39-
<div class="ui small dropdown type jump item gt-mr-0">
40-
<span class="text">
41-
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
42-
</span>
35+
<div class="item ui small dropdown jump">
36+
<span class="text">{{ctx.Locale.Tr "repo.issues.filter_sort"}}</span>
4337
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
4438
<div class="menu">
4539
<label class="{{if eq .SortType "newest"}}active {{end}}item"><input hidden type="radio" name="sort" {{if eq .SortType "newest"}}checked{{end}} value="newest"> {{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</label>
@@ -61,8 +55,10 @@
6155
</form>
6256
</div>
6357
{{if and .PageIsExploreRepositories .OnlyShowRelevant}}
64-
<div class="ui message explore-relevancy-note">
65-
<span data-tooltip-content="{{ctx.Locale.Tr "explore.relevant_repositories_tooltip"}}">{{ctx.Locale.Tr "explore.relevant_repositories" (printf "?only_show_relevant=0&sort=%s&q=%s&language=%s" $.SortType (QueryEscape $.Keyword) (QueryEscape $.Language))}}</span>
58+
<div class="ui message">
59+
<span data-tooltip-content="{{ctx.Locale.Tr "explore.relevant_repositories_tooltip"}}">
60+
{{ctx.Locale.Tr "explore.relevant_repositories" (printf "?only_show_relevant=0&sort=%s&q=%s&language=%s" $.SortType (QueryEscape $.Keyword) (QueryEscape $.Language))}}
61+
</span>
6662
</div>
6763
{{end}}
6864
<div class="divider"></div>

templates/shared/search/input.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{{/* Value - value of the search field (for search results page) */}}
22
{{/* Disabled (optional) - if search field has to be disabled */}}
33
{{/* Placeholder (optional) - placeholder text to be used */}}
4-
<input type="search" spellcheck="false" name="q" maxlength="255" placeholder="{{with .Placeholder}}{{.}}{{else}}{{ctx.Locale.Tr "search.search"}}{{end}}"{{with .Value}} value="{{.}}"{{end}}{{if .Disabled}} disabled{{end}}>
4+
<input type="search" name="q"{{with .Value}} value="{{.}}"{{end}} maxlength="255" spellcheck="false" placeholder="{{with .Placeholder}}{{.}}{{else}}{{ctx.Locale.Tr "search.search"}}{{end}}"{{if .Disabled}} disabled{{end}}>

tests/integration/explore_repos_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/tests"
11+
12+
"github.com/stretchr/testify/assert"
1113
)
1214

1315
func TestExploreRepos(t *testing.T) {
1416
defer tests.PrepareTestEnv(t)()
1517

16-
req := NewRequest(t, "GET", "/explore/repos")
17-
MakeRequest(t, req, http.StatusOK)
18+
req := NewRequest(t, "GET", "/explore/repos?q=TheKeyword&topic=1&language=TheLang")
19+
resp := MakeRequest(t, req, http.StatusOK)
20+
respStr := resp.Body.String()
21+
22+
assert.Contains(t, respStr, `<input type="hidden" name="topic" value="true">`)
23+
assert.Contains(t, respStr, `<input type="hidden" name="language" value="TheLang">`)
24+
assert.Contains(t, respStr, `<input type="search" name="q" value="TheKeyword"`)
1825
}

web_src/css/base.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,6 @@ table th[data-sortt-desc] .svg {
19801980
.ui.ui.button,
19811981
.ui.ui.dropdown,
19821982
.ui.ui.label,
1983-
.flex-items-inline > .item,
19841983
.flex-text-inline {
19851984
display: inline-flex;
19861985
align-items: center;
@@ -2017,3 +2016,10 @@ table th[data-sortt-desc] .svg {
20172016
align-items: center;
20182017
gap: .25rem;
20192018
}
2019+
2020+
/* to override Fomantic's default display: block for ".menu .item", and use a slightly larger gap for menu item content */
2021+
.ui.dropdown .menu.flex-items-menu > .item {
2022+
display: flex !important;
2023+
align-items: center;
2024+
gap: .5rem;
2025+
}

0 commit comments

Comments
 (0)