Class: Flowbite::Sidebar

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/sidebar.rb,
app/components/flowbite/sidebar/item.rb,
app/components/flowbite/sidebar/navigation.rb

Overview

Renders a fixed-position sidebar container.

Use Sidebar as the outer shell and Navigation inside it to render the list of Items.

Examples:

Usage

<%= render(Flowbite::Sidebar.new) do %>
  <%= render(Flowbite::Sidebar::Navigation.new) do |nav| %>
    <% nav.with_item do %>
      <%= render(Flowbite::Sidebar::Item.new(href: "/dashboard")) { "Dashboard" } %>
    <% end %>
  <% end %>
<% end %>

See Also:

Defined Under Namespace

Classes: Item, Navigation

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class: nil, **options) ⇒ Sidebar

Returns a new instance of Sidebar.

Parameters:

  • class (Array<String>) (defaults to: nil)

    Additional CSS classes for the sidebar container.

  • options (Hash)

    Additional HTML options for the sidebar container.



34
35
36
37
38
# File 'app/components/flowbite/sidebar.rb', line 34

def initialize(class: nil, **options)
  super()
  @class = Array.wrap(binding.local_variable_get(:class))
  @options = options
end

Class Method Details

.classesObject



23
24
25
26
27
28
# File 'app/components/flowbite/sidebar.rb', line 23

def classes
  [
    "fixed", "top-0", "left-0", "z-40", "w-64", "h-screen",
    "transition-transform", "-translate-x-full", "sm:translate-x-0"
  ]
end

Instance Method Details

#callObject



40
41
42
43
44
45
46
# File 'app/components/flowbite/sidebar.rb', line 40

def call
  (:aside, aside_options) do
    (:div, class: wrapper_classes) do
      content
    end
  end
end