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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/polaris_view_components/button_controller.js +48 -0
  3. data/app/assets/javascripts/polaris_view_components/index.js +11 -1
  4. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  5. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +24 -0
  6. data/app/assets/javascripts/polaris_view_components/popover_controller.js +45 -0
  7. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  8. data/app/assets/javascripts/polaris_view_components.js +1533 -1
  9. data/app/assets/stylesheets/polaris_view_components/custom.css +26 -1
  10. data/app/assets/stylesheets/polaris_view_components.css +21 -1
  11. data/app/components/polaris/action.rb +3 -3
  12. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  13. data/app/components/polaris/action_list/item_component.rb +41 -0
  14. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  15. data/app/components/polaris/action_list/section_component.rb +26 -0
  16. data/app/components/polaris/action_list_component.html.erb +13 -0
  17. data/app/components/polaris/action_list_component.rb +25 -0
  18. data/app/components/polaris/application_component.rb +19 -19
  19. data/app/components/polaris/avatar_component.rb +1 -1
  20. data/app/components/polaris/badge_component.rb +1 -1
  21. data/app/components/polaris/banner_component.rb +6 -6
  22. data/app/components/polaris/base_button.rb +1 -1
  23. data/app/components/polaris/button_component.html.erb +13 -0
  24. data/app/components/polaris/button_group_component.rb +5 -5
  25. data/app/components/polaris/callout_card_component.rb +5 -5
  26. data/app/components/polaris/caption_component.rb +2 -2
  27. data/app/components/polaris/card/header_component.rb +1 -1
  28. data/app/components/polaris/card/section_component.rb +2 -2
  29. data/app/components/polaris/card_component.html.erb +4 -0
  30. data/app/components/polaris/card_component.rb +5 -4
  31. data/app/components/polaris/character_count.rb +10 -10
  32. data/app/components/polaris/checkbox_component.rb +4 -4
  33. data/app/components/polaris/choice_component.rb +1 -1
  34. data/app/components/polaris/choice_list_component.rb +4 -4
  35. data/app/components/polaris/data_table/cell_component.rb +3 -3
  36. data/app/components/polaris/data_table_component.rb +3 -3
  37. data/app/components/polaris/description_list_component.rb +3 -3
  38. data/app/components/polaris/display_text_component.rb +2 -2
  39. data/app/components/polaris/dropzone/component.rb +36 -36
  40. data/app/components/polaris/empty_state_component.rb +3 -3
  41. data/app/components/polaris/exception_list/item_component.rb +2 -2
  42. data/app/components/polaris/exception_list_component.rb +1 -1
  43. data/app/components/polaris/filters_component.rb +2 -2
  44. data/app/components/polaris/footer_help_component.rb +1 -1
  45. data/app/components/polaris/form_layout/group_component.rb +3 -3
  46. data/app/components/polaris/form_layout/item_component.rb +1 -1
  47. data/app/components/polaris/form_layout_component.rb +3 -3
  48. data/app/components/polaris/heading_component.rb +1 -1
  49. data/app/components/polaris/headless_button.html.erb +13 -0
  50. data/app/components/polaris/headless_button.rb +17 -5
  51. data/app/components/polaris/icon_component.rb +2 -2
  52. data/app/components/polaris/index_table/cell_component.rb +2 -2
  53. data/app/components/polaris/index_table_component.rb +3 -3
  54. data/app/components/polaris/inline_error_component.rb +1 -1
  55. data/app/components/polaris/label_component.rb +2 -2
  56. data/app/components/polaris/labelled_component.rb +2 -2
  57. data/app/components/polaris/layout/annotated_section.rb +1 -1
  58. data/app/components/polaris/layout/section.rb +1 -1
  59. data/app/components/polaris/layout_component.rb +3 -3
  60. data/app/components/polaris/link_component.rb +3 -3
  61. data/app/components/polaris/list_component.rb +3 -3
  62. data/app/components/polaris/modal/section_component.rb +19 -0
  63. data/app/components/polaris/modal_component.html.erb +79 -0
  64. data/app/components/polaris/modal_component.rb +98 -0
  65. data/app/components/polaris/page_actions_component.rb +8 -7
  66. data/app/components/polaris/page_component.rb +4 -4
  67. data/app/components/polaris/pagination_component.rb +1 -5
  68. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  69. data/app/components/polaris/popover/pane_component.rb +20 -0
  70. data/app/components/polaris/popover/section_component.rb +19 -0
  71. data/app/components/polaris/popover_component.html.erb +38 -0
  72. data/app/components/polaris/popover_component.rb +90 -0
  73. data/app/components/polaris/progress_bar_component.rb +5 -5
  74. data/app/components/polaris/radio_button_component.rb +3 -3
  75. data/app/components/polaris/resource_item_component.html.erb +16 -6
  76. data/app/components/polaris/resource_item_component.rb +42 -9
  77. data/app/components/polaris/resource_list_component.rb +2 -2
  78. data/app/components/polaris/scrollable_component.html.erb +5 -0
  79. data/app/components/polaris/scrollable_component.rb +48 -0
  80. data/app/components/polaris/select_component.rb +3 -3
  81. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  82. data/app/components/polaris/setting_toggle_component.rb +24 -0
  83. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  84. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  85. data/app/components/polaris/spacer_component.rb +3 -3
  86. data/app/components/polaris/spinner_component.rb +2 -2
  87. data/app/components/polaris/stack_component.rb +5 -5
  88. data/app/components/polaris/subheading_component.rb +1 -1
  89. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  90. data/app/components/polaris/tabs/tab_component.rb +34 -0
  91. data/app/components/polaris/tabs_component.html.erb +7 -0
  92. data/app/components/polaris/tabs_component.rb +37 -0
  93. data/app/components/polaris/tag_component.rb +1 -1
  94. data/app/components/polaris/text_container_component.rb +2 -2
  95. data/app/components/polaris/text_field_component.rb +8 -8
  96. data/app/components/polaris/text_style_component.rb +4 -4
  97. data/app/components/polaris/thumbnail_component.rb +2 -2
  98. data/app/helpers/polaris/form_builder.rb +4 -2
  99. data/app/helpers/polaris/url_helper.rb +3 -3
  100. data/app/helpers/polaris/view_helper.rb +11 -3
  101. data/app/validators/type_validator.rb +2 -2
  102. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  103. data/lib/polaris/view_components/engine.rb +6 -0
  104. data/lib/polaris/view_components/version.rb +1 -1
  105. data/lib/polaris_view_components.rb +1 -1
  106. metadata +30 -3
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  class ChoiceListComponent < Polaris::NewComponent
5
- renders_many :checkboxes, -> (value:, disabled: false, **system_arguments) do
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, -> (value:, disabled: false, **system_arguments) do
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,7 +21,7 @@ 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
 
@@ -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
 
@@ -4,7 +4,7 @@ class Polaris::DataTable::CellComponent < Polaris::NewComponent
4
4
  top: "Polaris-DataTable__Cell--verticalAlignTop",
5
5
  bottom: "Polaris-DataTable__Cell--verticalAlignBottom",
6
6
  middle: "Polaris-DataTable__Cell--verticalAlignMiddle",
7
- baseline: "Polaris-DataTable__Cell--verticalAlignBaseline",
7
+ baseline: "Polaris-DataTable__Cell--verticalAlignBaseline"
8
8
  }
9
9
  ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
10
10
 
@@ -31,7 +31,7 @@ class Polaris::DataTable::CellComponent < Polaris::NewComponent
31
31
  end
32
32
 
33
33
  def system_arguments
34
- { tag: "td" }.deep_merge(@system_arguments).tap do |args|
34
+ {tag: "td"}.deep_merge(@system_arguments).tap do |args|
35
35
  args[:classes] = class_names(
36
36
  args[:classes],
37
37
  "Polaris-DataTable__Cell",
@@ -42,7 +42,7 @@ class Polaris::DataTable::CellComponent < Polaris::NewComponent
42
42
  "Polaris-DataTable__Cell--total": @total,
43
43
  "Polaris-DataTable__Cell--sortable": @sort_url.present?,
44
44
  "Polaris-DataTable__Cell--sorted": @sorted,
45
- "Polaris-DataTable--cellTotalFooter": @total_footer,
45
+ "Polaris-DataTable--cellTotalFooter": @total_footer
46
46
  )
47
47
  end
48
48
  end
@@ -5,7 +5,7 @@ module Polaris
5
5
  ALIGNMENT_DEFAULT = :top
6
6
  ALIGNMENT_OPTIONS = [:top, :bottom, :middle, :baseline]
7
7
 
8
- renders_many :columns, -> (title, **system_arguments, &block) do
8
+ renders_many :columns, ->(title, **system_arguments, &block) do
9
9
  DataTable::ColumnComponent.new(title, **system_arguments, &block)
10
10
  end
11
11
  renders_one :footer
@@ -27,10 +27,10 @@ module Polaris
27
27
  end
28
28
 
29
29
  def system_arguments
30
- { tag: "div" }.deep_merge(@system_arguments).tap do |args|
30
+ {tag: "div"}.deep_merge(@system_arguments).tap do |args|
31
31
  args[:classes] = class_names(
32
32
  args[:classes],
33
- "Polaris-DataTable",
33
+ "Polaris-DataTable"
34
34
  )
35
35
  end
36
36
  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
 
@@ -5,7 +5,7 @@ module Polaris
5
5
  class Component < Polaris::Component
6
6
  ALLOWED_TYPES = %w[file image]
7
7
 
8
- validates :type, inclusion: { in: ALLOWED_TYPES, message: "%{value} is not a valid type" }
8
+ validates :type, inclusion: {in: ALLOWED_TYPES, message: "%{value} is not a valid type"}
9
9
  validates :label_action, type: Action, allow_nil: true
10
10
 
11
11
  # TODO
@@ -77,52 +77,52 @@ module Polaris
77
77
  multiple: @allow_multiple,
78
78
  data: {
79
79
  action: "focus->polaris--dropzone#onFocus blur->polaris--dropzone#onBlur change->polaris--dropzone#onChange",
80
- 'polaris--dropzone-target': 'input',
80
+ 'polaris--dropzone-target': "input"
81
81
  }
82
82
  }
83
83
  end
84
84
 
85
85
  private
86
86
 
87
- def additional_aria
88
- {
89
- disabled: @disabled.to_s,
90
- }
91
- end
92
-
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
87
+ def additional_aria
88
+ {
89
+ disabled: @disabled.to_s
90
+ }
91
+ end
104
92
 
105
- def drop_actions
106
- event_scope = @drop_on_page ? "@document" : ""
93
+ def additional_data
94
+ {
95
+ controller: "polaris--dropzone",
96
+ action: "click->polaris--dropzone#onClick #{drop_actions}",
97
+ 'polaris--dropzone-accept-value': @accept,
98
+ 'polaris--dropzone-allowMultiple-value': @allow_multiple.to_s,
99
+ 'polaris--dropzone-disabled-value': @disabled.to_s,
100
+ 'polaris--dropzone-focused-value': "false",
101
+ 'polaris--dropzone-drop-on-page-value': "false"
102
+ }
103
+ end
107
104
 
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
105
+ def drop_actions
106
+ event_scope = @drop_on_page ? "@document" : ""
115
107
 
116
- def classes
117
- classes = %w[Polaris-DropZone Polaris-DropZone--sizeExtraLarge]
108
+ [
109
+ "drop#{event_scope}->polaris--dropzone#onDrop",
110
+ "dragover#{event_scope}->polaris--dropzone#onDragOver",
111
+ "dragenter#{event_scope}->polaris--dropzone#onDragEnter",
112
+ "dragleave#{event_scope}->polaris--dropzone#onDragLeave"
113
+ ].join(" ")
114
+ end
118
115
 
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
116
+ def classes
117
+ classes = %w[Polaris-DropZone Polaris-DropZone--sizeExtraLarge]
123
118
 
124
- classes
125
- end
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
123
+
124
+ classes
125
+ end
126
126
  end
127
127
  end
128
128
  end
@@ -5,11 +5,11 @@ module Polaris
5
5
  WITHIN_DEFAULT = :page
6
6
  WITHIN_MAPPINGS = {
7
7
  WITHIN_DEFAULT => "",
8
- container: "Polaris-EmptyState--withinContentContainer",
8
+ :container => "Polaris-EmptyState--withinContentContainer"
9
9
  }
10
10
  WITHIN_OPTIONS = WITHIN_MAPPINGS.keys
11
11
 
12
- renders_one :primary_action, -> (primary: true, **system_arguments) do
12
+ renders_one :primary_action, ->(primary: true, **system_arguments) do
13
13
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
14
14
  end
15
15
  renders_one :secondary_action, Polaris::ButtonComponent
@@ -32,7 +32,7 @@ module Polaris
32
32
  @system_arguments[:classes],
33
33
  "Polaris-EmptyState",
34
34
  WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)],
35
- "Polaris-EmptyState--fullWidth": full_width,
35
+ "Polaris-EmptyState--fullWidth": full_width
36
36
  )
37
37
  end
38
38
  end
@@ -3,7 +3,7 @@ class Polaris::ExceptionList::ItemComponent < Polaris::NewComponent
3
3
  STATUS_MAPPINGS = {
4
4
  STATUS_DEFAULT => "",
5
5
  :critical => "Polaris-ExceptionList--statusCritical",
6
- :warning => "Polaris-ExceptionList--statusWarning",
6
+ :warning => "Polaris-ExceptionList--statusWarning"
7
7
  }
8
8
  STATUS_OPTIONS = STATUS_MAPPINGS.keys
9
9
 
@@ -21,7 +21,7 @@ class Polaris::ExceptionList::ItemComponent < Polaris::NewComponent
21
21
  @system_arguments[:classes] = class_names(
22
22
  @system_arguments[:classes],
23
23
  "Polaris-ExceptionList__Item",
24
- STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)],
24
+ STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
25
25
  )
26
26
  end
27
27
  end
@@ -9,7 +9,7 @@ module Polaris
9
9
  @system_arguments[:tag] = "ul"
10
10
  @system_arguments[:classes] = class_names(
11
11
  @system_arguments[:classes],
12
- "Polaris-ExceptionList",
12
+ "Polaris-ExceptionList"
13
13
  )
14
14
  end
15
15
 
@@ -13,7 +13,7 @@ module Polaris
13
13
  opts[:tag] = "div"
14
14
  opts[:classes] = class_names(
15
15
  @system_arguments[:classes],
16
- "Polaris-Filters",
16
+ "Polaris-Filters"
17
17
  )
18
18
  end
19
19
  end
@@ -22,7 +22,7 @@ module Polaris
22
22
  def initialize(clear_button: true, **system_arguments)
23
23
  @system_arguments = system_arguments.merge(
24
24
  label_hidden: true,
25
- clear_button: clear_button,
25
+ clear_button: clear_button
26
26
  )
27
27
  end
28
28
 
@@ -6,7 +6,7 @@ module Polaris
6
6
  @system_arguments = system_arguments
7
7
  @system_arguments[:classes] = class_names(
8
8
  @system_arguments[:classes],
9
- "Polaris-FooterHelp",
9
+ "Polaris-FooterHelp"
10
10
  )
11
11
  end
12
12
  end
@@ -10,7 +10,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
10
10
  @system_arguments[:tag] = "div"
11
11
  @system_arguments[:classes] = class_names(
12
12
  @system_arguments[:classes],
13
- "Polaris-FormLayout__Items",
13
+ "Polaris-FormLayout__Items"
14
14
  )
15
15
 
16
16
  @wrapper_arguments = {}
@@ -18,7 +18,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
18
18
  @wrapper_arguments[:role] = "group"
19
19
  @wrapper_arguments[:classes] = class_names(
20
20
  "Polaris-FormLayout--grouped": !condensed,
21
- "Polaris-FormLayout--condensed": condensed,
21
+ "Polaris-FormLayout--condensed": condensed
22
22
  )
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
28
28
  @system_arguments[:tag] = "div"
29
29
  @system_arguments[:classes] = class_names(
30
30
  @system_arguments[:classes],
31
- "Polaris-FormLayout__Item",
31
+ "Polaris-FormLayout__Item"
32
32
  )
33
33
  end
34
34
 
@@ -8,7 +8,7 @@ class Polaris::FormLayout::ItemComponent < Polaris::NewComponent
8
8
  @system_arguments[:tag] = "div"
9
9
  @system_arguments[:classes] = class_names(
10
10
  @system_arguments[:classes],
11
- "Polaris-FormLayout__Item",
11
+ "Polaris-FormLayout__Item"
12
12
  )
13
13
  end
14
14
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Polaris
4
4
  class FormLayoutComponent < Polaris::NewComponent
5
- renders_many :items, -> (**system_arguments) do
5
+ renders_many :items, ->(**system_arguments) do
6
6
  @counter += 1
7
7
  Polaris::FormLayout::ItemComponent.new(position: @counter, **system_arguments)
8
8
  end
9
- renders_many :groups, -> (**system_arguments) do
9
+ renders_many :groups, ->(**system_arguments) do
10
10
  @counter += 1
11
11
  Polaris::FormLayout::GroupComponent.new(position: @counter, **system_arguments)
12
12
  end
@@ -18,7 +18,7 @@ module Polaris
18
18
  @system_arguments[:tag] = "div"
19
19
  @system_arguments[:classes] = class_names(
20
20
  @system_arguments[:classes],
21
- "Polaris-FormLayout",
21
+ "Polaris-FormLayout"
22
22
  )
23
23
  end
24
24
 
@@ -13,7 +13,7 @@ module Polaris
13
13
  @system_arguments[:tag] = element
14
14
  @system_arguments[:classes] = class_names(
15
15
  @system_arguments[:classes],
16
- 'Polaris-Heading'
16
+ "Polaris-Heading"
17
17
  )
18
18
  end
19
19
 
@@ -19,4 +19,17 @@
19
19
  <%= content %>
20
20
  </div>
21
21
  <% end %>
22
+
23
+ <% if @disclosure.present? %>
24
+ <div class="Polaris-Button__Icon">
25
+ <% case @disclosure %>
26
+ <% when :down %>
27
+ <%= polaris_icon(name: "CaretDownMinor") %>
28
+ <% when :up %>
29
+ <%= polaris_icon(name: "CaretUpMinor") %>
30
+ <% when :select %>
31
+ <%= polaris_icon(name: "SelectMinor") %>
32
+ <% end %>
33
+ </div>
34
+ <% end %>
22
35
  </span>
@@ -6,7 +6,7 @@ module Polaris
6
6
  SIZE_MAPPINGS = {
7
7
  SIZE_DEFAULT => "",
8
8
  :slim => "Polaris-Button--sizeSlim",
9
- :large => "Polaris-Button--sizeLarge",
9
+ :large => "Polaris-Button--sizeLarge"
10
10
  }
11
11
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
12
12
 
@@ -15,10 +15,13 @@ module Polaris
15
15
  TEXT_ALIGN_DEFAULT => "",
16
16
  :left => "Polaris-Button--textAlignLeft",
17
17
  :center => "Polaris-Button--textAlignCenter",
18
- :right => "Polaris-Button--textAlignRight",
18
+ :right => "Polaris-Button--textAlignRight"
19
19
  }
20
20
  TEXT_ALIGN_OPTIONS = TEXT_ALIGN_MAPPINGS.keys
21
21
 
22
+ DISCLOSURE_DEFAULT = false
23
+ DISCLOSURE_OPTIONS = [true, false, :down, :up, :select]
24
+
22
25
  renders_one :icon, IconComponent
23
26
 
24
27
  def initialize(
@@ -31,6 +34,8 @@ module Polaris
31
34
  loading: false,
32
35
  destructive: false,
33
36
  disabled: false,
37
+ disable_with_loader: false,
38
+ disclosure: DISCLOSURE_DEFAULT,
34
39
  external: false,
35
40
  full_width: false,
36
41
  submit: false,
@@ -39,15 +44,17 @@ module Polaris
39
44
  text_align: TEXT_ALIGN_DEFAULT,
40
45
  **system_arguments
41
46
  )
42
- @tag = url.present? ? 'a' : 'button'
47
+ @tag = url.present? ? "a" : "button"
43
48
  @text_classes = class_names(
44
49
  "Polaris-Button__Text",
45
50
  "Polaris-Button--removeUnderline": plain && monochrome && remove_underline
46
51
  )
47
52
  @loading = loading
53
+ @disclosure = fetch_or_fallback(DISCLOSURE_OPTIONS, disclosure, DISCLOSURE_DEFAULT)
54
+ @disclosure = :down if @disclosure === true
48
55
 
49
56
  @system_arguments = system_arguments
50
- @system_arguments[:type] = submit ? 'submit' : 'button'
57
+ @system_arguments[:type] = submit ? "submit" : "button"
51
58
  if loading
52
59
  @system_arguments[:disabled] = true
53
60
  end
@@ -59,6 +66,11 @@ module Polaris
59
66
  if disabled
60
67
  @system_arguments[:disabled] = disabled
61
68
  end
69
+ @system_arguments[:data] ||= {}
70
+ prepend_option(@system_arguments[:data], :controller, "polaris-button")
71
+ if disable_with_loader
72
+ prepend_option(@system_arguments[:data], :action, "polaris-button#disable")
73
+ end
62
74
  @system_arguments[:classes] = class_names(
63
75
  @system_arguments[:classes],
64
76
  "Polaris-Button",
@@ -80,7 +92,7 @@ module Polaris
80
92
  def system_arguments
81
93
  @system_arguments[:classes] = class_names(
82
94
  @system_arguments[:classes],
83
- "Polaris-Button--iconOnly": icon.present? && content.blank?,
95
+ "Polaris-Button--iconOnly": icon.present? && content.blank?
84
96
  )
85
97
  @system_arguments
86
98
  end
@@ -11,7 +11,7 @@ module Polaris
11
11
  :warning => "Polaris-Icon--colorWarning",
12
12
  :highlight => "Polaris-Icon--colorHighlight",
13
13
  :success => "Polaris-Icon--colorSuccess",
14
- :primary => "Polaris-Icon--colorPrimary",
14
+ :primary => "Polaris-Icon--colorPrimary"
15
15
  }
16
16
  COLOR_OPTIONS = COLOR_MAPPINGS.keys
17
17
 
@@ -29,7 +29,7 @@ module Polaris
29
29
  "Polaris-Icon",
30
30
  COLOR_MAPPINGS[fetch_or_fallback(COLOR_OPTIONS, color, COLOR_DEFAULT)],
31
31
  "Polaris-Icon--hasBackdrop" => backdrop,
32
- "Polaris-Icon--applyColor" => color != :default,
32
+ "Polaris-Icon--applyColor" => color != :default
33
33
  )
34
34
  end
35
35
  end
@@ -5,11 +5,11 @@ class Polaris::IndexTable::CellComponent < Polaris::NewComponent
5
5
  end
6
6
 
7
7
  def system_arguments
8
- { tag: "td" }.deep_merge(@system_arguments).tap do |args|
8
+ {tag: "td"}.deep_merge(@system_arguments).tap do |args|
9
9
  args[:classes] = class_names(
10
10
  args[:classes],
11
11
  "Polaris-IndexTable__TableCell",
12
- "Polaris-IndexTable__TableCell--flush": @flush,
12
+ "Polaris-IndexTable__TableCell--flush": @flush
13
13
  )
14
14
  end
15
15
  end
@@ -1,6 +1,6 @@
1
1
  module Polaris
2
2
  class IndexTableComponent < Polaris::NewComponent
3
- renders_many :columns, -> (title, **system_arguments, &block) do
3
+ renders_many :columns, ->(title, **system_arguments, &block) do
4
4
  IndexTable::ColumnComponent.new(title, **system_arguments, &block)
5
5
  end
6
6
 
@@ -10,10 +10,10 @@ module Polaris
10
10
  end
11
11
 
12
12
  def system_arguments
13
- { tag: "div" }.deep_merge(@system_arguments).tap do |args|
13
+ {tag: "div"}.deep_merge(@system_arguments).tap do |args|
14
14
  args[:classes] = class_names(
15
15
  args[:classes],
16
- "Polaris-IndexTable",
16
+ "Polaris-IndexTable"
17
17
  )
18
18
  end
19
19
  end
@@ -7,7 +7,7 @@ module Polaris
7
7
  @system_arguments[:tag] = "div"
8
8
  @system_arguments[:classes] = class_names(
9
9
  @system_arguments[:classes],
10
- "Polaris-InlineError",
10
+ "Polaris-InlineError"
11
11
  )
12
12
  end
13
13
 
@@ -19,13 +19,13 @@ module Polaris
19
19
  @system_arguments[:tag] = "div"
20
20
  @system_arguments[:classes] = class_names(
21
21
  @system_arguments[:classes],
22
- "Polaris-Label",
22
+ "Polaris-Label"
23
23
  )
24
24
 
25
25
  @label_options = {}
26
26
  @label_options[:class] = class_names(
27
27
  "Polaris-Label__Text",
28
- "Polaris-Label__RequiredIndicator": required,
28
+ "Polaris-Label__RequiredIndicator": required
29
29
  )
30
30
  end
31
31
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  class LabelledComponent < Polaris::NewComponent
5
- renders_one :label_action, -> (**system_arguments) do
5
+ renders_one :label_action, ->(**system_arguments) do
6
6
  Polaris::ButtonComponent.new(plain: true, **system_arguments)
7
7
  end
8
8
 
@@ -38,7 +38,7 @@ module Polaris
38
38
  attribute: attribute,
39
39
  name: name,
40
40
  label: label,
41
- required: required,
41
+ required: required
42
42
  }
43
43
  end
44
44
 
@@ -13,7 +13,7 @@ module Polaris
13
13
  @system_arguments = system_arguments
14
14
  @system_arguments[:classes] = class_names(
15
15
  @system_arguments[:classes],
16
- "Polaris-Layout__AnnotatedSection",
16
+ "Polaris-Layout__AnnotatedSection"
17
17
  )
18
18
  end
19
19
  end
@@ -25,7 +25,7 @@ module Polaris
25
25
  "Polaris-Layout__Section--fullWidth" => full_width,
26
26
  "Polaris-Layout__Section--oneHalf" => one_half,
27
27
  "Polaris-Layout__Section--oneThird" => one_third,
28
- "Polaris-Layout__Section--oneFourth" => one_fourth,
28
+ "Polaris-Layout__Section--oneFourth" => one_fourth
29
29
  )
30
30
  end
31
31
 
@@ -9,7 +9,7 @@ module Polaris
9
9
  # @param one_half [Boolean] The section will only take up 50% of the width
10
10
  # @param one_third [Boolean] The section will only take up 33.33% of the width
11
11
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
12
- renders_many :sections, -> (**system_arguments) do
12
+ renders_many :sections, ->(**system_arguments) do
13
13
  @counter += 1
14
14
  Layout::Section.new(position: @counter, **system_arguments)
15
15
  end
@@ -19,7 +19,7 @@ module Polaris
19
19
  # @param title [String] Title
20
20
  # @param description [String] Description
21
21
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22
- renders_many :annotated_sections, -> (**system_arguments) do
22
+ renders_many :annotated_sections, ->(**system_arguments) do
23
23
  @counter += 1
24
24
  Layout::AnnotatedSection.new(position: @counter, **system_arguments)
25
25
  end
@@ -29,7 +29,7 @@ module Polaris
29
29
  @system_arguments = system_arguments
30
30
  @system_arguments[:classes] = class_names(
31
31
  @system_arguments[:classes],
32
- 'Polaris-Layout'
32
+ "Polaris-Layout"
33
33
  )
34
34
  end
35
35
 
@@ -24,7 +24,7 @@ module Polaris
24
24
  @system_arguments[:classes],
25
25
  "Polaris-Link",
26
26
  "Polaris-Link--monochrome" => monochrome,
27
- "Polaris-Link--removeUnderline" => no_underline,
27
+ "Polaris-Link--removeUnderline" => no_underline
28
28
  )
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ module Polaris
32
32
  render(Polaris::BaseComponent.new(**@system_arguments)) do
33
33
  safe_join [
34
34
  content.strip.html_safe,
35
- (external_icon if @external),
35
+ (external_icon if @external)
36
36
  ].compact
37
37
  end
38
38
  end
@@ -42,7 +42,7 @@ module Polaris
42
42
  def external_icon
43
43
  tag.span(class: "Polaris-Link__IconLockup") do
44
44
  tag.span(class: "Polaris-Link__IconLayout") do
45
- polaris_icon(name: "ExternalSmallMinor", aria: { label: "(opens a new window)" })
45
+ polaris_icon(name: "ExternalSmallMinor", aria: {label: "(opens a new window)"})
46
46
  end
47
47
  end
48
48
  end