polaris_view_components 0.10.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -62
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +9 -3
  4. data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +18 -8
  5. data/app/assets/javascripts/polaris_view_components/popover_controller.js +39 -13
  6. data/app/assets/javascripts/polaris_view_components.js +112 -59
  7. data/app/assets/stylesheets/polaris_view_components/custom.css +27 -8
  8. data/app/assets/stylesheets/polaris_view_components.css +21 -9
  9. data/app/components/polaris/autocomplete_component.html.erb +3 -0
  10. data/app/components/polaris/autocomplete_component.rb +3 -0
  11. data/app/components/polaris/button_component.html.erb +2 -0
  12. data/app/components/polaris/card/header_component.html.erb +4 -2
  13. data/app/components/polaris/data_table/column_component.rb +2 -1
  14. data/app/components/polaris/data_table_component.html.erb +6 -2
  15. data/app/components/polaris/data_table_component.rb +10 -0
  16. data/app/components/polaris/dropzone_component.html.erb +38 -32
  17. data/app/components/polaris/dropzone_component.rb +4 -1
  18. data/app/components/polaris/empty_search_results_component.html.erb +15 -0
  19. data/app/components/polaris/empty_search_results_component.rb +21 -0
  20. data/app/components/polaris/headless_button.html.erb +2 -0
  21. data/app/components/polaris/headless_button.rb +1 -1
  22. data/app/components/polaris/index_table/column_component.rb +2 -1
  23. data/app/components/polaris/index_table_component.html.erb +3 -5
  24. data/app/components/polaris/index_table_component.rb +10 -0
  25. data/app/components/polaris/page_component.html.erb +4 -4
  26. data/app/components/polaris/page_component.rb +7 -2
  27. data/app/components/polaris/popover_component.html.erb +26 -16
  28. data/app/components/polaris/popover_component.rb +6 -1
  29. data/app/components/polaris/resource_item/shortcut_actions_component.html.erb +21 -0
  30. data/app/components/polaris/resource_item/shortcut_actions_component.rb +88 -0
  31. data/app/components/polaris/resource_item_component.html.erb +3 -0
  32. data/app/components/polaris/resource_item_component.rb +11 -1
  33. data/app/components/polaris/resource_list_component.html.erb +11 -0
  34. data/app/components/polaris/resource_list_component.rb +21 -0
  35. data/app/components/polaris/skeleton_page_component.html.erb +23 -0
  36. data/app/components/polaris/skeleton_page_component.rb +22 -0
  37. data/app/helpers/polaris/url_helper.rb +37 -0
  38. data/app/helpers/polaris/view_helper.rb +2 -0
  39. data/lib/install/install.rb +57 -0
  40. data/lib/polaris/view_components/version.rb +1 -1
  41. data/lib/tasks/polaris_view_components_tasks.rake +6 -0
  42. metadata +10 -6
  43. data/lib/generators/polaris_view_components/USAGE +0 -5
  44. data/lib/generators/polaris_view_components/install_generator.rb +0 -35
  45. data/lib/generators/polaris_view_components/templates/README +0 -14
  46. data/lib/generators/polaris_view_components/templates/stimulus_index.js +0 -6
@@ -36,15 +36,16 @@ a.Polaris-Tag__Button {
36
36
  font-size: 1.25rem;
37
37
  }
38
38
 
39
- /* Remove box-shadow from buttons and links */
40
- .Polaris-Button::after,
41
- .Polaris-Button:focus::after,
42
- .Polaris-Breadcrumbs__Breadcrumb::after {
43
- box-shadow: none !important;
39
+ /* Remove focus styles for non-keyboard focus from buttons and links */
40
+ .Polaris-Button, .Polaris-Breadcrumbs__Breadcrumb {
41
+ &:focus:not(:focus-visible)::after {
42
+ box-shadow: none !important;
43
+ }
44
44
  }
45
-
46
- .Polaris-Tabs__Tab:focus > .Polaris-Tabs__Title::after {
47
- box-shadow: none !important;
45
+ .Polaris-Tabs__Tab {
46
+ &:focus:not(:focus-visible) > .Polaris-Tabs__Title::after {
47
+ box-shadow: none !important;
48
+ }
48
49
  }
49
50
 
50
51
  /* ResourceItem */
@@ -176,3 +177,21 @@ a.Polaris-Tag__Button {
176
177
  display: none;
177
178
  }
178
179
  }
180
+
181
+ /* EmptySearchResults */
182
+ .Polaris-EmptySearchResults {
183
+ padding: 84px 0;
184
+
185
+ &__Content {
186
+ display: flex;
187
+ flex-direction: column;
188
+ align-items: center;
189
+ text-align: center;
190
+ }
191
+ }
192
+
193
+ /* ActionList */
194
+
195
+ .Polaris-ActionList__Item {
196
+ border: none !important;
197
+ }
@@ -2268,15 +2268,13 @@ a.Polaris-Tag__Button {
2268
2268
  .Polaris-TextStyle--sizeSmall {
2269
2269
  font-size: 1.25rem;
2270
2270
  }
2271
- /* Remove box-shadow from buttons and links */
2272
- .Polaris-Button::after,
2273
- .Polaris-Button:focus::after,
2274
- .Polaris-Breadcrumbs__Breadcrumb::after {
2275
- box-shadow: none !important;
2276
- }
2277
- .Polaris-Tabs__Tab:focus > .Polaris-Tabs__Title::after {
2278
- box-shadow: none !important;
2279
- }
2271
+ /* Remove focus styles for non-keyboard focus from buttons and links */
2272
+ .Polaris-Button:focus:not(:focus-visible)::after, .Polaris-Breadcrumbs__Breadcrumb:focus:not(:focus-visible)::after {
2273
+ box-shadow: none !important;
2274
+ }
2275
+ .Polaris-Tabs__Tab:focus:not(:focus-visible) > .Polaris-Tabs__Title::after {
2276
+ box-shadow: none !important;
2277
+ }
2280
2278
  /* ResourceItem */
2281
2279
  .Polaris-ResourceItem__Owned--offset {
2282
2280
  padding-left: 2rem;
@@ -2373,3 +2371,17 @@ a.Polaris-Tag__Button {
2373
2371
  display: none;
2374
2372
  }
2375
2373
  }
2374
+ /* EmptySearchResults */
2375
+ .Polaris-EmptySearchResults {
2376
+ padding: 84px 0;
2377
+ }
2378
+ .Polaris-EmptySearchResults__Content {
2379
+ display: flex;
2380
+ flex-direction: column;
2381
+ align-items: center;
2382
+ text-align: center;
2383
+ }
2384
+ /* ActionList */
2385
+ .Polaris-ActionList__Item {
2386
+ border: none !important;
2387
+ }
@@ -2,6 +2,9 @@
2
2
  <%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
3
3
  <% popover.activator do %>
4
4
  <%= text_field %>
5
+ <% if @name.present? %>
6
+ <%= hidden_field_tag @name, nil, data: {polaris_autocomplete_target: "hiddenInput"} %>
7
+ <% end %>
5
8
  <% end %>
6
9
 
7
10
  <% if empty_state.present? %>
@@ -24,11 +24,13 @@ module Polaris
24
24
  def initialize(
25
25
  multiple: false,
26
26
  url: nil,
27
+ name: nil,
27
28
  selected: [],
28
29
  **system_arguments
29
30
  )
30
31
  @multiple = multiple
31
32
  @url = url
33
+ @name = name
32
34
  @selected = selected
33
35
  @system_arguments = system_arguments
34
36
  end
@@ -42,6 +44,7 @@ module Polaris
42
44
  opts[:data][:polaris_autocomplete_url_value] = @url
43
45
  end
44
46
  opts[:data][:polaris_autocomplete_selected_value] = @selected
47
+ opts[:data][:polaris_autocomplete_multiple_value] = @multiple if @multiple.present?
45
48
  end
46
49
  end
47
50
 
@@ -30,6 +30,8 @@
30
30
  <%= polaris_icon(name: "CaretUpMinor") %>
31
31
  <% when :select %>
32
32
  <%= polaris_icon(name: "SelectMinor") %>
33
+ <% when :horizontal_dots %>
34
+ <%= polaris_icon(name: "HorizontalDotsMinor") %>
33
35
  <% end %>
34
36
  </div>
35
37
  <% end %>
@@ -17,8 +17,10 @@
17
17
  <% end %>
18
18
  <% end %>
19
19
 
20
- <% stack.item do %>
21
- <%= content %>
20
+ <% if content.present? %>
21
+ <% stack.item do %>
22
+ <%= content %>
23
+ <% end %>
22
24
  <% end %>
23
25
  <% end %>
24
26
  <% end %>
@@ -2,7 +2,7 @@ class Polaris::DataTable::ColumnComponent < Polaris::Component
2
2
  SORT_DEFAULT = false
3
3
  SORT_OPTIONS = [false, :asc, :desc]
4
4
 
5
- attr_reader :title, :numeric, :total, :sorted, :sort_url
5
+ attr_reader :title, :numeric, :total, :sorted, :sort_url, :system_arguments
6
6
 
7
7
  def initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block)
8
8
  @title = title
@@ -11,6 +11,7 @@ class Polaris::DataTable::ColumnComponent < Polaris::Component
11
11
  @sorted = fetch_or_fallback(SORT_OPTIONS, sorted, SORT_DEFAULT)
12
12
  @sort_url = sort_url
13
13
  @block = block
14
+ @system_arguments = system_arguments
14
15
  end
15
16
 
16
17
  def call(row)
@@ -12,6 +12,7 @@
12
12
  header: true,
13
13
  sort_url: column.sort_url,
14
14
  sorted: column.sorted,
15
+ **column.system_arguments
15
16
  ) do %>
16
17
  <%= column.title %>
17
18
  <% end %>
@@ -26,6 +27,7 @@
26
27
  tag: (index.zero? ? "th" : "td"),
27
28
  scope: ("row" if index.zero?),
28
29
  total: true,
30
+ **column.system_arguments
29
31
  ) do %>
30
32
  <%= column.total %>
31
33
  <% end %>
@@ -35,18 +37,19 @@
35
37
  </thead>
36
38
  <tbody>
37
39
  <% @data.each do |row| %>
38
- <tr class="Polaris-DataTable__TableRow <%= "Polaris-DataTable--hoverable" if @hoverable %>">
40
+ <%= render Polaris::BaseComponent.new(**row_arguments(row)) do %>
39
41
  <% columns.each_with_index do |column, index| %>
40
42
  <%= render_cell(
41
43
  first: index.zero?,
42
44
  numeric: column.numeric,
43
45
  tag: (index.zero? ? "th" : "td"),
44
46
  scope: ("row" if index.zero?),
47
+ **column.system_arguments
45
48
  ) do %>
46
49
  <%= column.call(row) %>
47
50
  <% end %>
48
51
  <% end %>
49
- </tr>
52
+ <% end %>
50
53
  <% end %>
51
54
  </tbody>
52
55
  <% if @totals_in_footer %>
@@ -60,6 +63,7 @@
60
63
  scope: ("row" if index.zero?),
61
64
  total: true,
62
65
  total_footer: true,
66
+ **column.system_arguments
63
67
  ) do %>
64
68
  <%= column.total %>
65
69
  <% end %>
@@ -35,6 +35,16 @@ module Polaris
35
35
  end
36
36
  end
37
37
 
38
+ def row_arguments(row)
39
+ {tag: "tr"}.tap do |args|
40
+ args[:classes] = class_names(
41
+ "Polaris-DataTable__TableRow",
42
+ "Polaris-DataTable--hoverable": @hoverable
43
+ )
44
+ args[:id] = dom_id(row) if row.respond_to?(:to_key)
45
+ end
46
+ end
47
+
38
48
  def render_cell(**arguments, &block)
39
49
  render(DataTable::CellComponent.new(vertical_alignment: @vertical_alignment, **arguments), &block)
40
50
  end
@@ -30,48 +30,54 @@
30
30
 
31
31
  <div class="Polaris-DropZone__Container" data-polaris-dropzone-target="container">
32
32
  <%= render Polaris::BaseComponent.new(**file_upload_arguments) do %>
33
- <%= render Polaris::StackComponent.new(vertical: true, spacing: :tight) do |stack| %>
34
- <% unless @size == :medium %>
35
- <% stack.item do %>
36
- <img width="<%= @size == :small ? 20 : 40 %>" src="data:image/svg+xml,%3csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M20 10a10 10 0 11-20 0 10 10 0 0120 0zM5.3 8.3l4-4a1 1 0 011.4 0l4 4a1 1 0 01-1.4 1.4L11 7.4V15a1 1 0 11-2 0V7.4L6.7 9.7a1 1 0 01-1.4-1.4z' fill='%235C5F62'/%3e%3c/svg%3e" alt="">
33
+ <% if content.present? %>
34
+ <%= content %>
35
+ <% else %>
36
+ <%= render Polaris::StackComponent.new(vertical: true, spacing: :tight) do |stack| %>
37
+ <% unless @size == :medium %>
38
+ <% stack.item do %>
39
+ <img width="<%= @size == :small ? 20 : 40 %>" src="data:image/svg+xml,%3csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M20 10a10 10 0 11-20 0 10 10 0 0120 0zM5.3 8.3l4-4a1 1 0 011.4 0l4 4a1 1 0 01-1.4 1.4L11 7.4V15a1 1 0 11-2 0V7.4L6.7 9.7a1 1 0 01-1.4-1.4z' fill='%235C5F62'/%3e%3c/svg%3e" alt="">
40
+ <% end %>
37
41
  <% end %>
38
- <% end %>
39
42
 
40
- <% unless @size == :small %>
41
- <% stack.item do %>
42
- <% if @size == :medium %>
43
- <div class="Polaris-DropZone-FileUpload__ActionTitle">
44
- <%= @file_upload_button %>
45
- </div>
46
- <% else %>
47
- <div class="Polaris-DropZone-FileUpload__Button">
48
- <%= @file_upload_button %>
49
- </div>
43
+ <% unless @size == :small %>
44
+ <% stack.item do %>
45
+ <% if @size == :medium %>
46
+ <div class="Polaris-DropZone-FileUpload__ActionTitle">
47
+ <%= @file_upload_button %>
48
+ </div>
49
+ <% else %>
50
+ <div class="Polaris-DropZone-FileUpload__Button">
51
+ <%= @file_upload_button %>
52
+ </div>
53
+ <% end %>
50
54
  <% end %>
51
55
  <% end %>
52
- <% end %>
53
56
 
54
- <% unless @size == :small %>
55
- <% stack.item do %>
56
- <% help_text = capture do %>
57
- <%= render Polaris::TextStyleComponent.new(variation: :subdued) do %>
58
- <%= @file_upload_help %>
57
+ <% unless @size == :small %>
58
+ <% stack.item do %>
59
+ <% help_text = capture do %>
60
+ <%= render Polaris::TextStyleComponent.new(variation: :subdued) do %>
61
+ <%= @file_upload_help %>
62
+ <% end %>
59
63
  <% end %>
60
- <% end %>
61
64
 
62
- <% if @size == :medium %>
63
- <%= polaris_caption { help_text } %>
64
- <% else %>
65
- <%= help_text %>
65
+ <% if @size == :medium %>
66
+ <%= polaris_caption { help_text } %>
67
+ <% else %>
68
+ <%= help_text %>
69
+ <% end %>
66
70
  <% end %>
67
71
  <% end %>
68
72
  <% end %>
69
73
  <% end %>
70
74
  <% end %>
71
75
 
72
- <div class="Polaris-DropZone__Loader Polaris--hidden" data-polaris-dropzone-target="loader">
73
- <%= polaris_spinner(size: (@size == :small) ? :small : :large) %>
74
- </div>
76
+ <% if @preview %>
77
+ <div class="Polaris-DropZone__Loader Polaris--hidden" data-polaris-dropzone-target="loader">
78
+ <%= polaris_spinner(size: (@size == :small) ? :small : :large) %>
79
+ </div>
80
+ <% end %>
75
81
  </div>
76
82
 
77
83
  <%= render Polaris::VisuallyHiddenComponent.new do %>
@@ -85,12 +91,12 @@
85
91
  <template data-polaris-dropzone-target="previewTemplate">
86
92
  <%= tag.div(
87
93
  data: { polaris_dropzone_target: "preview" },
88
- class: [
89
- "Polaris-DropZone__Preview",
94
+ class: {
95
+ "Polaris-DropZone__Preview": true,
90
96
  "Polaris-DropZone__Preview--singleFile": !@multiple,
91
97
  "Polaris-DropZone__Preview--sizeMedium": @size == :medium,
92
98
  "Polaris-DropZone__Preview--sizeSmall": @size == :small,
93
- ]
99
+ }
94
100
  ) do %>
95
101
  <% if @size.in?(%i[small]) %>
96
102
  <span class="target"></span>
@@ -37,6 +37,7 @@ module Polaris
37
37
  label_action: nil,
38
38
  disabled: false,
39
39
  error: false,
40
+ remove_previews_after_upload: true,
40
41
  file_upload_button: nil,
41
42
  file_upload_help: "or drop files to upload",
42
43
  file_upload_arguments: {},
@@ -62,6 +63,7 @@ module Polaris
62
63
  @label_action = label_action
63
64
  @disabled = disabled
64
65
  @error = error
66
+ @remove_previews_after_upload = remove_previews_after_upload
65
67
  @file_upload_button = file_upload_button
66
68
  @file_upload_button ||= "Add #{multiple ? "files" : "file"}"
67
69
  @file_upload_help = file_upload_help
@@ -82,7 +84,8 @@ module Polaris
82
84
  polaris_dropzone_focused_value: "false",
83
85
  polaris_dropzone_drop_on_page_value: @drop_on_page,
84
86
  polaris_dropzone_render_preview_value: @preview,
85
- polaris_dropzone_size_value: @size
87
+ polaris_dropzone_size_value: @size,
88
+ polaris_dropzone_remove_previews_after_upload_value: @remove_previews_after_upload
86
89
  }
87
90
  }.deep_merge(@system_arguments).tap do |opts|
88
91
  prepend_option(opts[:data], :controller, "polaris-dropzone")
@@ -0,0 +1,15 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-EmptySearchResults__Content">
3
+ <%= polaris_text_container do %>
4
+ <% if image.present? %>
5
+ <div><%= image %></div>
6
+ <% end %>
7
+ <%= polaris_display_text(size: :small) do %>
8
+ <%= @title %>
9
+ <% end %>
10
+ <% if @description.present? %>
11
+ <div><%= polaris_text_subdued { @description } %></div>
12
+ <% end %>
13
+ <% end %>
14
+ </div>
15
+ <% end %>
@@ -0,0 +1,21 @@
1
+ module Polaris
2
+ class EmptySearchResultsComponent < Polaris::Component
3
+ renders_one :image
4
+
5
+ def initialize(title:, description: nil, **system_arguments)
6
+ @title = title
7
+ @description = description
8
+ @system_arguments = system_arguments
9
+ end
10
+
11
+ def system_arguments
12
+ @system_arguments.tap do |args|
13
+ args[:tag] = "div"
14
+ args[:classes] = class_names(
15
+ args[:classes],
16
+ "Polaris-EmptySearchResults"
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -29,6 +29,8 @@
29
29
  <%= polaris_icon(name: "CaretUpMinor") %>
30
30
  <% when :select %>
31
31
  <%= polaris_icon(name: "SelectMinor") %>
32
+ <% when :horizontal_dots %>
33
+ <%= polaris_icon(name: "HorizontalDotsMinor") %>
32
34
  <% end %>
33
35
  </div>
34
36
  <% end %>
@@ -20,7 +20,7 @@ module Polaris
20
20
  TEXT_ALIGN_OPTIONS = TEXT_ALIGN_MAPPINGS.keys
21
21
 
22
22
  DISCLOSURE_DEFAULT = false
23
- DISCLOSURE_OPTIONS = [true, false, :down, :up, :select]
23
+ DISCLOSURE_OPTIONS = [true, false, :down, :up, :select, :horizontal_dots]
24
24
 
25
25
  renders_one :icon, IconComponent
26
26
 
@@ -1,10 +1,11 @@
1
1
  class Polaris::IndexTable::ColumnComponent < Polaris::Component
2
- attr_reader :title, :flush
2
+ attr_reader :title, :flush, :system_arguments
3
3
 
4
4
  def initialize(title, flush: false, **system_arguments, &block)
5
5
  @title = title
6
6
  @flush = flush
7
7
  @block = block
8
+ @system_arguments = system_arguments
8
9
  end
9
10
 
10
11
  def call(row)
@@ -12,15 +12,13 @@
12
12
  </thead>
13
13
  <tbody>
14
14
  <% @data.each do |row| %>
15
- <tr class="Polaris-IndexTable__TableRow Polaris-IndexTable__TableRow--unclickable">
15
+ <%= render Polaris::BaseComponent.new(**row_arguments(row)) do %>
16
16
  <% columns.each_with_index do |column, index| %>
17
- <%= render_cell(
18
- flush: column.flush,
19
- ) do %>
17
+ <%= render_cell(flush: column.flush, **column.system_arguments) do %>
20
18
  <%= column.call(row) %>
21
19
  <% end %>
22
20
  <% end %>
23
- </tr>
21
+ <% end %>
24
22
  <% end %>
25
23
  </tbody>
26
24
  </table>
@@ -18,6 +18,16 @@ module Polaris
18
18
  end
19
19
  end
20
20
 
21
+ def row_arguments(row)
22
+ {tag: "tr"}.tap do |args|
23
+ args[:classes] = class_names(
24
+ "Polaris-IndexTable__TableRow",
25
+ "Polaris-IndexTable__TableRow--unclickable"
26
+ )
27
+ args[:id] = dom_id(row) if row.respond_to?(:to_key)
28
+ end
29
+ end
30
+
21
31
  def render_cell(**arguments, &block)
22
32
  render(IndexTable::CellComponent.new(**arguments), &block)
23
33
  end
@@ -46,13 +46,13 @@
46
46
  <% end %>
47
47
  </div>
48
48
 
49
- <% if @secondary_actions.any? || action_group.present? || primary_action.present? || has_pagination? %>
49
+ <% if @secondary_actions.any? || action_group.present? || render_primary_action? || has_pagination? %>
50
50
  <div class="Polaris-Page-Header__RightAlign">
51
51
  <div class="Polaris-Page-Header__Actions">
52
52
  <% if @secondary_actions.any? || action_group.present? %>
53
53
  <div class="Polaris-ActionMenu Polaris-ActionMenu--mobile">
54
54
  <div class="Polaris-ActionMenu-RollupActions__RollupActivator">
55
- <%= polaris_popover do |popover| %>
55
+ <%= polaris_popover(position: :below, alignment: :right) do |popover| %>
56
56
  <% popover.button do |button| %>
57
57
  <% button.icon(name: "HorizontalDotsMinor") %>
58
58
  <% end %>
@@ -98,9 +98,9 @@
98
98
  </div>
99
99
  </div>
100
100
  <% end %>
101
- <% if primary_action.present? %>
101
+ <% if render_primary_action? %>
102
102
  <div class="Polaris-Page-Header__PrimaryActionWrapper">
103
- <%= primary_action %>
103
+ <%= primary_action || custom_primary_action %>
104
104
  </div>
105
105
  <% end %>
106
106
  <% if has_pagination? %>
@@ -7,6 +7,7 @@ module Polaris
7
7
  renders_one :primary_action, ->(primary: true, **system_arguments) do
8
8
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
9
9
  end
10
+ renders_one :custom_primary_action
10
11
  renders_one :action_group, "ActionGroupComponent"
11
12
 
12
13
  def initialize(
@@ -81,7 +82,11 @@ module Polaris
81
82
  end
82
83
 
83
84
  def render_header?
84
- @title.present? || @subtitle.present? || @back_url.present? || primary_action.present?
85
+ @title.present? || @subtitle.present? || @back_url.present? || render_primary_action?
86
+ end
87
+
88
+ def render_primary_action?
89
+ primary_action.present? || custom_primary_action.present?
85
90
  end
86
91
 
87
92
  def has_pagination?
@@ -98,7 +103,7 @@ module Polaris
98
103
  end
99
104
 
100
105
  def call
101
- render(Polaris::PopoverComponent.new) do |popover|
106
+ render(Polaris::PopoverComponent.new(position: :below)) do |popover|
102
107
  popover.button(disclosure: true) { @title }
103
108
 
104
109
  polaris_action_list do |list|
@@ -7,25 +7,35 @@
7
7
  <% end %>
8
8
  </div>
9
9
 
10
- <%= render Polaris::BaseComponent.new(**system_arguments) do %>
11
- <%= render Polaris::BaseComponent.new(**popover_arguments) do %>
12
- <div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
13
- <div style="">
14
- <div class="Polaris-Popover__Wrapper">
15
- <%= render Polaris::BaseComponent.new(**content_arguments) do %>
16
- <% if panes.present? %>
17
- <% panes.each do |pane| %>
18
- <%= pane %>
19
- <% end %>
20
- <% else %>
21
- <%= render Polaris::Popover::PaneComponent.new(sectioned: @sectioned) do %>
22
- <%= content %>
10
+ <% popover = capture do %>
11
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
12
+ <%= render Polaris::BaseComponent.new(**popover_arguments) do %>
13
+ <div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
14
+ <div style="">
15
+ <div class="Polaris-Popover__Wrapper">
16
+ <%= render Polaris::BaseComponent.new(**content_arguments) do %>
17
+ <% if panes.present? %>
18
+ <% panes.each do |pane| %>
19
+ <%= pane %>
20
+ <% end %>
21
+ <% else %>
22
+ <%= render Polaris::Popover::PaneComponent.new(sectioned: @sectioned) do %>
23
+ <%= content %>
24
+ <% end %>
23
25
  <% end %>
24
26
  <% end %>
25
- <% end %>
27
+ </div>
26
28
  </div>
27
- </div>
28
- <div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
29
+ <div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
30
+ <% end %>
29
31
  <% end %>
30
32
  <% end %>
33
+
34
+ <% if @append_to_body %>
35
+ <template data-polaris-popover-target="template">
36
+ <%= popover %>
37
+ </template>
38
+ <% else %>
39
+ <%= popover %>
40
+ <% end %>
31
41
  <% end %>
@@ -24,6 +24,7 @@ module Polaris
24
24
  sectioned: false,
25
25
  alignment: ALIGNMENT_DEFAULT,
26
26
  position: POSITION_DEFAULT,
27
+ append_to_body: false,
27
28
  wrapper_arguments: {},
28
29
  **system_arguments
29
30
  )
@@ -36,6 +37,7 @@ module Polaris
36
37
  @sectioned = sectioned
37
38
  @alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, alignment, ALIGNMENT_DEFAULT)
38
39
  @position = fetch_or_fallback(POSITION_OPTIONS, position, POSITION_DEFAULT)
40
+ @append_to_body = append_to_body
39
41
  @wrapper_arguments = wrapper_arguments
40
42
  @system_arguments = system_arguments
41
43
  @popover_arguments = {}
@@ -47,6 +49,7 @@ module Polaris
47
49
  opts[:tag] = "div"
48
50
  opts[:data] ||= {}
49
51
  prepend_option(opts[:data], :controller, "polaris-popover")
52
+ opts[:data][:polaris_popover_append_to_body_value] = @append_to_body
50
53
  opts[:data][:polaris_popover_active_value] = @active
51
54
  opts[:data][:polaris_popover_placement_value] = popperjs_placement
52
55
  opts[:data][:polaris_popover_open_class] = "Polaris-Popover__PopoverOverlay--open"
@@ -61,7 +64,9 @@ module Polaris
61
64
  @system_arguments.tap do |opts|
62
65
  opts[:tag] = "div"
63
66
  opts[:data] ||= {}
64
- opts[:data]["polaris_popover_target"] = "popover"
67
+ unless @append_to_body
68
+ opts[:data]["polaris_popover_target"] = "popover"
69
+ end
65
70
  opts[:classes] = class_names(
66
71
  @system_arguments[:classes],
67
72
  "Polaris-PositionedOverlay",
@@ -0,0 +1,21 @@
1
+ <%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %>
2
+ <%= render(Polaris::ButtonGroupComponent.new(**system_arguments)) do |group| %>
3
+ <% buttons.each do |button| %>
4
+ <% group.button(**button.system_arguments) { button.content } %>
5
+ <% end %>
6
+ <% end %>
7
+ <% end %>
8
+
9
+ <% if @persist_actions %>
10
+ <%= render(Polaris::BaseComponent.new(**disclosure_arguments)) do %>
11
+ <%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
12
+ <% popover.button(disclosure: :horizontal_dots, plain: true) %>
13
+
14
+ <%= render(Polaris::ActionListComponent.new) do |action_list| %>
15
+ <% buttons.each do |button| %>
16
+ <% action_list.item(**button.action_list_item_arguments) { button.content } %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
21
+ <% end %>