Class: Polaris::Navigation::ItemComponent::SecondaryActionComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Polaris::Navigation::ItemComponent::SecondaryActionComponent
- Defined in:
- app/components/polaris/navigation/item_component.rb
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(url: nil, external: false, icon: nil, **system_arguments) ⇒ SecondaryActionComponent
constructor
A new instance of SecondaryActionComponent.
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(url: nil, external: false, icon: nil, **system_arguments) ⇒ SecondaryActionComponent
Returns a new instance of SecondaryActionComponent.
77 78 79 80 81 82 |
# File 'app/components/polaris/navigation/item_component.rb', line 77 def initialize(url: nil, external: false, icon: nil, **system_arguments) @url = url @external = external @icon = icon @system_arguments = system_arguments end |
Instance Method Details
#call ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/components/polaris/navigation/item_component.rb', line 101 def call tag.span do render(Polaris::BaseComponent.new(**system_arguments)) do if @icon.present? render(Polaris::IconComponent.new(name: @icon)) else content end end end end |
#system_arguments ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/components/polaris/navigation/item_component.rb', line 84 def system_arguments @system_arguments.tap do |opts| if @url.present? opts[:tag] = "a" opts[:href] = @url opts[:target] = "_blank" if @external else opts[:tag] = "button" opts[:type] = "button" end opts[:classes] = class_names( @system_arguments[:classes], "Polaris-Navigation__SecondaryAction" ) end end |