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
@@ -8,21 +8,37 @@ module Polaris
8
8
  ALIGNMENT_DEFAULT = :default
9
9
  ALIGNMENT_MAPPINGS = {
10
10
  ALIGNMENT_DEFAULT => "",
11
- center: "Polaris-ResourceItem--alignmentCenter",
11
+ :center => "Polaris-ResourceItem--alignmentCenter"
12
12
  }
13
13
  ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
14
14
 
15
+ renders_one :checkbox, ->(**system_arguments) do
16
+ Polaris::CheckboxComponent.new(
17
+ label_hidden: true,
18
+ **system_arguments
19
+ )
20
+ end
21
+ renders_one :radio_button, ->(**system_arguments) do
22
+ Polaris::RadioButtonComponent.new(
23
+ label_hidden: true,
24
+ **system_arguments
25
+ )
26
+ end
15
27
  renders_one :media
16
28
 
17
29
  def initialize(
18
30
  url: nil,
19
31
  vertical_alignment: ALIGNMENT_DEFAULT,
32
+ selectable: false,
33
+ offset: false,
20
34
  wrapper_arguments: {},
21
35
  container_arguments: {},
22
36
  **system_arguments
23
37
  )
24
38
  @url = url
25
39
  @vertical_alignment = vertical_alignment
40
+ @selectable = selectable
41
+ @offset = offset
26
42
  @wrapper_arguments = wrapper_arguments
27
43
  @container_arguments = container_arguments
28
44
  @system_arguments = system_arguments
@@ -31,11 +47,11 @@ module Polaris
31
47
  def wrapper_arguments
32
48
  {
33
49
  tag: "li",
34
- data: {},
50
+ data: {}
35
51
  }.deep_merge(@wrapper_arguments).tap do |args|
36
52
  args[:classes] = class_names(
37
53
  args[:classes],
38
- "Polaris-ResourceItem__ListItem",
54
+ "Polaris-ResourceItem__ListItem"
39
55
  )
40
56
  prepend_option(args[:data], :controller, "polaris-resource-item")
41
57
  end
@@ -43,12 +59,12 @@ module Polaris
43
59
 
44
60
  def container_arguments
45
61
  {
46
- tag: "div",
62
+ tag: "div"
47
63
  }.deep_merge(@container_arguments).tap do |args|
48
64
  args[:classes] = class_names(
49
65
  args[:classes],
50
66
  "Polaris-ResourceItem__Container",
51
- ALIGNMENT_MAPPINGS[fetch_or_fallback(ALIGNMENT_OPTIONS, @vertical_alignment, ALIGNMENT_DEFAULT)],
67
+ ALIGNMENT_MAPPINGS[fetch_or_fallback(ALIGNMENT_OPTIONS, @vertical_alignment, ALIGNMENT_DEFAULT)]
52
68
  )
53
69
  end
54
70
  end
@@ -56,20 +72,37 @@ module Polaris
56
72
  def system_arguments
57
73
  {
58
74
  tag: "div",
59
- data: {},
75
+ data: {}
60
76
  }.deep_merge(@system_arguments).tap do |args|
61
77
  args[:classes] = class_names(
62
78
  args[:classes],
63
79
  "Polaris-ResourceItem",
80
+ "Polaris-ResourceItem--selectable": @selectable
64
81
  )
65
82
  prepend_option(args, :style, "cursor: #{cursor};")
66
83
  prepend_option(args[:data], :action, "click->polaris-resource-item#open")
67
84
  end
68
85
  end
69
86
 
87
+ def owned?
88
+ checkbox.present? || radio_button.present? || media.present?
89
+ end
90
+
91
+ def owned_arguments
92
+ {
93
+ tag: "div",
94
+ classes: class_names(
95
+ "Polaris-ResourceItem__Owned",
96
+ "Polaris-ResourceItem__OwnedNoMedia": media.blank?,
97
+ "Polaris-ResourceItem__Owned--offset": @offset
98
+ )
99
+ }
100
+ end
101
+
70
102
  private
71
- def cursor
72
- @url.present? ? "pointer" : "default"
73
- end
103
+
104
+ def cursor
105
+ @url.present? ? "pointer" : "default"
106
+ end
74
107
  end
75
108
  end
@@ -12,14 +12,14 @@ module Polaris
12
12
  @wrapper_arguments[:tag] = "div"
13
13
  @wrapper_arguments[:classes] = class_names(
14
14
  @wrapper_arguments[:classes],
15
- "Polaris-ResourceList__ResourceListWrapper",
15
+ "Polaris-ResourceList__ResourceListWrapper"
16
16
  )
17
17
 
18
18
  @system_arguments = system_arguments
19
19
  @system_arguments[:tag] = "ul"
20
20
  @system_arguments[:classes] = class_names(
21
21
  @system_arguments[:classes],
22
- "Polaris-ResourceList",
22
+ "Polaris-ResourceList"
23
23
  )
24
24
  end
25
25
  end
@@ -0,0 +1,5 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <span data-polaris-scrollable-target="topEdge"></span>
3
+ <%= content %>
4
+ <span data-polaris-scrollable-target="bottomEdge"></span>
5
+ <% end %>
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class ScrollableComponent < Polaris::NewComponent
5
+ def initialize(
6
+ height: nil,
7
+ width: nil,
8
+ vertical: true,
9
+ horizontal: false,
10
+ shadow: false,
11
+ focusable: false,
12
+ **system_arguments
13
+ )
14
+ @height = height
15
+ @width = width
16
+ @vertical = vertical
17
+ @horizontal = horizontal
18
+ @shadow = shadow
19
+ @focusable = focusable
20
+ @system_arguments = system_arguments
21
+ end
22
+
23
+ def system_arguments
24
+ {
25
+ tag: "div",
26
+ data: {
27
+ polaris_scrollable_shadow_value: @shadow,
28
+ polaris_scrollable_top_shadow_class: "Polaris-Scrollable--hasTopShadow",
29
+ polaris_scrollable_bottom_shadow_class: "Polaris-Scrollable--hasBottomShadow"
30
+ }
31
+ }.deep_merge(@system_arguments).tap do |opts|
32
+ prepend_option(opts[:data], :controller, "polaris-scrollable")
33
+ opts[:tabindex] = "0" if @focusable
34
+ opts[:classes] = class_names(
35
+ @system_arguments[:classes],
36
+ "Polaris-Scrollable",
37
+ "Polaris-Scrollable--horizontal" => @horizontal,
38
+ "Polaris-Scrollable--vertical" => @vertical
39
+ )
40
+ opts[:style] = class_names(
41
+ @system_arguments[:style],
42
+ "height: #{@height};" => @height.present?,
43
+ "width: #{@width};" => @width.present?
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
@@ -3,10 +3,10 @@
3
3
  module Polaris
4
4
  class SelectComponent < Polaris::NewComponent
5
5
  def initialize(
6
+ options:,
6
7
  form: nil,
7
8
  attribute: nil,
8
9
  name: nil,
9
- options:,
10
10
  selected: nil,
11
11
  disabled_options: nil,
12
12
  label: nil,
@@ -42,7 +42,7 @@ module Polaris
42
42
  @system_arguments[:classes],
43
43
  "Polaris-Select",
44
44
  "Polaris-Select--disabled": disabled,
45
- "Polaris-Select--error": error,
45
+ "Polaris-Select--error": error
46
46
  )
47
47
 
48
48
  @wrapper_arguments = {
@@ -54,7 +54,7 @@ module Polaris
54
54
  label_action: label_action,
55
55
  required: required,
56
56
  help_text: help_text,
57
- error: error,
57
+ error: error
58
58
  }.merge(wrapper_arguments)
59
59
 
60
60
  @select_options = select_options
@@ -0,0 +1,10 @@
1
+ <%= polaris_card do %>
2
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
3
+ <div class="Polaris-SettingAction__Setting">
4
+ <%= content %>
5
+ </div>
6
+ <div class="Polaris-SettingAction__Action">
7
+ <%= action %>
8
+ </div>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class SettingToggleComponent < Polaris::NewComponent
5
+ renders_one :action, ->(**system_arguments) do
6
+ Polaris::ButtonComponent.new(primary: !@enabled, **system_arguments)
7
+ end
8
+
9
+ def initialize(enabled: false, **system_arguments)
10
+ @enabled = enabled
11
+ @system_arguments = system_arguments
12
+ end
13
+
14
+ def system_arguments
15
+ @system_arguments.tap do |opts|
16
+ opts[:tag] = "div"
17
+ opts[:classes] = class_names(
18
+ @system_arguments[:classes],
19
+ "Polaris-SettingAction"
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  class ShopifyNavigationComponent < Polaris::NewComponent
5
- renders_many :links, -> (**system_arguments) do
5
+ renders_many :links, ->(**system_arguments) do
6
6
  ShopifyNavigationLinkComponent.new(auto_detect_active: @auto_detect_active, **system_arguments)
7
7
  end
8
8
 
@@ -13,7 +13,7 @@ module Polaris
13
13
  @system_arguments[:tag] = "div"
14
14
  @system_arguments[:classes] = class_names(
15
15
  @system_arguments[:classes],
16
- "shp-Navigation",
16
+ "shp-Navigation"
17
17
  )
18
18
  end
19
19
 
@@ -42,13 +42,13 @@ module Polaris
42
42
  tag: "a",
43
43
  href: @url,
44
44
  role: "tab",
45
- data: { polaris_unstyled: true },
46
- aria: {},
45
+ data: {polaris_unstyled: true},
46
+ aria: {}
47
47
  }.deep_merge(@system_arguments).tap do |args|
48
48
  args[:aria][:selected] = @active || detect_active(@url)
49
49
  args[:classes] = class_names(
50
50
  args[:classes],
51
- "shp-Navigation_Link",
51
+ "shp-Navigation_Link"
52
52
  )
53
53
  end
54
54
  end
@@ -56,7 +56,7 @@ module Polaris
56
56
  def detect_active(url)
57
57
  return unless @auto_detect_active
58
58
 
59
- request.path.include?(url.split('?').first)
59
+ request.path.include?(url.split("?").first)
60
60
  end
61
61
  end
62
62
  end
@@ -8,7 +8,7 @@ module Polaris
8
8
  @system_arguments[:tag] = "div"
9
9
  @system_arguments[:classes] = class_names(
10
10
  @system_arguments[:classes],
11
- "Polaris-SkeletonBodyText__SkeletonBodyTextContainer",
11
+ "Polaris-SkeletonBodyText__SkeletonBodyTextContainer"
12
12
  )
13
13
  end
14
14
  end
@@ -10,7 +10,7 @@ module Polaris
10
10
  :base_tight => "Polaris-Spacer--verticalSpacingBaseTight",
11
11
  :base => "Polaris-Spacer--verticalSpacingBase",
12
12
  :loose => "Polaris-Spacer--verticalSpacingLoose",
13
- :extra_loose => "Polaris-Spacer--verticalSpacingExtraLoose",
13
+ :extra_loose => "Polaris-Spacer--verticalSpacingExtraLoose"
14
14
  }
15
15
  VERTICAL_SPACING_OPTIONS = VERTICAL_SPACING_MAPPINGS.keys
16
16
 
@@ -22,7 +22,7 @@ module Polaris
22
22
  :base_tight => "Polaris-Spacer--horizontalSpacingBaseTight",
23
23
  :base => "Polaris-Spacer--horizontalSpacingBase",
24
24
  :loose => "Polaris-Spacer--horizontalSpacingLoose",
25
- :extra_loose => "Polaris-Spacer--horizontalSpacingExtraLoose",
25
+ :extra_loose => "Polaris-Spacer--horizontalSpacingExtraLoose"
26
26
  }
27
27
  HORIZONTAL_SPACING_OPTIONS = HORIZONTAL_SPACING_MAPPINGS.keys
28
28
 
@@ -37,7 +37,7 @@ module Polaris
37
37
  @system_arguments[:classes],
38
38
  "Polaris-Spacer",
39
39
  VERTICAL_SPACING_MAPPINGS[fetch_or_fallback(VERTICAL_SPACING_OPTIONS, vertical, VERTICAL_SPACING_DEFAULT)],
40
- HORIZONTAL_SPACING_MAPPINGS[fetch_or_fallback(HORIZONTAL_SPACING_OPTIONS, horizontal, HORIZONTAL_SPACING_DEFAULT)],
40
+ HORIZONTAL_SPACING_MAPPINGS[fetch_or_fallback(HORIZONTAL_SPACING_OPTIONS, horizontal, HORIZONTAL_SPACING_DEFAULT)]
41
41
  )
42
42
  end
43
43
 
@@ -5,7 +5,7 @@ module Polaris
5
5
  SIZE_DEFAULT = :large
6
6
  SIZE_MAPPINGS = {
7
7
  small: "Polaris-Spinner--sizeSmall",
8
- large: "Polaris-Spinner--sizeLarge",
8
+ large: "Polaris-Spinner--sizeLarge"
9
9
  }
10
10
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
11
11
 
@@ -18,7 +18,7 @@ module Polaris
18
18
  @system_arguments[:classes] = class_names(
19
19
  @system_arguments[:classes],
20
20
  "Polaris-Spinner",
21
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
21
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
22
22
  )
23
23
  end
24
24
  end
@@ -9,7 +9,7 @@ module Polaris
9
9
  :trailing => "Polaris-Stack--alignmentTrailing",
10
10
  :center => "Polaris-Stack--alignmentCenter",
11
11
  :fill => "Polaris-Stack--alignmentFill",
12
- :baseline => "Polaris-Stack--alignmentBaseline",
12
+ :baseline => "Polaris-Stack--alignmentBaseline"
13
13
  }
14
14
  ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
15
15
 
@@ -21,7 +21,7 @@ module Polaris
21
21
  :trailing => "Polaris-Stack--distributionTrailing",
22
22
  :center => "Polaris-Stack--distributionCenter",
23
23
  :fill => "Polaris-Stack--distributionFill",
24
- :fill_evenly => "Polaris-Stack--distributionFillEvenly",
24
+ :fill_evenly => "Polaris-Stack--distributionFillEvenly"
25
25
  }
26
26
  DISTRIBUTION_OPTIONS = DISTRIBUTION_MAPPINGS.keys
27
27
 
@@ -33,7 +33,7 @@ module Polaris
33
33
  :base_tight => "Polaris-Stack--spacingBaseTight",
34
34
  :loose => "Polaris-Stack--spacingLoose",
35
35
  :extra_loose => "Polaris-Stack--spacingExtraLoose",
36
- :none => "Polaris-Stack--spacingNone",
36
+ :none => "Polaris-Stack--spacingNone"
37
37
  }
38
38
  SPACING_OPTIONS = SPACING_MAPPINGS.keys
39
39
 
@@ -56,7 +56,7 @@ module Polaris
56
56
  DISTRIBUTION_MAPPINGS[fetch_or_fallback(DISTRIBUTION_OPTIONS, distribution, DISTRIBUTION_DEFAULT)],
57
57
  SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)],
58
58
  "Polaris-Stack--vertical": vertical,
59
- "Polaris-Stack--noWrap": !wrap,
59
+ "Polaris-Stack--noWrap": !wrap
60
60
  )
61
61
  end
62
62
 
@@ -67,7 +67,7 @@ module Polaris
67
67
  @system_arguments[:classes] = class_names(
68
68
  @system_arguments[:classes],
69
69
  "Polaris-Stack__Item",
70
- "Polaris-Stack__Item--fill": fill,
70
+ "Polaris-Stack__Item--fill": fill
71
71
  )
72
72
  end
73
73
 
@@ -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-Subheading'
16
+ "Polaris-Subheading"
17
17
  )
18
18
  end
19
19
 
@@ -0,0 +1,10 @@
1
+ <li class="Polaris-Tabs__TabContainer" role="presentation">
2
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
3
+ <span class="Polaris-Tabs__Title">
4
+ <%= @title %>
5
+ <% if badge.present? %>
6
+ <%= badge %>
7
+ <% end %>
8
+ </span>
9
+ <% end %>
10
+ </li>
@@ -0,0 +1,34 @@
1
+ class Polaris::Tabs::TabComponent < Polaris::NewComponent
2
+ renders_one :badge, Polaris::BadgeComponent
3
+
4
+ def initialize(
5
+ title:,
6
+ url: nil,
7
+ active: false,
8
+ **system_arguments
9
+ )
10
+ @title = title
11
+ @url = url
12
+ @active = active
13
+ @system_arguments = system_arguments
14
+ end
15
+
16
+ def system_arguments
17
+ @system_arguments.tap do |opts|
18
+ opts[:rol] = "tab"
19
+ opts[:tabindex] = "0"
20
+ if @url.present?
21
+ opts[:tag] = "a"
22
+ opts[:href] = @url
23
+ else
24
+ opts[:tag] = "button"
25
+ opts[:type] = "button"
26
+ end
27
+ opts[:classes] = class_names(
28
+ @system_arguments[:classes],
29
+ "Polaris-Tabs__Tab",
30
+ "Polaris-Tabs__Tab--selected": @active
31
+ )
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ <%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %>
2
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
3
+ <% tabs.each do |tab| %>
4
+ <%= tab %>
5
+ <% end %>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,37 @@
1
+ module Polaris
2
+ class TabsComponent < Polaris::NewComponent
3
+ renders_many :tabs, Polaris::Tabs::TabComponent
4
+
5
+ def initialize(fitted: false, wrapper_arguments: {}, **system_arguments)
6
+ @fitted = fitted
7
+ @wrapper_arguments = wrapper_arguments
8
+ @system_arguments = system_arguments
9
+ end
10
+
11
+ def wrapper_arguments
12
+ @wrapper_arguments.tap do |opts|
13
+ opts[:tag] = "div"
14
+ opts[:classes] = class_names(
15
+ @wrapper_arguments[:classes],
16
+ "Polaris-Tabs__Wrapper"
17
+ )
18
+ end
19
+ end
20
+
21
+ def system_arguments
22
+ @system_arguments.tap do |opts|
23
+ opts[:tag] = "ul"
24
+ opts[:role] = "tablist"
25
+ opts[:classes] = class_names(
26
+ @system_arguments[:classes],
27
+ "Polaris-Tabs",
28
+ "Polaris-Tabs--fitted": @fitted
29
+ )
30
+ end
31
+ end
32
+
33
+ def renders?
34
+ tabs.present?
35
+ end
36
+ end
37
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Polaris
4
4
  class TagComponent < Polaris::NewComponent
5
- renders_one :remove_button, -> (**system_arguments) do
5
+ renders_one :remove_button, ->(**system_arguments) do
6
6
  render Polaris::BaseButton.new(
7
7
  classes: "Polaris-Tag__Button",
8
8
  disabled: @disabled,
@@ -6,7 +6,7 @@ module Polaris
6
6
  SPACING_MAPPINGS = {
7
7
  SPACING_DEFAULT => "",
8
8
  :tight => "Polaris-TextContainer--spacingTight",
9
- :loose => "Polaris-TextContainer--spacingLoose",
9
+ :loose => "Polaris-TextContainer--spacingLoose"
10
10
  }
11
11
  SPACING_OPTIONS = SPACING_MAPPINGS.keys
12
12
 
@@ -19,7 +19,7 @@ module Polaris
19
19
  @system_arguments[:classes] = class_names(
20
20
  @system_arguments[:classes],
21
21
  "Polaris-TextContainer",
22
- SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)],
22
+ SPACING_MAPPINGS[fetch_or_fallback(SPACING_OPTIONS, spacing, SPACING_DEFAULT)]
23
23
  )
24
24
  end
25
25
 
@@ -13,7 +13,7 @@ module Polaris
13
13
  ALIGN_DEFAULT => "",
14
14
  :left => "Polaris-TextField__Input--alignLeft",
15
15
  :center => "Polaris-TextField__Input--alignCenter",
16
- :right => "Polaris-TextField__Input--alignRight",
16
+ :right => "Polaris-TextField__Input--alignRight"
17
17
  }
18
18
  ALIGN_OPTIONS = ALIGN_MAPPINGS.keys
19
19
 
@@ -96,7 +96,7 @@ module Polaris
96
96
  label_action: @label_action,
97
97
  required: @required,
98
98
  help_text: @help_text,
99
- error: @error,
99
+ error: @error
100
100
  }.deep_merge(@wrapper_arguments)
101
101
  end
102
102
 
@@ -105,8 +105,8 @@ module Polaris
105
105
  tag: "div",
106
106
  data: {
107
107
  polaris_text_field_has_value_class: "Polaris-TextField--hasValue",
108
- polaris_text_field_clear_button_hidden_class: "Polaris-TextField__ClearButton--hidden",
109
- },
108
+ polaris_text_field_clear_button_hidden_class: "Polaris-TextField__ClearButton--hidden"
109
+ }
110
110
  }.deep_merge(@system_arguments).tap do |opts|
111
111
  opts[:classes] = class_names(
112
112
  opts[:classes],
@@ -114,7 +114,7 @@ module Polaris
114
114
  "Polaris-TextField--disabled": @disabled,
115
115
  "Polaris-TextField--error": @error,
116
116
  "Polaris-TextField--hasValue": @value.present?,
117
- "Polaris-TextField--multiline": @multiline,
117
+ "Polaris-TextField--multiline": @multiline
118
118
  )
119
119
  prepend_option(opts[:data], :controller, "polaris-text-field")
120
120
  if @show_character_count
@@ -132,13 +132,13 @@ module Polaris
132
132
  placeholder: @placeholder,
133
133
  maxlength: @maxlength,
134
134
  minlength: @minlength,
135
- data: { polaris_text_field_target: "input" },
135
+ data: {polaris_text_field_target: "input"}
136
136
  }
137
137
  if @type == :number
138
138
  default_options.merge!({
139
139
  step: @step,
140
140
  min: @min,
141
- max: @max,
141
+ max: @max
142
142
  })
143
143
  end
144
144
  if @multiline
@@ -151,7 +151,7 @@ module Polaris
151
151
  "Polaris-TextField__Input",
152
152
  @align_class,
153
153
  "Polaris-TextField--monospaced": @monospaced,
154
- "Polaris-TextField__Input--suffixed": @suffix.present?,
154
+ "Polaris-TextField__Input--suffixed": @suffix.present?
155
155
  )
156
156
  prepend_option(opts[:data], :action, "polaris-text-field#syncValue")
157
157
  end
@@ -9,14 +9,14 @@ module Polaris
9
9
  :negative => "Polaris-TextStyle--variationNegative",
10
10
  :strong => "Polaris-TextStyle--variationStrong",
11
11
  :subdued => "Polaris-TextStyle--variationSubdued",
12
- :code => "Polaris-TextStyle--variationCode",
12
+ :code => "Polaris-TextStyle--variationCode"
13
13
  }
14
14
  VARIATION_OPTIONS = VARIATION_MAPPINGS.keys
15
15
 
16
16
  SIZE_DEFAULT = :default
17
17
  SIZE_MAPPINGS = {
18
18
  SIZE_DEFAULT => "",
19
- small: "Polaris-TextStyle--sizeSmall",
19
+ :small => "Polaris-TextStyle--sizeSmall"
20
20
  }
21
21
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
22
22
 
@@ -26,11 +26,11 @@ module Polaris
26
26
  **system_arguments
27
27
  )
28
28
  @system_arguments = system_arguments
29
- @system_arguments[:tag] = 'span'
29
+ @system_arguments[:tag] = "span"
30
30
  @system_arguments[:classes] = class_names(
31
31
  @system_arguments[:classes],
32
32
  VARIATION_MAPPINGS[fetch_or_fallback(VARIATION_OPTIONS, variation, VARIATION_DEFAULT)],
33
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
33
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
34
34
  )
35
35
  end
36
36
 
@@ -6,7 +6,7 @@ module Polaris
6
6
  SIZE_MAPPINGS = {
7
7
  small: "Polaris-Thumbnail--sizeSmall",
8
8
  medium: "Polaris-Thumbnail--sizeMedium",
9
- large: "Polaris-Thumbnail--sizeLarge",
9
+ large: "Polaris-Thumbnail--sizeLarge"
10
10
  }
11
11
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
12
12
 
@@ -26,7 +26,7 @@ module Polaris
26
26
  @system_arguments[:classes] = class_names(
27
27
  @system_arguments[:classes],
28
28
  "Polaris-Thumbnail",
29
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
29
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
30
30
  )
31
31
  end
32
32
 
@@ -1,5 +1,7 @@
1
1
  module Polaris
2
2
  class FormBuilder < ActionView::Helpers::FormBuilder
3
+ include ActionView::Helpers::OutputSafetyHelper
4
+
3
5
  attr_reader :template
4
6
 
5
7
  delegate :render, :pluralize, to: :template
@@ -12,7 +14,7 @@ module Polaris
12
14
 
13
15
  render Polaris::BannerComponent.new(
14
16
  title: "There's #{pluralize(object.errors.count, "error")} with this #{model_name}:",
15
- status: :critical,
17
+ status: :critical
16
18
  ) do
17
19
  render(Polaris::ListComponent.new) do |list|
18
20
  object.errors.each do |error|
@@ -26,7 +28,7 @@ module Polaris
26
28
  return if object.blank?
27
29
  return unless object.errors.key?(method)
28
30
 
29
- object.errors.full_messages_for(method)&.first.html_safe
31
+ raw object.errors.full_messages_for(method)&.first
30
32
  end
31
33
 
32
34
  def polaris_inline_error_for(method, **options, &block)