Class: Primer::LayoutComponent
- Inherits:
-
Component
- Object
- Component
- Primer::LayoutComponent
- Defined in:
- app/components/primer/layout_component.rb
Overview
Use Layout to build a main/sidebar layout.
Constant Summary collapse
- DEFAULT_SIDE =
:right- ALLOWED_SIDES =
[DEFAULT_SIDE, :left].freeze
- MAX_COL =
12- DEFAULT_SIDEBAR_COL =
3- ALLOWED_SIDEBAR_COLS =
(1..(MAX_COL - 1)).to_a.freeze
Instance Method Summary collapse
-
#initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **system_arguments) ⇒ LayoutComponent
constructor
A new instance of LayoutComponent.
Constructor Details
#initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **system_arguments) ⇒ LayoutComponent
Returns a new instance of LayoutComponent.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/primer/layout_component.rb', line 45 def initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **system_arguments) @system_arguments = system_arguments @side = fetch_or_fallback(ALLOWED_SIDES, side, DEFAULT_SIDE) @responsive = responsive @system_arguments[:classes] = class_names( "gutter-condensed gutter-lg", @system_arguments[:classes] ) @system_arguments[:direction] = responsive ? [:column, nil, :row] : nil @system_arguments[:display] = :flex @system_arguments[:tag] = :div @sidebar_col = fetch_or_fallback(ALLOWED_SIDEBAR_COLS, , DEFAULT_SIDEBAR_COL) @main_col = MAX_COL - @sidebar_col end |