Class: Railsboot::OffcanvasComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/offcanvas_component.rb

Constant Summary collapse

PLACEMENTS =
["start", "end", "top", "bottom"].freeze
DEFAULT_PLACEMENT =
"start".freeze

Constants inherited from Component

Component::COLORS, Component::DEFAULT_COLOR

Instance Method Summary collapse

Constructor Details

#initialize(placement: DEFAULT_PLACEMENT, **html_attributes) ⇒ OffcanvasComponent

Returns a new instance of OffcanvasComponent.



8
9
10
11
12
13
14
15
16
17
18
# File 'app/components/railsboot/offcanvas_component.rb', line 8

def initialize(placement: DEFAULT_PLACEMENT, **html_attributes)
  @placement = fetch_or_fallback(placement, PLACEMENTS, DEFAULT_PLACEMENT)
  @html_attributes = html_attributes

  @html_attributes[:tag] = "div"
  @html_attributes[:class] = class_names(
    "offcanvas",
    "offcanvas-#{@placement}",
    html_attributes.delete(:class)
  )
end