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
@@ -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: {
|
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':
|
80
|
+
'polaris--dropzone-target': "input"
|
83
81
|
}
|
84
82
|
}
|
85
83
|
end
|
86
84
|
|
87
85
|
private
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
108
|
-
|
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
|
-
|
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
|
-
|
119
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
127
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<%
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
<% if secondary_action.present? %>
|
28
|
+
<% stack.item do %>
|
29
|
+
<%= secondary_action %>
|
30
|
+
<% end %>
|
29
31
|
<% end %>
|
30
32
|
<% end %>
|
31
|
-
|
32
|
-
|
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
|
8
|
+
:container => "Polaris-EmptyState--withinContentContainer"
|
9
9
|
}
|
10
10
|
WITHIN_OPTIONS = WITHIN_MAPPINGS.keys
|
11
11
|
|
12
|
-
renders_one :primary_action, ->
|
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
|
@@ -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
|
@@ -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
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class FormLayoutComponent < Polaris::NewComponent
|
5
|
-
renders_many :items, ->
|
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, ->
|
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
|