Class: Railsboot::ContainerComponent

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

Overview

ViewComponent: renders the container block.

Constant Summary collapse

BREAKPOINTS =

Breakpoints.

%w[sm md lg xl xxl].freeze
DEFAULT_BREAKPOINT =

Default breakpoint.

"".freeze

Instance Method Summary collapse

Constructor Details

#initialize(breakpoint: DEFAULT_BREAKPOINT, fluid: false, **html_attributes) ⇒ ContainerComponent

Returns a new instance of ContainerComponent.



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

def initialize(breakpoint: DEFAULT_BREAKPOINT, fluid: false, **html_attributes)
  @breakpoint = breakpoint
  @fluid = fluid
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    ("container-#{breakpoint}" if @breakpoint.in?(BREAKPOINTS)),
    ("container-fluid" if @fluid),
    ("container" if @fluid.blank? && !@breakpoint.in?(BREAKPOINTS)),
    html_attributes.delete(:class)
  )
end

Instance Method Details

#callObject



22
23
24
25
26
# File 'app/components/railsboot/container_component.rb', line 22

def call
  render Railsboot::BaseComponent.new(tag: "div", **@html_attributes) do
    content
  end
end