polaris_view_components 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -2
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +4 -5
  5. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  6. data/app/assets/javascripts/polaris_view_components/index.js +9 -1
  7. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  8. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +4 -0
  9. data/app/assets/javascripts/polaris_view_components/popover_controller.js +6 -2
  10. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  11. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  12. data/app/assets/javascripts/polaris_view_components.js +415 -18
  13. data/app/assets/stylesheets/polaris_view_components/custom.css +41 -0
  14. data/app/assets/stylesheets/polaris_view_components.css +25 -0
  15. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  16. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  17. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  18. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  19. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  20. data/app/components/polaris/autocomplete_component.rb +58 -0
  21. data/app/components/polaris/base_checkbox.rb +48 -0
  22. data/app/components/polaris/base_radio_button.rb +38 -0
  23. data/app/components/polaris/checkbox_component.html.erb +1 -5
  24. data/app/components/polaris/checkbox_component.rb +15 -8
  25. data/app/components/polaris/choice_list_component.rb +1 -1
  26. data/app/components/polaris/filters_component.html.erb +22 -0
  27. data/app/components/polaris/filters_component.rb +57 -4
  28. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  29. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  30. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  31. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  32. data/app/components/polaris/frame_component.html.erb +44 -0
  33. data/app/components/polaris/frame_component.rb +33 -0
  34. data/app/components/polaris/logo.rb +13 -0
  35. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  36. data/app/components/polaris/navigation/item_component.rb +85 -0
  37. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  38. data/app/components/polaris/navigation/section_component.rb +64 -0
  39. data/app/components/polaris/navigation_component.html.erb +29 -0
  40. data/app/components/polaris/navigation_component.rb +15 -0
  41. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  42. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  43. data/app/components/polaris/option_list/option_component.rb +24 -0
  44. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  45. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  46. data/app/components/polaris/option_list/section_component.rb +53 -0
  47. data/app/components/polaris/option_list_component.html.erb +15 -0
  48. data/app/components/polaris/option_list_component.rb +67 -0
  49. data/app/components/polaris/popover_component.html.erb +2 -9
  50. data/app/components/polaris/popover_component.rb +17 -0
  51. data/app/components/polaris/radio_button_component.html.erb +1 -6
  52. data/app/components/polaris/radio_button_component.rb +14 -4
  53. data/app/components/polaris/text_field_component.rb +16 -2
  54. data/app/components/polaris/toast_component.html.erb +21 -0
  55. data/app/components/polaris/toast_component.rb +40 -0
  56. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  57. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  58. data/app/helpers/polaris/form_builder.rb +2 -2
  59. data/app/helpers/polaris/view_helper.rb +11 -0
  60. data/lib/polaris/view_components/engine.rb +5 -1
  61. data/lib/polaris/view_components/version.rb +1 -1
  62. metadata +46 -9
@@ -0,0 +1,12 @@
1
+ module Polaris
2
+ class Autocomplete::SectionComponent < NewComponent
3
+ renders_many :options, ->(**system_arguments) do
4
+ Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
5
+ end
6
+
7
+ def initialize(multiple: false, **system_arguments)
8
+ @multiple = multiple
9
+ @system_arguments = system_arguments
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
3
+ <% popover.activator do %>
4
+ <%= text_field %>
5
+ <% end %>
6
+
7
+ <% if empty_state.present? %>
8
+ <div
9
+ data-polaris-autocomplete-target="emptyState"
10
+ class="Polaris-Autocomplete__EmptyState Polaris--hidden"
11
+ >
12
+ <%= empty_state %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= polaris_option_list(**option_list_arguments) do |list| %>
17
+ <% if sections.present? %>
18
+ <% sections.each do |section| %>
19
+ <%= section %>
20
+ <% end %>
21
+ <% elsif options.present? %>
22
+ <% options.each do |option| %>
23
+ <%= option %>
24
+ <% end %>
25
+ <% else %>
26
+ <%= content %>
27
+ <% end %>
28
+ <% end %>
29
+ <% end %>
30
+ <% end %>
@@ -0,0 +1,58 @@
1
+ module Polaris
2
+ class AutocompleteComponent < NewComponent
3
+ renders_one :text_field, ->(**system_arguments) do
4
+ system_arguments[:data] ||= {}
5
+ prepend_option(system_arguments[:data], :action, %w[
6
+ click->polaris-autocomplete#toggle
7
+ click@window->polaris-popover#hide
8
+ ])
9
+
10
+ system_arguments[:input_options] ||= {}
11
+ system_arguments[:input_options][:data] ||= {}
12
+ system_arguments[:input_options][:data][:polaris_autocomplete_target] = "input"
13
+
14
+ TextFieldComponent.new(**system_arguments)
15
+ end
16
+ renders_many :sections, ->(**system_arguments) do
17
+ Autocomplete::SectionComponent.new(multiple: @multiple, **system_arguments)
18
+ end
19
+ renders_many :options, ->(**system_arguments) do
20
+ Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
21
+ end
22
+ renders_one :empty_state
23
+
24
+ def initialize(multiple: false, url: nil, **system_arguments)
25
+ @multiple = multiple
26
+ @url = url
27
+ @system_arguments = system_arguments
28
+ end
29
+
30
+ def system_arguments
31
+ @system_arguments.tap do |opts|
32
+ opts[:tag] = "div"
33
+ opts[:data] ||= {}
34
+ opts[:data][:controller] = "polaris-autocomplete"
35
+ if @url.present?
36
+ opts[:data][:polaris_autocomplete_url_value] = @url
37
+ end
38
+ end
39
+ end
40
+
41
+ def popover_arguments
42
+ {
43
+ alignment: :left,
44
+ full_width: true,
45
+ inline: false,
46
+ wrapper_arguments: {
47
+ data: {polaris_autocomplete_target: "popover"}
48
+ }
49
+ }
50
+ end
51
+
52
+ def option_list_arguments
53
+ {
54
+ data: {polaris_autocomplete_target: "results"}
55
+ }
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,48 @@
1
+ module Polaris
2
+ class BaseCheckbox < Polaris::NewComponent
3
+ def initialize(
4
+ form: nil,
5
+ attribute: nil,
6
+ name: nil,
7
+ checked: false,
8
+ disabled: false,
9
+ value: "1",
10
+ unchecked_value: "0",
11
+ **system_arguments
12
+ )
13
+ @form = form
14
+ @attribute = attribute
15
+ @name = name
16
+ @checked = checked
17
+ @disabled = disabled
18
+ @value = value
19
+ @unchecked_value = unchecked_value
20
+ @system_arguments = system_arguments
21
+ end
22
+
23
+ def system_arguments
24
+ @system_arguments.tap do |opts|
25
+ opts[:disabled] = true if @disabled
26
+ opts[:aria] ||= {}
27
+ opts[:aria][:checked] = @checked
28
+ if indeterminate?
29
+ @system_arguments[:indeterminate] = true
30
+ @system_arguments[:aria][:checked] = "mixed"
31
+ end
32
+ opts[:class] = opts.delete(:classes)
33
+ end
34
+ end
35
+
36
+ def indeterminate?
37
+ @checked == :indeterminate
38
+ end
39
+
40
+ def call
41
+ if @form.present? && @attribute.present?
42
+ @form.check_box(@attribute, system_arguments, @value, @unchecked_value)
43
+ else
44
+ check_box_tag(@name, @value, @checked, system_arguments)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,38 @@
1
+ module Polaris
2
+ class BaseRadioButton < Polaris::NewComponent
3
+ def initialize(
4
+ form: nil,
5
+ attribute: nil,
6
+ name: nil,
7
+ checked: false,
8
+ disabled: false,
9
+ value: nil,
10
+ **system_arguments
11
+ )
12
+ @form = form
13
+ @attribute = attribute
14
+ @name = name
15
+ @checked = checked
16
+ @disabled = disabled
17
+ @value = value
18
+ @system_arguments = system_arguments
19
+ end
20
+
21
+ def system_arguments
22
+ @system_arguments.tap do |opts|
23
+ opts[:disabled] = true if @disabled
24
+ opts[:aria] ||= {}
25
+ opts[:aria][:checked] = @checked
26
+ opts[:class] = opts.delete(:classes)
27
+ end
28
+ end
29
+
30
+ def call
31
+ if @form.present? && @attribute.present?
32
+ @form.radio_button(@attribute, @value, system_arguments)
33
+ else
34
+ radio_button_tag(@name, @value, @checked, system_arguments)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,10 +1,6 @@
1
1
  <%= render Polaris::ChoiceComponent.new(**@wrapper_arguments) do %>
2
2
  <%= render Polaris::BaseComponent.new(**@system_arguments) do %>
3
- <% if @form.present? && @attribute.present? %>
4
- <%= @form.check_box(@attribute, @input_options, @value, @unchecked_value) %>
5
- <% else %>
6
- <%= check_box_tag(@name, @value, @checked, @input_options) %>
7
- <% end %>
3
+ <%= checkbox %>
8
4
 
9
5
  <span class="Polaris-Checkbox__Backdrop"></span>
10
6
 
@@ -28,6 +28,7 @@ module Polaris
28
28
  @attribute = attribute
29
29
  @name = name
30
30
  @checked = checked
31
+ @disabled = disabled
31
32
  @value = value
32
33
  @unchecked_value = unchecked_value
33
34
 
@@ -49,14 +50,7 @@ module Polaris
49
50
  }.merge(wrapper_arguments)
50
51
 
51
52
  @input_options = input_options
52
- @input_options[:aria] ||= {}
53
- @input_options[:disabled] = true if disabled
54
- @input_options[:aria][:checked] = checked
55
- if indeterminate?
56
- @input_options[:indeterminate] = true
57
- @input_options[:aria][:checked] = "mixed"
58
- end
59
- @input_options[:class] = class_names(
53
+ @input_options[:classes] = class_names(
60
54
  @input_options[:classes],
61
55
  "Polaris-Checkbox__Input",
62
56
  "Polaris-Checkbox__Input--indeterminate": indeterminate?
@@ -74,5 +68,18 @@ module Polaris
74
68
  def before_render
75
69
  validate!
76
70
  end
71
+
72
+ def checkbox
73
+ render Polaris::BaseCheckbox.new(
74
+ form: @form,
75
+ attribute: @attribute,
76
+ name: @name,
77
+ checked: @checked,
78
+ disabled: @disabled,
79
+ value: @value,
80
+ unchecked_value: @unchecked_value,
81
+ **@input_options
82
+ )
83
+ end
77
84
  end
78
85
  end
@@ -26,7 +26,7 @@ module Polaris
26
26
  end
27
27
 
28
28
  def initialize(
29
- title:,
29
+ title: nil,
30
30
  title_hidden: false,
31
31
  form: nil,
32
32
  attribute: nil,
@@ -8,6 +8,28 @@
8
8
  </div>
9
9
  </div>
10
10
  <% end %>
11
+ <% if items.present? %>
12
+ <div class="<%= items_wrapper_classes %>">
13
+ <% items.each do |item| %>
14
+ <%= item %>
15
+ <% end %>
16
+ </div>
17
+ <% end %>
11
18
  </div>
19
+ <% if content.present? %>
20
+ <div class="Polaris-Filters-ConnectedFilterControl__AuxiliaryContainer">
21
+ <%= content %>
22
+ </div>
23
+ <% end %>
12
24
  </div>
25
+ <% if tags.present? %>
26
+ <div class="Polaris-Filters__TagsContainer">
27
+ <%= tags %>
28
+ </div>
29
+ <% end %>
30
+ <% if @help_text.present? %>
31
+ <div class="Polaris-Filters__HelpText">
32
+ <%= polaris_text_subdued { @help_text } %>
33
+ </div>
34
+ <% end %>
13
35
  <% end %>
@@ -2,9 +2,17 @@
2
2
 
3
3
  module Polaris
4
4
  class FiltersComponent < Polaris::NewComponent
5
- renders_one :query, "QueryComponent"
5
+ renders_one :query, ->(**system_arguments) do
6
+ QueryComponent.new(disabled: @disabled, **system_arguments)
7
+ end
8
+ renders_many :items, ->(**system_arguments) do
9
+ ItemComponent.new(disabled: @disabled, **system_arguments)
10
+ end
11
+ renders_one :tags
6
12
 
7
- def initialize(**system_arguments)
13
+ def initialize(disabled: false, help_text: nil, **system_arguments)
14
+ @disabled = disabled
15
+ @help_text = help_text
8
16
  @system_arguments = system_arguments
9
17
  end
10
18
 
@@ -18,8 +26,17 @@ module Polaris
18
26
  end
19
27
  end
20
28
 
29
+ def items_wrapper_classes
30
+ class_names(
31
+ "Polaris-Filters-ConnectedFilterControl__RightContainer",
32
+ "Polaris-Filters-ConnectedFilterControl__RightContainerWithoutMoreFilters",
33
+ "Polaris-Filters-ConnectedFilterControl--queryFieldHidden": @query.blank?
34
+ )
35
+ end
36
+
21
37
  class QueryComponent < Polaris::NewComponent
22
- def initialize(clear_button: true, **system_arguments)
38
+ def initialize(clear_button: true, disabled: false, **system_arguments)
39
+ @disabled = disabled
23
40
  @system_arguments = system_arguments.merge(
24
41
  label_hidden: true,
25
42
  clear_button: clear_button
@@ -27,12 +44,48 @@ module Polaris
27
44
  end
28
45
 
29
46
  def call
30
- polaris_text_field(**@system_arguments) do |text_field|
47
+ polaris_text_field(disabled: @disabled, **@system_arguments) do |text_field|
31
48
  text_field.prefix do
32
49
  polaris_icon(name: "SearchMinor")
33
50
  end
34
51
  end
35
52
  end
36
53
  end
54
+
55
+ class ItemComponent < Polaris::NewComponent
56
+ def initialize(label:, sectioned: true, width: nil, disabled: false, **system_arguments)
57
+ @label = label
58
+ @sectioned = sectioned
59
+ @width = width
60
+ @disabled = disabled
61
+ @system_arguments = system_arguments
62
+ end
63
+
64
+ def system_arguments
65
+ @system_arguments.tap do |opts|
66
+ opts[:tag] = "div"
67
+ opts[:classes] = class_names(
68
+ @system_arguments[:classes],
69
+ "Polaris-Filters-ConnectedFilterControl__Item"
70
+ )
71
+ end
72
+ end
73
+
74
+ def popover_arguments
75
+ {
76
+ sectioned: @sectioned,
77
+ style: ("width: #{@width}" if @width.present?)
78
+ }
79
+ end
80
+
81
+ def call
82
+ render(Polaris::BaseComponent.new(**system_arguments)) do
83
+ render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover|
84
+ popover.button(disclosure: true, disabled: @disabled) { @label }
85
+ content
86
+ end
87
+ end
88
+ end
89
+ end
37
90
  end
38
91
  end
@@ -0,0 +1,23 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <% if @logo.present? && !@flush %>
3
+ <div class="Polaris-Frame-ContextualSaveBar__LogoContainer" style="width: <%= @logo.width %>">
4
+ <%= image_tag @logo.src, style: "width: #{@logo.width}", alt: @logo.alt %>
5
+ </div>
6
+ <% end %>
7
+
8
+ <div class="<%= content_classes %>">
9
+ <h2 class="Polaris-Frame-ContextualSaveBar__Message">
10
+ <%= @message %>
11
+ </h2>
12
+ <div class="Polaris-Frame-ContextualSaveBar__ActionContainer">
13
+ <%= polaris_stack(spacing: :tight) do |stack| %>
14
+ <% stack.item do %>
15
+ <%= discard_action %>
16
+ <% end %>
17
+ <% stack.item do %>
18
+ <%= save_action %>
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,31 @@
1
+ class Polaris::Frame::SaveBarComponent < Polaris::NewComponent
2
+ renders_one :save_action, ->(**system_arguments) do
3
+ Polaris::ButtonComponent.new(primary: true, **system_arguments)
4
+ end
5
+ renders_one :discard_action, Polaris::ButtonComponent
6
+
7
+ def initialize(message:, flush: false, full_width: false, logo: nil, **system_arguments)
8
+ @message = message
9
+ @flush = flush
10
+ @full_width = full_width
11
+ @logo = logo.is_a?(Hash) ? Polaris::Logo.new(**logo) : logo
12
+ @system_arguments = system_arguments
13
+ end
14
+
15
+ def system_arguments
16
+ @system_arguments.tap do |opts|
17
+ opts[:tag] = "div"
18
+ opts[:classes] = class_names(
19
+ @system_arguments[:classes],
20
+ "Polaris-Frame-ContextualSaveBar"
21
+ )
22
+ end
23
+ end
24
+
25
+ def content_classes
26
+ class_names(
27
+ "Polaris-Frame-ContextualSaveBar__Contents",
28
+ "Polaris-Frame-ContextualSaveBar--fullWidth": @full_width
29
+ )
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <button data-action="polaris-frame#openMenu" type="button" class="Polaris-TopBar__NavigationIcon">
3
+ <%= polaris_icon(name: "MobileHamburgerMajor") %>
4
+ </button>
5
+
6
+ <% if @logo.present? %>
7
+ <div class="Polaris-TopBar__LogoContainer Polaris-TopBar__LogoDisplayControl">
8
+ <%= link_to(@logo.url,
9
+ class: "Polaris-TopBar__LogoLink",
10
+ style: "width: #{@logo.width}"
11
+ ) do %>
12
+ <%= image_tag @logo.src,
13
+ class: "Polaris-TopBar__Logo",
14
+ style: "width: #{@logo.width}",
15
+ alt: @logo.alt %>
16
+ <% end %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <div class="Polaris-TopBar__Contents">
21
+ <%# FIXME: Not implemented yet %>
22
+ <div class="Polaris-TopBar__SearchField"></div>
23
+ <div class="Polaris-TopBar__SecondaryMenu"></div>
24
+ <div>
25
+ <div class="Polaris-TopBar-Menu__ActivatorWrapper">
26
+ <%= user_menu %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ <% end %>
@@ -0,0 +1,18 @@
1
+ class Polaris::Frame::TopBarComponent < Polaris::NewComponent
2
+ renders_one :user_menu, Polaris::TopBar::UserMenuComponent
3
+
4
+ def initialize(logo:, **system_arguments)
5
+ @logo = logo.is_a?(Hash) ? Polaris::Logo.new(**logo) : logo
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(
13
+ @system_arguments[:classes],
14
+ "Polaris-TopBar"
15
+ )
16
+ end
17
+ end
18
+ end
@@ -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
@@ -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,31 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-Navigation__ItemWrapper">
3
+ <%= link_to @url, class: link_classes, tabindex: "0" do %>
4
+ <% if @icon.present? %>
5
+ <div class="Polaris-Navigation__Icon">
6
+ <%= polaris_icon(name: @icon) %>
7
+ </div>
8
+ <% end %>
9
+ <span class="Polaris-Navigation__Text">
10
+ <%= @label %>
11
+ </span>
12
+ <% if @badge.present? %>
13
+ <div class="Polaris-Navigation__Badge">
14
+ <%= polaris_badge { @badge } %>
15
+ </div>
16
+ <% end %>
17
+ <% end %>
18
+ <%= secondary_action %>
19
+ </div>
20
+ <% if sub_items.present? %>
21
+ <div class="Polaris-Navigation__SecondaryNavigation Polaris-Navigation--isExpanded">
22
+ <div class="Polaris-Collapsible" style="max-height: none; overflow: visible;">
23
+ <ul class="Polaris-Navigation__List">
24
+ <% sub_items.each do |sub_item| %>
25
+ <%= sub_item %>
26
+ <% end %>
27
+ </ul>
28
+ </div>
29
+ </div>
30
+ <% end %>
31
+ <% end %>