Skip to content

Commit 79b3b38

Browse files
authored
Merge pull request #1743 from codidact/0valt/1112/search-title-pos
0valt/1112/search title pos
2 parents 938fbb2 + 8b38781 commit 79b3b38

3 files changed

Lines changed: 81 additions & 58 deletions

File tree

app/assets/stylesheets/search.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import 'variables';
2+
3+
.search-filters:not([open]) {
4+
border-top: 1px solid $muted-graphic;
5+
}
6+
7+
.search-sorting {
8+
align-items: center;
9+
display: flex;
10+
justify-content: space-between;
11+
12+
.search-sorting-types {
13+
margin: 0.5em;
14+
margin-right: 0;
15+
}
16+
}

app/views/search/_widget.html.erb

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
<%= form_tag search_path, method: :get, role: 'search' do %>
2-
<div class="form-group-horizontal">
3-
<div class="form-group">
4-
<%= label_tag :search, 'Search term', class: "form-element" %>
5-
<%= search_field_tag :search, params[:search], class: 'form-element' %>
6-
</div>
7-
<div class="actions has-padding-bottom-1">
8-
<%= submit_tag 'Search', class: 'button is-medium is-outlined', name: nil %>
9-
</div>
1+
<div class="form-group-horizontal">
2+
<div class="form-group">
3+
<%= label_tag :search, 'Search term', class: "form-element" %>
4+
<%= search_field_tag :search, params[:search], class: 'form-element' %>
5+
</div>
6+
<div class="actions has-padding-bottom-1">
7+
<%= submit_tag 'Search', class: 'button is-medium is-outlined', name: nil %>
108
</div>
9+
</div>
1110

12-
<% if @signed_out_me %>
11+
<% if @signed_out_me %>
1312
<div class="widget is-red">
1413
<div class="widget--body">
1514
<p>
@@ -18,22 +17,15 @@
1817
</p>
1918
</div>
2019
</div>
21-
<% end %>
20+
<% end %>
2221

23-
<div class="widget is-teal">
24-
<div class="widget--header">
25-
Advanced Search Options
26-
</div>
27-
<div class="widget--body">
28-
<%= raw(sanitize(render_markdown(SiteSetting['JITAdvancedSearchHelp']), scrubber: scrubber)) %>
29-
<p>Further help with searching is available <%= link_to 'in the help center', help_path('search') %>.</p>
30-
<p>Quick hints: <code>tag:tagname</code>, <code>user:xxx</code>, <code>"exact phrase"</code>, <code>post_type:xxx</code>, <code>created:&lt;N{d,w,mo,y}</code>, <code>score:&gt;=0.5</code></p>
31-
</div>
22+
<div class="widget is-teal">
23+
<div class="widget--header">
24+
Advanced Search Options
3225
</div>
33-
34-
<details>
35-
<summary>Filters</summary>
36-
<%= render 'filters' %>
37-
</details>
38-
39-
<% end %>
26+
<div class="widget--body">
27+
<%= raw(sanitize(render_markdown(SiteSetting['JITAdvancedSearchHelp']), scrubber: scrubber)) %>
28+
<p>Further help with searching is available <%= link_to 'in the help center', help_path('search') %>.</p>
29+
<p>Quick hints: <code>tag:tagname</code>, <code>user:xxx</code>, <code>"exact phrase"</code>, <code>post_type:xxx</code>, <code>created:&lt;N{d,w,mo,y}</code>, <code>score:&gt;=0.5</code></p>
30+
</div>
31+
</div>

app/views/search/search.html.erb

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,56 @@
22

33
<h1>Search</h1>
44

5-
<%= render 'widget' %>
6-
7-
<% unless @posts.nil? %>
8-
<% post_count = @posts.count %>
9-
<div class="has-color-tertiary-500 flex-row jc-sb ai-c">
10-
<span title="<%= post_count %> posts">
11-
<%= short_number_to_human post_count, precision: 1, significant: false %>
12-
<%= 'post'.pluralize(post_count) %>
13-
</span>
14-
<div class="button-list is-gutterless has-margin-2">
15-
<%= link_to 'Relevance', request.params.merge(sort: 'relevance'), class: "button is-outlined is-muted #{params[:sort] == 'relevance' || params[:sort].nil? ? 'is-active' : ''}",
16-
role: 'button', 'aria-label': 'Sort by relevance' %>
17-
<%= link_to 'Activity', request.params.merge(sort: 'activity'), class: "button is-outlined is-muted #{params[:sort] == 'activity' ? 'is-active' : ''}",
18-
role: 'button', 'aria-label': 'Sort by activity' %>
19-
<%= link_to 'Age', request.params.merge(sort: 'age'), class: "button is-outlined is-muted #{params[:sort] == 'age' ? 'is-active' : ''}",
20-
role: 'button', 'aria-label': 'Sort by age' %>
21-
<%= link_to 'Score', request.params.merge(sort: 'score'), class: "button is-outlined is-muted #{params[:sort] == 'score' ? 'is-active' : ''}",
22-
role: 'button', 'aria-label': 'Sort by score' %>
5+
<%= form_tag search_path, method: :get, role: 'search' do %>
6+
<%= render 'search/widget' %>
7+
8+
<% unless @posts.nil? %>
9+
<% post_count = @posts.count %>
10+
<div class="search-sorting has-color-tertiary-500">
11+
<span title="<%= post_count %> posts">
12+
<%= short_number_to_human post_count, precision: 1, significant: false %>
13+
<%= 'post'.pluralize(post_count) %>
14+
</span>
15+
<div class="search-sorting-types button-list is-gutterless">
16+
<%= link_to 'Relevance',
17+
request.params.merge(sort: 'relevance'),
18+
class: "button is-outlined is-muted #{'is-active' if params[:sort] == 'relevance' || params[:sort].nil?}",
19+
role: 'button', 'aria-label': 'Sort by relevance' %>
20+
<%= link_to 'Activity',
21+
request.params.merge(sort: 'activity'),
22+
class: "button is-outlined is-muted #{'is-active' if params[:sort] == 'activity'}",
23+
role: 'button', 'aria-label': 'Sort by activity' %>
24+
<%= link_to 'Age',
25+
request.params.merge(sort: 'age'),
26+
class: "button is-outlined is-muted #{'is-active' if params[:sort] == 'age'}",
27+
role: 'button', 'aria-label': 'Sort by age' %>
28+
<%= link_to 'Score',
29+
request.params.merge(sort: 'score'),
30+
class: "button is-outlined is-muted #{'is-active' if params[:sort] == 'score'}",
31+
role: 'button', 'aria-label': 'Sort by score' %>
32+
</div>
2333
</div>
24-
</div>
2534

26-
<div class="has-clear-clear">&nbsp;</div>
35+
<details class="search-filters">
36+
<summary>Filters</summary>
37+
<%= render 'search/filters' %>
38+
</details>
2739

28-
<% if @posts.size == 0 %>
29-
<p class="has-color-tertiary"><em>No results for <strong><%= params[:search] %></strong>. Try using a different search term.</em></p>
30-
<% end %>
40+
<div class="has-clear-clear">&nbsp;</div>
3141

32-
<div class="item-list has-border-top-width-1 has-border-top-style-solid has-border-color-tertiary-050">
33-
<% @posts.each do |post| %>
34-
<% next if post.nil? %>
35-
<%= render 'posts/type_agnostic', post: post, show_type_tag: true, show_category_tag: true %>
42+
<% if @posts.size == 0 %>
43+
<p class="has-color-tertiary">
44+
<em>No results for <strong><%= params[:search] %></strong>. Try using a different search term.</em>
45+
</p>
3646
<% end %>
37-
</div>
38-
<% end %>
3947

40-
<% unless @posts.nil? %>
41-
<%= will_paginate @posts, renderer: BootstrapPagination::Rails %>
48+
<div class="item-list has-border-top-width-1 has-border-top-style-solid has-border-color-tertiary-050">
49+
<% @posts.each do |post| %>
50+
<% next if post.nil? %>
51+
<%= render 'posts/type_agnostic', post: post, show_type_tag: true, show_category_tag: true %>
52+
<% end %>
53+
</div>
54+
55+
<%= will_paginate @posts, renderer: BootstrapPagination::Rails %>
56+
<% end %>
4257
<% end %>

0 commit comments

Comments
 (0)