Class: Primer::LayoutComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/layout_component.rb

Constant Summary collapse

DEFAULT_SIDE =
:right
ALLOWED_SIDES =
[DEFAULT_SIDE, :left]

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(responsive: false, side: DEFAULT_SIDE, **kwargs) ⇒ LayoutComponent

Returns a new instance of LayoutComponent.



10
11
12
13
14
15
16
17
18
19
# File 'app/components/primer/layout_component.rb', line 10

def initialize(responsive: false, side: DEFAULT_SIDE, **kwargs)
  @kwargs = kwargs
  @side = fetch_or_fallback(ALLOWED_SIDES, side, DEFAULT_SIDE)
  @responsive = responsive
  @kwargs[:classes] = class_names(
    "gutter-condensed gutter-lg",
    @kwargs[:classes]
  )
  @kwargs[:direction] = responsive ? [:column, nil, :row] : nil
end