-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button text setting to search box
Adds ability to change the visually hidden text inside the search box button.
- Loading branch information
Showing
3 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
43 changes: 27 additions & 16 deletions
43
app/views/govuk_publishing_components/components/_search.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,48 @@ | ||
<% | ||
size ||= "" | ||
no_border ||= false | ||
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) | ||
classes = %w(gem-c-search) | ||
|
||
aria_controls ||= nil | ||
button_text ||= "Search" | ||
id ||= "search-main-" + SecureRandom.hex(4) | ||
label_text ||= "Search on GOV.UK" | ||
name ||= "q" | ||
no_border ||= false | ||
size ||= "" | ||
value ||= "" | ||
|
||
classes = %w[gem-c-search] | ||
classes << (shared_helper.get_margin_top) | ||
classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom] | ||
classes << "gem-c-search--large" if size == 'large' | ||
classes << "gem-c-search--large" if size == "large" | ||
classes << "gem-c-search--no-border" if no_border | ||
if local_assigns[:on_govuk_blue].eql?(true) | ||
classes << "gem-c-search--on-govuk-blue" | ||
else | ||
classes << "gem-c-search--on-white" | ||
end | ||
classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label) | ||
|
||
value ||= "" | ||
id ||= "search-main-" + SecureRandom.hex(4) | ||
label_text ||= "Search on GOV.UK" | ||
name ||= 'q' | ||
aria_controls ||= nil | ||
%> | ||
|
||
<div class="<%= classes.join(' ') %>" data-module="gem-toggle-input-class-on-focus"> | ||
<div class="<%= classes.join(" ") %>" data-module="gem-toggle-input-class-on-focus"> | ||
<label for="<%= id %>" class="gem-c-search__label"> | ||
<%= label_text %> | ||
</label> | ||
<div class="gem-c-search__item-wrapper"> | ||
<input type="search" value="<%= value %>" | ||
id="<%= id %>" name="<%= name %>" title="Search" | ||
aria-controls="<%= aria_controls %>" | ||
class="gem-c-search__item gem-c-search__input js-class-toggle"> | ||
<%= tag.input( | ||
aria: { | ||
controls: aria_controls, | ||
}, | ||
class: "gem-c-search__item gem-c-search__input js-class-toggle", | ||
id: id, | ||
name: name, | ||
title: "Search", | ||
type: "search", | ||
value: value, | ||
) %> | ||
<div class="gem-c-search__item gem-c-search__submit-wrapper"> | ||
<button type="submit" class="gem-c-search__submit">Search</button> | ||
<button class="gem-c-search__submit" type="submit"> | ||
<%= button_text %> | ||
</button> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters