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.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -2
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +136 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +495 -0
  6. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  7. data/app/assets/javascripts/polaris_view_components/index.js +21 -1
  8. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  9. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  10. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  11. data/app/assets/javascripts/polaris_view_components/popover_controller.js +56 -0
  12. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  13. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  14. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  15. data/app/assets/javascripts/polaris_view_components/utils.js +23 -0
  16. data/app/assets/javascripts/polaris_view_components.js +2400 -1
  17. data/app/assets/stylesheets/polaris_view_components/custom.css +104 -6
  18. data/app/assets/stylesheets/polaris_view_components.css +2147 -2021
  19. data/app/assets/stylesheets/polaris_view_components.postcss.css +1 -1
  20. data/app/components/polaris/action.rb +3 -3
  21. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  22. data/app/components/polaris/action_list/item_component.rb +41 -0
  23. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  24. data/app/components/polaris/action_list/section_component.rb +26 -0
  25. data/app/components/polaris/action_list_component.html.erb +13 -0
  26. data/app/components/polaris/action_list_component.rb +25 -0
  27. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  28. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  29. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  30. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  31. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  32. data/app/components/polaris/autocomplete_component.rb +65 -0
  33. data/app/components/polaris/avatar_component.rb +2 -2
  34. data/app/components/polaris/badge_component.rb +2 -2
  35. data/app/components/polaris/banner_component.rb +8 -8
  36. data/app/components/polaris/base_button.rb +2 -2
  37. data/app/components/polaris/base_checkbox.rb +48 -0
  38. data/app/components/polaris/base_component.rb +1 -1
  39. data/app/components/polaris/base_radio_button.rb +38 -0
  40. data/app/components/polaris/button_component.html.erb +13 -0
  41. data/app/components/polaris/button_group_component.rb +8 -8
  42. data/app/components/polaris/callout_card_component.rb +6 -6
  43. data/app/components/polaris/caption_component.rb +3 -3
  44. data/app/components/polaris/card/header_component.rb +2 -2
  45. data/app/components/polaris/card/section_component.rb +4 -4
  46. data/app/components/polaris/card_component.html.erb +4 -0
  47. data/app/components/polaris/card_component.rb +6 -5
  48. data/app/components/polaris/character_count.rb +10 -10
  49. data/app/components/polaris/checkbox_component.html.erb +1 -5
  50. data/app/components/polaris/checkbox_component.rb +20 -13
  51. data/app/components/polaris/choice_component.rb +2 -2
  52. data/app/components/polaris/choice_list_component.rb +6 -6
  53. data/app/components/polaris/component.rb +6 -1
  54. data/app/components/polaris/data_table/cell_component.rb +4 -4
  55. data/app/components/polaris/data_table/column_component.rb +1 -1
  56. data/app/components/polaris/data_table_component.rb +4 -4
  57. data/app/components/polaris/description_list_component.rb +5 -5
  58. data/app/components/polaris/display_text_component.rb +3 -3
  59. data/app/components/polaris/dropzone_component.html.erb +156 -0
  60. data/app/components/polaris/dropzone_component.rb +150 -0
  61. data/app/components/polaris/empty_state_component.rb +4 -4
  62. data/app/components/polaris/exception_list/item_component.rb +3 -3
  63. data/app/components/polaris/exception_list_component.rb +2 -2
  64. data/app/components/polaris/filters_component.html.erb +22 -0
  65. data/app/components/polaris/filters_component.rb +61 -8
  66. data/app/components/polaris/footer_help_component.rb +2 -2
  67. data/app/components/polaris/form_layout/group_component.rb +5 -5
  68. data/app/components/polaris/form_layout/item_component.rb +2 -2
  69. data/app/components/polaris/form_layout_component.rb +4 -4
  70. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  71. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  72. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  73. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  74. data/app/components/polaris/frame_component.html.erb +44 -0
  75. data/app/components/polaris/frame_component.rb +33 -0
  76. data/app/components/polaris/heading_component.rb +2 -2
  77. data/app/components/polaris/headless_button.html.erb +13 -0
  78. data/app/components/polaris/headless_button.rb +18 -6
  79. data/app/components/polaris/icon_component.rb +3 -3
  80. data/app/components/polaris/index_table/cell_component.rb +3 -3
  81. data/app/components/polaris/index_table/column_component.rb +1 -1
  82. data/app/components/polaris/index_table_component.rb +4 -4
  83. data/app/components/polaris/inline_error_component.rb +2 -2
  84. data/app/components/polaris/label_component.rb +3 -3
  85. data/app/components/polaris/labelled_component.rb +3 -3
  86. data/app/components/polaris/layout/annotated_section.rb +2 -2
  87. data/app/components/polaris/layout/section.rb +2 -2
  88. data/app/components/polaris/layout_component.rb +4 -4
  89. data/app/components/polaris/link_component.rb +4 -4
  90. data/app/components/polaris/list_component.rb +5 -5
  91. data/app/components/polaris/logo.rb +13 -0
  92. data/app/components/polaris/modal/section_component.rb +19 -0
  93. data/app/components/polaris/modal_component.html.erb +79 -0
  94. data/app/components/polaris/modal_component.rb +98 -0
  95. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  96. data/app/components/polaris/navigation/item_component.rb +85 -0
  97. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  98. data/app/components/polaris/navigation/section_component.rb +64 -0
  99. data/app/components/polaris/navigation_component.html.erb +29 -0
  100. data/app/components/polaris/navigation_component.rb +15 -0
  101. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  102. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  103. data/app/components/polaris/option_list/option_component.rb +24 -0
  104. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  105. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/section_component.rb +53 -0
  107. data/app/components/polaris/option_list_component.html.erb +15 -0
  108. data/app/components/polaris/option_list_component.rb +67 -0
  109. data/app/components/polaris/page_actions_component.rb +9 -8
  110. data/app/components/polaris/page_component.rb +5 -5
  111. data/app/components/polaris/pagination_component.rb +2 -6
  112. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  113. data/app/components/polaris/popover/pane_component.rb +20 -0
  114. data/app/components/polaris/popover/section_component.rb +19 -0
  115. data/app/components/polaris/popover_component.html.erb +31 -0
  116. data/app/components/polaris/popover_component.rb +113 -0
  117. data/app/components/polaris/progress_bar_component.rb +6 -6
  118. data/app/components/polaris/radio_button_component.html.erb +1 -6
  119. data/app/components/polaris/radio_button_component.rb +18 -8
  120. data/app/components/polaris/resource_item_component.html.erb +16 -6
  121. data/app/components/polaris/resource_item_component.rb +43 -10
  122. data/app/components/polaris/resource_list_component.rb +3 -3
  123. data/app/components/polaris/scrollable_component.html.erb +5 -0
  124. data/app/components/polaris/scrollable_component.rb +48 -0
  125. data/app/components/polaris/select_component.rb +4 -4
  126. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  127. data/app/components/polaris/setting_toggle_component.rb +24 -0
  128. data/app/components/polaris/shopify_navigation_component.rb +8 -8
  129. data/app/components/polaris/skeleton_body_text_component.rb +2 -2
  130. data/app/components/polaris/spacer_component.rb +4 -4
  131. data/app/components/polaris/spinner_component.rb +3 -3
  132. data/app/components/polaris/stack/item_component.rb +15 -0
  133. data/app/components/polaris/stack_component.rb +6 -22
  134. data/app/components/polaris/subheading_component.rb +2 -2
  135. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  136. data/app/components/polaris/tabs/tab_component.rb +34 -0
  137. data/app/components/polaris/tabs_component.html.erb +7 -0
  138. data/app/components/polaris/tabs_component.rb +37 -0
  139. data/app/components/polaris/tag_component.rb +3 -2
  140. data/app/components/polaris/text_container_component.rb +3 -3
  141. data/app/components/polaris/text_field_component.rb +25 -11
  142. data/app/components/polaris/text_style_component.rb +5 -5
  143. data/app/components/polaris/thumbnail_component.rb +3 -3
  144. data/app/components/polaris/toast_component.html.erb +21 -0
  145. data/app/components/polaris/toast_component.rb +40 -0
  146. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  147. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  148. data/app/components/polaris/visually_hidden_component.rb +1 -1
  149. data/app/helpers/polaris/form_builder.rb +19 -8
  150. data/app/helpers/polaris/url_helper.rb +3 -3
  151. data/app/helpers/polaris/view_helper.rb +24 -4
  152. data/app/validators/type_validator.rb +2 -2
  153. data/config/locales/en.yml +6 -0
  154. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  155. data/lib/polaris/view_components/engine.rb +16 -2
  156. data/lib/polaris/view_components/version.rb +1 -1
  157. data/lib/polaris_view_components.rb +1 -1
  158. metadata +79 -16
  159. data/app/components/polaris/application_component.rb +0 -35
  160. data/app/components/polaris/dropzone/component.html.erb +0 -72
  161. data/app/components/polaris/dropzone/component.rb +0 -128
  162. data/app/components/polaris/dropzone/controller.js +0 -226
  163. data/app/components/polaris/dropzone/utils.js +0 -57
  164. data/app/components/polaris/new_component.rb +0 -10
  165. 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::NewComponent
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, -> (primary: true, **system_arguments) do
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
- (primary_action.present? && secondary_actions.any?) ? :equal_spacing : :trailing
36
- end
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::NewComponent
5
- renders_one :primary_action, -> (primary: true, **system_arguments) do
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::NewComponent
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
- if label.present?
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