polaris_view_components 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polaris_view_components/button_controller.js +48 -0
- data/app/assets/javascripts/polaris_view_components/index.js +11 -1
- data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
- data/app/assets/javascripts/polaris_view_components/polaris_controller.js +24 -0
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +45 -0
- data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
- data/app/assets/javascripts/polaris_view_components.js +1533 -1
- data/app/assets/stylesheets/polaris_view_components/custom.css +26 -1
- data/app/assets/stylesheets/polaris_view_components.css +21 -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/application_component.rb +19 -19
- data/app/components/polaris/avatar_component.rb +1 -1
- data/app/components/polaris/badge_component.rb +1 -1
- data/app/components/polaris/banner_component.rb +6 -6
- data/app/components/polaris/base_button.rb +1 -1
- data/app/components/polaris/button_component.html.erb +13 -0
- data/app/components/polaris/button_group_component.rb +5 -5
- data/app/components/polaris/callout_card_component.rb +5 -5
- data/app/components/polaris/caption_component.rb +2 -2
- data/app/components/polaris/card/header_component.rb +1 -1
- data/app/components/polaris/card/section_component.rb +2 -2
- data/app/components/polaris/card_component.html.erb +4 -0
- data/app/components/polaris/card_component.rb +5 -4
- data/app/components/polaris/character_count.rb +10 -10
- data/app/components/polaris/checkbox_component.rb +4 -4
- data/app/components/polaris/choice_component.rb +1 -1
- data/app/components/polaris/choice_list_component.rb +4 -4
- data/app/components/polaris/data_table/cell_component.rb +3 -3
- data/app/components/polaris/data_table_component.rb +3 -3
- data/app/components/polaris/description_list_component.rb +3 -3
- data/app/components/polaris/display_text_component.rb +2 -2
- data/app/components/polaris/dropzone/component.rb +36 -36
- data/app/components/polaris/empty_state_component.rb +3 -3
- data/app/components/polaris/exception_list/item_component.rb +2 -2
- data/app/components/polaris/exception_list_component.rb +1 -1
- data/app/components/polaris/filters_component.rb +2 -2
- data/app/components/polaris/footer_help_component.rb +1 -1
- data/app/components/polaris/form_layout/group_component.rb +3 -3
- data/app/components/polaris/form_layout/item_component.rb +1 -1
- data/app/components/polaris/form_layout_component.rb +3 -3
- data/app/components/polaris/heading_component.rb +1 -1
- data/app/components/polaris/headless_button.html.erb +13 -0
- data/app/components/polaris/headless_button.rb +17 -5
- data/app/components/polaris/icon_component.rb +2 -2
- data/app/components/polaris/index_table/cell_component.rb +2 -2
- data/app/components/polaris/index_table_component.rb +3 -3
- data/app/components/polaris/inline_error_component.rb +1 -1
- data/app/components/polaris/label_component.rb +2 -2
- data/app/components/polaris/labelled_component.rb +2 -2
- data/app/components/polaris/layout/annotated_section.rb +1 -1
- data/app/components/polaris/layout/section.rb +1 -1
- data/app/components/polaris/layout_component.rb +3 -3
- data/app/components/polaris/link_component.rb +3 -3
- data/app/components/polaris/list_component.rb +3 -3
- 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/page_actions_component.rb +8 -7
- data/app/components/polaris/page_component.rb +4 -4
- data/app/components/polaris/pagination_component.rb +1 -5
- 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 +38 -0
- data/app/components/polaris/popover_component.rb +90 -0
- data/app/components/polaris/progress_bar_component.rb +5 -5
- data/app/components/polaris/radio_button_component.rb +3 -3
- data/app/components/polaris/resource_item_component.html.erb +16 -6
- data/app/components/polaris/resource_item_component.rb +42 -9
- data/app/components/polaris/resource_list_component.rb +2 -2
- 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 +3 -3
- 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 +6 -6
- data/app/components/polaris/skeleton_body_text_component.rb +1 -1
- data/app/components/polaris/spacer_component.rb +3 -3
- data/app/components/polaris/spinner_component.rb +2 -2
- data/app/components/polaris/stack_component.rb +5 -5
- data/app/components/polaris/subheading_component.rb +1 -1
- 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 +1 -1
- data/app/components/polaris/text_container_component.rb +2 -2
- data/app/components/polaris/text_field_component.rb +8 -8
- data/app/components/polaris/text_style_component.rb +4 -4
- data/app/components/polaris/thumbnail_component.rb +2 -2
- data/app/helpers/polaris/form_builder.rb +4 -2
- data/app/helpers/polaris/url_helper.rb +3 -3
- data/app/helpers/polaris/view_helper.rb +11 -3
- data/app/validators/type_validator.rb +2 -2
- data/lib/generators/polaris_view_components/install_generator.rb +5 -5
- data/lib/polaris/view_components/engine.rb +6 -0
- data/lib/polaris/view_components/version.rb +1 -1
- data/lib/polaris_view_components.rb +1 -1
- metadata +30 -3
@@ -7,11 +7,11 @@ module Polaris
|
|
7
7
|
TYPE_DEFAULT = :bullet
|
8
8
|
TYPE_TAG_MAPPINGS = {
|
9
9
|
bullet: :ul,
|
10
|
-
number: :ol
|
10
|
+
number: :ol
|
11
11
|
}
|
12
12
|
TYPE_CLASS_MAPPINGS = {
|
13
13
|
bullet: "",
|
14
|
-
number: "Polaris-List--typeNumber"
|
14
|
+
number: "Polaris-List--typeNumber"
|
15
15
|
}
|
16
16
|
TYPE_OPTIONS = TYPE_TAG_MAPPINGS.keys
|
17
17
|
|
@@ -24,7 +24,7 @@ module Polaris
|
|
24
24
|
@system_arguments[:classes] = class_names(
|
25
25
|
@system_arguments[:classes],
|
26
26
|
"Polaris-List",
|
27
|
-
TYPE_CLASS_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, "")]
|
27
|
+
TYPE_CLASS_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, "")]
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Polaris::Modal::SectionComponent < Polaris::NewComponent
|
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-Modal-Section"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
render(Polaris::BaseComponent.new(**system_arguments)) { content }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<% modal_content = capture do %>
|
2
|
+
<% if sections.present? %>
|
3
|
+
<% sections.each do |section| %>
|
4
|
+
<%= section %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if content.present? %>
|
9
|
+
<% if @sectioned %>
|
10
|
+
<%= render Polaris::Modal::SectionComponent.new do %>
|
11
|
+
<%= content %>
|
12
|
+
<% end %>
|
13
|
+
<% else %>
|
14
|
+
<%= content %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
20
|
+
<div>
|
21
|
+
<%= render(Polaris::BaseComponent.new(**dialog_arguments)) do %>
|
22
|
+
<div class="<%= modal_classes %>">
|
23
|
+
<div class="<%= header_classes %>">
|
24
|
+
<div class="Polaris-Modal-Header__Title">
|
25
|
+
<%= polaris_display_text(element: :h2, size: :small) do %>
|
26
|
+
<%= @title %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
<% if close_button.present? %>
|
30
|
+
<%= close_button %>
|
31
|
+
<% else %>
|
32
|
+
<%= render(Polaris::BaseComponent.new(**close_button_arguments)) do %>
|
33
|
+
<%= polaris_icon(name: "MobileCancelMajor", color: :base) %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="Polaris-Modal__BodyWrapper">
|
39
|
+
<% if @scrollable %>
|
40
|
+
<%= polaris_scrollable(classes: "Polaris-Modal__Body") do %>
|
41
|
+
<%= modal_content %>
|
42
|
+
<% end %>
|
43
|
+
<% else %>
|
44
|
+
<%= modal_content %>
|
45
|
+
<% end %>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<% if render_footer? %>
|
49
|
+
<div class="Polaris-Modal-Footer">
|
50
|
+
<div class="Polaris-Modal-Footer__FooterContent">
|
51
|
+
<%= polaris_stack(alignment: :center) do |stack| %>
|
52
|
+
<% stack.item(fill: true) do %>
|
53
|
+
<% end %>
|
54
|
+
|
55
|
+
<% stack.item do %>
|
56
|
+
<%= polaris_button_group do |group| %>
|
57
|
+
<% if secondary_actions %>
|
58
|
+
<% secondary_actions.each do |action| %>
|
59
|
+
<% group.item do %>
|
60
|
+
<%= action %>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
|
64
|
+
<% if primary_action %>
|
65
|
+
<% group.item do %>
|
66
|
+
<%= primary_action %>
|
67
|
+
<% end %>
|
68
|
+
<% end %>
|
69
|
+
<% end %>
|
70
|
+
<% end %>
|
71
|
+
<% end %>
|
72
|
+
<% end %>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
<% end %>
|
78
|
+
</div>
|
79
|
+
<% end %>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Polaris
|
4
|
+
class ModalComponent < Polaris::NewComponent
|
5
|
+
renders_one :close_button, ->(**system_arguments) do
|
6
|
+
button_arguments = @close_button_arguments.deep_merge(system_arguments)
|
7
|
+
render(Polaris::BaseComponent.new(**button_arguments)) do
|
8
|
+
polaris_icon(name: "MobileCancelMajor", color: :base)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
renders_many :sections, Polaris::Modal::SectionComponent
|
12
|
+
renders_one :primary_action, ->(primary: true, **system_arguments) do
|
13
|
+
Polaris::ButtonComponent.new(primary: primary, **system_arguments)
|
14
|
+
end
|
15
|
+
renders_many :secondary_actions, Polaris::ButtonComponent
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
title:,
|
19
|
+
open: false,
|
20
|
+
sectioned: true,
|
21
|
+
scrollable: true,
|
22
|
+
large: false,
|
23
|
+
small: false,
|
24
|
+
limit_height: false,
|
25
|
+
dialog_arguments: {},
|
26
|
+
**system_arguments
|
27
|
+
)
|
28
|
+
@title = title
|
29
|
+
@open = open
|
30
|
+
@sectioned = sectioned
|
31
|
+
@scrollable = scrollable
|
32
|
+
@large = large
|
33
|
+
@small = small
|
34
|
+
@limit_height = limit_height
|
35
|
+
@dialog_arguments = dialog_arguments
|
36
|
+
@system_arguments = system_arguments
|
37
|
+
@close_button_arguments = {
|
38
|
+
tag: "button",
|
39
|
+
type: "button",
|
40
|
+
classes: "Polaris-Modal-CloseButton",
|
41
|
+
aria: {label: "Close"}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def system_arguments
|
46
|
+
@system_arguments.tap do |opts|
|
47
|
+
opts[:tag] = "div"
|
48
|
+
opts[:data] ||= {}
|
49
|
+
prepend_option(opts[:data], :controller, "polaris-modal")
|
50
|
+
opts[:data][:polaris_modal_open_value] = @open
|
51
|
+
opts[:data][:polaris_modal_hidden_class] = "Polaris--hidden"
|
52
|
+
opts[:data][:polaris_modal_backdrop_class] = "Polaris-Backdrop"
|
53
|
+
opts[:classes] = class_names(
|
54
|
+
@system_arguments[:classes],
|
55
|
+
"Polaris-Modal-Dialog__Container",
|
56
|
+
"Polaris--hidden"
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def dialog_arguments
|
62
|
+
@dialog_arguments.tap do |opts|
|
63
|
+
opts[:tag] = "div"
|
64
|
+
opts[:role] = "dialog"
|
65
|
+
opts[:aria] ||= {}
|
66
|
+
opts[:aria][:modal] = "true"
|
67
|
+
opts[:tabindex] = "-1"
|
68
|
+
opts[:classes] = class_names(
|
69
|
+
@dialog_arguments[:classes],
|
70
|
+
"Polaris-Modal-Dialog"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def close_button_arguments
|
76
|
+
@close_button_arguments.deep_merge({
|
77
|
+
data: {action: "polaris-modal#close"}
|
78
|
+
})
|
79
|
+
end
|
80
|
+
|
81
|
+
def modal_classes
|
82
|
+
class_names(
|
83
|
+
"Polaris-Modal-Dialog__Modal",
|
84
|
+
"Polaris-Modal-Dialog--sizeLarge": @large,
|
85
|
+
"Polaris-Modal-Dialog--sizeSmall": @small,
|
86
|
+
"Polaris-Modal-Dialog--limitHeight": @limit_height
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def header_classes
|
91
|
+
@title.present? ? "Polaris-Modal-Header" : "Polaris-Modal-Header--titleHidden"
|
92
|
+
end
|
93
|
+
|
94
|
+
def render_footer?
|
95
|
+
primary_action.present? || secondary_actions.any?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -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
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class PageComponent < Polaris::NewComponent
|
5
|
-
renders_one :primary_action, ->
|
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
|
|
@@ -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::NewComponent
|
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::NewComponent
|
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
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div
|
2
|
+
data-controller="polaris-popover"
|
3
|
+
data-polaris-popover-active-value="<%= @active %>"
|
4
|
+
data-polaris-popover-placement-value="<%= popperjs_placement %>"
|
5
|
+
data-polaris-popover-open-class="Polaris-Popover__PopoverOverlay--open"
|
6
|
+
data-polaris-popover-closed-class="Polaris-Popover__PopoverOverlay--closed"
|
7
|
+
style="<%= "display: inline-block;" if @inline %>"
|
8
|
+
>
|
9
|
+
<div data-polaris-popover-target="activator">
|
10
|
+
<% if activator.present? %>
|
11
|
+
<%= activator %>
|
12
|
+
<% elsif button.present? %>
|
13
|
+
<%= button %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
18
|
+
<%= render Polaris::BaseComponent.new(**popover_arguments) do %>
|
19
|
+
<div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
|
20
|
+
<div style="">
|
21
|
+
<div class="Polaris-Popover__Wrapper">
|
22
|
+
<%= render Polaris::BaseComponent.new(**content_arguments) do %>
|
23
|
+
<% if panes.present? %>
|
24
|
+
<% panes.each do |pane| %>
|
25
|
+
<%= pane %>
|
26
|
+
<% end %>
|
27
|
+
<% else %>
|
28
|
+
<%= render Polaris::Popover::PaneComponent.new(sectioned: @sectioned) do %>
|
29
|
+
<%= content %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
|
36
|
+
<% end %>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Polaris
|
2
|
+
class PopoverComponent < Polaris::NewComponent
|
3
|
+
ALIGNMENT_DEFAULT = :center
|
4
|
+
ALIGNMENT_OPTIONS = [:left, :right, :center]
|
5
|
+
|
6
|
+
POSITION_DEFAULT = :below
|
7
|
+
POSITION_OPTIONS = [:above, :below]
|
8
|
+
|
9
|
+
renders_one :button, ->(**system_arguments) do
|
10
|
+
system_arguments[:data] ||= {}
|
11
|
+
prepend_option(system_arguments[:data], :action, "polaris-popover#toggle click@window->polaris-popover#hide")
|
12
|
+
Polaris::ButtonComponent.new(**system_arguments)
|
13
|
+
end
|
14
|
+
renders_one :activator
|
15
|
+
renders_many :panes, Polaris::Popover::PaneComponent
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
active: false,
|
19
|
+
inline: true,
|
20
|
+
fixed: false,
|
21
|
+
fluid_content: false,
|
22
|
+
full_height: false,
|
23
|
+
full_width: false,
|
24
|
+
sectioned: false,
|
25
|
+
alignment: ALIGNMENT_DEFAULT,
|
26
|
+
position: POSITION_DEFAULT,
|
27
|
+
**system_arguments
|
28
|
+
)
|
29
|
+
@active = active
|
30
|
+
@inline = inline
|
31
|
+
@fixed = fixed
|
32
|
+
@fluid_content = fluid_content
|
33
|
+
@full_height = full_height
|
34
|
+
@full_width = full_width
|
35
|
+
@sectioned = sectioned
|
36
|
+
@alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, alignment, ALIGNMENT_DEFAULT)
|
37
|
+
@position = fetch_or_fallback(POSITION_OPTIONS, position, POSITION_DEFAULT)
|
38
|
+
@system_arguments = system_arguments
|
39
|
+
@popover_arguments = {}
|
40
|
+
@content_arguments = {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def system_arguments
|
44
|
+
@system_arguments.tap do |opts|
|
45
|
+
opts[:tag] = "div"
|
46
|
+
opts[:data] ||= {}
|
47
|
+
opts[:data]["polaris_popover_target"] = "popover"
|
48
|
+
opts[:classes] = class_names(
|
49
|
+
@system_arguments[:classes],
|
50
|
+
"Polaris-PositionedOverlay",
|
51
|
+
"Polaris-Popover__PopoverOverlay",
|
52
|
+
"Polaris-Popover__PopoverOverlay--closed",
|
53
|
+
"Polaris-Popover__PopoverOverlay--fixed": @fixed
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def popover_arguments
|
59
|
+
@popover_arguments.tap do |opts|
|
60
|
+
opts[:tag] = "div"
|
61
|
+
opts[:classes] = class_names(
|
62
|
+
@content_arguments[:classes],
|
63
|
+
"Polaris-Popover",
|
64
|
+
"Polaris-Popover--fullWidth": @full_width,
|
65
|
+
"Polaris-Popover--positionedAbove": @position == :above
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def content_arguments
|
71
|
+
@content_arguments.tap do |opts|
|
72
|
+
opts[:tag] = "div"
|
73
|
+
opts[:tabindex] ||= "-1"
|
74
|
+
opts[:classes] = class_names(
|
75
|
+
@content_arguments[:classes],
|
76
|
+
"Polaris-Popover__Content",
|
77
|
+
"Polaris-Popover__Content--fluidContent": @fluid_content,
|
78
|
+
"Polaris-Popover__Content--fullHeight": @full_height
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def popperjs_placement
|
84
|
+
placement = @position == :above ? "top" : "bottom"
|
85
|
+
placement += "-start" if @alignment == :left
|
86
|
+
placement += "-end" if @alignment == :right
|
87
|
+
placement
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -5,16 +5,16 @@ module Polaris
|
|
5
5
|
COLOR_DEFAULT = :highlight
|
6
6
|
COLOR_MAPPINGS = {
|
7
7
|
COLOR_DEFAULT => "Polaris-ProgressBar--colorHighlight",
|
8
|
-
primary
|
9
|
-
success
|
8
|
+
:primary => "Polaris-ProgressBar--colorPrimary",
|
9
|
+
:success => "Polaris-ProgressBar--colorSuccess"
|
10
10
|
}
|
11
11
|
COLOR_OPTIONS = COLOR_MAPPINGS.keys
|
12
12
|
|
13
13
|
SIZE_DEFAULT = :medium
|
14
14
|
SIZE_MAPPINGS = {
|
15
15
|
SIZE_DEFAULT => "Polaris-ProgressBar--sizeMedium",
|
16
|
-
small
|
17
|
-
large
|
16
|
+
:small => "Polaris-ProgressBar--sizeSmall",
|
17
|
+
:large => "Polaris-ProgressBar--sizeLarge"
|
18
18
|
}
|
19
19
|
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
20
20
|
|
@@ -31,7 +31,7 @@ module Polaris
|
|
31
31
|
@system_arguments[:classes],
|
32
32
|
"Polaris-ProgressBar",
|
33
33
|
COLOR_MAPPINGS[fetch_or_fallback(COLOR_OPTIONS, color, COLOR_DEFAULT)],
|
34
|
-
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
|
34
|
+
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
|
35
35
|
)
|
36
36
|
|
37
37
|
@animated = animated
|
@@ -27,14 +27,14 @@ module Polaris
|
|
27
27
|
@system_arguments[:classes] = class_names(
|
28
28
|
@system_arguments[:classes],
|
29
29
|
"Polaris-RadioButton",
|
30
|
-
"Polaris-RadioButton--labelHidden": label_hidden
|
30
|
+
"Polaris-RadioButton--labelHidden": label_hidden
|
31
31
|
)
|
32
32
|
|
33
33
|
@wrapper_arguments = {
|
34
34
|
label: label,
|
35
35
|
label_hidden: label_hidden,
|
36
36
|
help_text: help_text,
|
37
|
-
disabled: disabled
|
37
|
+
disabled: disabled
|
38
38
|
}.merge(wrapper_arguments)
|
39
39
|
|
40
40
|
@input_options = input_options
|
@@ -43,7 +43,7 @@ module Polaris
|
|
43
43
|
@input_options[:aria][:checked] = checked
|
44
44
|
@input_options[:class] = class_names(
|
45
45
|
@input_options[:classes],
|
46
|
-
"Polaris-RadioButton__Input"
|
46
|
+
"Polaris-RadioButton__Input"
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -11,12 +11,22 @@
|
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<%= render(Polaris::BaseComponent.new(**container_arguments)) do %>
|
14
|
-
<% if
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
<% if owned? %>
|
15
|
+
<%= render(Polaris::BaseComponent.new(**owned_arguments)) do %>
|
16
|
+
<% if checkbox.present? || radio_button.present? %>
|
17
|
+
<div class="Polaris-ResourceItem__Handle">
|
18
|
+
<div class="Polaris-ResourceItem__CheckboxWrapper">
|
19
|
+
<%= checkbox.presence || radio_button %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% if media.present? %>
|
25
|
+
<div class="Polaris-ResourceItem__Media">
|
26
|
+
<%= media %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
20
30
|
<% end %>
|
21
31
|
<div class="Polaris-ResourceItem__Content">
|
22
32
|
<%= content %>
|