polaris_view_components 0.3.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  6. data/app/assets/javascripts/polaris_view_components/index.js +19 -1
  7. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  8. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  9. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  10. data/app/assets/javascripts/polaris_view_components/popover_controller.js +49 -0
  11. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  12. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  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.js +1936 -5
  16. data/app/assets/stylesheets/polaris_view_components/custom.css +109 -0
  17. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  18. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  19. data/app/assets/stylesheets/polaris_view_components.css +118 -3
  20. data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
  21. data/app/components/polaris/action.rb +3 -3
  22. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  23. data/app/components/polaris/action_list/item_component.rb +41 -0
  24. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  25. data/app/components/polaris/action_list/section_component.rb +26 -0
  26. data/app/components/polaris/action_list_component.html.erb +13 -0
  27. data/app/components/polaris/action_list_component.rb +25 -0
  28. data/app/components/polaris/application_component.rb +19 -19
  29. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  30. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  31. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  32. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  33. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  34. data/app/components/polaris/autocomplete_component.rb +58 -0
  35. data/app/components/polaris/avatar_component.rb +1 -1
  36. data/app/components/polaris/badge_component.rb +1 -1
  37. data/app/components/polaris/banner_component.rb +6 -6
  38. data/app/components/polaris/base_button.rb +1 -1
  39. data/app/components/polaris/base_checkbox.rb +48 -0
  40. data/app/components/polaris/base_radio_button.rb +38 -0
  41. data/app/components/polaris/button_component.html.erb +13 -0
  42. data/app/components/polaris/button_group_component.rb +5 -5
  43. data/app/components/polaris/callout_card_component.rb +5 -5
  44. data/app/components/polaris/caption_component.rb +2 -2
  45. data/app/components/polaris/card/header_component.rb +1 -3
  46. data/app/components/polaris/card/section_component.rb +6 -2
  47. data/app/components/polaris/card_component.html.erb +4 -0
  48. data/app/components/polaris/card_component.rb +5 -6
  49. data/app/components/polaris/character_count.rb +10 -10
  50. data/app/components/polaris/checkbox_component.html.erb +1 -5
  51. data/app/components/polaris/checkbox_component.rb +19 -12
  52. data/app/components/polaris/choice_component.rb +1 -1
  53. data/app/components/polaris/choice_list_component.rb +5 -5
  54. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  55. data/app/components/polaris/data_table/cell_component.rb +49 -0
  56. data/app/components/polaris/data_table/column_component.rb +19 -0
  57. data/app/components/polaris/data_table_component.html.erb +77 -0
  58. data/app/components/polaris/data_table_component.rb +42 -0
  59. data/app/components/polaris/description_list_component.rb +3 -3
  60. data/app/components/polaris/display_text_component.rb +2 -2
  61. data/app/components/polaris/dropzone/component.rb +36 -38
  62. data/app/components/polaris/empty_state_component.html.erb +16 -11
  63. data/app/components/polaris/empty_state_component.rb +4 -3
  64. data/app/components/polaris/exception_list/item_component.rb +2 -2
  65. data/app/components/polaris/exception_list_component.rb +1 -1
  66. data/app/components/polaris/filters_component.html.erb +35 -0
  67. data/app/components/polaris/filters_component.rb +91 -0
  68. data/app/components/polaris/footer_help_component.rb +1 -1
  69. data/app/components/polaris/form_layout/group_component.rb +3 -3
  70. data/app/components/polaris/form_layout/item_component.rb +1 -1
  71. data/app/components/polaris/form_layout_component.rb +3 -3
  72. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  73. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  74. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  75. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  76. data/app/components/polaris/frame_component.html.erb +44 -0
  77. data/app/components/polaris/frame_component.rb +33 -0
  78. data/app/components/polaris/heading_component.rb +1 -1
  79. data/app/components/polaris/headless_button.html.erb +13 -0
  80. data/app/components/polaris/headless_button.rb +17 -5
  81. data/app/components/polaris/icon_component.rb +2 -2
  82. data/app/components/polaris/index_table/cell_component.rb +22 -0
  83. data/app/components/polaris/index_table/column_component.rb +13 -0
  84. data/app/components/polaris/index_table_component.html.erb +28 -0
  85. data/app/components/polaris/index_table_component.rb +25 -0
  86. data/app/components/polaris/inline_error_component.html.erb +2 -2
  87. data/app/components/polaris/inline_error_component.rb +7 -1
  88. data/app/components/polaris/label_component.rb +2 -2
  89. data/app/components/polaris/labelled_component.rb +2 -2
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +2 -0
  92. data/app/components/polaris/layout_component.rb +3 -3
  93. data/app/components/polaris/link_component.rb +5 -3
  94. data/app/components/polaris/list_component.rb +3 -3
  95. data/app/components/polaris/logo.rb +13 -0
  96. data/app/components/polaris/modal/section_component.rb +19 -0
  97. data/app/components/polaris/modal_component.html.erb +79 -0
  98. data/app/components/polaris/modal_component.rb +98 -0
  99. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  100. data/app/components/polaris/navigation/item_component.rb +85 -0
  101. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  102. data/app/components/polaris/navigation/section_component.rb +64 -0
  103. data/app/components/polaris/navigation_component.html.erb +29 -0
  104. data/app/components/polaris/navigation_component.rb +15 -0
  105. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  107. data/app/components/polaris/option_list/option_component.rb +24 -0
  108. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  109. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  110. data/app/components/polaris/option_list/section_component.rb +53 -0
  111. data/app/components/polaris/option_list_component.html.erb +15 -0
  112. data/app/components/polaris/option_list_component.rb +67 -0
  113. data/app/components/polaris/page_actions_component.rb +21 -6
  114. data/app/components/polaris/page_component.rb +4 -4
  115. data/app/components/polaris/pagination_component.rb +1 -5
  116. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  117. data/app/components/polaris/popover/pane_component.rb +20 -0
  118. data/app/components/polaris/popover/section_component.rb +19 -0
  119. data/app/components/polaris/popover_component.html.erb +31 -0
  120. data/app/components/polaris/popover_component.rb +107 -0
  121. data/app/components/polaris/progress_bar_component.rb +5 -5
  122. data/app/components/polaris/radio_button_component.html.erb +1 -6
  123. data/app/components/polaris/radio_button_component.rb +17 -7
  124. data/app/components/polaris/resource_item_component.html.erb +16 -6
  125. data/app/components/polaris/resource_item_component.rb +42 -9
  126. data/app/components/polaris/resource_list_component.html.erb +10 -0
  127. data/app/components/polaris/resource_list_component.rb +4 -10
  128. data/app/components/polaris/scrollable_component.html.erb +5 -0
  129. data/app/components/polaris/scrollable_component.rb +48 -0
  130. data/app/components/polaris/select_component.rb +10 -5
  131. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  132. data/app/components/polaris/setting_toggle_component.rb +24 -0
  133. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  134. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  135. data/app/components/polaris/spacer_component.rb +50 -0
  136. data/app/components/polaris/spinner_component.rb +2 -2
  137. data/app/components/polaris/stack_component.rb +5 -5
  138. data/app/components/polaris/subheading_component.rb +1 -1
  139. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  140. data/app/components/polaris/tabs/tab_component.rb +34 -0
  141. data/app/components/polaris/tabs_component.html.erb +7 -0
  142. data/app/components/polaris/tabs_component.rb +37 -0
  143. data/app/components/polaris/tag_component.rb +2 -2
  144. data/app/components/polaris/text_container_component.rb +2 -2
  145. data/app/components/polaris/text_field_component.rb +24 -10
  146. data/app/components/polaris/text_style_component.rb +11 -2
  147. data/app/components/polaris/thumbnail_component.rb +2 -2
  148. data/app/components/polaris/toast_component.html.erb +21 -0
  149. data/app/components/polaris/toast_component.rb +40 -0
  150. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  151. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  152. data/app/helpers/polaris/form_builder.rb +31 -4
  153. data/app/helpers/polaris/url_helper.rb +3 -3
  154. data/app/helpers/polaris/view_helper.rb +37 -6
  155. data/app/validators/type_validator.rb +2 -2
  156. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  157. data/lib/polaris/view_components/engine.rb +11 -2
  158. data/lib/polaris/view_components/version.rb +1 -1
  159. data/lib/polaris_view_components.rb +1 -1
  160. metadata +88 -12
  161. data/app/components/polaris/choice_list/component.html.erb +0 -34
  162. data/app/components/polaris/choice_list/component.rb +0 -65
  163. data/app/helpers/polaris/action_helper.rb +0 -14
@@ -0,0 +1,77 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-DataTable__ScrollContainer">
3
+ <table class="Polaris-DataTable__Table">
4
+ <thead>
5
+ <tr>
6
+ <% columns.each_with_index do |column, index| %>
7
+ <%= render_cell(
8
+ first: index.zero?,
9
+ numeric: column.numeric,
10
+ tag: "th",
11
+ scope: "col",
12
+ header: true,
13
+ sort_url: column.sort_url,
14
+ sorted: column.sorted,
15
+ ) do %>
16
+ <%= column.title %>
17
+ <% end %>
18
+ <% end %>
19
+ </tr>
20
+ <% if @totals_in_header %>
21
+ <tr>
22
+ <% columns.each_with_index do |column, index| %>
23
+ <%= render_cell(
24
+ first: index.zero?,
25
+ numeric: column.numeric,
26
+ tag: (index.zero? ? "th" : "td"),
27
+ scope: ("row" if index.zero?),
28
+ total: true,
29
+ ) do %>
30
+ <%= column.total %>
31
+ <% end %>
32
+ <% end %>
33
+ </tr>
34
+ <% end %>
35
+ </thead>
36
+ <tbody>
37
+ <% @data.each do |row| %>
38
+ <tr class="Polaris-DataTable__TableRow <%= "Polaris-DataTable--hoverable" if @hoverable %>">
39
+ <% columns.each_with_index do |column, index| %>
40
+ <%= render_cell(
41
+ first: index.zero?,
42
+ numeric: column.numeric,
43
+ tag: (index.zero? ? "th" : "td"),
44
+ scope: ("row" if index.zero?),
45
+ ) do %>
46
+ <%= column.call(row) %>
47
+ <% end %>
48
+ <% end %>
49
+ </tr>
50
+ <% end %>
51
+ </tbody>
52
+ <% if @totals_in_footer %>
53
+ <tfoot>
54
+ <tr>
55
+ <% columns.each_with_index do |column, index| %>
56
+ <%= render_cell(
57
+ first: index.zero?,
58
+ numeric: column.numeric,
59
+ tag: (index.zero? ? "th" : "td"),
60
+ scope: ("row" if index.zero?),
61
+ total: true,
62
+ total_footer: true,
63
+ ) do %>
64
+ <%= column.total %>
65
+ <% end %>
66
+ <% end %>
67
+ </tr>
68
+ </tfoot>
69
+ <% end %>
70
+ </table>
71
+ </div>
72
+ <% if footer.present? %>
73
+ <div class="Polaris-DataTable__Footer">
74
+ <%= footer %>
75
+ </div>
76
+ <% end %>
77
+ <% end %>
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class DataTableComponent < Polaris::NewComponent
5
+ ALIGNMENT_DEFAULT = :top
6
+ ALIGNMENT_OPTIONS = [:top, :bottom, :middle, :baseline]
7
+
8
+ renders_many :columns, ->(title, **system_arguments, &block) do
9
+ DataTable::ColumnComponent.new(title, **system_arguments, &block)
10
+ end
11
+ renders_one :footer
12
+
13
+ def initialize(
14
+ data,
15
+ hoverable: true,
16
+ vertical_alignment: ALIGNMENT_DEFAULT,
17
+ totals_in_header: false,
18
+ totals_in_footer: false,
19
+ **system_arguments
20
+ )
21
+ @data = data
22
+ @hoverable = hoverable
23
+ @vertical_alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, vertical_alignment, ALIGNMENT_DEFAULT)
24
+ @totals_in_header = totals_in_header
25
+ @totals_in_footer = totals_in_footer
26
+ @system_arguments = system_arguments
27
+ end
28
+
29
+ def system_arguments
30
+ {tag: "div"}.deep_merge(@system_arguments).tap do |args|
31
+ args[:classes] = class_names(
32
+ args[:classes],
33
+ "Polaris-DataTable"
34
+ )
35
+ end
36
+ end
37
+
38
+ def render_cell(**arguments, &block)
39
+ render(DataTable::CellComponent.new(vertical_alignment: @vertical_alignment, **arguments), &block)
40
+ end
41
+ end
42
+ end
@@ -5,7 +5,7 @@ module Polaris
5
5
  SPACING_DEFAULT = :loose
6
6
  SPACING_MAPPINGS = {
7
7
  SPACING_DEFAULT => "",
8
- :tight => "Polaris-DescriptionList--spacingTight",
8
+ :tight => "Polaris-DescriptionList--spacingTight"
9
9
  }
10
10
  SPACING_OPTIONS = SPACING_MAPPINGS.keys
11
11
 
@@ -17,7 +17,7 @@ module Polaris
17
17
  @system_arguments[:classes] = class_names(
18
18
  @system_arguments[:classes],
19
19
  "Polaris-DescriptionList",
20
- SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)],
20
+ SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)]
21
21
  )
22
22
  end
23
23
 
@@ -33,7 +33,7 @@ module Polaris
33
33
  def call
34
34
  safe_join [
35
35
  tag.dt(class: "Polaris-DescriptionList__Term") { @term },
36
- tag.dd(class: "Polaris-DescriptionList__Description") { content },
36
+ tag.dd(class: "Polaris-DescriptionList__Description") { content }
37
37
  ]
38
38
  end
39
39
  end
@@ -10,7 +10,7 @@ module Polaris
10
10
  small: "Polaris-DisplayText--sizeSmall",
11
11
  medium: "Polaris-DisplayText--sizeMedium",
12
12
  large: "Polaris-DisplayText--sizeLarge",
13
- extra_large: "Polaris-DisplayText--sizeExtraLarge",
13
+ extra_large: "Polaris-DisplayText--sizeExtraLarge"
14
14
  }
15
15
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
16
16
 
@@ -24,7 +24,7 @@ module Polaris
24
24
  @system_arguments[:classes] = class_names(
25
25
  @system_arguments[:classes],
26
26
  "Polaris-DisplayText",
27
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
27
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
28
28
  )
29
29
  end
30
30
 
@@ -3,11 +3,9 @@
3
3
  module Polaris
4
4
  module Dropzone
5
5
  class Component < Polaris::Component
6
- include Polaris::ActionHelper
7
-
8
6
  ALLOWED_TYPES = %w[file image]
9
7
 
10
- validates :type, inclusion: { in: ALLOWED_TYPES, message: "%{value} is not a valid type" }
8
+ validates :type, inclusion: {in: ALLOWED_TYPES, message: "%{value} is not a valid type"}
11
9
  validates :label_action, type: Action, allow_nil: true
12
10
 
13
11
  # TODO
@@ -79,52 +77,52 @@ module Polaris
79
77
  multiple: @allow_multiple,
80
78
  data: {
81
79
  action: "focus->polaris--dropzone#onFocus blur->polaris--dropzone#onBlur change->polaris--dropzone#onChange",
82
- 'polaris--dropzone-target': 'input',
80
+ 'polaris--dropzone-target': "input"
83
81
  }
84
82
  }
85
83
  end
86
84
 
87
85
  private
88
86
 
89
- def additional_aria
90
- {
91
- disabled: @disabled.to_s,
92
- }
93
- end
94
-
95
- def additional_data
96
- {
97
- controller: "polaris--dropzone",
98
- action: "click->polaris--dropzone#onClick #{drop_actions}",
99
- 'polaris--dropzone-accept-value': @accept,
100
- 'polaris--dropzone-allowMultiple-value': @allow_multiple.to_s,
101
- 'polaris--dropzone-disabled-value': @disabled.to_s,
102
- 'polaris--dropzone-focused-value': 'false',
103
- 'polaris--dropzone-drop-on-page-value': 'false',
104
- }
105
- end
87
+ def additional_aria
88
+ {
89
+ disabled: @disabled.to_s
90
+ }
91
+ end
106
92
 
107
- def drop_actions
108
- event_scope = @drop_on_page ? "@document" : ""
93
+ def additional_data
94
+ {
95
+ controller: "polaris--dropzone",
96
+ action: "click->polaris--dropzone#onClick #{drop_actions}",
97
+ 'polaris--dropzone-accept-value': @accept,
98
+ 'polaris--dropzone-allowMultiple-value': @allow_multiple.to_s,
99
+ 'polaris--dropzone-disabled-value': @disabled.to_s,
100
+ 'polaris--dropzone-focused-value': "false",
101
+ 'polaris--dropzone-drop-on-page-value': "false"
102
+ }
103
+ end
109
104
 
110
- [
111
- "drop#{event_scope}->polaris--dropzone#onDrop",
112
- "dragover#{event_scope}->polaris--dropzone#onDragOver",
113
- "dragenter#{event_scope}->polaris--dropzone#onDragEnter",
114
- "dragleave#{event_scope}->polaris--dropzone#onDragLeave"
115
- ].join(" ")
116
- end
105
+ def drop_actions
106
+ event_scope = @drop_on_page ? "@document" : ""
117
107
 
118
- def classes
119
- classes = %w[Polaris-DropZone Polaris-DropZone--sizeExtraLarge]
108
+ [
109
+ "drop#{event_scope}->polaris--dropzone#onDrop",
110
+ "dragover#{event_scope}->polaris--dropzone#onDragOver",
111
+ "dragenter#{event_scope}->polaris--dropzone#onDragEnter",
112
+ "dragleave#{event_scope}->polaris--dropzone#onDragLeave"
113
+ ].join(" ")
114
+ end
115
+
116
+ def classes
117
+ classes = %w[Polaris-DropZone Polaris-DropZone--sizeExtraLarge]
120
118
 
121
- classes << "Polaris-DropZone--isDisabled" if @disabled
122
- classes << "Polaris-DropZone--isDisabled" if @disabled
123
- classes << "Polaris-DropZone--hasError" if @error.present?
124
- classes << "Polaris-DropZone--hasOutline" if @outline
119
+ classes << "Polaris-DropZone--isDisabled" if @disabled
120
+ classes << "Polaris-DropZone--isDisabled" if @disabled
121
+ classes << "Polaris-DropZone--hasError" if @error.present?
122
+ classes << "Polaris-DropZone--hasOutline" if @outline
125
123
 
126
- classes
127
- end
124
+ classes
125
+ end
128
126
  end
129
127
  end
130
128
  end
@@ -16,20 +16,22 @@
16
16
  <% end %>
17
17
  </div>
18
18
  <% end %>
19
- <div class="Polaris-EmptyState__Actions">
20
- <%= polaris_stack(spacing: :tight, distribution: :center, alignment: :center) do |stack| %>
21
- <% if primary_action.present? %>
22
- <% stack.item do %>
23
- <%= primary_action %>
19
+ <% if primary_action.present? || secondary_action.present? %>
20
+ <div class="Polaris-EmptyState__Actions">
21
+ <%= polaris_stack(spacing: :tight, distribution: :center, alignment: :center) do |stack| %>
22
+ <% if primary_action.present? %>
23
+ <% stack.item do %>
24
+ <%= primary_action %>
25
+ <% end %>
24
26
  <% end %>
25
- <% end %>
26
- <% if secondary_action.present? %>
27
- <% stack.item do %>
28
- <%= secondary_action %>
27
+ <% if secondary_action.present? %>
28
+ <% stack.item do %>
29
+ <%= secondary_action %>
30
+ <% end %>
29
31
  <% end %>
30
32
  <% end %>
31
- <% end %>
32
- </div>
33
+ </div>
34
+ <% end %>
33
35
  <% if footer.present? %>
34
36
  <div class="Polaris-EmptyState__FooterContent">
35
37
  <div class="Polaris-TextContainer">
@@ -44,4 +46,7 @@
44
46
  <img src="<%= @image %>" role="presentation" alt="" class="Polaris-EmptyState__Image">
45
47
  </div>
46
48
  </div>
49
+ <% if unsectioned_content.present? %>
50
+ <%= unsectioned_content %>
51
+ <% end %>
47
52
  <% end %>
@@ -5,15 +5,16 @@ module Polaris
5
5
  WITHIN_DEFAULT = :page
6
6
  WITHIN_MAPPINGS = {
7
7
  WITHIN_DEFAULT => "",
8
- container: "Polaris-EmptyState--withinContentContainer",
8
+ :container => "Polaris-EmptyState--withinContentContainer"
9
9
  }
10
10
  WITHIN_OPTIONS = WITHIN_MAPPINGS.keys
11
11
 
12
- renders_one :primary_action, -> (primary: true, **system_arguments) do
12
+ renders_one :primary_action, ->(primary: true, **system_arguments) do
13
13
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
14
14
  end
15
15
  renders_one :secondary_action, Polaris::ButtonComponent
16
16
  renders_one :footer
17
+ renders_one :unsectioned_content
17
18
 
18
19
  def initialize(
19
20
  image:,
@@ -31,7 +32,7 @@ module Polaris
31
32
  @system_arguments[:classes],
32
33
  "Polaris-EmptyState",
33
34
  WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)],
34
- "Polaris-EmptyState--fullWidth": full_width,
35
+ "Polaris-EmptyState--fullWidth": full_width
35
36
  )
36
37
  end
37
38
  end
@@ -3,7 +3,7 @@ class Polaris::ExceptionList::ItemComponent < Polaris::NewComponent
3
3
  STATUS_MAPPINGS = {
4
4
  STATUS_DEFAULT => "",
5
5
  :critical => "Polaris-ExceptionList--statusCritical",
6
- :warning => "Polaris-ExceptionList--statusWarning",
6
+ :warning => "Polaris-ExceptionList--statusWarning"
7
7
  }
8
8
  STATUS_OPTIONS = STATUS_MAPPINGS.keys
9
9
 
@@ -21,7 +21,7 @@ class Polaris::ExceptionList::ItemComponent < Polaris::NewComponent
21
21
  @system_arguments[:classes] = class_names(
22
22
  @system_arguments[:classes],
23
23
  "Polaris-ExceptionList__Item",
24
- STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)],
24
+ STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
25
25
  )
26
26
  end
27
27
  end
@@ -9,7 +9,7 @@ module Polaris
9
9
  @system_arguments[:tag] = "ul"
10
10
  @system_arguments[:classes] = class_names(
11
11
  @system_arguments[:classes],
12
- "Polaris-ExceptionList",
12
+ "Polaris-ExceptionList"
13
13
  )
14
14
  end
15
15
 
@@ -0,0 +1,35 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-Filters-ConnectedFilterControl__Wrapper">
3
+ <div class="Polaris-Filters-ConnectedFilterControl Polaris-Filters-ConnectedFilterControl--right">
4
+ <% if query.present? %>
5
+ <div class="Polaris-Filters-ConnectedFilterControl__CenterContainer">
6
+ <div class="Polaris-Filters-ConnectedFilterControl__Item">
7
+ <%= query %>
8
+ </div>
9
+ </div>
10
+ <% end %>
11
+ <% if items.present? %>
12
+ <div class="<%= items_wrapper_classes %>">
13
+ <% items.each do |item| %>
14
+ <%= item %>
15
+ <% end %>
16
+ </div>
17
+ <% end %>
18
+ </div>
19
+ <% if content.present? %>
20
+ <div class="Polaris-Filters-ConnectedFilterControl__AuxiliaryContainer">
21
+ <%= content %>
22
+ </div>
23
+ <% end %>
24
+ </div>
25
+ <% if tags.present? %>
26
+ <div class="Polaris-Filters__TagsContainer">
27
+ <%= tags %>
28
+ </div>
29
+ <% end %>
30
+ <% if @help_text.present? %>
31
+ <div class="Polaris-Filters__HelpText">
32
+ <%= polaris_text_subdued { @help_text } %>
33
+ </div>
34
+ <% end %>
35
+ <% end %>
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class FiltersComponent < Polaris::NewComponent
5
+ renders_one :query, ->(**system_arguments) do
6
+ QueryComponent.new(disabled: @disabled, **system_arguments)
7
+ end
8
+ renders_many :items, ->(**system_arguments) do
9
+ ItemComponent.new(disabled: @disabled, **system_arguments)
10
+ end
11
+ renders_one :tags
12
+
13
+ def initialize(disabled: false, help_text: nil, **system_arguments)
14
+ @disabled = disabled
15
+ @help_text = help_text
16
+ @system_arguments = system_arguments
17
+ end
18
+
19
+ def system_arguments
20
+ @system_arguments.tap do |opts|
21
+ opts[:tag] = "div"
22
+ opts[:classes] = class_names(
23
+ @system_arguments[:classes],
24
+ "Polaris-Filters"
25
+ )
26
+ end
27
+ end
28
+
29
+ def items_wrapper_classes
30
+ class_names(
31
+ "Polaris-Filters-ConnectedFilterControl__RightContainer",
32
+ "Polaris-Filters-ConnectedFilterControl__RightContainerWithoutMoreFilters",
33
+ "Polaris-Filters-ConnectedFilterControl--queryFieldHidden": @query.blank?
34
+ )
35
+ end
36
+
37
+ class QueryComponent < Polaris::NewComponent
38
+ def initialize(clear_button: true, disabled: false, **system_arguments)
39
+ @disabled = disabled
40
+ @system_arguments = system_arguments.merge(
41
+ label_hidden: true,
42
+ clear_button: clear_button
43
+ )
44
+ end
45
+
46
+ def call
47
+ polaris_text_field(disabled: @disabled, **@system_arguments) do |text_field|
48
+ text_field.prefix do
49
+ polaris_icon(name: "SearchMinor")
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ class ItemComponent < Polaris::NewComponent
56
+ def initialize(label:, sectioned: true, width: nil, disabled: false, **system_arguments)
57
+ @label = label
58
+ @sectioned = sectioned
59
+ @width = width
60
+ @disabled = disabled
61
+ @system_arguments = system_arguments
62
+ end
63
+
64
+ def system_arguments
65
+ @system_arguments.tap do |opts|
66
+ opts[:tag] = "div"
67
+ opts[:classes] = class_names(
68
+ @system_arguments[:classes],
69
+ "Polaris-Filters-ConnectedFilterControl__Item"
70
+ )
71
+ end
72
+ end
73
+
74
+ def popover_arguments
75
+ {
76
+ sectioned: @sectioned,
77
+ style: ("width: #{@width}" if @width.present?)
78
+ }
79
+ end
80
+
81
+ def call
82
+ render(Polaris::BaseComponent.new(**system_arguments)) do
83
+ render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover|
84
+ popover.button(disclosure: true, disabled: @disabled) { @label }
85
+ content
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -6,7 +6,7 @@ module Polaris
6
6
  @system_arguments = system_arguments
7
7
  @system_arguments[:classes] = class_names(
8
8
  @system_arguments[:classes],
9
- "Polaris-FooterHelp",
9
+ "Polaris-FooterHelp"
10
10
  )
11
11
  end
12
12
  end
@@ -10,7 +10,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
10
10
  @system_arguments[:tag] = "div"
11
11
  @system_arguments[:classes] = class_names(
12
12
  @system_arguments[:classes],
13
- "Polaris-FormLayout__Items",
13
+ "Polaris-FormLayout__Items"
14
14
  )
15
15
 
16
16
  @wrapper_arguments = {}
@@ -18,7 +18,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
18
18
  @wrapper_arguments[:role] = "group"
19
19
  @wrapper_arguments[:classes] = class_names(
20
20
  "Polaris-FormLayout--grouped": !condensed,
21
- "Polaris-FormLayout--condensed": condensed,
21
+ "Polaris-FormLayout--condensed": condensed
22
22
  )
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
28
28
  @system_arguments[:tag] = "div"
29
29
  @system_arguments[:classes] = class_names(
30
30
  @system_arguments[:classes],
31
- "Polaris-FormLayout__Item",
31
+ "Polaris-FormLayout__Item"
32
32
  )
33
33
  end
34
34
 
@@ -8,7 +8,7 @@ class Polaris::FormLayout::ItemComponent < Polaris::NewComponent
8
8
  @system_arguments[:tag] = "div"
9
9
  @system_arguments[:classes] = class_names(
10
10
  @system_arguments[:classes],
11
- "Polaris-FormLayout__Item",
11
+ "Polaris-FormLayout__Item"
12
12
  )
13
13
  end
14
14
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Polaris
4
4
  class FormLayoutComponent < Polaris::NewComponent
5
- renders_many :items, -> (**system_arguments) do
5
+ renders_many :items, ->(**system_arguments) do
6
6
  @counter += 1
7
7
  Polaris::FormLayout::ItemComponent.new(position: @counter, **system_arguments)
8
8
  end
9
- renders_many :groups, -> (**system_arguments) do
9
+ renders_many :groups, ->(**system_arguments) do
10
10
  @counter += 1
11
11
  Polaris::FormLayout::GroupComponent.new(position: @counter, **system_arguments)
12
12
  end
@@ -18,7 +18,7 @@ module Polaris
18
18
  @system_arguments[:tag] = "div"
19
19
  @system_arguments[:classes] = class_names(
20
20
  @system_arguments[:classes],
21
- "Polaris-FormLayout",
21
+ "Polaris-FormLayout"
22
22
  )
23
23
  end
24
24
 
@@ -0,0 +1,23 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <% if @logo.present? && !@flush %>
3
+ <div class="Polaris-Frame-ContextualSaveBar__LogoContainer" style="width: <%= @logo.width %>">
4
+ <%= image_tag @logo.src, style: "width: #{@logo.width}", alt: @logo.alt %>
5
+ </div>
6
+ <% end %>
7
+
8
+ <div class="<%= content_classes %>">
9
+ <h2 class="Polaris-Frame-ContextualSaveBar__Message">
10
+ <%= @message %>
11
+ </h2>
12
+ <div class="Polaris-Frame-ContextualSaveBar__ActionContainer">
13
+ <%= polaris_stack(spacing: :tight) do |stack| %>
14
+ <% stack.item do %>
15
+ <%= discard_action %>
16
+ <% end %>
17
+ <% stack.item do %>
18
+ <%= save_action %>
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,31 @@
1
+ class Polaris::Frame::SaveBarComponent < Polaris::NewComponent
2
+ renders_one :save_action, ->(**system_arguments) do
3
+ Polaris::ButtonComponent.new(primary: true, **system_arguments)
4
+ end
5
+ renders_one :discard_action, Polaris::ButtonComponent
6
+
7
+ def initialize(message:, flush: false, full_width: false, logo: nil, **system_arguments)
8
+ @message = message
9
+ @flush = flush
10
+ @full_width = full_width
11
+ @logo = logo.is_a?(Hash) ? Polaris::Logo.new(**logo) : logo
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-Frame-ContextualSaveBar"
21
+ )
22
+ end
23
+ end
24
+
25
+ def content_classes
26
+ class_names(
27
+ "Polaris-Frame-ContextualSaveBar__Contents",
28
+ "Polaris-Frame-ContextualSaveBar--fullWidth": @full_width
29
+ )
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <button data-action="polaris-frame#openMenu" type="button" class="Polaris-TopBar__NavigationIcon">
3
+ <%= polaris_icon(name: "MobileHamburgerMajor") %>
4
+ </button>
5
+
6
+ <% if @logo.present? %>
7
+ <div class="Polaris-TopBar__LogoContainer Polaris-TopBar__LogoDisplayControl">
8
+ <%= link_to(@logo.url,
9
+ class: "Polaris-TopBar__LogoLink",
10
+ style: "width: #{@logo.width}"
11
+ ) do %>
12
+ <%= image_tag @logo.src,
13
+ class: "Polaris-TopBar__Logo",
14
+ style: "width: #{@logo.width}",
15
+ alt: @logo.alt %>
16
+ <% end %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <div class="Polaris-TopBar__Contents">
21
+ <%# FIXME: Not implemented yet %>
22
+ <div class="Polaris-TopBar__SearchField"></div>
23
+ <div class="Polaris-TopBar__SecondaryMenu"></div>
24
+ <div>
25
+ <div class="Polaris-TopBar-Menu__ActivatorWrapper">
26
+ <%= user_menu %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ <% end %>
@@ -0,0 +1,18 @@
1
+ class Polaris::Frame::TopBarComponent < Polaris::NewComponent
2
+ renders_one :user_menu, Polaris::TopBar::UserMenuComponent
3
+
4
+ def initialize(logo:, **system_arguments)
5
+ @logo = logo.is_a?(Hash) ? Polaris::Logo.new(**logo) : logo
6
+ @system_arguments = system_arguments
7
+ end
8
+
9
+ def system_arguments
10
+ @system_arguments.tap do |opts|
11
+ opts[:tag] = "div"
12
+ opts[:classes] = class_names(
13
+ @system_arguments[:classes],
14
+ "Polaris-TopBar"
15
+ )
16
+ end
17
+ end
18
+ end