polaris_view_components 0.5.0 → 0.8.1
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/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 +2400 -1
- data/app/assets/stylesheets/polaris_view_components/custom.css +104 -6
- data/app/assets/stylesheets/polaris_view_components.css +2147 -2021
- 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 +4 -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 +22 -0
- data/app/components/polaris/filters_component.rb +61 -8
- 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 +3 -3
- data/app/components/polaris/index_table/column_component.rb +1 -1
- data/app/components/polaris/index_table_component.rb +4 -4
- data/app/components/polaris/inline_error_component.rb +2 -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 +9 -8
- 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.rb +3 -3
- 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 +4 -4
- 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 +5 -5
- 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 +19 -8
- data/app/helpers/polaris/url_helper.rb +3 -3
- data/app/helpers/polaris/view_helper.rb +24 -4
- data/app/validators/type_validator.rb +2 -2
- data/config/locales/en.yml +6 -0
- 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 +79 -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
@@ -0,0 +1,85 @@
|
|
1
|
+
class Polaris::Navigation::ItemComponent < Polaris::Component
|
2
|
+
renders_many :sub_items, Polaris::Navigation::ItemComponent
|
3
|
+
renders_one :secondary_action, "SecondaryActionComponent"
|
4
|
+
|
5
|
+
attr_reader :selected
|
6
|
+
|
7
|
+
def initialize(
|
8
|
+
url:,
|
9
|
+
label:,
|
10
|
+
icon: nil,
|
11
|
+
badge: nil,
|
12
|
+
selected: false,
|
13
|
+
disabled: false,
|
14
|
+
**system_arguments
|
15
|
+
)
|
16
|
+
@url = url
|
17
|
+
@label = label
|
18
|
+
@icon = icon
|
19
|
+
@badge = badge
|
20
|
+
@selected = selected
|
21
|
+
@disabled = disabled
|
22
|
+
@system_arguments = system_arguments
|
23
|
+
end
|
24
|
+
|
25
|
+
def system_arguments
|
26
|
+
@system_arguments.tap do |opts|
|
27
|
+
opts[:tag] = "li"
|
28
|
+
opts[:classes] = class_names(
|
29
|
+
@system_arguments[:classes],
|
30
|
+
"Polaris-Navigation__ListItem"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def link_classes
|
36
|
+
class_names(
|
37
|
+
"Polaris-Navigation__Item",
|
38
|
+
"Polaris-Navigation__Item--selected": @selected,
|
39
|
+
"Polaris-Navigation--subNavigationActive": @selected || selected_sub_items?,
|
40
|
+
"Polaris-Navigation__Item--disabled": @disabled
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def selected_sub_items?
|
45
|
+
return unless sub_items.present?
|
46
|
+
|
47
|
+
sub_items.any?(&:selected)
|
48
|
+
end
|
49
|
+
|
50
|
+
class SecondaryActionComponent < Polaris::Component
|
51
|
+
def initialize(url: nil, external: false, icon: nil, **system_arguments)
|
52
|
+
@url = url
|
53
|
+
@external = external
|
54
|
+
@icon = icon
|
55
|
+
@system_arguments = system_arguments
|
56
|
+
end
|
57
|
+
|
58
|
+
def system_arguments
|
59
|
+
@system_arguments.tap do |opts|
|
60
|
+
if @url.present?
|
61
|
+
opts[:tag] = "a"
|
62
|
+
opts[:href] = @url
|
63
|
+
opts[:target] = "_blank" if @external
|
64
|
+
else
|
65
|
+
opts[:tag] = "button"
|
66
|
+
opts[:type] = "button"
|
67
|
+
end
|
68
|
+
opts[:classes] = class_names(
|
69
|
+
@system_arguments[:classes],
|
70
|
+
"Polaris-Navigation__SecondaryAction"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def call
|
76
|
+
render(Polaris::BaseComponent.new(**system_arguments)) do
|
77
|
+
if @icon.present?
|
78
|
+
render(Polaris::IconComponent.new(name: @icon))
|
79
|
+
else
|
80
|
+
content
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
2
|
+
<% if items.present? %>
|
3
|
+
<% if @title.present? %>
|
4
|
+
<li class="Polaris-Navigation__SectionHeading">
|
5
|
+
<span class="Polaris-Navigation__Text">
|
6
|
+
<%= @title %>
|
7
|
+
</span>
|
8
|
+
<%= action %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
<% items.each do |item| %>
|
12
|
+
<%= item %>
|
13
|
+
<% end %>
|
14
|
+
<% else %>
|
15
|
+
<%= content %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Polaris::Navigation::SectionComponent < Polaris::Component
|
2
|
+
renders_many :items, Polaris::Navigation::ItemComponent
|
3
|
+
renders_one :action, "ActionComponent"
|
4
|
+
|
5
|
+
def initialize(
|
6
|
+
title: nil,
|
7
|
+
separator: false,
|
8
|
+
fill: false,
|
9
|
+
**system_arguments
|
10
|
+
)
|
11
|
+
@title = title
|
12
|
+
@separator = separator
|
13
|
+
@fill = fill
|
14
|
+
@system_arguments = system_arguments
|
15
|
+
end
|
16
|
+
|
17
|
+
def system_arguments
|
18
|
+
@system_arguments.tap do |opts|
|
19
|
+
opts[:tag] = "ul"
|
20
|
+
opts[:classes] = class_names(
|
21
|
+
@system_arguments[:classes],
|
22
|
+
"Polaris-Navigation__Section",
|
23
|
+
"Polaris-Navigation__Section--fill": @fill,
|
24
|
+
"Polaris-Navigation__Section--withSeparator": @separator
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class ActionComponent < Polaris::Component
|
30
|
+
def initialize(url: nil, external: false, icon: nil, **system_arguments)
|
31
|
+
@url = url
|
32
|
+
@external = external
|
33
|
+
@icon = icon
|
34
|
+
@system_arguments = system_arguments
|
35
|
+
end
|
36
|
+
|
37
|
+
def system_arguments
|
38
|
+
@system_arguments.tap do |opts|
|
39
|
+
if @url.present?
|
40
|
+
opts[:tag] = "a"
|
41
|
+
opts[:href] = @url
|
42
|
+
opts[:target] = "_blank" if @external
|
43
|
+
else
|
44
|
+
opts[:tag] = "button"
|
45
|
+
opts[:type] = "button"
|
46
|
+
end
|
47
|
+
opts[:classes] = class_names(
|
48
|
+
@system_arguments[:classes],
|
49
|
+
"Polaris-Navigation__Action"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def call
|
55
|
+
render(Polaris::BaseComponent.new(**system_arguments)) do
|
56
|
+
if @icon.present?
|
57
|
+
render(Polaris::IconComponent.new(name: @icon))
|
58
|
+
else
|
59
|
+
content
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<nav class="Polaris-Navigation">
|
2
|
+
<% if @logo.present? %>
|
3
|
+
<div class="Polaris-Navigation__LogoContainer">
|
4
|
+
<%= link_to(@logo.url,
|
5
|
+
class: "Polaris-Navigation__LogoLink",
|
6
|
+
style: "width: #{@logo.width}"
|
7
|
+
) do %>
|
8
|
+
<%= image_tag @logo.src,
|
9
|
+
class: "Polaris-Navigation__Logo",
|
10
|
+
style: "width: #{@logo.width}",
|
11
|
+
alt: @logo.alt %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= polaris_scrollable(classes: "Polaris-Navigation__PrimaryNavigation") do %>
|
17
|
+
<% if sections.present? %>
|
18
|
+
<% sections.each do |section| %>
|
19
|
+
<%= section %>
|
20
|
+
<% end %>
|
21
|
+
<% else %>
|
22
|
+
<%= render(Polaris::Navigation::SectionComponent.new) do %>
|
23
|
+
<% items.each do |item| %>
|
24
|
+
<%= item %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
</nav>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Polaris
|
2
|
+
class NavigationComponent < Polaris::Component
|
3
|
+
renders_many :sections, Polaris::Navigation::SectionComponent
|
4
|
+
renders_many :items, Polaris::Navigation::ItemComponent
|
5
|
+
|
6
|
+
def initialize(logo: nil, **system_arguments)
|
7
|
+
@logo = logo.is_a?(Hash) ? Polaris::Logo.new(**logo) : logo
|
8
|
+
@system_arguments = system_arguments
|
9
|
+
end
|
10
|
+
|
11
|
+
def renders?
|
12
|
+
sections.any? || items.any?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %>
|
2
|
+
<label class="Polaris-OptionList-Option__Label">
|
3
|
+
<div class="Polaris-OptionList-Option__Checkbox">
|
4
|
+
<div class="Polaris-OptionList-Checkbox">
|
5
|
+
<%= checkbox %>
|
6
|
+
<div class="Polaris-OptionList-Checkbox__Backdrop"></div>
|
7
|
+
<div class="Polaris-OptionList-Checkbox__Icon">
|
8
|
+
<%= polaris_icon(name: "TickMinor") %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<%= @label %>
|
13
|
+
</label>
|
14
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Polaris::OptionList::CheckboxComponent < Polaris::Component
|
2
|
+
def initialize(
|
3
|
+
label:,
|
4
|
+
value:,
|
5
|
+
wrapper_arguments: {},
|
6
|
+
**system_arguments
|
7
|
+
)
|
8
|
+
@label = label
|
9
|
+
@value = value
|
10
|
+
@wrapper_arguments = wrapper_arguments
|
11
|
+
@system_arguments = system_arguments
|
12
|
+
end
|
13
|
+
|
14
|
+
def wrapper_arguments
|
15
|
+
@wrapper_arguments.tap do |opts|
|
16
|
+
opts[:tag] = "li"
|
17
|
+
opts[:tabindex] = "-1"
|
18
|
+
opts[:classes] = class_names(
|
19
|
+
@wrapper_arguments[:classes],
|
20
|
+
"Polaris-OptionList-Option"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def system_arguments
|
26
|
+
@system_arguments.tap do |opts|
|
27
|
+
opts[:classes] = class_names(
|
28
|
+
@system_arguments[:classes],
|
29
|
+
"Polaris-OptionList-Checkbox__Input"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def checkbox
|
35
|
+
render Polaris::BaseCheckbox.new(value: @value, **system_arguments)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Polaris::OptionList::OptionComponent < Polaris::Component
|
2
|
+
def initialize(**system_arguments)
|
3
|
+
@system_arguments = system_arguments
|
4
|
+
end
|
5
|
+
|
6
|
+
def system_arguments
|
7
|
+
@system_arguments.tap do |opts|
|
8
|
+
opts[:tag] = "li"
|
9
|
+
opts[:tabindex] = "-1"
|
10
|
+
opts[:classes] = class_names(
|
11
|
+
@system_arguments[:classes],
|
12
|
+
"Polaris-OptionList-Option"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
render(Polaris::BaseComponent.new(**system_arguments)) do
|
19
|
+
tag.label(class: "Polaris-OptionList-Option__Label") do
|
20
|
+
content
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Polaris::OptionList::RadioButtonComponent < Polaris::Component
|
2
|
+
def initialize(
|
3
|
+
label:,
|
4
|
+
value:,
|
5
|
+
wrapper_arguments: {},
|
6
|
+
**system_arguments
|
7
|
+
)
|
8
|
+
@label = label
|
9
|
+
@value = value
|
10
|
+
@wrapper_arguments = wrapper_arguments
|
11
|
+
@system_arguments = system_arguments
|
12
|
+
end
|
13
|
+
|
14
|
+
def wrapper_arguments
|
15
|
+
@wrapper_arguments.tap do |opts|
|
16
|
+
opts[:tag] = "li"
|
17
|
+
opts[:tabindex] = "-1"
|
18
|
+
opts[:classes] = class_names(
|
19
|
+
@wrapper_arguments[:classes],
|
20
|
+
"Polaris-OptionList-Option"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def system_arguments
|
26
|
+
@system_arguments.tap do |opts|
|
27
|
+
opts[:classes] = class_names(
|
28
|
+
@system_arguments[:classes],
|
29
|
+
"Polaris--hidden"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
render(Polaris::BaseComponent.new(**wrapper_arguments)) do
|
36
|
+
tag.label(
|
37
|
+
class: "Polaris-OptionList-Option__SingleSelectOption",
|
38
|
+
data: {
|
39
|
+
polaris_option_list_target: "radioButton",
|
40
|
+
action: "click->polaris-option-list#update"
|
41
|
+
}
|
42
|
+
) do
|
43
|
+
safe_join [
|
44
|
+
radio_button,
|
45
|
+
@label
|
46
|
+
]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def radio_button
|
52
|
+
render Polaris::BaseRadioButton.new(value: @value, **system_arguments)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<li>
|
2
|
+
<% if @title.present? %>
|
3
|
+
<p class="Polaris-OptionList__Title"><%= @title %></p>
|
4
|
+
<% end %>
|
5
|
+
<ul class="Polaris-OptionList__Options">
|
6
|
+
<% if items.present? %>
|
7
|
+
<% items.each do |item| %>
|
8
|
+
<%= item %>
|
9
|
+
<% end %>
|
10
|
+
<% else %>
|
11
|
+
<%= content %>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</li>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Polaris::OptionList::SectionComponent < Polaris::Component
|
2
|
+
renders_many :options, Polaris::OptionList::OptionComponent
|
3
|
+
renders_many :radio_buttons, ->(value:, **system_arguments) do
|
4
|
+
Polaris::OptionList::RadioButtonComponent.new(
|
5
|
+
form: @form,
|
6
|
+
attribute: @attribute,
|
7
|
+
name: @name,
|
8
|
+
value: value,
|
9
|
+
checked: @selected.include?(value),
|
10
|
+
**system_arguments
|
11
|
+
)
|
12
|
+
end
|
13
|
+
renders_many :checkboxes, ->(value:, **system_arguments) do
|
14
|
+
Polaris::OptionList::CheckboxComponent.new(
|
15
|
+
form: @form,
|
16
|
+
attribute: @attribute,
|
17
|
+
name: @name && "#{@name}[]",
|
18
|
+
value: value,
|
19
|
+
checked: @selected.include?(value),
|
20
|
+
**system_arguments
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(
|
25
|
+
title: nil,
|
26
|
+
form: nil,
|
27
|
+
attribute: nil,
|
28
|
+
name: nil,
|
29
|
+
selected: [],
|
30
|
+
**system_arguments
|
31
|
+
)
|
32
|
+
@title = title
|
33
|
+
@form = form
|
34
|
+
@attribute = attribute
|
35
|
+
@name = name
|
36
|
+
@selected = selected
|
37
|
+
@system_arguments = system_arguments
|
38
|
+
end
|
39
|
+
|
40
|
+
def system_arguments
|
41
|
+
@system_arguments.tap do |opts|
|
42
|
+
opts[:tag] = "ul"
|
43
|
+
opts[:classes] = class_names(
|
44
|
+
@system_arguments[:classes],
|
45
|
+
"Polaris-OptionList__Options"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def items
|
51
|
+
radio_buttons.presence || checkboxes.presence || options
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
2
|
+
<% if sections.present? %>
|
3
|
+
<% sections.each do |section| %>
|
4
|
+
<%= section %>
|
5
|
+
<% end %>
|
6
|
+
<% elsif items.present? %>
|
7
|
+
<%= render(Polaris::OptionList::SectionComponent.new(title: @title)) do %>
|
8
|
+
<% items.each do |item| %>
|
9
|
+
<%= item %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<% else %>
|
13
|
+
<%= content %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Polaris
|
2
|
+
class OptionListComponent < Polaris::Component
|
3
|
+
renders_many :sections, ->(**system_arguments) do
|
4
|
+
Polaris::OptionList::SectionComponent.new(
|
5
|
+
form: @form,
|
6
|
+
attribute: @attribute,
|
7
|
+
name: @name,
|
8
|
+
selected: @selected,
|
9
|
+
**system_arguments
|
10
|
+
)
|
11
|
+
end
|
12
|
+
renders_many :options, Polaris::OptionList::OptionComponent
|
13
|
+
renders_many :radio_buttons, ->(value:, **system_arguments) do
|
14
|
+
Polaris::OptionList::RadioButtonComponent.new(
|
15
|
+
form: @form,
|
16
|
+
attribute: @attribute,
|
17
|
+
name: @name,
|
18
|
+
value: value,
|
19
|
+
checked: @selected.include?(value),
|
20
|
+
**system_arguments
|
21
|
+
)
|
22
|
+
end
|
23
|
+
renders_many :checkboxes, ->(value:, **system_arguments) do
|
24
|
+
Polaris::OptionList::CheckboxComponent.new(
|
25
|
+
form: @form,
|
26
|
+
attribute: @attribute,
|
27
|
+
name: @name && "#{@name}[]",
|
28
|
+
value: value,
|
29
|
+
checked: @selected.include?(value),
|
30
|
+
**system_arguments
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(
|
35
|
+
title: nil,
|
36
|
+
form: nil,
|
37
|
+
attribute: nil,
|
38
|
+
name: nil,
|
39
|
+
selected: [],
|
40
|
+
**system_arguments
|
41
|
+
)
|
42
|
+
@title = title
|
43
|
+
@form = form
|
44
|
+
@attribute = attribute
|
45
|
+
@name = name
|
46
|
+
@selected = selected
|
47
|
+
@system_arguments = system_arguments
|
48
|
+
end
|
49
|
+
|
50
|
+
def system_arguments
|
51
|
+
@system_arguments.tap do |opts|
|
52
|
+
opts[:tag] = "ul"
|
53
|
+
opts[:data] ||= {}
|
54
|
+
prepend_option(opts[:data], :controller, "polaris-option-list")
|
55
|
+
opts[:data][:polaris_option_list_selected_class] = "Polaris-OptionList-Option--select"
|
56
|
+
opts[:classes] = class_names(
|
57
|
+
@system_arguments[:classes],
|
58
|
+
"Polaris-OptionList"
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def items
|
64
|
+
radio_buttons.presence || checkboxes.presence || options
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class PageActionsComponent < Polaris::
|
4
|
+
class PageActionsComponent < Polaris::Component
|
5
5
|
DISTRIBUTION_DEFAULT = nil
|
6
6
|
DISTRIBUTION_OPTIONS = [
|
7
7
|
DISTRIBUTION_DEFAULT,
|
@@ -10,10 +10,10 @@ module Polaris
|
|
10
10
|
:trailing,
|
11
11
|
:center,
|
12
12
|
:fill,
|
13
|
-
:fill_evenly
|
13
|
+
:fill_evenly
|
14
14
|
]
|
15
15
|
|
16
|
-
renders_one :primary_action, ->
|
16
|
+
renders_one :primary_action, ->(primary: true, **system_arguments) do
|
17
17
|
Polaris::ButtonComponent.new(primary: primary, **system_arguments)
|
18
18
|
end
|
19
19
|
renders_many :secondary_actions, Polaris::ButtonComponent
|
@@ -24,15 +24,16 @@ module Polaris
|
|
24
24
|
@system_arguments[:tag] = "div"
|
25
25
|
@system_arguments[:classes] = class_names(
|
26
26
|
@system_arguments[:classes],
|
27
|
-
"Polaris-PageActions"
|
27
|
+
"Polaris-PageActions"
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
|
-
def stack_distribution
|
33
|
-
return @distribution if @distribution.present?
|
34
32
|
|
35
|
-
|
36
|
-
|
33
|
+
def stack_distribution
|
34
|
+
return @distribution if @distribution.present?
|
35
|
+
|
36
|
+
primary_action.present? && secondary_actions.any? ? :equal_spacing : :trailing
|
37
|
+
end
|
37
38
|
end
|
38
39
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class PageComponent < Polaris::
|
5
|
-
renders_one :primary_action, ->
|
4
|
+
class PageComponent < Polaris::Component
|
5
|
+
renders_one :primary_action, ->(primary: true, **system_arguments) do
|
6
6
|
Polaris::ButtonComponent.new(primary: primary, **system_arguments)
|
7
7
|
end
|
8
8
|
# renders_many :secondary_actions, Polaris::ButtonComponent
|
@@ -28,7 +28,7 @@ module Polaris
|
|
28
28
|
@system_arguments[:classes],
|
29
29
|
"Polaris-Page",
|
30
30
|
"Polaris-Page--narrowWidth": narrow_width,
|
31
|
-
"Polaris-Page--fullWidth": full_width
|
31
|
+
"Polaris-Page--fullWidth": full_width
|
32
32
|
)
|
33
33
|
|
34
34
|
@header_arguments = {}
|
@@ -38,14 +38,14 @@ module Polaris
|
|
38
38
|
"Polaris-Page-Header--mobileView",
|
39
39
|
"Polaris-Page-Header--mediumTitle",
|
40
40
|
"Polaris-Page-Header--hasNavigation": back_url.present?,
|
41
|
-
"Polaris-Page-Header--noBreadcrumbs": back_url.blank
|
41
|
+
"Polaris-Page-Header--noBreadcrumbs": back_url.blank?
|
42
42
|
)
|
43
43
|
|
44
44
|
@content_arguments = {}
|
45
45
|
@content_arguments[:tag] = "div"
|
46
46
|
@content_arguments[:classes] = class_names(
|
47
47
|
"Polaris-Page__Content",
|
48
|
-
"Polaris-Page--divider": divider
|
48
|
+
"Polaris-Page--divider": divider
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Polaris
|
4
|
-
class PaginationComponent < Polaris::
|
4
|
+
class PaginationComponent < Polaris::Component
|
5
5
|
def initialize(
|
6
6
|
previous_url: nil,
|
7
7
|
next_url: nil,
|
@@ -16,11 +16,7 @@ module Polaris
|
|
16
16
|
@system_arguments["aria-label"] = "Pagination"
|
17
17
|
|
18
18
|
@button_group_arguments = {}
|
19
|
-
|
20
|
-
@button_group_arguments[:segmented] = false
|
21
|
-
else
|
22
|
-
@button_group_arguments[:segmented] = true
|
23
|
-
end
|
19
|
+
@button_group_arguments[:segmented] = !label.present?
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<% pane_content = capture do %>
|
2
|
+
<% if sections.present? %>
|
3
|
+
<% sections.each do |section| %>
|
4
|
+
<%= section %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if @sectioned %>
|
9
|
+
<%= render Polaris::Popover::SectionComponent.new do %>
|
10
|
+
<%= content %>
|
11
|
+
<% end %>
|
12
|
+
<% else %>
|
13
|
+
<%= content %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if @fixed %>
|
18
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
19
|
+
<%= pane_content %>
|
20
|
+
<% end %>
|
21
|
+
<% else %>
|
22
|
+
<%= render Polaris::ScrollableComponent.new(shadow: true, **system_arguments) do %>
|
23
|
+
<%= pane_content %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Polaris::Popover::PaneComponent < Polaris::Component
|
2
|
+
renders_many :sections, Polaris::Popover::SectionComponent
|
3
|
+
|
4
|
+
def initialize(fixed: false, sectioned: false, **system_arguments)
|
5
|
+
@fixed = fixed
|
6
|
+
@sectioned = sectioned
|
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-Popover__Pane",
|
16
|
+
"Polaris-Popover__Pane--fixed": @fixed
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Polaris::Popover::SectionComponent < Polaris::Component
|
2
|
+
def initialize(**system_arguments)
|
3
|
+
@system_arguments = system_arguments
|
4
|
+
end
|
5
|
+
|
6
|
+
def system_arguments
|
7
|
+
@system_arguments.tap do |opts|
|
8
|
+
opts[:tag] = "div"
|
9
|
+
opts[:classes] = class_names(
|
10
|
+
@system_arguments[:classes],
|
11
|
+
"Polaris-Popover__Section"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
render(Polaris::BaseComponent.new(**system_arguments)) { content }
|
18
|
+
end
|
19
|
+
end
|