-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to add prefix and suffix to autocomplete options (#414)
- Loading branch information
Showing
9 changed files
with
224 additions
and
134 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
app/components/polaris/autocomplete/option_component.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% if @multiple %> | ||
<%= render Polaris::OptionList::CheckboxComponent.new(**system_arguments) %> | ||
<% else %> | ||
<%= render Polaris::OptionList::RadioButtonComponent.new(**system_arguments, prefix: prefix, suffix: suffix) %> | ||
<% end %> |
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
22 changes: 22 additions & 0 deletions
22
app/components/polaris/option_list/radio_button_component.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<% pref = prefix || @prefix %> | ||
<% suf = suffix || @suffix %> | ||
|
||
<%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %> | ||
<%= tag.label( | ||
class: "Polaris-OptionList-Option__SingleSelectOption", | ||
data: { | ||
polaris_option_list_target: "radioButton", | ||
action: "click->polaris-option-list#update" | ||
} | ||
) do %> | ||
<%= tag.div(class: "Polaris-OptionList-Option__Layout", style: suf.blank? ? "justify-content: normal;" : "") do %> | ||
<% if pref %> | ||
<%= tag.div(pref, style: "margin-right: 5px;") %> | ||
<% end %> | ||
<%= tag.div { safe_join [radio_button, @label] } %> | ||
<% if suf %> | ||
<%= tag.div(suf, style: "margin-left: 5px;") %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
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
43 changes: 43 additions & 0 deletions
43
demo/app/previews/autocomplete_component_preview/with_prefix_or_suffix.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<%= polaris_autocomplete do |autocomplete| %> | ||
<% autocomplete.with_text_field(name: :tags, label: "Tags", placeholder: "Search") do |c| %> | ||
<% c.with_prefix do %> | ||
<%= polaris_icon(name: "SearchIcon") %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% autocomplete.with_option(label: "Rustic", value: "rustic") do |option| %> | ||
<% option.with_prefix do %> | ||
<%= polaris_thumbnail( | ||
source: "https://burst.shopifycdn.com/photos/black-leather-choker-necklace_373x@2x.jpg", | ||
alt: "Black choker necklace", | ||
size: :small, | ||
) %> | ||
<% end %> | ||
<% end %> | ||
<% autocomplete.with_option(label: "Antique", value: "antique") do |option| %> | ||
<% option.with_suffix do %> | ||
<%= polaris_thumbnail( | ||
source: "https://burst.shopifycdn.com/photos/black-leather-choker-necklace_373x@2x.jpg", | ||
alt: "Black choker necklace", | ||
size: :small, | ||
) %> | ||
<% end %> | ||
<% end %> | ||
<% autocomplete.with_option(label: "Vinyl", value: "vinyl") do |option| %> | ||
<% option.with_prefix do %> | ||
<%= polaris_thumbnail( | ||
source: "https://burst.shopifycdn.com/photos/black-leather-choker-necklace_373x@2x.jpg", | ||
alt: "Black choker necklace", | ||
size: :small, | ||
) %> | ||
<% end %> | ||
<% option.with_suffix do %> | ||
<%= polaris_thumbnail( | ||
source: "https://burst.shopifycdn.com/photos/black-leather-choker-necklace_373x@2x.jpg", | ||
alt: "Black choker necklace", | ||
size: :small, | ||
) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
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