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.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
- data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
- data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
- data/app/assets/javascripts/polaris_view_components/index.js +19 -1
- data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
- data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
- data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +49 -0
- data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
- data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
- data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
- data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
- data/app/assets/javascripts/polaris_view_components.js +1936 -5
- data/app/assets/stylesheets/polaris_view_components/custom.css +109 -0
- data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
- data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
- data/app/assets/stylesheets/polaris_view_components.css +118 -3
- data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
- 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/autocomplete/action_component.rb +7 -0
- data/app/components/polaris/autocomplete/option_component.rb +35 -0
- data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
- data/app/components/polaris/autocomplete/section_component.rb +12 -0
- data/app/components/polaris/autocomplete_component.html.erb +30 -0
- data/app/components/polaris/autocomplete_component.rb +58 -0
- 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/base_checkbox.rb +48 -0
- data/app/components/polaris/base_radio_button.rb +38 -0
- data/app/components/polaris/button_component.html.erb +13 -0
- data/app/components/polaris/button_group_component.rb +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 -3
- data/app/components/polaris/card/section_component.rb +6 -2
- data/app/components/polaris/card_component.html.erb +4 -0
- data/app/components/polaris/card_component.rb +5 -6
- data/app/components/polaris/character_count.rb +10 -10
- data/app/components/polaris/checkbox_component.html.erb +1 -5
- data/app/components/polaris/checkbox_component.rb +19 -12
- data/app/components/polaris/choice_component.rb +1 -1
- data/app/components/polaris/choice_list_component.rb +5 -5
- data/app/components/polaris/data_table/cell_component.html.erb +18 -0
- data/app/components/polaris/data_table/cell_component.rb +49 -0
- data/app/components/polaris/data_table/column_component.rb +19 -0
- data/app/components/polaris/data_table_component.html.erb +77 -0
- data/app/components/polaris/data_table_component.rb +42 -0
- 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 -38
- data/app/components/polaris/empty_state_component.html.erb +16 -11
- data/app/components/polaris/empty_state_component.rb +4 -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.html.erb +35 -0
- data/app/components/polaris/filters_component.rb +91 -0
- 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/frame/save_bar_component.html.erb +23 -0
- data/app/components/polaris/frame/save_bar_component.rb +31 -0
- data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
- data/app/components/polaris/frame/top_bar_component.rb +18 -0
- data/app/components/polaris/frame_component.html.erb +44 -0
- data/app/components/polaris/frame_component.rb +33 -0
- data/app/components/polaris/heading_component.rb +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 +22 -0
- data/app/components/polaris/index_table/column_component.rb +13 -0
- data/app/components/polaris/index_table_component.html.erb +28 -0
- data/app/components/polaris/index_table_component.rb +25 -0
- data/app/components/polaris/inline_error_component.html.erb +2 -2
- data/app/components/polaris/inline_error_component.rb +7 -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 +2 -0
- data/app/components/polaris/layout_component.rb +3 -3
- data/app/components/polaris/link_component.rb +5 -3
- data/app/components/polaris/list_component.rb +3 -3
- data/app/components/polaris/logo.rb +13 -0
- data/app/components/polaris/modal/section_component.rb +19 -0
- data/app/components/polaris/modal_component.html.erb +79 -0
- data/app/components/polaris/modal_component.rb +98 -0
- data/app/components/polaris/navigation/item_component.html.erb +31 -0
- data/app/components/polaris/navigation/item_component.rb +85 -0
- data/app/components/polaris/navigation/section_component.html.erb +17 -0
- data/app/components/polaris/navigation/section_component.rb +64 -0
- data/app/components/polaris/navigation_component.html.erb +29 -0
- data/app/components/polaris/navigation_component.rb +15 -0
- data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
- data/app/components/polaris/option_list/checkbox_component.rb +37 -0
- data/app/components/polaris/option_list/option_component.rb +24 -0
- data/app/components/polaris/option_list/radio_button_component.rb +54 -0
- data/app/components/polaris/option_list/section_component.html.erb +14 -0
- data/app/components/polaris/option_list/section_component.rb +53 -0
- data/app/components/polaris/option_list_component.html.erb +15 -0
- data/app/components/polaris/option_list_component.rb +67 -0
- data/app/components/polaris/page_actions_component.rb +21 -6
- 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 +31 -0
- data/app/components/polaris/popover_component.rb +107 -0
- data/app/components/polaris/progress_bar_component.rb +5 -5
- data/app/components/polaris/radio_button_component.html.erb +1 -6
- data/app/components/polaris/radio_button_component.rb +17 -7
- 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.html.erb +10 -0
- data/app/components/polaris/resource_list_component.rb +4 -10
- 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 +10 -5
- 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 +50 -0
- 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 +2 -2
- data/app/components/polaris/text_container_component.rb +2 -2
- data/app/components/polaris/text_field_component.rb +24 -10
- data/app/components/polaris/text_style_component.rb +11 -2
- data/app/components/polaris/thumbnail_component.rb +2 -2
- data/app/components/polaris/toast_component.html.erb +21 -0
- data/app/components/polaris/toast_component.rb +40 -0
- data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
- data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
- data/app/helpers/polaris/form_builder.rb +31 -4
- data/app/helpers/polaris/url_helper.rb +3 -3
- data/app/helpers/polaris/view_helper.rb +37 -6
- 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 +11 -2
- data/lib/polaris/view_components/version.rb +1 -1
- data/lib/polaris_view_components.rb +1 -1
- metadata +88 -12
- data/app/components/polaris/choice_list/component.html.erb +0 -34
- data/app/components/polaris/choice_list/component.rb +0 -65
- data/app/helpers/polaris/action_helper.rb +0 -14
@@ -44,7 +44,7 @@ module Polaris
|
|
44
44
|
"Polaris-Badge",
|
45
45
|
PROGRESS_MAPPINGS[fetch_or_fallback(PROGRESS_OPTIONS, progress, PROGRESS_DEFAULT)],
|
46
46
|
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
|
47
|
-
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
|
47
|
+
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
@@ -8,14 +8,14 @@ module Polaris
|
|
8
8
|
:success => "Polaris-Banner--statusSuccess",
|
9
9
|
:info => "Polaris-Banner--statusInfo",
|
10
10
|
:warning => "Polaris-Banner--statusWarning",
|
11
|
-
:critical => "Polaris-Banner--statusCritical"
|
11
|
+
:critical => "Polaris-Banner--statusCritical"
|
12
12
|
}
|
13
13
|
STATUS_OPTIONS = STATUS_MAPPINGS.keys
|
14
14
|
|
15
15
|
WITHIN_DEFAULT = :page
|
16
16
|
WITHIN_MAPPINGS = {
|
17
17
|
page: "Polaris-Banner--withinPage",
|
18
|
-
container: "Polaris-Banner--withinContentContainer"
|
18
|
+
container: "Polaris-Banner--withinContentContainer"
|
19
19
|
}
|
20
20
|
WITHIN_OPTIONS = WITHIN_MAPPINGS.keys
|
21
21
|
|
@@ -24,14 +24,14 @@ module Polaris
|
|
24
24
|
success: :success,
|
25
25
|
info: :highlight,
|
26
26
|
warning: :warning,
|
27
|
-
critical: :critical
|
27
|
+
critical: :critical
|
28
28
|
}
|
29
29
|
|
30
|
-
renders_one :action, ->
|
30
|
+
renders_one :action, ->(**system_arguments) do
|
31
31
|
Polaris::ButtonComponent.new(classes: "Polaris-Banner__Button", **system_arguments)
|
32
32
|
end
|
33
33
|
renders_one :secondary_action, "SecondaryAction"
|
34
|
-
renders_one :dismiss_button, ->
|
34
|
+
renders_one :dismiss_button, ->(**system_arguments) do
|
35
35
|
render Polaris::ButtonComponent.new(plain: true, **system_arguments) do |button|
|
36
36
|
button.icon(name: "CancelSmallMinor")
|
37
37
|
end
|
@@ -55,7 +55,7 @@ module Polaris
|
|
55
55
|
@system_arguments[:classes],
|
56
56
|
"Polaris-Banner",
|
57
57
|
STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)],
|
58
|
-
WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)]
|
58
|
+
WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)]
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Polaris
|
2
|
+
class BaseCheckbox < Polaris::NewComponent
|
3
|
+
def initialize(
|
4
|
+
form: nil,
|
5
|
+
attribute: nil,
|
6
|
+
name: nil,
|
7
|
+
checked: false,
|
8
|
+
disabled: false,
|
9
|
+
value: "1",
|
10
|
+
unchecked_value: "0",
|
11
|
+
**system_arguments
|
12
|
+
)
|
13
|
+
@form = form
|
14
|
+
@attribute = attribute
|
15
|
+
@name = name
|
16
|
+
@checked = checked
|
17
|
+
@disabled = disabled
|
18
|
+
@value = value
|
19
|
+
@unchecked_value = unchecked_value
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
end
|
22
|
+
|
23
|
+
def system_arguments
|
24
|
+
@system_arguments.tap do |opts|
|
25
|
+
opts[:disabled] = true if @disabled
|
26
|
+
opts[:aria] ||= {}
|
27
|
+
opts[:aria][:checked] = @checked
|
28
|
+
if indeterminate?
|
29
|
+
@system_arguments[:indeterminate] = true
|
30
|
+
@system_arguments[:aria][:checked] = "mixed"
|
31
|
+
end
|
32
|
+
opts[:class] = opts.delete(:classes)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def indeterminate?
|
37
|
+
@checked == :indeterminate
|
38
|
+
end
|
39
|
+
|
40
|
+
def call
|
41
|
+
if @form.present? && @attribute.present?
|
42
|
+
@form.check_box(@attribute, system_arguments, @value, @unchecked_value)
|
43
|
+
else
|
44
|
+
check_box_tag(@name, @value, @checked, system_arguments)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Polaris
|
2
|
+
class BaseRadioButton < Polaris::NewComponent
|
3
|
+
def initialize(
|
4
|
+
form: nil,
|
5
|
+
attribute: nil,
|
6
|
+
name: nil,
|
7
|
+
checked: false,
|
8
|
+
disabled: false,
|
9
|
+
value: nil,
|
10
|
+
**system_arguments
|
11
|
+
)
|
12
|
+
@form = form
|
13
|
+
@attribute = attribute
|
14
|
+
@name = name
|
15
|
+
@checked = checked
|
16
|
+
@disabled = disabled
|
17
|
+
@value = value
|
18
|
+
@system_arguments = system_arguments
|
19
|
+
end
|
20
|
+
|
21
|
+
def system_arguments
|
22
|
+
@system_arguments.tap do |opts|
|
23
|
+
opts[:disabled] = true if @disabled
|
24
|
+
opts[:aria] ||= {}
|
25
|
+
opts[:aria][:checked] = @checked
|
26
|
+
opts[:class] = opts.delete(:classes)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def call
|
31
|
+
if @form.present? && @attribute.present?
|
32
|
+
@form.radio_button(@attribute, @value, system_arguments)
|
33
|
+
else
|
34
|
+
radio_button_tag(@name, @value, @checked, system_arguments)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -20,5 +20,18 @@
|
|
20
20
|
<%= content %>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
23
|
+
|
24
|
+
<% if @disclosure.present? %>
|
25
|
+
<div class="Polaris-Button__Icon">
|
26
|
+
<% case @disclosure %>
|
27
|
+
<% when :down %>
|
28
|
+
<%= polaris_icon(name: "CaretDownMinor") %>
|
29
|
+
<% when :up %>
|
30
|
+
<%= polaris_icon(name: "CaretUpMinor") %>
|
31
|
+
<% when :select %>
|
32
|
+
<%= polaris_icon(name: "SelectMinor") %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
23
36
|
</span>
|
24
37
|
<% end %>
|
@@ -7,17 +7,17 @@ module Polaris
|
|
7
7
|
SPACING_DEFAULT => "",
|
8
8
|
:extra_tight => "Polaris-ButtonGroup--extraTight",
|
9
9
|
:tight => "Polaris-ButtonGroup--tight",
|
10
|
-
:loose => "Polaris-ButtonGroup--loose"
|
10
|
+
:loose => "Polaris-ButtonGroup--loose"
|
11
11
|
}
|
12
12
|
SPACING_OPTIONS = SPACING_MAPPINGS.keys
|
13
13
|
|
14
|
-
renders_many :buttons, ->
|
14
|
+
renders_many :buttons, ->(**system_arguments) do
|
15
15
|
@counter += 1
|
16
16
|
|
17
17
|
ButtonGroupItemButtonComponent.new(position: @counter, **system_arguments)
|
18
18
|
end
|
19
19
|
|
20
|
-
renders_many :items, ->
|
20
|
+
renders_many :items, ->(**system_arguments) do
|
21
21
|
@counter += 1
|
22
22
|
|
23
23
|
ButtonGroupItemComponent.new(position: @counter, **system_arguments)
|
@@ -47,7 +47,7 @@ module Polaris
|
|
47
47
|
"Polaris-ButtonGroup",
|
48
48
|
SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)],
|
49
49
|
"Polaris-ButtonGroup--fullWidth": full_width,
|
50
|
-
"Polaris-ButtonGroup--segmented": segmented
|
50
|
+
"Polaris-ButtonGroup--segmented": segmented
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
@@ -97,7 +97,7 @@ module Polaris
|
|
97
97
|
@system_arguments[:tag] = :div
|
98
98
|
@system_arguments[:classes] = class_names(
|
99
99
|
@system_arguments[:classes],
|
100
|
-
"Polaris-ButtonGroup__Item"
|
100
|
+
"Polaris-ButtonGroup__Item"
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Polaris
|
4
4
|
class CalloutCardComponent < Polaris::NewComponent
|
5
5
|
renders_one :primary_action, Polaris::ButtonComponent
|
6
|
-
renders_one :secondary_action, ->
|
6
|
+
renders_one :secondary_action, ->(plain: true, **system_arguments) do
|
7
7
|
Polaris::ButtonComponent.new(plain: plain, **system_arguments)
|
8
8
|
end
|
9
|
-
renders_one :dismiss_button, ->
|
9
|
+
renders_one :dismiss_button, ->(**system_arguments) do
|
10
10
|
render Polaris::ButtonComponent.new(plain: true, **system_arguments) do |button|
|
11
11
|
button.icon(name: "CancelSmallMinor")
|
12
12
|
end
|
@@ -24,21 +24,21 @@ module Polaris
|
|
24
24
|
@system_arguments[:tag] = "div"
|
25
25
|
@system_arguments[:classes] = class_names(
|
26
26
|
@system_arguments[:classes],
|
27
|
-
"Polaris-Card"
|
27
|
+
"Polaris-Card"
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
31
|
def container_classes
|
32
32
|
class_names(
|
33
33
|
"Polaris-CalloutCard__Container",
|
34
|
-
"Polaris-CalloutCard--hasDismiss": dismiss_button.present
|
34
|
+
"Polaris-CalloutCard--hasDismiss": dismiss_button.present?
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
38
38
|
def image_classes
|
39
39
|
class_names(
|
40
40
|
"Polaris-CalloutCard__Image",
|
41
|
-
"Polaris-CalloutCard__DismissImage": dismiss_button.present
|
41
|
+
"Polaris-CalloutCard__DismissImage": dismiss_button.present?
|
42
42
|
)
|
43
43
|
end
|
44
44
|
end
|
@@ -4,10 +4,10 @@ module Polaris
|
|
4
4
|
class CaptionComponent < Polaris::NewComponent
|
5
5
|
def initialize(**system_arguments)
|
6
6
|
@system_arguments = system_arguments
|
7
|
-
@system_arguments[:tag] =
|
7
|
+
@system_arguments[:tag] = "p"
|
8
8
|
@system_arguments[:classes] = class_names(
|
9
9
|
@system_arguments[:classes],
|
10
|
-
"Polaris-Caption"
|
10
|
+
"Polaris-Caption"
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
class Polaris::Card::HeaderComponent < Polaris::NewComponent
|
2
|
-
include Polaris::ActionHelper
|
3
|
-
|
4
2
|
def initialize(
|
5
3
|
title: "",
|
6
4
|
actions: [],
|
@@ -10,7 +8,7 @@ class Polaris::Card::HeaderComponent < Polaris::NewComponent
|
|
10
8
|
@system_arguments[:tag] = :div
|
11
9
|
@system_arguments[:classes] = class_names(
|
12
10
|
@system_arguments[:classes],
|
13
|
-
"Polaris-Card__Header"
|
11
|
+
"Polaris-Card__Header"
|
14
12
|
)
|
15
13
|
|
16
14
|
@title = title
|
@@ -7,6 +7,8 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
|
|
7
7
|
flush: false,
|
8
8
|
full_width: false,
|
9
9
|
unstyled: false,
|
10
|
+
border_top: false,
|
11
|
+
border_bottom: false,
|
10
12
|
actions: [],
|
11
13
|
**system_arguments
|
12
14
|
)
|
@@ -14,10 +16,12 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
|
|
14
16
|
@system_arguments[:tag] = :div
|
15
17
|
@system_arguments[:classes] = class_names(
|
16
18
|
@system_arguments[:classes],
|
19
|
+
"Polaris-Card__Section": !unstyled,
|
17
20
|
"Polaris-Card__Section--flush": flush,
|
18
21
|
"Polaris-Card__Section--subdued": subdued,
|
19
22
|
"Polaris-Card__Section--fullWidth": full_width,
|
20
|
-
"Polaris-Card__Section":
|
23
|
+
"Polaris-Card__Section--borderTop": border_top,
|
24
|
+
"Polaris-Card__Section--borderBottom": border_bottom
|
21
25
|
)
|
22
26
|
|
23
27
|
@title = title
|
@@ -30,7 +34,7 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
|
|
30
34
|
@system_arguments[:tag] = :div
|
31
35
|
@system_arguments[:classes] = class_names(
|
32
36
|
@system_arguments[:classes],
|
33
|
-
"Polaris-Card__Subsection"
|
37
|
+
"Polaris-Card__Subsection"
|
34
38
|
)
|
35
39
|
end
|
36
40
|
|
@@ -2,18 +2,17 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class CardComponent < Polaris::NewComponent
|
5
|
-
include Polaris::ActionHelper
|
6
|
-
|
7
5
|
FOOTER_ACTION_ALIGNMENT_DEFAULT = :right
|
8
6
|
FOOTER_ACTION_ALIGNMENT_MAPPINGS = {
|
9
7
|
FOOTER_ACTION_ALIGNMENT_DEFAULT => "",
|
10
|
-
:left => "Polaris-Card__LeftJustified"
|
8
|
+
:left => "Polaris-Card__LeftJustified"
|
11
9
|
}
|
12
10
|
FOOTER_ACTION_ALIGNMENT_OPTIONS = FOOTER_ACTION_ALIGNMENT_MAPPINGS.keys
|
13
11
|
|
12
|
+
renders_one :tabs, Polaris::TabsComponent
|
14
13
|
renders_one :header, Polaris::Card::HeaderComponent
|
15
14
|
renders_many :sections, Polaris::Card::SectionComponent
|
16
|
-
renders_one :primary_footer_action, ->
|
15
|
+
renders_one :primary_footer_action, ->(primary: true, **system_arguments) do
|
17
16
|
Polaris::ButtonComponent.new(primary: primary, **system_arguments)
|
18
17
|
end
|
19
18
|
renders_many :secondary_footer_actions, Polaris::ButtonComponent
|
@@ -36,7 +35,7 @@ module Polaris
|
|
36
35
|
@system_arguments[:classes] = class_names(
|
37
36
|
@system_arguments[:classes],
|
38
37
|
"Polaris-Card",
|
39
|
-
"Polaris-Card--subdued": subdued
|
38
|
+
"Polaris-Card--subdued": subdued
|
40
39
|
)
|
41
40
|
end
|
42
41
|
|
@@ -47,7 +46,7 @@ module Polaris
|
|
47
46
|
def footer_classes
|
48
47
|
class_names(
|
49
48
|
"Polaris-Card__Footer",
|
50
|
-
FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)]
|
49
|
+
FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)]
|
51
50
|
)
|
52
51
|
end
|
53
52
|
end
|
@@ -16,7 +16,7 @@ module Polaris
|
|
16
16
|
def text
|
17
17
|
return "#{count}/#{@max_length}" if max_length?
|
18
18
|
|
19
|
-
|
19
|
+
count.to_s
|
20
20
|
end
|
21
21
|
|
22
22
|
def label_template
|
@@ -35,16 +35,16 @@ module Polaris
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def max_length?
|
39
|
+
@max_length.present?
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def normalized_value
|
43
|
+
@text_field.value.to_s || ""
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
def count
|
47
|
+
normalized_value.length
|
48
|
+
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
<%= render Polaris::ChoiceComponent.new(**@wrapper_arguments) do %>
|
2
2
|
<%= render Polaris::BaseComponent.new(**@system_arguments) do %>
|
3
|
-
|
4
|
-
<%= @form.check_box(@attribute, @input_options, @value, @unchecked_value) %>
|
5
|
-
<% else %>
|
6
|
-
<%= check_box_tag(@name, @value, @checked, @input_options) %>
|
7
|
-
<% end %>
|
3
|
+
<%= checkbox %>
|
8
4
|
|
9
5
|
<span class="Polaris-Checkbox__Backdrop"></span>
|
10
6
|
|
@@ -6,7 +6,7 @@ module Polaris
|
|
6
6
|
|
7
7
|
attr_reader :checked
|
8
8
|
|
9
|
-
validates :checked, inclusion: {
|
9
|
+
validates :checked, inclusion: {in: [true, false, :indeterminate]}
|
10
10
|
|
11
11
|
def initialize(
|
12
12
|
form: nil,
|
@@ -28,6 +28,7 @@ module Polaris
|
|
28
28
|
@attribute = attribute
|
29
29
|
@name = name
|
30
30
|
@checked = checked
|
31
|
+
@disabled = disabled
|
31
32
|
@value = value
|
32
33
|
@unchecked_value = unchecked_value
|
33
34
|
|
@@ -37,7 +38,7 @@ module Polaris
|
|
37
38
|
@system_arguments[:classes],
|
38
39
|
"Polaris-Checkbox",
|
39
40
|
"Polaris-Checkbox--labelHidden": label_hidden,
|
40
|
-
"Polaris-Checkbox--error": error.present
|
41
|
+
"Polaris-Checkbox--error": error.present?
|
41
42
|
)
|
42
43
|
|
43
44
|
@wrapper_arguments = {
|
@@ -45,21 +46,14 @@ module Polaris
|
|
45
46
|
label_hidden: label_hidden,
|
46
47
|
disabled: disabled,
|
47
48
|
help_text: help_text,
|
48
|
-
error: error
|
49
|
+
error: error
|
49
50
|
}.merge(wrapper_arguments)
|
50
51
|
|
51
52
|
@input_options = input_options
|
52
|
-
@input_options[:
|
53
|
-
@input_options[:disabled] = true if disabled
|
54
|
-
@input_options[:aria][:checked] = checked
|
55
|
-
if indeterminate?
|
56
|
-
@input_options[:indeterminate] = true
|
57
|
-
@input_options[:aria][:checked] = "mixed"
|
58
|
-
end
|
59
|
-
@input_options[:class] = class_names(
|
53
|
+
@input_options[:classes] = class_names(
|
60
54
|
@input_options[:classes],
|
61
55
|
"Polaris-Checkbox__Input",
|
62
|
-
"Polaris-Checkbox__Input--indeterminate": indeterminate
|
56
|
+
"Polaris-Checkbox__Input--indeterminate": indeterminate?
|
63
57
|
)
|
64
58
|
end
|
65
59
|
|
@@ -74,5 +68,18 @@ module Polaris
|
|
74
68
|
def before_render
|
75
69
|
validate!
|
76
70
|
end
|
71
|
+
|
72
|
+
def checkbox
|
73
|
+
render Polaris::BaseCheckbox.new(
|
74
|
+
form: @form,
|
75
|
+
attribute: @attribute,
|
76
|
+
name: @name,
|
77
|
+
checked: @checked,
|
78
|
+
disabled: @disabled,
|
79
|
+
value: @value,
|
80
|
+
unchecked_value: @unchecked_value,
|
81
|
+
**@input_options
|
82
|
+
)
|
83
|
+
end
|
77
84
|
end
|
78
85
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class ChoiceListComponent < Polaris::NewComponent
|
5
|
-
renders_many :checkboxes, ->
|
5
|
+
renders_many :checkboxes, ->(value:, disabled: false, **system_arguments) do
|
6
6
|
Polaris::CheckboxComponent.new(
|
7
7
|
form: @form,
|
8
8
|
attribute: @attribute,
|
@@ -13,7 +13,7 @@ module Polaris
|
|
13
13
|
**system_arguments
|
14
14
|
)
|
15
15
|
end
|
16
|
-
renders_many :radio_buttons, ->
|
16
|
+
renders_many :radio_buttons, ->(value:, disabled: false, **system_arguments) do
|
17
17
|
Polaris::RadioButtonComponent.new(
|
18
18
|
form: @form,
|
19
19
|
attribute: @attribute,
|
@@ -21,12 +21,12 @@ module Polaris
|
|
21
21
|
value: value,
|
22
22
|
checked: @selected.include?(value),
|
23
23
|
disabled: disabled || @disabled,
|
24
|
-
**system_arguments
|
24
|
+
**system_arguments
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
28
28
|
def initialize(
|
29
|
-
title
|
29
|
+
title: nil,
|
30
30
|
title_hidden: false,
|
31
31
|
form: nil,
|
32
32
|
attribute: nil,
|
@@ -49,7 +49,7 @@ module Polaris
|
|
49
49
|
@system_arguments[:classes] = class_names(
|
50
50
|
@system_arguments[:classes],
|
51
51
|
"Polaris-ChoiceList",
|
52
|
-
"Polaris-ChoiceList--titleHidden": title_hidden
|
52
|
+
"Polaris-ChoiceList--titleHidden": title_hidden
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if @sort_url %>
|
2
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
3
|
+
<%= link_to @sort_url, class: "Polaris-DataTable__Heading" do %>
|
4
|
+
<span class="Polaris-DataTable__Icon">
|
5
|
+
<% if @sorted == :asc %>
|
6
|
+
<%= polaris_icon(name: "CaretUpMinor") %>
|
7
|
+
<% else %>
|
8
|
+
<%= polaris_icon(name: "CaretDownMinor") %>
|
9
|
+
<% end %>
|
10
|
+
</span>
|
11
|
+
<%= content %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
<% else %>
|
15
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
16
|
+
<%= content %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Polaris::DataTable::CellComponent < Polaris::NewComponent
|
2
|
+
ALIGNMENT_DEFAULT = :top
|
3
|
+
ALIGNMENT_MAPPINGS = {
|
4
|
+
top: "Polaris-DataTable__Cell--verticalAlignTop",
|
5
|
+
bottom: "Polaris-DataTable__Cell--verticalAlignBottom",
|
6
|
+
middle: "Polaris-DataTable__Cell--verticalAlignMiddle",
|
7
|
+
baseline: "Polaris-DataTable__Cell--verticalAlignBaseline"
|
8
|
+
}
|
9
|
+
ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
|
10
|
+
|
11
|
+
def initialize(
|
12
|
+
vertical_alignment:,
|
13
|
+
first: false,
|
14
|
+
numeric: false,
|
15
|
+
header: false,
|
16
|
+
total: false,
|
17
|
+
total_footer: false,
|
18
|
+
sorted: false,
|
19
|
+
sort_url: nil,
|
20
|
+
**system_arguments
|
21
|
+
)
|
22
|
+
@vertical_alignment = vertical_alignment
|
23
|
+
@numeric = numeric
|
24
|
+
@first = first
|
25
|
+
@header = header
|
26
|
+
@total = total
|
27
|
+
@total_footer = total_footer
|
28
|
+
@sorted = sorted
|
29
|
+
@sort_url = sort_url
|
30
|
+
@system_arguments = system_arguments
|
31
|
+
end
|
32
|
+
|
33
|
+
def system_arguments
|
34
|
+
{tag: "td"}.deep_merge(@system_arguments).tap do |args|
|
35
|
+
args[:classes] = class_names(
|
36
|
+
args[:classes],
|
37
|
+
"Polaris-DataTable__Cell",
|
38
|
+
ALIGNMENT_MAPPINGS[@vertical_alignment],
|
39
|
+
"Polaris-DataTable__Cell--firstColumn": @first,
|
40
|
+
"Polaris-DataTable__Cell--numeric": @numeric,
|
41
|
+
"Polaris-DataTable__Cell--header": @header,
|
42
|
+
"Polaris-DataTable__Cell--total": @total,
|
43
|
+
"Polaris-DataTable__Cell--sortable": @sort_url.present?,
|
44
|
+
"Polaris-DataTable__Cell--sorted": @sorted,
|
45
|
+
"Polaris-DataTable--cellTotalFooter": @total_footer
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Polaris::DataTable::ColumnComponent < Polaris::NewComponent
|
2
|
+
SORT_DEFAULT = false
|
3
|
+
SORT_OPTIONS = [false, :asc, :desc]
|
4
|
+
|
5
|
+
attr_reader :title, :numeric, :total, :sorted, :sort_url
|
6
|
+
|
7
|
+
def initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block)
|
8
|
+
@title = title
|
9
|
+
@numeric = numeric
|
10
|
+
@total = total
|
11
|
+
@sorted = fetch_or_fallback(SORT_OPTIONS, sorted, SORT_DEFAULT)
|
12
|
+
@sort_url = sort_url
|
13
|
+
@block = block
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(row)
|
17
|
+
@block.call(row)
|
18
|
+
end
|
19
|
+
end
|