polaris_view_components 0.3.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/polaris_view_components/button_controller.js +48 -0
  4. data/app/assets/javascripts/polaris_view_components/index.js +11 -1
  5. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  6. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +24 -0
  7. data/app/assets/javascripts/polaris_view_components/popover_controller.js +45 -0
  8. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  9. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  10. data/app/assets/javascripts/polaris_view_components.js +1539 -5
  11. data/app/assets/stylesheets/polaris_view_components/custom.css +68 -0
  12. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  13. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  14. data/app/assets/stylesheets/polaris_view_components.css +93 -3
  15. data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
  16. data/app/components/polaris/action.rb +3 -3
  17. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  18. data/app/components/polaris/action_list/item_component.rb +41 -0
  19. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  20. data/app/components/polaris/action_list/section_component.rb +26 -0
  21. data/app/components/polaris/action_list_component.html.erb +13 -0
  22. data/app/components/polaris/action_list_component.rb +25 -0
  23. data/app/components/polaris/application_component.rb +19 -19
  24. data/app/components/polaris/avatar_component.rb +1 -1
  25. data/app/components/polaris/badge_component.rb +1 -1
  26. data/app/components/polaris/banner_component.rb +6 -6
  27. data/app/components/polaris/base_button.rb +1 -1
  28. data/app/components/polaris/button_component.html.erb +13 -0
  29. data/app/components/polaris/button_group_component.rb +5 -5
  30. data/app/components/polaris/callout_card_component.rb +5 -5
  31. data/app/components/polaris/caption_component.rb +2 -2
  32. data/app/components/polaris/card/header_component.rb +1 -3
  33. data/app/components/polaris/card/section_component.rb +6 -2
  34. data/app/components/polaris/card_component.html.erb +4 -0
  35. data/app/components/polaris/card_component.rb +5 -6
  36. data/app/components/polaris/character_count.rb +10 -10
  37. data/app/components/polaris/checkbox_component.rb +4 -4
  38. data/app/components/polaris/choice_component.rb +1 -1
  39. data/app/components/polaris/choice_list_component.rb +4 -4
  40. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  41. data/app/components/polaris/data_table/cell_component.rb +49 -0
  42. data/app/components/polaris/data_table/column_component.rb +19 -0
  43. data/app/components/polaris/data_table_component.html.erb +77 -0
  44. data/app/components/polaris/data_table_component.rb +42 -0
  45. data/app/components/polaris/description_list_component.rb +3 -3
  46. data/app/components/polaris/display_text_component.rb +2 -2
  47. data/app/components/polaris/dropzone/component.rb +36 -38
  48. data/app/components/polaris/empty_state_component.html.erb +16 -11
  49. data/app/components/polaris/empty_state_component.rb +4 -3
  50. data/app/components/polaris/exception_list/item_component.rb +2 -2
  51. data/app/components/polaris/exception_list_component.rb +1 -1
  52. data/app/components/polaris/filters_component.html.erb +13 -0
  53. data/app/components/polaris/filters_component.rb +38 -0
  54. data/app/components/polaris/footer_help_component.rb +1 -1
  55. data/app/components/polaris/form_layout/group_component.rb +3 -3
  56. data/app/components/polaris/form_layout/item_component.rb +1 -1
  57. data/app/components/polaris/form_layout_component.rb +3 -3
  58. data/app/components/polaris/heading_component.rb +1 -1
  59. data/app/components/polaris/headless_button.html.erb +13 -0
  60. data/app/components/polaris/headless_button.rb +17 -5
  61. data/app/components/polaris/icon_component.rb +2 -2
  62. data/app/components/polaris/index_table/cell_component.rb +22 -0
  63. data/app/components/polaris/index_table/column_component.rb +13 -0
  64. data/app/components/polaris/index_table_component.html.erb +28 -0
  65. data/app/components/polaris/index_table_component.rb +25 -0
  66. data/app/components/polaris/inline_error_component.html.erb +2 -2
  67. data/app/components/polaris/inline_error_component.rb +7 -1
  68. data/app/components/polaris/label_component.rb +2 -2
  69. data/app/components/polaris/labelled_component.rb +2 -2
  70. data/app/components/polaris/layout/annotated_section.rb +1 -1
  71. data/app/components/polaris/layout/section.rb +2 -0
  72. data/app/components/polaris/layout_component.rb +3 -3
  73. data/app/components/polaris/link_component.rb +5 -3
  74. data/app/components/polaris/list_component.rb +3 -3
  75. data/app/components/polaris/modal/section_component.rb +19 -0
  76. data/app/components/polaris/modal_component.html.erb +79 -0
  77. data/app/components/polaris/modal_component.rb +98 -0
  78. data/app/components/polaris/page_actions_component.rb +21 -6
  79. data/app/components/polaris/page_component.rb +4 -4
  80. data/app/components/polaris/pagination_component.rb +1 -5
  81. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  82. data/app/components/polaris/popover/pane_component.rb +20 -0
  83. data/app/components/polaris/popover/section_component.rb +19 -0
  84. data/app/components/polaris/popover_component.html.erb +38 -0
  85. data/app/components/polaris/popover_component.rb +90 -0
  86. data/app/components/polaris/progress_bar_component.rb +5 -5
  87. data/app/components/polaris/radio_button_component.rb +3 -3
  88. data/app/components/polaris/resource_item_component.html.erb +16 -6
  89. data/app/components/polaris/resource_item_component.rb +42 -9
  90. data/app/components/polaris/resource_list_component.html.erb +10 -0
  91. data/app/components/polaris/resource_list_component.rb +4 -10
  92. data/app/components/polaris/scrollable_component.html.erb +5 -0
  93. data/app/components/polaris/scrollable_component.rb +48 -0
  94. data/app/components/polaris/select_component.rb +10 -5
  95. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  96. data/app/components/polaris/setting_toggle_component.rb +24 -0
  97. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  98. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  99. data/app/components/polaris/spacer_component.rb +50 -0
  100. data/app/components/polaris/spinner_component.rb +2 -2
  101. data/app/components/polaris/stack_component.rb +5 -5
  102. data/app/components/polaris/subheading_component.rb +1 -1
  103. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  104. data/app/components/polaris/tabs/tab_component.rb +34 -0
  105. data/app/components/polaris/tabs_component.html.erb +7 -0
  106. data/app/components/polaris/tabs_component.rb +37 -0
  107. data/app/components/polaris/tag_component.rb +2 -2
  108. data/app/components/polaris/text_container_component.rb +2 -2
  109. data/app/components/polaris/text_field_component.rb +8 -8
  110. data/app/components/polaris/text_style_component.rb +11 -2
  111. data/app/components/polaris/thumbnail_component.rb +2 -2
  112. data/app/helpers/polaris/form_builder.rb +30 -3
  113. data/app/helpers/polaris/url_helper.rb +3 -3
  114. data/app/helpers/polaris/view_helper.rb +26 -6
  115. data/app/validators/type_validator.rb +2 -2
  116. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  117. data/lib/polaris/view_components/engine.rb +6 -1
  118. data/lib/polaris/view_components/version.rb +1 -1
  119. data/lib/polaris_view_components.rb +1 -1
  120. metadata +45 -6
  121. data/app/components/polaris/choice_list/component.html.erb +0 -34
  122. data/app/components/polaris/choice_list/component.rb +0 -65
  123. data/app/helpers/polaris/action_helper.rb +0 -14
@@ -7,6 +7,8 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
7
7
  flush: false,
8
8
  full_width: false,
9
9
  unstyled: false,
10
+ border_top: false,
11
+ border_bottom: false,
10
12
  actions: [],
11
13
  **system_arguments
12
14
  )
@@ -14,10 +16,12 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
14
16
  @system_arguments[:tag] = :div
15
17
  @system_arguments[:classes] = class_names(
16
18
  @system_arguments[:classes],
19
+ "Polaris-Card__Section": !unstyled,
17
20
  "Polaris-Card__Section--flush": flush,
18
21
  "Polaris-Card__Section--subdued": subdued,
19
22
  "Polaris-Card__Section--fullWidth": full_width,
20
- "Polaris-Card__Section": !unstyled,
23
+ "Polaris-Card__Section--borderTop": border_top,
24
+ "Polaris-Card__Section--borderBottom": border_bottom
21
25
  )
22
26
 
23
27
  @title = title
@@ -30,7 +34,7 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
30
34
  @system_arguments[:tag] = :div
31
35
  @system_arguments[:classes] = class_names(
32
36
  @system_arguments[:classes],
33
- "Polaris-Card__Subsection",
37
+ "Polaris-Card__Subsection"
34
38
  )
35
39
  end
36
40
 
@@ -1,4 +1,8 @@
1
1
  <%= render Polaris::BaseComponent.new(**@system_arguments) do %>
2
+ <% if tabs.present? %>
3
+ <%= tabs %>
4
+ <% end %>
5
+
2
6
  <% if header.present? %>
3
7
  <%= header %>
4
8
  <% end %>
@@ -2,18 +2,17 @@
2
2
 
3
3
  module Polaris
4
4
  class CardComponent < Polaris::NewComponent
5
- include Polaris::ActionHelper
6
-
7
5
  FOOTER_ACTION_ALIGNMENT_DEFAULT = :right
8
6
  FOOTER_ACTION_ALIGNMENT_MAPPINGS = {
9
7
  FOOTER_ACTION_ALIGNMENT_DEFAULT => "",
10
- :left => "Polaris-Card__LeftJustified",
8
+ :left => "Polaris-Card__LeftJustified"
11
9
  }
12
10
  FOOTER_ACTION_ALIGNMENT_OPTIONS = FOOTER_ACTION_ALIGNMENT_MAPPINGS.keys
13
11
 
12
+ renders_one :tabs, Polaris::TabsComponent
14
13
  renders_one :header, Polaris::Card::HeaderComponent
15
14
  renders_many :sections, Polaris::Card::SectionComponent
16
- renders_one :primary_footer_action, -> (primary: true, **system_arguments) do
15
+ renders_one :primary_footer_action, ->(primary: true, **system_arguments) do
17
16
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
18
17
  end
19
18
  renders_many :secondary_footer_actions, Polaris::ButtonComponent
@@ -36,7 +35,7 @@ module Polaris
36
35
  @system_arguments[:classes] = class_names(
37
36
  @system_arguments[:classes],
38
37
  "Polaris-Card",
39
- "Polaris-Card--subdued": subdued,
38
+ "Polaris-Card--subdued": subdued
40
39
  )
41
40
  end
42
41
 
@@ -47,7 +46,7 @@ module Polaris
47
46
  def footer_classes
48
47
  class_names(
49
48
  "Polaris-Card__Footer",
50
- FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)],
49
+ FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)]
51
50
  )
52
51
  end
53
52
  end
@@ -16,7 +16,7 @@ module Polaris
16
16
  def text
17
17
  return "#{count}/#{@max_length}" if max_length?
18
18
 
19
- "#{count}"
19
+ count.to_s
20
20
  end
21
21
 
22
22
  def label_template
@@ -35,16 +35,16 @@ module Polaris
35
35
 
36
36
  private
37
37
 
38
- def max_length?
39
- @max_length.present?
40
- end
38
+ def max_length?
39
+ @max_length.present?
40
+ end
41
41
 
42
- def normalized_value
43
- @text_field.value.to_s || ''
44
- end
42
+ def normalized_value
43
+ @text_field.value.to_s || ""
44
+ end
45
45
 
46
- def count
47
- normalized_value.length
48
- end
46
+ def count
47
+ normalized_value.length
48
+ end
49
49
  end
50
50
  end
@@ -6,7 +6,7 @@ module Polaris
6
6
 
7
7
  attr_reader :checked
8
8
 
9
- validates :checked, inclusion: { in: [true, false, :indeterminate] }
9
+ validates :checked, inclusion: {in: [true, false, :indeterminate]}
10
10
 
11
11
  def initialize(
12
12
  form: nil,
@@ -37,7 +37,7 @@ module Polaris
37
37
  @system_arguments[:classes],
38
38
  "Polaris-Checkbox",
39
39
  "Polaris-Checkbox--labelHidden": label_hidden,
40
- "Polaris-Checkbox--error": error.present?,
40
+ "Polaris-Checkbox--error": error.present?
41
41
  )
42
42
 
43
43
  @wrapper_arguments = {
@@ -45,7 +45,7 @@ module Polaris
45
45
  label_hidden: label_hidden,
46
46
  disabled: disabled,
47
47
  help_text: help_text,
48
- error: error,
48
+ error: error
49
49
  }.merge(wrapper_arguments)
50
50
 
51
51
  @input_options = input_options
@@ -59,7 +59,7 @@ module Polaris
59
59
  @input_options[:class] = class_names(
60
60
  @input_options[:classes],
61
61
  "Polaris-Checkbox__Input",
62
- "Polaris-Checkbox__Input--indeterminate": indeterminate?,
62
+ "Polaris-Checkbox__Input--indeterminate": indeterminate?
63
63
  )
64
64
  end
65
65
 
@@ -22,7 +22,7 @@ module Polaris
22
22
  @system_arguments[:classes],
23
23
  "Polaris-Choice",
24
24
  "Polaris-Choice--labelHidden": label_hidden,
25
- "Polaris-Choice--disabled": disabled,
25
+ "Polaris-Choice--disabled": disabled
26
26
  )
27
27
  end
28
28
  end
@@ -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
 
@@ -0,0 +1,18 @@
1
+ <% if @sort_url %>
2
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
3
+ <%= link_to @sort_url, class: "Polaris-DataTable__Heading" do %>
4
+ <span class="Polaris-DataTable__Icon">
5
+ <% if @sorted == :asc %>
6
+ <%= polaris_icon(name: "CaretUpMinor") %>
7
+ <% else %>
8
+ <%= polaris_icon(name: "CaretDownMinor") %>
9
+ <% end %>
10
+ </span>
11
+ <%= content %>
12
+ <% end %>
13
+ <% end %>
14
+ <% else %>
15
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
16
+ <%= content %>
17
+ <% end %>
18
+ <% end %>
@@ -0,0 +1,49 @@
1
+ class Polaris::DataTable::CellComponent < Polaris::NewComponent
2
+ ALIGNMENT_DEFAULT = :top
3
+ ALIGNMENT_MAPPINGS = {
4
+ top: "Polaris-DataTable__Cell--verticalAlignTop",
5
+ bottom: "Polaris-DataTable__Cell--verticalAlignBottom",
6
+ middle: "Polaris-DataTable__Cell--verticalAlignMiddle",
7
+ baseline: "Polaris-DataTable__Cell--verticalAlignBaseline"
8
+ }
9
+ ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
10
+
11
+ def initialize(
12
+ vertical_alignment:,
13
+ first: false,
14
+ numeric: false,
15
+ header: false,
16
+ total: false,
17
+ total_footer: false,
18
+ sorted: false,
19
+ sort_url: nil,
20
+ **system_arguments
21
+ )
22
+ @vertical_alignment = vertical_alignment
23
+ @numeric = numeric
24
+ @first = first
25
+ @header = header
26
+ @total = total
27
+ @total_footer = total_footer
28
+ @sorted = sorted
29
+ @sort_url = sort_url
30
+ @system_arguments = system_arguments
31
+ end
32
+
33
+ def system_arguments
34
+ {tag: "td"}.deep_merge(@system_arguments).tap do |args|
35
+ args[:classes] = class_names(
36
+ args[:classes],
37
+ "Polaris-DataTable__Cell",
38
+ ALIGNMENT_MAPPINGS[@vertical_alignment],
39
+ "Polaris-DataTable__Cell--firstColumn": @first,
40
+ "Polaris-DataTable__Cell--numeric": @numeric,
41
+ "Polaris-DataTable__Cell--header": @header,
42
+ "Polaris-DataTable__Cell--total": @total,
43
+ "Polaris-DataTable__Cell--sortable": @sort_url.present?,
44
+ "Polaris-DataTable__Cell--sorted": @sorted,
45
+ "Polaris-DataTable--cellTotalFooter": @total_footer
46
+ )
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ class Polaris::DataTable::ColumnComponent < Polaris::NewComponent
2
+ SORT_DEFAULT = false
3
+ SORT_OPTIONS = [false, :asc, :desc]
4
+
5
+ attr_reader :title, :numeric, :total, :sorted, :sort_url
6
+
7
+ def initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block)
8
+ @title = title
9
+ @numeric = numeric
10
+ @total = total
11
+ @sorted = fetch_or_fallback(SORT_OPTIONS, sorted, SORT_DEFAULT)
12
+ @sort_url = sort_url
13
+ @block = block
14
+ end
15
+
16
+ def call(row)
17
+ @block.call(row)
18
+ end
19
+ end
@@ -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: { in: ALLOWED_TYPES, message: "%{value} is not a valid type" }
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': 'input',
80
+ 'polaris--dropzone-target': "input"
83
81
  }
84
82
  }
85
83
  end
86
84
 
87
85
  private
88
86
 
89
- def additional_aria
90
- {
91
- disabled: @disabled.to_s,
92
- }
93
- end
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
- def drop_actions
108
- 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
109
104
 
110
- [
111
- "drop#{event_scope}->polaris--dropzone#onDrop",
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
- def classes
119
- 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
115
+
116
+ def classes
117
+ classes = %w[Polaris-DropZone Polaris-DropZone--sizeExtraLarge]
120
118
 
121
- classes << "Polaris-DropZone--isDisabled" if @disabled
122
- classes << "Polaris-DropZone--isDisabled" if @disabled
123
- classes << "Polaris-DropZone--hasError" if @error.present?
124
- classes << "Polaris-DropZone--hasOutline" if @outline
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
- classes
127
- end
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
- <div class="Polaris-EmptyState__Actions">
20
- <%= polaris_stack(spacing: :tight, distribution: :center, alignment: :center) do |stack| %>
21
- <% if primary_action.present? %>
22
- <% stack.item do %>
23
- <%= primary_action %>
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
- <% end %>
26
- <% if secondary_action.present? %>
27
- <% stack.item do %>
28
- <%= secondary_action %>
27
+ <% if secondary_action.present? %>
28
+ <% stack.item do %>
29
+ <%= secondary_action %>
30
+ <% end %>
29
31
  <% end %>
30
32
  <% end %>
31
- <% end %>
32
- </div>
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: "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
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
@@ -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
 
@@ -0,0 +1,13 @@
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
+ </div>
12
+ </div>
13
+ <% end %>