Class: Flowbite::Sidebar::Item
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Flowbite::Sidebar::Item
- Defined in:
- app/components/flowbite/sidebar/item.rb
Overview
Renders a sidebar navigation item.
Each item renders as a list item containing a link. Optionally, an icon can be provided using the icon slot, which will be displayed before the label text.
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(href:, class: nil, **options) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(href:, class: nil, **options) ⇒ Item
Returns a new instance of Item.
40 41 42 43 44 45 |
# File 'app/components/flowbite/sidebar/item.rb', line 40 def initialize(href:, class: nil, **) super() @class = Array.wrap(binding.local_variable_get(:class)) @href = href @options = end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
26 27 28 |
# File 'app/components/flowbite/sidebar/item.rb', line 26 def href @href end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'app/components/flowbite/sidebar/item.rb', line 26 def @options end |
Class Method Details
.classes ⇒ Object
29 30 31 32 33 34 |
# File 'app/components/flowbite/sidebar/item.rb', line 29 def classes [ "flex", "items-center", "px-2", "py-1.5", "text-body", "rounded-base", "hover:bg-neutral-tertiary", "hover:text-fg-brand", "group" ] end |
Instance Method Details
#call ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/components/flowbite/sidebar/item.rb', line 47 def call content_tag(:li) do = {class: link_classes}.merge() content_tag(:a, href: href, **) do concat(icon) if icon? concat(content_tag(:span, content, class: label_classes)) end end end |