polaris_view_components 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/icons/polaris/AnalyticsMinor.svg +1 -0
  3. data/app/assets/icons/polaris/AppsMinor.svg +1 -0
  4. data/app/assets/icons/polaris/BlockMinor.svg +1 -0
  5. data/app/assets/icons/polaris/ButtonMinor.svg +1 -0
  6. data/app/assets/icons/polaris/CaretDownMinor.svg +1 -1
  7. data/app/assets/icons/polaris/CaretUpMinor.svg +1 -1
  8. data/app/assets/icons/polaris/CircleTickMinor.svg +1 -0
  9. data/app/assets/icons/polaris/Columns3Minor.svg +1 -0
  10. data/app/assets/icons/polaris/CustomersMinor.svg +1 -1
  11. data/app/assets/icons/polaris/DiscountsMinor.svg +1 -0
  12. data/app/assets/icons/polaris/DropdownMinor.svg +1 -1
  13. data/app/assets/icons/polaris/FinancesMajor.svg +1 -0
  14. data/app/assets/icons/polaris/FinancesMinor.svg +1 -0
  15. data/app/assets/icons/polaris/HomeMinor.svg +1 -0
  16. data/app/assets/icons/polaris/MarketingMinor.svg +1 -0
  17. data/app/assets/icons/polaris/OnlineStoreMinor.svg +1 -0
  18. data/app/assets/icons/polaris/OrdersMinor.svg +1 -0
  19. data/app/assets/icons/polaris/ProductsMinor.svg +1 -0
  20. data/app/assets/icons/polaris/QuestionMarkInverseMajor.svg +1 -0
  21. data/app/assets/icons/polaris/QuestionMarkInverseMinor.svg +1 -0
  22. data/app/assets/icons/polaris/SelectMinor.svg +1 -1
  23. data/app/assets/icons/polaris/TitleMinor.svg +1 -0
  24. data/app/assets/icons/polaris/WandMinor.svg +1 -0
  25. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +32 -15
  26. data/app/assets/javascripts/polaris_view_components/collapsible_controller.js +19 -0
  27. data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +495 -0
  28. data/app/assets/javascripts/polaris_view_components/index.js +4 -0
  29. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +4 -0
  30. data/app/assets/javascripts/polaris_view_components/popover_controller.js +9 -2
  31. data/app/assets/javascripts/polaris_view_components/toast_controller.js +13 -2
  32. data/app/assets/javascripts/polaris_view_components/utils.js +23 -0
  33. data/app/assets/javascripts/polaris_view_components.js +560 -65
  34. data/app/assets/stylesheets/polaris_view_components/custom.css +38 -6
  35. data/app/assets/stylesheets/polaris_view_components.css +2107 -2021
  36. data/app/assets/stylesheets/polaris_view_components.postcss.css +1 -1
  37. data/app/components/polaris/action_list/item_component.rb +1 -1
  38. data/app/components/polaris/action_list/section_component.rb +1 -1
  39. data/app/components/polaris/action_list_component.rb +1 -1
  40. data/app/components/polaris/autocomplete/action_component.rb +1 -1
  41. data/app/components/polaris/autocomplete/option_component.rb +1 -1
  42. data/app/components/polaris/autocomplete/section_component.rb +1 -1
  43. data/app/components/polaris/autocomplete_component.rb +9 -2
  44. data/app/components/polaris/avatar_component.rb +1 -1
  45. data/app/components/polaris/badge_component.rb +1 -1
  46. data/app/components/polaris/banner_component.rb +2 -2
  47. data/app/components/polaris/base_button.rb +1 -1
  48. data/app/components/polaris/base_checkbox.rb +1 -1
  49. data/app/components/polaris/base_component.rb +1 -1
  50. data/app/components/polaris/base_radio_button.rb +1 -1
  51. data/app/components/polaris/button_group_component.rb +3 -3
  52. data/app/components/polaris/callout_card_component.rb +1 -1
  53. data/app/components/polaris/caption_component.rb +1 -1
  54. data/app/components/polaris/card/header_component.rb +1 -1
  55. data/app/components/polaris/card/section_component.rb +2 -2
  56. data/app/components/polaris/card_component.rb +1 -1
  57. data/app/components/polaris/checkbox_component.rb +1 -1
  58. data/app/components/polaris/choice_component.rb +1 -1
  59. data/app/components/polaris/choice_list_component.rb +1 -1
  60. data/app/components/polaris/collapsible_component.rb +37 -0
  61. data/app/components/polaris/component.rb +6 -1
  62. data/app/components/polaris/data_table/cell_component.rb +1 -1
  63. data/app/components/polaris/data_table/column_component.rb +1 -1
  64. data/app/components/polaris/data_table_component.rb +1 -1
  65. data/app/components/polaris/description_list_component.rb +2 -2
  66. data/app/components/polaris/display_text_component.rb +1 -1
  67. data/app/components/polaris/dropzone_component.html.erb +156 -0
  68. data/app/components/polaris/dropzone_component.rb +150 -0
  69. data/app/components/polaris/empty_state_component.rb +1 -1
  70. data/app/components/polaris/exception_list/item_component.rb +1 -1
  71. data/app/components/polaris/exception_list_component.rb +1 -1
  72. data/app/components/polaris/filters_component.rb +3 -3
  73. data/app/components/polaris/footer_help_component.rb +1 -1
  74. data/app/components/polaris/form_layout/group_component.rb +2 -2
  75. data/app/components/polaris/form_layout/item_component.rb +1 -1
  76. data/app/components/polaris/form_layout_component.rb +1 -1
  77. data/app/components/polaris/frame/save_bar_component.rb +1 -1
  78. data/app/components/polaris/frame/top_bar_component.rb +1 -1
  79. data/app/components/polaris/frame_component.rb +1 -1
  80. data/app/components/polaris/heading_component.rb +1 -1
  81. data/app/components/polaris/headless_button.rb +1 -1
  82. data/app/components/polaris/icon_component.rb +1 -1
  83. data/app/components/polaris/index_table/cell_component.rb +1 -1
  84. data/app/components/polaris/index_table/column_component.rb +1 -1
  85. data/app/components/polaris/index_table_component.rb +1 -1
  86. data/app/components/polaris/inline_error_component.rb +1 -1
  87. data/app/components/polaris/keyboard_key_component.rb +20 -0
  88. data/app/components/polaris/label_component.rb +1 -1
  89. data/app/components/polaris/labelled_component.rb +1 -1
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +1 -1
  92. data/app/components/polaris/layout_component.rb +1 -1
  93. data/app/components/polaris/link_component.rb +1 -1
  94. data/app/components/polaris/list_component.rb +2 -2
  95. data/app/components/polaris/modal/section_component.rb +1 -1
  96. data/app/components/polaris/modal_component.rb +1 -1
  97. data/app/components/polaris/navigation/item_component.rb +2 -2
  98. data/app/components/polaris/navigation/section_component.rb +2 -2
  99. data/app/components/polaris/navigation_component.rb +1 -1
  100. data/app/components/polaris/option_list/checkbox_component.rb +1 -1
  101. data/app/components/polaris/option_list/option_component.rb +1 -1
  102. data/app/components/polaris/option_list/radio_button_component.rb +1 -1
  103. data/app/components/polaris/option_list/section_component.rb +1 -1
  104. data/app/components/polaris/option_list_component.rb +1 -1
  105. data/app/components/polaris/page_actions_component.rb +1 -1
  106. data/app/components/polaris/page_component.rb +1 -1
  107. data/app/components/polaris/pagination_component.rb +1 -1
  108. data/app/components/polaris/popover/pane_component.rb +1 -1
  109. data/app/components/polaris/popover/section_component.rb +1 -1
  110. data/app/components/polaris/popover_component.rb +10 -4
  111. data/app/components/polaris/progress_bar_component.rb +1 -1
  112. data/app/components/polaris/radio_button_component.rb +1 -1
  113. data/app/components/polaris/resource_item_component.rb +4 -2
  114. data/app/components/polaris/resource_list_component.rb +1 -1
  115. data/app/components/polaris/scrollable_component.rb +1 -1
  116. data/app/components/polaris/select_component.rb +1 -1
  117. data/app/components/polaris/setting_toggle_component.rb +1 -1
  118. data/app/components/polaris/shopify_navigation_component.rb +2 -2
  119. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  120. data/app/components/polaris/skeleton_display_text_component.rb +32 -0
  121. data/app/components/polaris/skeleton_thumbnail_component.rb +31 -0
  122. data/app/components/polaris/spacer_component.rb +1 -1
  123. data/app/components/polaris/spinner_component.rb +1 -1
  124. data/app/components/polaris/stack/item_component.rb +15 -0
  125. data/app/components/polaris/stack_component.rb +2 -18
  126. data/app/components/polaris/subheading_component.rb +1 -1
  127. data/app/components/polaris/tabs/tab_component.rb +1 -1
  128. data/app/components/polaris/tabs_component.rb +1 -1
  129. data/app/components/polaris/tag_component.rb +3 -2
  130. data/app/components/polaris/text_container_component.rb +1 -1
  131. data/app/components/polaris/text_field_component.rb +2 -2
  132. data/app/components/polaris/text_style_component.rb +1 -1
  133. data/app/components/polaris/thumbnail_component.rb +1 -1
  134. data/app/components/polaris/toast_component.rb +1 -1
  135. data/app/components/polaris/top_bar/user_menu_component.rb +1 -1
  136. data/app/components/polaris/visually_hidden_component.rb +1 -1
  137. data/app/helpers/polaris/form_builder.rb +14 -5
  138. data/app/helpers/polaris/view_helper.rb +6 -1
  139. data/config/locales/en.yml +6 -0
  140. data/lib/polaris/view_components/engine.rb +5 -1
  141. data/lib/polaris/view_components/version.rb +1 -1
  142. metadata +31 -21
  143. data/app/components/polaris/application_component.rb +0 -35
  144. data/app/components/polaris/dropzone/component.html.erb +0 -72
  145. data/app/components/polaris/dropzone/component.rb +0 -128
  146. data/app/components/polaris/dropzone/controller.js +0 -226
  147. data/app/components/polaris/dropzone/utils.js +0 -57
  148. data/app/components/polaris/new_component.rb +0 -10
  149. data/app/helpers/polaris/conditional_helper.rb +0 -11
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ # Lets users upload files by dragging and dropping the files into an area on a page, or activating a button.
5
+ class DropzoneComponent < Polaris::Component
6
+ include ActiveModel::Validations
7
+
8
+ SIZE_DEFAULT = :extra_large
9
+ SIZE_MAPPINGS = {
10
+ small: "Polaris-DropZone--sizeSmall",
11
+ medium: "Polaris-DropZone--sizeMedium",
12
+ large: "Polaris-DropZone--sizeLarge",
13
+ extra_large: "Polaris-DropZone--sizeExtraLarge"
14
+ }
15
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
16
+
17
+ attr_reader :label_action
18
+
19
+ validates :label_action, type: Action, allow_nil: true
20
+
21
+ def initialize(
22
+ form: nil,
23
+ attribute: nil,
24
+ name: nil,
25
+ accept: "",
26
+ direct_upload: false,
27
+ multiple: true,
28
+ size: SIZE_DEFAULT,
29
+ drop_on_page: false,
30
+ preview: true,
31
+ outline: true,
32
+ overlay_text: "Drop files to upload",
33
+ error_overlay_text: "This file type isn't accepted",
34
+ upload_error_text: "File upload failed",
35
+ label: nil,
36
+ label_hidden: true,
37
+ label_action: nil,
38
+ disabled: false,
39
+ error: false,
40
+ file_upload_button: nil,
41
+ file_upload_help: "or drop files to upload",
42
+ file_upload_arguments: {},
43
+ wrapper_arguments: {},
44
+ input_options: {},
45
+ **system_arguments
46
+ )
47
+ @form = form
48
+ @attribute = attribute
49
+ @name = name
50
+ @accept = accept
51
+ @direct_upload = direct_upload
52
+ @multiple = multiple
53
+ @size = size
54
+ @drop_on_page = drop_on_page
55
+ @preview = preview
56
+ @outline = outline
57
+ @overlay_text = overlay_text
58
+ @error_overlay_text = error_overlay_text
59
+ @upload_error_text = upload_error_text
60
+ @label = label
61
+ @label_hidden = label_hidden
62
+ @label_action = label_action
63
+ @disabled = disabled
64
+ @error = error
65
+ @file_upload_button = file_upload_button
66
+ @file_upload_button ||= "Add #{multiple ? "files" : "file"}"
67
+ @file_upload_help = file_upload_help
68
+ @file_upload_arguments = file_upload_arguments
69
+ @wrapper_arguments = wrapper_arguments
70
+ @input_options = input_options
71
+ @system_arguments = system_arguments
72
+ end
73
+
74
+ def system_arguments
75
+ {
76
+ tag: "div",
77
+ data: {
78
+ polaris_dropzone_accept_value: @accept,
79
+ polaris_dropzone_allow_multiple_value: @multiple.to_s,
80
+ polaris_dropzone_disabled_value: @disabled.to_s,
81
+ polaris_dropzone_disabled_class: "Polaris-DropZone--isDisabled",
82
+ polaris_dropzone_focused_value: "false",
83
+ polaris_dropzone_drop_on_page_value: @drop_on_page,
84
+ polaris_dropzone_render_preview_value: @preview,
85
+ polaris_dropzone_size_value: @size
86
+ }
87
+ }.deep_merge(@system_arguments).tap do |opts|
88
+ prepend_option(opts[:data], :controller, "polaris-dropzone")
89
+ prepend_option(opts[:data], :action, "click->polaris-dropzone#onClick #{drop_actions}")
90
+ opts[:classes] = class_names(
91
+ opts[:classes],
92
+ "Polaris-DropZone",
93
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, @size, SIZE_DEFAULT)],
94
+ "Polaris-DropZone--hasOutline": @outline,
95
+ "Polaris-DropZone--isDisabled": @disabled,
96
+ "Polaris-DropZone--hasError": @error
97
+ )
98
+ end
99
+ end
100
+
101
+ def wrapper_arguments
102
+ {
103
+ form: @form,
104
+ attribute: @attribute,
105
+ name: @name,
106
+ label: @label,
107
+ label_hidden: @label_hidden,
108
+ label_action: @label_action,
109
+ error: @error
110
+ }.deep_merge(@wrapper_arguments)
111
+ end
112
+
113
+ def input_options
114
+ {
115
+ accept: @accept,
116
+ direct_upload: @direct_upload,
117
+ disabled: @disabled,
118
+ multiple: @multiple,
119
+ data: {polaris_dropzone_target: "input"}
120
+ }.deep_merge(@input_options).tap do |opts|
121
+ prepend_option(opts[:data], :action, "focus->polaris-dropzone#onFocus blur->polaris-dropzone#onBlur change->polaris-dropzone#onChange")
122
+ end
123
+ end
124
+
125
+ def file_upload_arguments
126
+ {
127
+ tag: "div",
128
+ classes: class_names(
129
+ "Polaris-DropZone-FileUpload",
130
+ "Polaris-DropZone-FileUpload--large": @size.in?(%i[large extra_large]),
131
+ "Polaris-DropZone-FileUpload--small": @size == :small
132
+ ),
133
+ data: {
134
+ polaris_dropzone_target: "fileUpload"
135
+ }
136
+ }.deep_merge(@file_upload_arguments.except(:language))
137
+ end
138
+
139
+ def drop_actions
140
+ event_scope = @drop_on_page ? "@document" : ""
141
+
142
+ [
143
+ "drop#{event_scope}->polaris-dropzone#onDrop",
144
+ "dragover#{event_scope}->polaris-dropzone#onDragOver",
145
+ "dragenter#{event_scope}->polaris-dropzone#onDragEnter",
146
+ "dragleave#{event_scope}->polaris-dropzone#onDragLeave"
147
+ ].join(" ")
148
+ end
149
+ end
150
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class EmptyStateComponent < Polaris::NewComponent
4
+ class EmptyStateComponent < Polaris::Component
5
5
  WITHIN_DEFAULT = :page
6
6
  WITHIN_MAPPINGS = {
7
7
  WITHIN_DEFAULT => "",
@@ -1,4 +1,4 @@
1
- class Polaris::ExceptionList::ItemComponent < Polaris::NewComponent
1
+ class Polaris::ExceptionList::ItemComponent < Polaris::Component
2
2
  STATUS_DEFAULT = :default
3
3
  STATUS_MAPPINGS = {
4
4
  STATUS_DEFAULT => "",
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class ExceptionListComponent < Polaris::NewComponent
4
+ class ExceptionListComponent < Polaris::Component
5
5
  renders_many :items, Polaris::ExceptionList::ItemComponent
6
6
 
7
7
  def initialize(**system_arguments)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class FiltersComponent < Polaris::NewComponent
4
+ class FiltersComponent < Polaris::Component
5
5
  renders_one :query, ->(**system_arguments) do
6
6
  QueryComponent.new(disabled: @disabled, **system_arguments)
7
7
  end
@@ -34,7 +34,7 @@ module Polaris
34
34
  )
35
35
  end
36
36
 
37
- class QueryComponent < Polaris::NewComponent
37
+ class QueryComponent < Polaris::Component
38
38
  def initialize(clear_button: true, disabled: false, **system_arguments)
39
39
  @disabled = disabled
40
40
  @system_arguments = system_arguments.merge(
@@ -52,7 +52,7 @@ module Polaris
52
52
  end
53
53
  end
54
54
 
55
- class ItemComponent < Polaris::NewComponent
55
+ class ItemComponent < Polaris::Component
56
56
  def initialize(label:, sectioned: true, width: nil, disabled: false, **system_arguments)
57
57
  @label = label
58
58
  @sectioned = sectioned
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class FooterHelpComponent < Polaris::NewComponent
4
+ class FooterHelpComponent < Polaris::Component
5
5
  def initialize(**system_arguments)
6
6
  @system_arguments = system_arguments
7
7
  @system_arguments[:classes] = class_names(
@@ -1,4 +1,4 @@
1
- class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
1
+ class Polaris::FormLayout::GroupComponent < Polaris::Component
2
2
  attr_reader :position
3
3
 
4
4
  renders_many :items, "GroupItemComponent"
@@ -22,7 +22,7 @@ class Polaris::FormLayout::GroupComponent < Polaris::NewComponent
22
22
  )
23
23
  end
24
24
 
25
- class GroupItemComponent < Polaris::NewComponent
25
+ class GroupItemComponent < Polaris::Component
26
26
  def initialize(**system_arguments)
27
27
  @system_arguments = system_arguments
28
28
  @system_arguments[:tag] = "div"
@@ -1,4 +1,4 @@
1
- class Polaris::FormLayout::ItemComponent < Polaris::NewComponent
1
+ class Polaris::FormLayout::ItemComponent < Polaris::Component
2
2
  attr_reader :position
3
3
 
4
4
  def initialize(position:, **system_arguments)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class FormLayoutComponent < Polaris::NewComponent
4
+ class FormLayoutComponent < Polaris::Component
5
5
  renders_many :items, ->(**system_arguments) do
6
6
  @counter += 1
7
7
  Polaris::FormLayout::ItemComponent.new(position: @counter, **system_arguments)
@@ -1,4 +1,4 @@
1
- class Polaris::Frame::SaveBarComponent < Polaris::NewComponent
1
+ class Polaris::Frame::SaveBarComponent < Polaris::Component
2
2
  renders_one :save_action, ->(**system_arguments) do
3
3
  Polaris::ButtonComponent.new(primary: true, **system_arguments)
4
4
  end
@@ -1,4 +1,4 @@
1
- class Polaris::Frame::TopBarComponent < Polaris::NewComponent
1
+ class Polaris::Frame::TopBarComponent < Polaris::Component
2
2
  renders_one :user_menu, Polaris::TopBar::UserMenuComponent
3
3
 
4
4
  def initialize(logo:, **system_arguments)
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
- class FrameComponent < Polaris::NewComponent
2
+ class FrameComponent < Polaris::Component
3
3
  renders_one :top_bar, ->(**system_arguments) do
4
4
  Polaris::Frame::TopBarComponent.new(logo: @logo, **system_arguments)
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class HeadingComponent < Polaris::NewComponent
4
+ class HeadingComponent < Polaris::Component
5
5
  ELEMENT_DEFAULT = :h2
6
6
  ELEMENT_OPTIONS = %i[p h1 h2 h3 h4 h5 h6]
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class HeadlessButton < Polaris::NewComponent
4
+ class HeadlessButton < Polaris::Component
5
5
  SIZE_DEFAULT = :medium
6
6
  SIZE_MAPPINGS = {
7
7
  SIZE_DEFAULT => "",
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class IconComponent < Polaris::NewComponent
4
+ class IconComponent < Polaris::Component
5
5
  COLOR_DEFAULT = :default
6
6
  COLOR_MAPPINGS = {
7
7
  COLOR_DEFAULT => "",
@@ -1,4 +1,4 @@
1
- class Polaris::IndexTable::CellComponent < Polaris::NewComponent
1
+ class Polaris::IndexTable::CellComponent < Polaris::Component
2
2
  def initialize(flush: false, **system_arguments)
3
3
  @flush = flush
4
4
  @system_arguments = system_arguments
@@ -1,4 +1,4 @@
1
- class Polaris::IndexTable::ColumnComponent < Polaris::NewComponent
1
+ class Polaris::IndexTable::ColumnComponent < Polaris::Component
2
2
  attr_reader :title, :flush
3
3
 
4
4
  def initialize(title, flush: false, **system_arguments, &block)
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
- class IndexTableComponent < Polaris::NewComponent
2
+ class IndexTableComponent < Polaris::Component
3
3
  renders_many :columns, ->(title, **system_arguments, &block) do
4
4
  IndexTable::ColumnComponent.new(title, **system_arguments, &block)
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class InlineErrorComponent < Polaris::NewComponent
4
+ class InlineErrorComponent < Polaris::Component
5
5
  def initialize(**system_arguments)
6
6
  @system_arguments = system_arguments
7
7
  @system_arguments[:tag] = "div"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class KeyboardKeyComponent < Polaris::Component
5
+ def initialize(**system_arguments)
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(opts[:classes], "Polaris-KeyboardKey")
13
+ end
14
+ end
15
+
16
+ def call
17
+ render(Polaris::BaseComponent.new(**system_arguments)) { content }
18
+ end
19
+ end
20
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class LabelComponent < Polaris::NewComponent
4
+ class LabelComponent < Polaris::Component
5
5
  def initialize(
6
6
  form: nil,
7
7
  attribute: nil,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class LabelledComponent < Polaris::NewComponent
4
+ class LabelledComponent < Polaris::Component
5
5
  renders_one :label_action, ->(**system_arguments) do
6
6
  Polaris::ButtonComponent.new(plain: true, **system_arguments)
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  module Layout
5
- class AnnotatedSection < Polaris::NewComponent
5
+ class AnnotatedSection < Polaris::Component
6
6
  attr_reader :position
7
7
 
8
8
  def initialize(position:, title:, description: nil, **system_arguments)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  module Layout
5
- class Section < Polaris::NewComponent
5
+ class Section < Polaris::Component
6
6
  attr_reader :position
7
7
 
8
8
  def initialize(
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class LayoutComponent < Polaris::NewComponent
4
+ class LayoutComponent < Polaris::Component
5
5
  # A list of sections
6
6
  #
7
7
  # @param secondary [Boolean] The section will act like a sidebar
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class LinkComponent < Polaris::NewComponent
4
+ class LinkComponent < Polaris::Component
5
5
  def initialize(
6
6
  url:,
7
7
  external: false,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class ListComponent < Polaris::NewComponent
4
+ class ListComponent < Polaris::Component
5
5
  renders_many :items, "ListItemComponent"
6
6
 
7
7
  TYPE_DEFAULT = :bullet
@@ -28,7 +28,7 @@ module Polaris
28
28
  )
29
29
  end
30
30
 
31
- class ListItemComponent < Polaris::NewComponent
31
+ class ListItemComponent < Polaris::Component
32
32
  def initialize(**system_arguments)
33
33
  @system_arguments = system_arguments
34
34
  @system_arguments[:tag] = :li
@@ -1,4 +1,4 @@
1
- class Polaris::Modal::SectionComponent < Polaris::NewComponent
1
+ class Polaris::Modal::SectionComponent < Polaris::Component
2
2
  def initialize(**system_arguments)
3
3
  @system_arguments = system_arguments
4
4
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class ModalComponent < Polaris::NewComponent
4
+ class ModalComponent < Polaris::Component
5
5
  renders_one :close_button, ->(**system_arguments) do
6
6
  button_arguments = @close_button_arguments.deep_merge(system_arguments)
7
7
  render(Polaris::BaseComponent.new(**button_arguments)) do
@@ -1,4 +1,4 @@
1
- class Polaris::Navigation::ItemComponent < Polaris::NewComponent
1
+ class Polaris::Navigation::ItemComponent < Polaris::Component
2
2
  renders_many :sub_items, Polaris::Navigation::ItemComponent
3
3
  renders_one :secondary_action, "SecondaryActionComponent"
4
4
 
@@ -47,7 +47,7 @@ class Polaris::Navigation::ItemComponent < Polaris::NewComponent
47
47
  sub_items.any?(&:selected)
48
48
  end
49
49
 
50
- class SecondaryActionComponent < Polaris::NewComponent
50
+ class SecondaryActionComponent < Polaris::Component
51
51
  def initialize(url: nil, external: false, icon: nil, **system_arguments)
52
52
  @url = url
53
53
  @external = external
@@ -1,4 +1,4 @@
1
- class Polaris::Navigation::SectionComponent < Polaris::NewComponent
1
+ class Polaris::Navigation::SectionComponent < Polaris::Component
2
2
  renders_many :items, Polaris::Navigation::ItemComponent
3
3
  renders_one :action, "ActionComponent"
4
4
 
@@ -26,7 +26,7 @@ class Polaris::Navigation::SectionComponent < Polaris::NewComponent
26
26
  end
27
27
  end
28
28
 
29
- class ActionComponent < Polaris::NewComponent
29
+ class ActionComponent < Polaris::Component
30
30
  def initialize(url: nil, external: false, icon: nil, **system_arguments)
31
31
  @url = url
32
32
  @external = external
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
- class NavigationComponent < Polaris::NewComponent
2
+ class NavigationComponent < Polaris::Component
3
3
  renders_many :sections, Polaris::Navigation::SectionComponent
4
4
  renders_many :items, Polaris::Navigation::ItemComponent
5
5
 
@@ -1,4 +1,4 @@
1
- class Polaris::OptionList::CheckboxComponent < Polaris::NewComponent
1
+ class Polaris::OptionList::CheckboxComponent < Polaris::Component
2
2
  def initialize(
3
3
  label:,
4
4
  value:,
@@ -1,4 +1,4 @@
1
- class Polaris::OptionList::OptionComponent < Polaris::NewComponent
1
+ class Polaris::OptionList::OptionComponent < Polaris::Component
2
2
  def initialize(**system_arguments)
3
3
  @system_arguments = system_arguments
4
4
  end
@@ -1,4 +1,4 @@
1
- class Polaris::OptionList::RadioButtonComponent < Polaris::NewComponent
1
+ class Polaris::OptionList::RadioButtonComponent < Polaris::Component
2
2
  def initialize(
3
3
  label:,
4
4
  value:,
@@ -1,4 +1,4 @@
1
- class Polaris::OptionList::SectionComponent < Polaris::NewComponent
1
+ class Polaris::OptionList::SectionComponent < Polaris::Component
2
2
  renders_many :options, Polaris::OptionList::OptionComponent
3
3
  renders_many :radio_buttons, ->(value:, **system_arguments) do
4
4
  Polaris::OptionList::RadioButtonComponent.new(
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
- class OptionListComponent < Polaris::NewComponent
2
+ class OptionListComponent < Polaris::Component
3
3
  renders_many :sections, ->(**system_arguments) do
4
4
  Polaris::OptionList::SectionComponent.new(
5
5
  form: @form,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class PageActionsComponent < Polaris::NewComponent
4
+ class PageActionsComponent < Polaris::Component
5
5
  DISTRIBUTION_DEFAULT = nil
6
6
  DISTRIBUTION_OPTIONS = [
7
7
  DISTRIBUTION_DEFAULT,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class PageComponent < Polaris::NewComponent
4
+ class PageComponent < Polaris::Component
5
5
  renders_one :primary_action, ->(primary: true, **system_arguments) do
6
6
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class PaginationComponent < Polaris::NewComponent
4
+ class PaginationComponent < Polaris::Component
5
5
  def initialize(
6
6
  previous_url: nil,
7
7
  next_url: nil,
@@ -1,4 +1,4 @@
1
- class Polaris::Popover::PaneComponent < Polaris::NewComponent
1
+ class Polaris::Popover::PaneComponent < Polaris::Component
2
2
  renders_many :sections, Polaris::Popover::SectionComponent
3
3
 
4
4
  def initialize(fixed: false, sectioned: false, **system_arguments)
@@ -1,4 +1,4 @@
1
- class Polaris::Popover::SectionComponent < Polaris::NewComponent
1
+ class Polaris::Popover::SectionComponent < Polaris::Component
2
2
  def initialize(**system_arguments)
3
3
  @system_arguments = system_arguments
4
4
  end
@@ -1,10 +1,10 @@
1
1
  module Polaris
2
- class PopoverComponent < Polaris::NewComponent
2
+ class PopoverComponent < Polaris::Component
3
3
  ALIGNMENT_DEFAULT = :center
4
4
  ALIGNMENT_OPTIONS = [:left, :right, :center]
5
5
 
6
- POSITION_DEFAULT = :below
7
- POSITION_OPTIONS = [:above, :below]
6
+ POSITION_DEFAULT = :auto
7
+ POSITION_OPTIONS = [:auto, :above, :below]
8
8
 
9
9
  renders_one :button, ->(**system_arguments) do
10
10
  system_arguments[:data] ||= {}
@@ -98,7 +98,13 @@ module Polaris
98
98
  end
99
99
 
100
100
  def popperjs_placement
101
- placement = @position == :above ? "top" : "bottom"
101
+ placement =
102
+ case @position
103
+ when :above then "top"
104
+ when :below then "bottom"
105
+ else
106
+ "auto"
107
+ end
102
108
  placement += "-start" if @alignment == :left
103
109
  placement += "-end" if @alignment == :right
104
110
  placement
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class ProgressBarComponent < Polaris::NewComponent
4
+ class ProgressBarComponent < Polaris::Component
5
5
  COLOR_DEFAULT = :highlight
6
6
  COLOR_MAPPINGS = {
7
7
  COLOR_DEFAULT => "Polaris-ProgressBar--colorHighlight",
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class RadioButtonComponent < Polaris::NewComponent
4
+ class RadioButtonComponent < Polaris::Component
5
5
  def initialize(
6
6
  form: nil,
7
7
  attribute: nil,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polaris
4
- class ResourceItemComponent < Polaris::NewComponent
4
+ class ResourceItemComponent < Polaris::Component
5
5
  CURSOR_DEFAULT = :default
6
6
  CURSOR_OPTIONS = %i[default pointer]
7
7
 
@@ -29,6 +29,7 @@ module Polaris
29
29
  def initialize(
30
30
  url: nil,
31
31
  vertical_alignment: ALIGNMENT_DEFAULT,
32
+ cursor: CURSOR_DEFAULT,
32
33
  selectable: false,
33
34
  offset: false,
34
35
  wrapper_arguments: {},
@@ -37,6 +38,7 @@ module Polaris
37
38
  )
38
39
  @url = url
39
40
  @vertical_alignment = vertical_alignment
41
+ @cursor = fetch_or_fallback(CURSOR_OPTIONS, cursor, CURSOR_DEFAULT)
40
42
  @selectable = selectable
41
43
  @offset = offset
42
44
  @wrapper_arguments = wrapper_arguments
@@ -79,7 +81,7 @@ module Polaris
79
81
  "Polaris-ResourceItem",
80
82
  "Polaris-ResourceItem--selectable": @selectable
81
83
  )
82
- prepend_option(args, :style, "cursor: #{cursor};")
84
+ prepend_option(args, :style, "cursor: #{@cursor};")
83
85
  prepend_option(args[:data], :action, "click->polaris-resource-item#open")
84
86
  end
85
87
  end