polaris_view_components 0.4.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +136 -0
- data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
- data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +495 -0
- data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
- data/app/assets/javascripts/polaris_view_components/index.js +21 -1
- data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
- data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
- data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +56 -0
- data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
- data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
- data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
- data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
- data/app/assets/javascripts/polaris_view_components/utils.js +23 -0
- data/app/assets/javascripts/polaris_view_components.js +2406 -5
- data/app/assets/stylesheets/polaris_view_components/custom.css +123 -0
- data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
- data/app/assets/stylesheets/polaris_view_components.css +2162 -2019
- data/app/assets/stylesheets/polaris_view_components.postcss.css +1 -1
- data/app/components/polaris/action.rb +3 -3
- data/app/components/polaris/action_list/item_component.html.erb +35 -0
- data/app/components/polaris/action_list/item_component.rb +41 -0
- data/app/components/polaris/action_list/section_component.html.erb +16 -0
- data/app/components/polaris/action_list/section_component.rb +26 -0
- data/app/components/polaris/action_list_component.html.erb +13 -0
- data/app/components/polaris/action_list_component.rb +25 -0
- data/app/components/polaris/autocomplete/action_component.rb +7 -0
- data/app/components/polaris/autocomplete/option_component.rb +35 -0
- data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
- data/app/components/polaris/autocomplete/section_component.rb +12 -0
- data/app/components/polaris/autocomplete_component.html.erb +30 -0
- data/app/components/polaris/autocomplete_component.rb +65 -0
- data/app/components/polaris/avatar_component.rb +2 -2
- data/app/components/polaris/badge_component.rb +2 -2
- data/app/components/polaris/banner_component.rb +8 -8
- data/app/components/polaris/base_button.rb +2 -2
- data/app/components/polaris/base_checkbox.rb +48 -0
- data/app/components/polaris/base_component.rb +1 -1
- data/app/components/polaris/base_radio_button.rb +38 -0
- data/app/components/polaris/button_component.html.erb +13 -0
- data/app/components/polaris/button_group_component.rb +8 -8
- data/app/components/polaris/callout_card_component.rb +6 -6
- data/app/components/polaris/caption_component.rb +3 -3
- data/app/components/polaris/card/header_component.rb +2 -2
- data/app/components/polaris/card/section_component.rb +8 -4
- data/app/components/polaris/card_component.html.erb +4 -0
- data/app/components/polaris/card_component.rb +6 -5
- data/app/components/polaris/character_count.rb +10 -10
- data/app/components/polaris/checkbox_component.html.erb +1 -5
- data/app/components/polaris/checkbox_component.rb +20 -13
- data/app/components/polaris/choice_component.rb +2 -2
- data/app/components/polaris/choice_list_component.rb +6 -6
- data/app/components/polaris/component.rb +6 -1
- data/app/components/polaris/data_table/cell_component.rb +4 -4
- data/app/components/polaris/data_table/column_component.rb +1 -1
- data/app/components/polaris/data_table_component.rb +4 -4
- data/app/components/polaris/description_list_component.rb +5 -5
- data/app/components/polaris/display_text_component.rb +3 -3
- data/app/components/polaris/dropzone_component.html.erb +156 -0
- data/app/components/polaris/dropzone_component.rb +150 -0
- data/app/components/polaris/empty_state_component.rb +4 -4
- data/app/components/polaris/exception_list/item_component.rb +3 -3
- data/app/components/polaris/exception_list_component.rb +2 -2
- data/app/components/polaris/filters_component.html.erb +35 -0
- data/app/components/polaris/filters_component.rb +91 -0
- data/app/components/polaris/footer_help_component.rb +2 -2
- data/app/components/polaris/form_layout/group_component.rb +5 -5
- data/app/components/polaris/form_layout/item_component.rb +2 -2
- data/app/components/polaris/form_layout_component.rb +4 -4
- data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
- data/app/components/polaris/frame/save_bar_component.rb +31 -0
- data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
- data/app/components/polaris/frame/top_bar_component.rb +18 -0
- data/app/components/polaris/frame_component.html.erb +44 -0
- data/app/components/polaris/frame_component.rb +33 -0
- data/app/components/polaris/heading_component.rb +2 -2
- data/app/components/polaris/headless_button.html.erb +13 -0
- data/app/components/polaris/headless_button.rb +18 -6
- data/app/components/polaris/icon_component.rb +3 -3
- data/app/components/polaris/index_table/cell_component.rb +22 -0
- data/app/components/polaris/index_table/column_component.rb +13 -0
- data/app/components/polaris/index_table_component.html.erb +28 -0
- data/app/components/polaris/index_table_component.rb +25 -0
- data/app/components/polaris/inline_error_component.html.erb +2 -2
- data/app/components/polaris/inline_error_component.rb +8 -2
- data/app/components/polaris/label_component.rb +3 -3
- data/app/components/polaris/labelled_component.rb +3 -3
- data/app/components/polaris/layout/annotated_section.rb +2 -2
- data/app/components/polaris/layout/section.rb +2 -2
- data/app/components/polaris/layout_component.rb +4 -4
- data/app/components/polaris/link_component.rb +4 -4
- data/app/components/polaris/list_component.rb +5 -5
- data/app/components/polaris/logo.rb +13 -0
- data/app/components/polaris/modal/section_component.rb +19 -0
- data/app/components/polaris/modal_component.html.erb +79 -0
- data/app/components/polaris/modal_component.rb +98 -0
- data/app/components/polaris/navigation/item_component.html.erb +31 -0
- data/app/components/polaris/navigation/item_component.rb +85 -0
- data/app/components/polaris/navigation/section_component.html.erb +17 -0
- data/app/components/polaris/navigation/section_component.rb +64 -0
- data/app/components/polaris/navigation_component.html.erb +29 -0
- data/app/components/polaris/navigation_component.rb +15 -0
- data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
- data/app/components/polaris/option_list/checkbox_component.rb +37 -0
- data/app/components/polaris/option_list/option_component.rb +24 -0
- data/app/components/polaris/option_list/radio_button_component.rb +54 -0
- data/app/components/polaris/option_list/section_component.html.erb +14 -0
- data/app/components/polaris/option_list/section_component.rb +53 -0
- data/app/components/polaris/option_list_component.html.erb +15 -0
- data/app/components/polaris/option_list_component.rb +67 -0
- data/app/components/polaris/page_actions_component.rb +22 -7
- data/app/components/polaris/page_component.rb +5 -5
- data/app/components/polaris/pagination_component.rb +2 -6
- data/app/components/polaris/popover/pane_component.html.erb +25 -0
- data/app/components/polaris/popover/pane_component.rb +20 -0
- data/app/components/polaris/popover/section_component.rb +19 -0
- data/app/components/polaris/popover_component.html.erb +31 -0
- data/app/components/polaris/popover_component.rb +113 -0
- data/app/components/polaris/progress_bar_component.rb +6 -6
- data/app/components/polaris/radio_button_component.html.erb +1 -6
- data/app/components/polaris/radio_button_component.rb +18 -8
- data/app/components/polaris/resource_item_component.html.erb +16 -6
- data/app/components/polaris/resource_item_component.rb +43 -10
- data/app/components/polaris/resource_list_component.html.erb +10 -0
- data/app/components/polaris/resource_list_component.rb +5 -11
- data/app/components/polaris/scrollable_component.html.erb +5 -0
- data/app/components/polaris/scrollable_component.rb +48 -0
- data/app/components/polaris/select_component.rb +11 -6
- data/app/components/polaris/setting_toggle_component.html.erb +10 -0
- data/app/components/polaris/setting_toggle_component.rb +24 -0
- data/app/components/polaris/shopify_navigation_component.rb +8 -8
- data/app/components/polaris/skeleton_body_text_component.rb +2 -2
- data/app/components/polaris/spacer_component.rb +4 -4
- data/app/components/polaris/spinner_component.rb +3 -3
- data/app/components/polaris/stack/item_component.rb +15 -0
- data/app/components/polaris/stack_component.rb +6 -22
- data/app/components/polaris/subheading_component.rb +2 -2
- data/app/components/polaris/tabs/tab_component.html.erb +10 -0
- data/app/components/polaris/tabs/tab_component.rb +34 -0
- data/app/components/polaris/tabs_component.html.erb +7 -0
- data/app/components/polaris/tabs_component.rb +37 -0
- data/app/components/polaris/tag_component.rb +3 -2
- data/app/components/polaris/text_container_component.rb +3 -3
- data/app/components/polaris/text_field_component.rb +25 -11
- data/app/components/polaris/text_style_component.rb +12 -3
- data/app/components/polaris/thumbnail_component.rb +3 -3
- data/app/components/polaris/toast_component.html.erb +21 -0
- data/app/components/polaris/toast_component.rb +40 -0
- data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
- data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
- data/app/components/polaris/visually_hidden_component.rb +1 -1
- data/app/helpers/polaris/form_builder.rb +44 -8
- data/app/helpers/polaris/url_helper.rb +3 -3
- data/app/helpers/polaris/view_helper.rb +37 -7
- data/app/validators/type_validator.rb +2 -2
- data/lib/generators/polaris_view_components/install_generator.rb +5 -5
- data/lib/polaris/view_components/engine.rb +16 -2
- data/lib/polaris/view_components/version.rb +1 -1
- data/lib/polaris_view_components.rb +1 -1
- metadata +85 -16
- data/app/components/polaris/application_component.rb +0 -35
- data/app/components/polaris/dropzone/component.html.erb +0 -72
- data/app/components/polaris/dropzone/component.rb +0 -128
- data/app/components/polaris/dropzone/controller.js +0 -226
- data/app/components/polaris/dropzone/utils.js +0 -57
- data/app/components/polaris/new_component.rb +0 -10
- data/app/helpers/polaris/conditional_helper.rb +0 -11
@@ -5,9 +5,9 @@ module Polaris
|
|
5
5
|
def initialize(
|
6
6
|
content:,
|
7
7
|
url:,
|
8
|
-
accessibility_label:
|
8
|
+
accessibility_label: "",
|
9
9
|
external: false,
|
10
|
-
id:
|
10
|
+
id: "",
|
11
11
|
data: {}
|
12
12
|
)
|
13
13
|
@content = content
|
@@ -25,7 +25,7 @@ module Polaris
|
|
25
25
|
external: @external,
|
26
26
|
id: @id,
|
27
27
|
url: @url,
|
28
|
-
data: @data
|
28
|
+
data: @data
|
29
29
|
}
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<li>
|
2
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
3
|
+
<div class="Polaris-ActionList__Content">
|
4
|
+
<% if @icon.present? %>
|
5
|
+
<span class="Polaris-ActionList__Prefix">
|
6
|
+
<%= polaris_icon(name: @icon) %>
|
7
|
+
</span>
|
8
|
+
<% end %>
|
9
|
+
<% if prefix.present? %>
|
10
|
+
<span class="Polaris-ActionList__Prefix">
|
11
|
+
<%= prefix %>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<span class="Polaris-ActionList__Text">
|
16
|
+
<% if @help_text.present? %>
|
17
|
+
<span class="Polaris-ActionList__ContentBlock">
|
18
|
+
<span class="Polaris-ActionList__ContentBlockInner">
|
19
|
+
<%= content %>
|
20
|
+
</span>
|
21
|
+
<%= polaris_text_subdued { @help_text } %>
|
22
|
+
</span>
|
23
|
+
<% else %>
|
24
|
+
<%= content %>
|
25
|
+
<% end %>
|
26
|
+
</span>
|
27
|
+
|
28
|
+
<% if suffix.present? %>
|
29
|
+
<span class="Polaris-ActionList__Suffix">
|
30
|
+
<%= suffix %>
|
31
|
+
</span>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
</li>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Polaris::ActionList::ItemComponent < Polaris::Component
|
2
|
+
renders_one :prefix
|
3
|
+
renders_one :suffix
|
4
|
+
|
5
|
+
def initialize(
|
6
|
+
url: nil,
|
7
|
+
icon: nil,
|
8
|
+
help_text: nil,
|
9
|
+
active: false,
|
10
|
+
destructive: false,
|
11
|
+
external: false,
|
12
|
+
**system_arguments
|
13
|
+
)
|
14
|
+
@url = url
|
15
|
+
@icon = icon
|
16
|
+
@help_text = help_text
|
17
|
+
@active = active
|
18
|
+
@destructive = destructive
|
19
|
+
@external = external
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
end
|
22
|
+
|
23
|
+
def system_arguments
|
24
|
+
@system_arguments.tap do |opts|
|
25
|
+
if @url.present?
|
26
|
+
opts[:tag] = "a"
|
27
|
+
opts[:href] = @url
|
28
|
+
opts[:target] = "_blank" if @external
|
29
|
+
else
|
30
|
+
opts[:tag] = "button"
|
31
|
+
opts[:type] = "button"
|
32
|
+
end
|
33
|
+
opts[:classes] = class_names(
|
34
|
+
@system_arguments[:classes],
|
35
|
+
"Polaris-ActionList__Item",
|
36
|
+
"Polaris-ActionList--active": @active,
|
37
|
+
"Polaris-ActionList--destructive": @destructive
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
|
+
<% if @title.present? %>
|
3
|
+
<p class="<%= title_classes %>">
|
4
|
+
<%= @title %>
|
5
|
+
</p>
|
6
|
+
<% end %>
|
7
|
+
<ul class="Polaris-ActionList__Actions">
|
8
|
+
<% if items.present? %>
|
9
|
+
<% items.each do |item| %>
|
10
|
+
<%= item %>
|
11
|
+
<% end %>
|
12
|
+
<% else %>
|
13
|
+
<%= content %>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Polaris::ActionList::SectionComponent < Polaris::Component
|
2
|
+
renders_many :items, Polaris::ActionList::ItemComponent
|
3
|
+
|
4
|
+
def initialize(position: 1, title: nil, **system_arguments)
|
5
|
+
@position = position
|
6
|
+
@title = title
|
7
|
+
@system_arguments = system_arguments
|
8
|
+
end
|
9
|
+
|
10
|
+
def system_arguments
|
11
|
+
@system_arguments.tap do |opts|
|
12
|
+
opts[:tag] = "div"
|
13
|
+
opts[:classes] = class_names(
|
14
|
+
@system_arguments[:classes],
|
15
|
+
"Polaris-ActionList__Section--withoutTitle": @title.blank?
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def title_classes
|
21
|
+
class_names(
|
22
|
+
"Polaris-ActionList__Title",
|
23
|
+
"Polaris-ActionList--firstSectionWithTitle": @position == 1
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
|
+
<% if sections.present? %>
|
3
|
+
<% sections.each do |section| %>
|
4
|
+
<%= section %>
|
5
|
+
<% end %>
|
6
|
+
<% else %>
|
7
|
+
<%= render Polaris::ActionList::SectionComponent.new do %>
|
8
|
+
<% items.each do |item| %>
|
9
|
+
<%= item %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Polaris
|
2
|
+
class ActionListComponent < Polaris::Component
|
3
|
+
renders_many :items, Polaris::ActionList::ItemComponent
|
4
|
+
renders_many :sections, ->(**system_arguments) do
|
5
|
+
@counter += 1
|
6
|
+
|
7
|
+
Polaris::ActionList::SectionComponent.new(position: @counter, **system_arguments)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(**system_arguments)
|
11
|
+
@counter = 0
|
12
|
+
@system_arguments = system_arguments
|
13
|
+
end
|
14
|
+
|
15
|
+
def system_arguments
|
16
|
+
@system_arguments.tap do |opts|
|
17
|
+
opts[:tag] = "div"
|
18
|
+
opts[:classes] = class_names(
|
19
|
+
@system_arguments[:classes],
|
20
|
+
"Polaris-ActionList"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Polaris
|
2
|
+
class Autocomplete::OptionComponent < Component
|
3
|
+
def initialize(
|
4
|
+
label:,
|
5
|
+
multiple: false,
|
6
|
+
**system_arguments
|
7
|
+
)
|
8
|
+
@label = label
|
9
|
+
@multiple = multiple
|
10
|
+
@system_arguments = system_arguments
|
11
|
+
end
|
12
|
+
|
13
|
+
def system_arguments
|
14
|
+
@system_arguments.tap do |args|
|
15
|
+
args[:label] = @label
|
16
|
+
|
17
|
+
args[:wrapper_arguments] ||= {}
|
18
|
+
args[:wrapper_arguments][:data] ||= {}
|
19
|
+
args[:wrapper_arguments][:data][:polaris_autocomplete_target] = "option"
|
20
|
+
args[:wrapper_arguments][:data][:label] = @label
|
21
|
+
|
22
|
+
args[:data] ||= {}
|
23
|
+
prepend_option(args[:data], :action, "polaris-autocomplete#select")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def call
|
28
|
+
if @multiple
|
29
|
+
render OptionList::CheckboxComponent.new(**system_arguments)
|
30
|
+
else
|
31
|
+
render OptionList::RadioButtonComponent.new(**system_arguments)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Polaris
|
2
|
+
class Autocomplete::SectionComponent < Component
|
3
|
+
renders_many :options, ->(**system_arguments) do
|
4
|
+
Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(multiple: false, **system_arguments)
|
8
|
+
@multiple = multiple
|
9
|
+
@system_arguments = system_arguments
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
2
|
+
<%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
|
3
|
+
<% popover.activator do %>
|
4
|
+
<%= text_field %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if empty_state.present? %>
|
8
|
+
<div
|
9
|
+
data-polaris-autocomplete-target="emptyState"
|
10
|
+
class="Polaris-Autocomplete__EmptyState Polaris--hidden"
|
11
|
+
>
|
12
|
+
<%= empty_state %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= polaris_option_list(**option_list_arguments) do |list| %>
|
17
|
+
<% if sections.present? %>
|
18
|
+
<% sections.each do |section| %>
|
19
|
+
<%= section %>
|
20
|
+
<% end %>
|
21
|
+
<% elsif options.present? %>
|
22
|
+
<% options.each do |option| %>
|
23
|
+
<%= option %>
|
24
|
+
<% end %>
|
25
|
+
<% else %>
|
26
|
+
<%= content %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Polaris
|
2
|
+
class AutocompleteComponent < Component
|
3
|
+
renders_one :text_field, ->(**system_arguments) do
|
4
|
+
system_arguments[:data] ||= {}
|
5
|
+
prepend_option(system_arguments[:data], :action, %w[
|
6
|
+
click->polaris-autocomplete#toggle
|
7
|
+
click@window->polaris-popover#hide
|
8
|
+
])
|
9
|
+
|
10
|
+
system_arguments[:input_options] ||= {}
|
11
|
+
system_arguments[:input_options][:data] ||= {}
|
12
|
+
system_arguments[:input_options][:data][:polaris_autocomplete_target] = "input"
|
13
|
+
|
14
|
+
TextFieldComponent.new(**system_arguments)
|
15
|
+
end
|
16
|
+
renders_many :sections, ->(**system_arguments) do
|
17
|
+
Autocomplete::SectionComponent.new(multiple: @multiple, **system_arguments)
|
18
|
+
end
|
19
|
+
renders_many :options, ->(**system_arguments) do
|
20
|
+
Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
|
21
|
+
end
|
22
|
+
renders_one :empty_state
|
23
|
+
|
24
|
+
def initialize(
|
25
|
+
multiple: false,
|
26
|
+
url: nil,
|
27
|
+
selected: [],
|
28
|
+
**system_arguments
|
29
|
+
)
|
30
|
+
@multiple = multiple
|
31
|
+
@url = url
|
32
|
+
@selected = selected
|
33
|
+
@system_arguments = system_arguments
|
34
|
+
end
|
35
|
+
|
36
|
+
def system_arguments
|
37
|
+
@system_arguments.tap do |opts|
|
38
|
+
opts[:tag] = "div"
|
39
|
+
opts[:data] ||= {}
|
40
|
+
opts[:data][:controller] = "polaris-autocomplete"
|
41
|
+
if @url.present?
|
42
|
+
opts[:data][:polaris_autocomplete_url_value] = @url
|
43
|
+
end
|
44
|
+
opts[:data][:polaris_autocomplete_selected_value] = @selected
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def popover_arguments
|
49
|
+
{
|
50
|
+
alignment: :left,
|
51
|
+
full_width: true,
|
52
|
+
inline: false,
|
53
|
+
wrapper_arguments: {
|
54
|
+
data: {polaris_autocomplete_target: "popover"}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def option_list_arguments
|
60
|
+
{
|
61
|
+
data: {polaris_autocomplete_target: "results"}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class AvatarComponent < Polaris::
|
4
|
+
class AvatarComponent < Polaris::Component
|
5
5
|
SIZE_DEFAULT = :medium
|
6
6
|
SIZE_MAPPINGS = {
|
7
7
|
small: "Polaris-Avatar--sizeSmall",
|
8
8
|
medium: "Polaris-Avatar--sizeMedium",
|
9
|
-
large: "Polaris-Avatar--sizeLarge"
|
9
|
+
large: "Polaris-Avatar--sizeLarge"
|
10
10
|
}
|
11
11
|
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
12
12
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class BadgeComponent < Polaris::
|
4
|
+
class BadgeComponent < Polaris::Component
|
5
5
|
PROGRESS_DEFAULT = :default
|
6
6
|
PROGRESS_MAPPINGS = {
|
7
7
|
PROGRESS_DEFAULT => "",
|
@@ -44,7 +44,7 @@ module Polaris
|
|
44
44
|
"Polaris-Badge",
|
45
45
|
PROGRESS_MAPPINGS[fetch_or_fallback(PROGRESS_OPTIONS, progress, PROGRESS_DEFAULT)],
|
46
46
|
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
|
47
|
-
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
|
47
|
+
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class BannerComponent < Polaris::
|
4
|
+
class BannerComponent < Polaris::Component
|
5
5
|
STATUS_DEFAULT = :default
|
6
6
|
STATUS_MAPPINGS = {
|
7
7
|
STATUS_DEFAULT => "",
|
8
8
|
:success => "Polaris-Banner--statusSuccess",
|
9
9
|
:info => "Polaris-Banner--statusInfo",
|
10
10
|
:warning => "Polaris-Banner--statusWarning",
|
11
|
-
:critical => "Polaris-Banner--statusCritical"
|
11
|
+
:critical => "Polaris-Banner--statusCritical"
|
12
12
|
}
|
13
13
|
STATUS_OPTIONS = STATUS_MAPPINGS.keys
|
14
14
|
|
15
15
|
WITHIN_DEFAULT = :page
|
16
16
|
WITHIN_MAPPINGS = {
|
17
17
|
page: "Polaris-Banner--withinPage",
|
18
|
-
container: "Polaris-Banner--withinContentContainer"
|
18
|
+
container: "Polaris-Banner--withinContentContainer"
|
19
19
|
}
|
20
20
|
WITHIN_OPTIONS = WITHIN_MAPPINGS.keys
|
21
21
|
|
@@ -24,14 +24,14 @@ module Polaris
|
|
24
24
|
success: :success,
|
25
25
|
info: :highlight,
|
26
26
|
warning: :warning,
|
27
|
-
critical: :critical
|
27
|
+
critical: :critical
|
28
28
|
}
|
29
29
|
|
30
|
-
renders_one :action, ->
|
30
|
+
renders_one :action, ->(**system_arguments) do
|
31
31
|
Polaris::ButtonComponent.new(classes: "Polaris-Banner__Button", **system_arguments)
|
32
32
|
end
|
33
33
|
renders_one :secondary_action, "SecondaryAction"
|
34
|
-
renders_one :dismiss_button, ->
|
34
|
+
renders_one :dismiss_button, ->(**system_arguments) do
|
35
35
|
render Polaris::ButtonComponent.new(plain: true, **system_arguments) do |button|
|
36
36
|
button.icon(name: "CancelSmallMinor")
|
37
37
|
end
|
@@ -55,7 +55,7 @@ module Polaris
|
|
55
55
|
@system_arguments[:classes],
|
56
56
|
"Polaris-Banner",
|
57
57
|
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)],
|
58
|
-
WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)]
|
58
|
+
WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)]
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
@@ -72,7 +72,7 @@ module Polaris
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
class SecondaryAction < Polaris::
|
75
|
+
class SecondaryAction < Polaris::Component
|
76
76
|
def initialize(**system_arguments)
|
77
77
|
@system_arguments = system_arguments
|
78
78
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class BaseButton < Polaris::
|
4
|
+
class BaseButton < Polaris::Component
|
5
5
|
def initialize(
|
6
6
|
url: nil,
|
7
7
|
external: false,
|
@@ -10,7 +10,7 @@ module Polaris
|
|
10
10
|
**system_arguments
|
11
11
|
)
|
12
12
|
@system_arguments = system_arguments
|
13
|
-
@system_arguments[:tag] = url.present? ?
|
13
|
+
@system_arguments[:tag] = url.present? ? "a" : "button"
|
14
14
|
if loading
|
15
15
|
@system_arguments[:disabled] = true
|
16
16
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Polaris
|
2
|
+
class BaseCheckbox < Polaris::Component
|
3
|
+
def initialize(
|
4
|
+
form: nil,
|
5
|
+
attribute: nil,
|
6
|
+
name: nil,
|
7
|
+
checked: false,
|
8
|
+
disabled: false,
|
9
|
+
value: "1",
|
10
|
+
unchecked_value: "0",
|
11
|
+
**system_arguments
|
12
|
+
)
|
13
|
+
@form = form
|
14
|
+
@attribute = attribute
|
15
|
+
@name = name
|
16
|
+
@checked = checked
|
17
|
+
@disabled = disabled
|
18
|
+
@value = value
|
19
|
+
@unchecked_value = unchecked_value
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
end
|
22
|
+
|
23
|
+
def system_arguments
|
24
|
+
@system_arguments.tap do |opts|
|
25
|
+
opts[:disabled] = true if @disabled
|
26
|
+
opts[:aria] ||= {}
|
27
|
+
opts[:aria][:checked] = @checked
|
28
|
+
if indeterminate?
|
29
|
+
@system_arguments[:indeterminate] = true
|
30
|
+
@system_arguments[:aria][:checked] = "mixed"
|
31
|
+
end
|
32
|
+
opts[:class] = opts.delete(:classes)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def indeterminate?
|
37
|
+
@checked == :indeterminate
|
38
|
+
end
|
39
|
+
|
40
|
+
def call
|
41
|
+
if @form.present? && @attribute.present?
|
42
|
+
@form.check_box(@attribute, system_arguments, @value, @unchecked_value)
|
43
|
+
else
|
44
|
+
check_box_tag(@name, @value, @checked, system_arguments)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Polaris
|
2
|
+
class BaseRadioButton < Polaris::Component
|
3
|
+
def initialize(
|
4
|
+
form: nil,
|
5
|
+
attribute: nil,
|
6
|
+
name: nil,
|
7
|
+
checked: false,
|
8
|
+
disabled: false,
|
9
|
+
value: nil,
|
10
|
+
**system_arguments
|
11
|
+
)
|
12
|
+
@form = form
|
13
|
+
@attribute = attribute
|
14
|
+
@name = name
|
15
|
+
@checked = checked
|
16
|
+
@disabled = disabled
|
17
|
+
@value = value
|
18
|
+
@system_arguments = system_arguments
|
19
|
+
end
|
20
|
+
|
21
|
+
def system_arguments
|
22
|
+
@system_arguments.tap do |opts|
|
23
|
+
opts[:disabled] = true if @disabled
|
24
|
+
opts[:aria] ||= {}
|
25
|
+
opts[:aria][:checked] = @checked
|
26
|
+
opts[:class] = opts.delete(:classes)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def call
|
31
|
+
if @form.present? && @attribute.present?
|
32
|
+
@form.radio_button(@attribute, @value, system_arguments)
|
33
|
+
else
|
34
|
+
radio_button_tag(@name, @value, @checked, system_arguments)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -20,5 +20,18 @@
|
|
20
20
|
<%= content %>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
23
|
+
|
24
|
+
<% if @disclosure.present? %>
|
25
|
+
<div class="Polaris-Button__Icon">
|
26
|
+
<% case @disclosure %>
|
27
|
+
<% when :down %>
|
28
|
+
<%= polaris_icon(name: "CaretDownMinor") %>
|
29
|
+
<% when :up %>
|
30
|
+
<%= polaris_icon(name: "CaretUpMinor") %>
|
31
|
+
<% when :select %>
|
32
|
+
<%= polaris_icon(name: "SelectMinor") %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
23
36
|
</span>
|
24
37
|
<% end %>
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class ButtonGroupComponent < Polaris::
|
4
|
+
class ButtonGroupComponent < Polaris::Component
|
5
5
|
SPACING_DEFAULT = :default
|
6
6
|
SPACING_MAPPINGS = {
|
7
7
|
SPACING_DEFAULT => "",
|
8
8
|
:extra_tight => "Polaris-ButtonGroup--extraTight",
|
9
9
|
:tight => "Polaris-ButtonGroup--tight",
|
10
|
-
:loose => "Polaris-ButtonGroup--loose"
|
10
|
+
:loose => "Polaris-ButtonGroup--loose"
|
11
11
|
}
|
12
12
|
SPACING_OPTIONS = SPACING_MAPPINGS.keys
|
13
13
|
|
14
|
-
renders_many :buttons, ->
|
14
|
+
renders_many :buttons, ->(**system_arguments) do
|
15
15
|
@counter += 1
|
16
16
|
|
17
17
|
ButtonGroupItemButtonComponent.new(position: @counter, **system_arguments)
|
18
18
|
end
|
19
19
|
|
20
|
-
renders_many :items, ->
|
20
|
+
renders_many :items, ->(**system_arguments) do
|
21
21
|
@counter += 1
|
22
22
|
|
23
23
|
ButtonGroupItemComponent.new(position: @counter, **system_arguments)
|
@@ -47,7 +47,7 @@ module Polaris
|
|
47
47
|
"Polaris-ButtonGroup",
|
48
48
|
SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)],
|
49
49
|
"Polaris-ButtonGroup--fullWidth": full_width,
|
50
|
-
"Polaris-ButtonGroup--segmented": segmented
|
50
|
+
"Polaris-ButtonGroup--segmented": segmented
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
@@ -63,7 +63,7 @@ module Polaris
|
|
63
63
|
all_items.sort_by(&:position)
|
64
64
|
end
|
65
65
|
|
66
|
-
class ButtonGroupItemButtonComponent < Polaris::
|
66
|
+
class ButtonGroupItemButtonComponent < Polaris::Component
|
67
67
|
attr_reader :position
|
68
68
|
|
69
69
|
def initialize(position:, **system_arguments)
|
@@ -87,7 +87,7 @@ module Polaris
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
class ButtonGroupItemComponent < Polaris::
|
90
|
+
class ButtonGroupItemComponent < Polaris::Component
|
91
91
|
attr_reader :position
|
92
92
|
|
93
93
|
def initialize(position:, **system_arguments)
|
@@ -97,7 +97,7 @@ module Polaris
|
|
97
97
|
@system_arguments[:tag] = :div
|
98
98
|
@system_arguments[:classes] = class_names(
|
99
99
|
@system_arguments[:classes],
|
100
|
-
"Polaris-ButtonGroup__Item"
|
100
|
+
"Polaris-ButtonGroup__Item"
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|