Class: Avo::Sidebar::LinkComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Avo::Sidebar::LinkComponent
- Defined in:
- app/components/avo/sidebar/link_component.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}) ⇒ LinkComponent
constructor
A new instance of LinkComponent.
- #is_external? ⇒ Boolean
-
#link_method ⇒ Object
For external links active_link_to marks them all as active.
Constructor Details
#initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}) ⇒ LinkComponent
Returns a new instance of LinkComponent.
10 11 12 13 14 15 16 |
# File 'app/components/avo/sidebar/link_component.rb', line 10 def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}) @label = label @path = path @active = active @target = target @data = data end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
4 5 6 |
# File 'app/components/avo/sidebar/link_component.rb', line 4 def active @active end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'app/components/avo/sidebar/link_component.rb', line 8 def data @data end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
6 7 8 |
# File 'app/components/avo/sidebar/link_component.rb', line 6 def label @label end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'app/components/avo/sidebar/link_component.rb', line 7 def path @path end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'app/components/avo/sidebar/link_component.rb', line 5 def target @target end |
Instance Method Details
#classes ⇒ Object
30 31 32 |
# File 'app/components/avo/sidebar/link_component.rb', line 30 def classes "px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100" end |
#is_external? ⇒ Boolean
18 19 20 21 22 23 |
# File 'app/components/avo/sidebar/link_component.rb', line 18 def is_external? # If the path contains the scheme, check if it includes the root path or not return !path.include?(Avo::App.root_path) if URI(path).scheme.present? false end |
#link_method ⇒ Object
For external links active_link_to marks them all as active.
26 27 28 |
# File 'app/components/avo/sidebar/link_component.rb', line 26 def link_method is_external? ? :link_to : :active_link_to end |