Class: Practical::Views::Navigation::NavigationLinkComponent
- Inherits:
-
ApplicationComponent
- Object
- ApplicationComponent
- Practical::Views::Navigation::NavigationLinkComponent
- Defined in:
- app/components/practical/views/navigation/navigation_link_component.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
Returns the value of attribute href.
-
#options ⇒ Object
Returns the value of attribute options.
-
#selected ⇒ Object
Returns the value of attribute selected.
Instance Method Summary collapse
- #call ⇒ Object
- #finalized_options ⇒ Object
- #flank_class ⇒ Object
-
#initialize(href:, selected:, options: {}) ⇒ NavigationLinkComponent
constructor
A new instance of NavigationLinkComponent.
- #selected? ⇒ Boolean
Constructor Details
#initialize(href:, selected:, options: {}) ⇒ NavigationLinkComponent
Returns a new instance of NavigationLinkComponent.
8 9 10 11 12 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 8 def initialize(href:, selected:, options: {}) self.href = href self. = self.selected = selected end |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
4 5 6 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 4 def href @href end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 4 def @options end |
#selected ⇒ Object
Returns the value of attribute selected.
4 5 6 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 4 def selected @selected end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 31 def call tag.a(**) { safe_join([ (icon if icon?), tag.span{ content } ]) } end |
#finalized_options ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 23 def mix({ href: href, class: helpers.class_names(flank_class, "navigation-link", "wa-accent"), data: {selected: selected?} }, ) end |
#flank_class ⇒ Object
14 15 16 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 14 def flank_class return "wa-flank wa-gap-2xs" if icon? end |
#selected? ⇒ Boolean
18 19 20 21 |
# File 'app/components/practical/views/navigation/navigation_link_component.rb', line 18 def selected? return true if selected return nil end |