Skip to content

Commit 85237f3

Browse files
committed
Refactor search form for visual design changes
Why these changes are being introduced: GeoData and USE UI currently share search form input and submit fields. These fields should be isolated for UXWS to easily make tweaks to the form for USE UI that won't affect GeoData. Relevant ticket(s): * [USE-127](https://mitlibraries.atlassian.net/browse/USE-127) How this addresses that need: This conditionally renders a submit button with class `geo-search-submit` if GeoData is enabled. If not, the button div has the class `basic-search-submit`. This also adds a conditional `inline` class to the input field if GeoData is not enabled. This class does not actually do anything yet, but it will make it easier for UXWS update the CSS such that the button renders inline with the input. Side effects of this change: The ID and classes associated with the form element have been renamed from `basic-search-form` to `search-form`. This more accurately captures the element they target, since the form is used both for USE UI (basic search) and GeoData (advanced search).
1 parent 0c0f13f commit 85237f3

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

app/assets/stylesheets/partials/_search.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ------------------------
44

55
/* basic search bar */
6-
.basic-search {
6+
.search-form {
77
background-color: #989898;
88
margin-bottom: 0rem;
99
padding: 2.4rem 2rem 1.6rem 2rem;
@@ -114,7 +114,7 @@
114114
}
115115
}
116116

117-
.basic-search-submit {
117+
.geo-search-submit {
118118
width: 150px;
119119
margin-top: 0.8rem;
120120
.btn {

app/views/search/_form.html.erb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ end
2222
keyword_placeholder = search_required ? "Enter your search" : "Keyword anywhere"
2323
%>
2424

25-
<form id="basic-search" class="form-horizontal basic-search" action="<%= results_path %>" method="get" role="search">
25+
<form id="search-form" class="form-horizontal search-form" action="<%= results_path %>" method="get" role="search">
2626
<div class="form-group">
2727
<input id="basic-search-main" type="search"
28-
class="field field-text basic-search-input <%= "required" if search_required %>" name="q"
28+
class="field field-text basic-search-input <%= "required" if search_required %> <%= "inline" unless Flipflop.enabled?(:gdt) %>" name="q"
2929
title="Keyword anywhere" placeholder="<%= keyword_placeholder %>"
3030
value="<%= params[:q] %>" <%= 'required' if search_required %>
3131
<%= 'aria-describedby=site-desc' if Flipflop.enabled?(:gdt) %>>
@@ -175,11 +175,15 @@ keyword_placeholder = search_required ? "Enter your search" : "Keyword anywhere"
175175
</div>
176176
</div>
177177
</details>
178-
<% end %>
179-
</div>
180178

181-
<div class="basic-search-submit">
182-
<button type="submit" class="btn button-primary">Search</button>
179+
<div class="geo-search-submit">
180+
<button type="submit" class="btn button-primary">Search</button>
181+
</div>
182+
<% else %>
183+
<div class="basic-search-submit">
184+
<button type="submit" class="btn button-primary">Search</button>
185+
</div>
186+
<% end %>
183187
</div>
184188
</form>
185189

test/controllers/search_controller_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def mock_timdex_search_success
7575
get '/'
7676
assert_response :success
7777

78-
assert_select 'form#basic-search', { count: 1 }
78+
assert_select 'form#search-form', { count: 1 }
7979
assert_select 'details#advanced-search-panel', count: 0
8080
end
8181

@@ -183,15 +183,15 @@ def mock_timdex_search_success
183183
get '/results?q=hallo'
184184
assert_response :success
185185

186-
assert_select 'form#basic-search', { count: 1 }
186+
assert_select 'form#search-form', { count: 1 }
187187
end
188188

189189
test 'timdex results with valid query shows search form' do
190190
mock_timdex_search_success
191191
get '/results?q=hallo&tab=timdex'
192192
assert_response :success
193193

194-
assert_select 'form#basic-search', { count: 1 }
194+
assert_select 'form#search-form', { count: 1 }
195195
end
196196

197197
test 'primo results with valid query populates search form with query' do

0 commit comments

Comments
 (0)