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.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  6. data/app/assets/javascripts/polaris_view_components/index.js +19 -1
  7. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  8. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  9. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  10. data/app/assets/javascripts/polaris_view_components/popover_controller.js +49 -0
  11. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  12. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  13. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  14. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  15. data/app/assets/javascripts/polaris_view_components.js +1936 -5
  16. data/app/assets/stylesheets/polaris_view_components/custom.css +109 -0
  17. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  18. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  19. data/app/assets/stylesheets/polaris_view_components.css +118 -3
  20. data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
  21. data/app/components/polaris/action.rb +3 -3
  22. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  23. data/app/components/polaris/action_list/item_component.rb +41 -0
  24. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  25. data/app/components/polaris/action_list/section_component.rb +26 -0
  26. data/app/components/polaris/action_list_component.html.erb +13 -0
  27. data/app/components/polaris/action_list_component.rb +25 -0
  28. data/app/components/polaris/application_component.rb +19 -19
  29. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  30. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  31. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  32. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  33. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  34. data/app/components/polaris/autocomplete_component.rb +58 -0
  35. data/app/components/polaris/avatar_component.rb +1 -1
  36. data/app/components/polaris/badge_component.rb +1 -1
  37. data/app/components/polaris/banner_component.rb +6 -6
  38. data/app/components/polaris/base_button.rb +1 -1
  39. data/app/components/polaris/base_checkbox.rb +48 -0
  40. data/app/components/polaris/base_radio_button.rb +38 -0
  41. data/app/components/polaris/button_component.html.erb +13 -0
  42. data/app/components/polaris/button_group_component.rb +5 -5
  43. data/app/components/polaris/callout_card_component.rb +5 -5
  44. data/app/components/polaris/caption_component.rb +2 -2
  45. data/app/components/polaris/card/header_component.rb +1 -3
  46. data/app/components/polaris/card/section_component.rb +6 -2
  47. data/app/components/polaris/card_component.html.erb +4 -0
  48. data/app/components/polaris/card_component.rb +5 -6
  49. data/app/components/polaris/character_count.rb +10 -10
  50. data/app/components/polaris/checkbox_component.html.erb +1 -5
  51. data/app/components/polaris/checkbox_component.rb +19 -12
  52. data/app/components/polaris/choice_component.rb +1 -1
  53. data/app/components/polaris/choice_list_component.rb +5 -5
  54. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  55. data/app/components/polaris/data_table/cell_component.rb +49 -0
  56. data/app/components/polaris/data_table/column_component.rb +19 -0
  57. data/app/components/polaris/data_table_component.html.erb +77 -0
  58. data/app/components/polaris/data_table_component.rb +42 -0
  59. data/app/components/polaris/description_list_component.rb +3 -3
  60. data/app/components/polaris/display_text_component.rb +2 -2
  61. data/app/components/polaris/dropzone/component.rb +36 -38
  62. data/app/components/polaris/empty_state_component.html.erb +16 -11
  63. data/app/components/polaris/empty_state_component.rb +4 -3
  64. data/app/components/polaris/exception_list/item_component.rb +2 -2
  65. data/app/components/polaris/exception_list_component.rb +1 -1
  66. data/app/components/polaris/filters_component.html.erb +35 -0
  67. data/app/components/polaris/filters_component.rb +91 -0
  68. data/app/components/polaris/footer_help_component.rb +1 -1
  69. data/app/components/polaris/form_layout/group_component.rb +3 -3
  70. data/app/components/polaris/form_layout/item_component.rb +1 -1
  71. data/app/components/polaris/form_layout_component.rb +3 -3
  72. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  73. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  74. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  75. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  76. data/app/components/polaris/frame_component.html.erb +44 -0
  77. data/app/components/polaris/frame_component.rb +33 -0
  78. data/app/components/polaris/heading_component.rb +1 -1
  79. data/app/components/polaris/headless_button.html.erb +13 -0
  80. data/app/components/polaris/headless_button.rb +17 -5
  81. data/app/components/polaris/icon_component.rb +2 -2
  82. data/app/components/polaris/index_table/cell_component.rb +22 -0
  83. data/app/components/polaris/index_table/column_component.rb +13 -0
  84. data/app/components/polaris/index_table_component.html.erb +28 -0
  85. data/app/components/polaris/index_table_component.rb +25 -0
  86. data/app/components/polaris/inline_error_component.html.erb +2 -2
  87. data/app/components/polaris/inline_error_component.rb +7 -1
  88. data/app/components/polaris/label_component.rb +2 -2
  89. data/app/components/polaris/labelled_component.rb +2 -2
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +2 -0
  92. data/app/components/polaris/layout_component.rb +3 -3
  93. data/app/components/polaris/link_component.rb +5 -3
  94. data/app/components/polaris/list_component.rb +3 -3
  95. data/app/components/polaris/logo.rb +13 -0
  96. data/app/components/polaris/modal/section_component.rb +19 -0
  97. data/app/components/polaris/modal_component.html.erb +79 -0
  98. data/app/components/polaris/modal_component.rb +98 -0
  99. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  100. data/app/components/polaris/navigation/item_component.rb +85 -0
  101. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  102. data/app/components/polaris/navigation/section_component.rb +64 -0
  103. data/app/components/polaris/navigation_component.html.erb +29 -0
  104. data/app/components/polaris/navigation_component.rb +15 -0
  105. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  107. data/app/components/polaris/option_list/option_component.rb +24 -0
  108. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  109. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  110. data/app/components/polaris/option_list/section_component.rb +53 -0
  111. data/app/components/polaris/option_list_component.html.erb +15 -0
  112. data/app/components/polaris/option_list_component.rb +67 -0
  113. data/app/components/polaris/page_actions_component.rb +21 -6
  114. data/app/components/polaris/page_component.rb +4 -4
  115. data/app/components/polaris/pagination_component.rb +1 -5
  116. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  117. data/app/components/polaris/popover/pane_component.rb +20 -0
  118. data/app/components/polaris/popover/section_component.rb +19 -0
  119. data/app/components/polaris/popover_component.html.erb +31 -0
  120. data/app/components/polaris/popover_component.rb +107 -0
  121. data/app/components/polaris/progress_bar_component.rb +5 -5
  122. data/app/components/polaris/radio_button_component.html.erb +1 -6
  123. data/app/components/polaris/radio_button_component.rb +17 -7
  124. data/app/components/polaris/resource_item_component.html.erb +16 -6
  125. data/app/components/polaris/resource_item_component.rb +42 -9
  126. data/app/components/polaris/resource_list_component.html.erb +10 -0
  127. data/app/components/polaris/resource_list_component.rb +4 -10
  128. data/app/components/polaris/scrollable_component.html.erb +5 -0
  129. data/app/components/polaris/scrollable_component.rb +48 -0
  130. data/app/components/polaris/select_component.rb +10 -5
  131. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  132. data/app/components/polaris/setting_toggle_component.rb +24 -0
  133. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  134. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  135. data/app/components/polaris/spacer_component.rb +50 -0
  136. data/app/components/polaris/spinner_component.rb +2 -2
  137. data/app/components/polaris/stack_component.rb +5 -5
  138. data/app/components/polaris/subheading_component.rb +1 -1
  139. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  140. data/app/components/polaris/tabs/tab_component.rb +34 -0
  141. data/app/components/polaris/tabs_component.html.erb +7 -0
  142. data/app/components/polaris/tabs_component.rb +37 -0
  143. data/app/components/polaris/tag_component.rb +2 -2
  144. data/app/components/polaris/text_container_component.rb +2 -2
  145. data/app/components/polaris/text_field_component.rb +24 -10
  146. data/app/components/polaris/text_style_component.rb +11 -2
  147. data/app/components/polaris/thumbnail_component.rb +2 -2
  148. data/app/components/polaris/toast_component.html.erb +21 -0
  149. data/app/components/polaris/toast_component.rb +40 -0
  150. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  151. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  152. data/app/helpers/polaris/form_builder.rb +31 -4
  153. data/app/helpers/polaris/url_helper.rb +3 -3
  154. data/app/helpers/polaris/view_helper.rb +37 -6
  155. data/app/validators/type_validator.rb +2 -2
  156. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  157. data/lib/polaris/view_components/engine.rb +11 -2
  158. data/lib/polaris/view_components/version.rb +1 -1
  159. data/lib/polaris_view_components.rb +1 -1
  160. metadata +88 -12
  161. data/app/components/polaris/choice_list/component.html.erb +0 -34
  162. data/app/components/polaris/choice_list/component.rb +0 -65
  163. data/app/helpers/polaris/action_helper.rb +0 -14
@@ -0,0 +1,44 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <% if top_bar.present? %>
3
+ <div class="Polaris-Frame__TopBar">
4
+ <%= top_bar %>
5
+ </div>
6
+ <% end %>
7
+
8
+ <% if navigation.present? %>
9
+ <div data-polaris-frame-target="navigation" class="Polaris-Frame__Navigation">
10
+ <%= navigation %>
11
+ <button
12
+ data-action="polaris-frame#closeMenu"
13
+ type="button"
14
+ class="Polaris-Frame__NavigationDismiss"
15
+ tabindex="-1"
16
+ >
17
+ <%= polaris_icon(name: "MobileCancelMajor") %>
18
+ </button>
19
+ </div>
20
+ <% end %>
21
+
22
+ <% if save_bar.present? %>
23
+ <div
24
+ data-polaris-frame-target="saveBar"
25
+ class="Polaris-Frame__ContextualSaveBar Polaris-Frame-CSSAnimation--startFade"
26
+ >
27
+ <%= save_bar %>
28
+ </div>
29
+ <% end %>
30
+
31
+ <div data-polaris-frame-target="navigationOverlay"></div>
32
+
33
+ <main class="Polaris-Frame__Main">
34
+ <div class="Polaris-Frame__Content">
35
+ <%= content %>
36
+ </div>
37
+ </main>
38
+ <% end %>
39
+
40
+ <% if toasts.present? %>
41
+ <div class="Polaris-Frame-ToastManager">
42
+ <%= toasts %>
43
+ </div>
44
+ <% end %>
@@ -0,0 +1,33 @@
1
+ module Polaris
2
+ class FrameComponent < Polaris::NewComponent
3
+ renders_one :top_bar, ->(**system_arguments) do
4
+ Polaris::Frame::TopBarComponent.new(logo: @logo, **system_arguments)
5
+ end
6
+ renders_one :navigation, ->(**system_arguments) do
7
+ Polaris::NavigationComponent.new(logo: @logo, **system_arguments)
8
+ end
9
+ renders_one :save_bar, ->(**system_arguments) do
10
+ Polaris::Frame::SaveBarComponent.new(logo: @logo, **system_arguments)
11
+ end
12
+ renders_one :toasts
13
+
14
+ def initialize(logo: nil, **system_arguments)
15
+ @logo = logo && Polaris::Logo.new(**logo)
16
+ @system_arguments = system_arguments
17
+ end
18
+
19
+ def system_arguments
20
+ @system_arguments.tap do |opts|
21
+ opts[:tag] = "div"
22
+ opts[:data] ||= {}
23
+ prepend_option(@system_arguments[:data], :controller, "polaris-frame")
24
+ opts[:classes] = class_names(
25
+ opts[:classes],
26
+ "Polaris-Frame",
27
+ "Polaris-Frame--hasNav": navigation.present?,
28
+ "Polaris-Frame--hasTopBar": top_bar.present?
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -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
@@ -0,0 +1,22 @@
1
+ class Polaris::IndexTable::CellComponent < Polaris::NewComponent
2
+ def initialize(flush: false, **system_arguments)
3
+ @flush = flush
4
+ @system_arguments = system_arguments
5
+ end
6
+
7
+ def system_arguments
8
+ {tag: "td"}.deep_merge(@system_arguments).tap do |args|
9
+ args[:classes] = class_names(
10
+ args[:classes],
11
+ "Polaris-IndexTable__TableCell",
12
+ "Polaris-IndexTable__TableCell--flush": @flush
13
+ )
14
+ end
15
+ end
16
+
17
+ def call
18
+ render(Polaris::BaseComponent.new(**system_arguments)) do
19
+ content
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ class Polaris::IndexTable::ColumnComponent < Polaris::NewComponent
2
+ attr_reader :title, :flush
3
+
4
+ def initialize(title, flush: false, **system_arguments, &block)
5
+ @title = title
6
+ @flush = flush
7
+ @block = block
8
+ end
9
+
10
+ def call(row)
11
+ @block.call(row)
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-IndexTable-ScrollContainer">
3
+ <table class="Polaris-IndexTable__Table">
4
+ <thead>
5
+ <tr>
6
+ <% columns.each_with_index do |column, index| %>
7
+ <th class="Polaris-IndexTable__TableHeading">
8
+ <%= column.title %>
9
+ </th>
10
+ <% end %>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% @data.each do |row| %>
15
+ <tr class="Polaris-IndexTable__TableRow Polaris-IndexTable__TableRow--unclickable">
16
+ <% columns.each_with_index do |column, index| %>
17
+ <%= render_cell(
18
+ flush: column.flush,
19
+ ) do %>
20
+ <%= column.call(row) %>
21
+ <% end %>
22
+ <% end %>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,25 @@
1
+ module Polaris
2
+ class IndexTableComponent < Polaris::NewComponent
3
+ renders_many :columns, ->(title, **system_arguments, &block) do
4
+ IndexTable::ColumnComponent.new(title, **system_arguments, &block)
5
+ end
6
+
7
+ def initialize(data, **system_arguments)
8
+ @data = data
9
+ @system_arguments = system_arguments
10
+ end
11
+
12
+ def system_arguments
13
+ {tag: "div"}.deep_merge(@system_arguments).tap do |args|
14
+ args[:classes] = class_names(
15
+ args[:classes],
16
+ "Polaris-IndexTable"
17
+ )
18
+ end
19
+ end
20
+
21
+ def render_cell(**arguments, &block)
22
+ render(IndexTable::CellComponent.new(**arguments), &block)
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
- <div class="Polaris-InlineError">
1
+ <%= render(Polaris::BaseComponent.new(**@system_arguments)) do %>
2
2
  <div class="Polaris-InlineError__Icon">
3
3
  <%= polaris_icon(name: "AlertMinor") %>
4
4
  </div>
5
5
  <%= content %>
6
- </div>
6
+ <% end %>
@@ -2,7 +2,13 @@
2
2
 
3
3
  module Polaris
4
4
  class InlineErrorComponent < Polaris::NewComponent
5
- def initialize
5
+ def initialize(**system_arguments)
6
+ @system_arguments = system_arguments
7
+ @system_arguments[:tag] = "div"
8
+ @system_arguments[:classes] = class_names(
9
+ @system_arguments[:classes],
10
+ "Polaris-InlineError"
11
+ )
6
12
  end
7
13
 
8
14
  def renders?
@@ -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
@@ -11,6 +11,7 @@ module Polaris
11
11
  full_width: false,
12
12
  one_half: false,
13
13
  one_third: false,
14
+ one_fourth: false,
14
15
  **system_arguments
15
16
  )
16
17
  @position = position
@@ -24,6 +25,7 @@ module Polaris
24
25
  "Polaris-Layout__Section--fullWidth" => full_width,
25
26
  "Polaris-Layout__Section--oneHalf" => one_half,
26
27
  "Polaris-Layout__Section--oneThird" => one_third,
28
+ "Polaris-Layout__Section--oneFourth" => one_fourth
27
29
  )
28
30
  end
29
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
 
@@ -6,6 +6,7 @@ module Polaris
6
6
  url:,
7
7
  external: false,
8
8
  monochrome: false,
9
+ no_underline: false,
9
10
  **system_arguments
10
11
  )
11
12
  @url = url
@@ -23,14 +24,15 @@ module Polaris
23
24
  @system_arguments[:classes],
24
25
  "Polaris-Link",
25
26
  "Polaris-Link--monochrome" => monochrome,
27
+ "Polaris-Link--removeUnderline" => no_underline
26
28
  )
27
29
  end
28
30
 
29
31
  def call
30
32
  render(Polaris::BaseComponent.new(**@system_arguments)) do
31
33
  safe_join [
32
- content.strip,
33
- (external_icon if @external),
34
+ content.strip.html_safe,
35
+ (external_icon if @external)
34
36
  ].compact
35
37
  end
36
38
  end
@@ -40,7 +42,7 @@ module Polaris
40
42
  def external_icon
41
43
  tag.span(class: "Polaris-Link__IconLockup") do
42
44
  tag.span(class: "Polaris-Link__IconLayout") do
43
- polaris_icon(name: "ExternalSmallMinor", aria: { label: "(opens a new window)" })
45
+ polaris_icon(name: "ExternalSmallMinor", aria: {label: "(opens a new window)"})
44
46
  end
45
47
  end
46
48
  end
@@ -7,11 +7,11 @@ module Polaris
7
7
  TYPE_DEFAULT = :bullet
8
8
  TYPE_TAG_MAPPINGS = {
9
9
  bullet: :ul,
10
- number: :ol,
10
+ number: :ol
11
11
  }
12
12
  TYPE_CLASS_MAPPINGS = {
13
13
  bullet: "",
14
- number: "Polaris-List--typeNumber",
14
+ number: "Polaris-List--typeNumber"
15
15
  }
16
16
  TYPE_OPTIONS = TYPE_TAG_MAPPINGS.keys
17
17
 
@@ -24,7 +24,7 @@ module Polaris
24
24
  @system_arguments[:classes] = class_names(
25
25
  @system_arguments[:classes],
26
26
  "Polaris-List",
27
- TYPE_CLASS_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, "")],
27
+ TYPE_CLASS_MAPPINGS[fetch_or_fallback(TYPE_OPTIONS, type, "")]
28
28
  )
29
29
  end
30
30
 
@@ -0,0 +1,13 @@
1
+ class Polaris::Logo
2
+ attr_reader :src
3
+ attr_reader :url
4
+ attr_reader :alt
5
+ attr_reader :width
6
+
7
+ def initialize(src:, url: nil, alt: nil, width: "125px")
8
+ @url = url
9
+ @src = src
10
+ @alt = alt
11
+ @width = width
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class Polaris::Modal::SectionComponent < Polaris::NewComponent
2
+ def initialize(**system_arguments)
3
+ @system_arguments = system_arguments
4
+ end
5
+
6
+ def system_arguments
7
+ @system_arguments.tap do |opts|
8
+ opts[:tag] = "div"
9
+ opts[:classes] = class_names(
10
+ @system_arguments[:classes],
11
+ "Polaris-Modal-Section"
12
+ )
13
+ end
14
+ end
15
+
16
+ def call
17
+ render(Polaris::BaseComponent.new(**system_arguments)) { content }
18
+ end
19
+ end
@@ -0,0 +1,79 @@
1
+ <% modal_content = capture do %>
2
+ <% if sections.present? %>
3
+ <% sections.each do |section| %>
4
+ <%= section %>
5
+ <% end %>
6
+ <% end %>
7
+
8
+ <% if content.present? %>
9
+ <% if @sectioned %>
10
+ <%= render Polaris::Modal::SectionComponent.new do %>
11
+ <%= content %>
12
+ <% end %>
13
+ <% else %>
14
+ <%= content %>
15
+ <% end %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
20
+ <div>
21
+ <%= render(Polaris::BaseComponent.new(**dialog_arguments)) do %>
22
+ <div class="<%= modal_classes %>">
23
+ <div class="<%= header_classes %>">
24
+ <div class="Polaris-Modal-Header__Title">
25
+ <%= polaris_display_text(element: :h2, size: :small) do %>
26
+ <%= @title %>
27
+ <% end %>
28
+ </div>
29
+ <% if close_button.present? %>
30
+ <%= close_button %>
31
+ <% else %>
32
+ <%= render(Polaris::BaseComponent.new(**close_button_arguments)) do %>
33
+ <%= polaris_icon(name: "MobileCancelMajor", color: :base) %>
34
+ <% end %>
35
+ <% end %>
36
+ </div>
37
+
38
+ <div class="Polaris-Modal__BodyWrapper">
39
+ <% if @scrollable %>
40
+ <%= polaris_scrollable(classes: "Polaris-Modal__Body") do %>
41
+ <%= modal_content %>
42
+ <% end %>
43
+ <% else %>
44
+ <%= modal_content %>
45
+ <% end %>
46
+ </div>
47
+
48
+ <% if render_footer? %>
49
+ <div class="Polaris-Modal-Footer">
50
+ <div class="Polaris-Modal-Footer__FooterContent">
51
+ <%= polaris_stack(alignment: :center) do |stack| %>
52
+ <% stack.item(fill: true) do %>
53
+ <% end %>
54
+
55
+ <% stack.item do %>
56
+ <%= polaris_button_group do |group| %>
57
+ <% if secondary_actions %>
58
+ <% secondary_actions.each do |action| %>
59
+ <% group.item do %>
60
+ <%= action %>
61
+ <% end %>
62
+ <% end %>
63
+
64
+ <% if primary_action %>
65
+ <% group.item do %>
66
+ <%= primary_action %>
67
+ <% end %>
68
+ <% end %>
69
+ <% end %>
70
+ <% end %>
71
+ <% end %>
72
+ <% end %>
73
+ </div>
74
+ </div>
75
+ <% end %>
76
+ </div>
77
+ <% end %>
78
+ </div>
79
+ <% end %>
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class ModalComponent < Polaris::NewComponent
5
+ renders_one :close_button, ->(**system_arguments) do
6
+ button_arguments = @close_button_arguments.deep_merge(system_arguments)
7
+ render(Polaris::BaseComponent.new(**button_arguments)) do
8
+ polaris_icon(name: "MobileCancelMajor", color: :base)
9
+ end
10
+ end
11
+ renders_many :sections, Polaris::Modal::SectionComponent
12
+ renders_one :primary_action, ->(primary: true, **system_arguments) do
13
+ Polaris::ButtonComponent.new(primary: primary, **system_arguments)
14
+ end
15
+ renders_many :secondary_actions, Polaris::ButtonComponent
16
+
17
+ def initialize(
18
+ title:,
19
+ open: false,
20
+ sectioned: true,
21
+ scrollable: true,
22
+ large: false,
23
+ small: false,
24
+ limit_height: false,
25
+ dialog_arguments: {},
26
+ **system_arguments
27
+ )
28
+ @title = title
29
+ @open = open
30
+ @sectioned = sectioned
31
+ @scrollable = scrollable
32
+ @large = large
33
+ @small = small
34
+ @limit_height = limit_height
35
+ @dialog_arguments = dialog_arguments
36
+ @system_arguments = system_arguments
37
+ @close_button_arguments = {
38
+ tag: "button",
39
+ type: "button",
40
+ classes: "Polaris-Modal-CloseButton",
41
+ aria: {label: "Close"}
42
+ }
43
+ end
44
+
45
+ def system_arguments
46
+ @system_arguments.tap do |opts|
47
+ opts[:tag] = "div"
48
+ opts[:data] ||= {}
49
+ prepend_option(opts[:data], :controller, "polaris-modal")
50
+ opts[:data][:polaris_modal_open_value] = @open
51
+ opts[:data][:polaris_modal_hidden_class] = "Polaris--hidden"
52
+ opts[:data][:polaris_modal_backdrop_class] = "Polaris-Backdrop"
53
+ opts[:classes] = class_names(
54
+ @system_arguments[:classes],
55
+ "Polaris-Modal-Dialog__Container",
56
+ "Polaris--hidden"
57
+ )
58
+ end
59
+ end
60
+
61
+ def dialog_arguments
62
+ @dialog_arguments.tap do |opts|
63
+ opts[:tag] = "div"
64
+ opts[:role] = "dialog"
65
+ opts[:aria] ||= {}
66
+ opts[:aria][:modal] = "true"
67
+ opts[:tabindex] = "-1"
68
+ opts[:classes] = class_names(
69
+ @dialog_arguments[:classes],
70
+ "Polaris-Modal-Dialog"
71
+ )
72
+ end
73
+ end
74
+
75
+ def close_button_arguments
76
+ @close_button_arguments.deep_merge({
77
+ data: {action: "polaris-modal#close"}
78
+ })
79
+ end
80
+
81
+ def modal_classes
82
+ class_names(
83
+ "Polaris-Modal-Dialog__Modal",
84
+ "Polaris-Modal-Dialog--sizeLarge": @large,
85
+ "Polaris-Modal-Dialog--sizeSmall": @small,
86
+ "Polaris-Modal-Dialog--limitHeight": @limit_height
87
+ )
88
+ end
89
+
90
+ def header_classes
91
+ @title.present? ? "Polaris-Modal-Header" : "Polaris-Modal-Header--titleHidden"
92
+ end
93
+
94
+ def render_footer?
95
+ primary_action.present? || secondary_actions.any?
96
+ end
97
+ end
98
+ end