Class: 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
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **system_arguments) ⇒ LayoutComponent
constructor
A new instance of LayoutComponent.
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
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 |