Class: Pulse::Layout::Main
- Defined in:
- app/components/pulse/layout.rb
Overview
The layout's main content.
Constant Summary collapse
- WIDTH_DEFAULT =
:full- WIDTH_OPTIONS =
[WIDTH_DEFAULT, :md, :lg, :xl].freeze
- TAG_DEFAULT =
:div- TAG_OPTIONS =
[TAG_DEFAULT, :main].freeze
Constants inherited from Component
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag: TAG_DEFAULT, width: WIDTH_DEFAULT, **system_arguments) ⇒ Main
constructor
A new instance of Main.
Methods inherited from Component
generate_id, #merge_attributes, #merge_classes
Methods included from SvgHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Methods included from AttributesHelper
#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Constructor Details
#initialize(tag: TAG_DEFAULT, width: WIDTH_DEFAULT, **system_arguments) ⇒ Main
Returns a new instance of Main.
88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/components/pulse/layout.rb', line 88 def initialize(tag: TAG_DEFAULT, width: WIDTH_DEFAULT, **system_arguments) @width = fetch_or_fallback(WIDTH_OPTIONS, width, WIDTH_DEFAULT) @system_arguments = system_arguments @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT) @system_arguments[:classes] = merge_classes( 'pulse-col-[2_/_span_2]', system_arguments[:classes] ) end |
Instance Method Details
#call ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/components/pulse/layout.rb', line 100 def call render(Pulse::BaseComponent.new(**@system_arguments)) do if @width == :full content else render( Pulse::BaseComponent.new( tag: :div, classes: "pulse-mx-auto Layout-main-centered-#{@width}" ) ) do render(Pulse::BaseComponent.new(tag: :div, container: @width)) do content end end end end end |