Class: HeaderComponent
- Defined in:
- app/components/header_component.rb
Overview
Header — page and content headers.
Usage:
Header(size: :h2) { text "Page Title" }
Header(size: :h3, sub: true) { text "Subtitle" }
Header(icon: "settings", dividing: true) { text "Settings" }
Header(size: :h4, image: true) { |c|
c.header_image { Image(src: "avatar.png", size: "mini", rounded: true) }
text "Lena"
SubHeader { text "Human Resources" }
}
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/header_component.rb', line 31 def to_s classes = class_names( "ui", color, aligned && "#{aligned} aligned", attached && "#{attached} attached", { "sub" => sub, "dividing" => dividing, "block" => block_header, "inverted" => inverted, "disabled" => disabled, "floating" => floating, "icon" => icon && !@content, "image" => image }, "header" ) tag_name = size.to_s.start_with?("h") ? size.to_s.to_sym : :h2 icon_el = icon ? tag.i(class: "#{icon} icon") : nil if image && @slots[:header_image] # Image header: image outside content div, text + sub header inside content div tag.public_send(tag_name, class: classes) { safe_join([ @slots[:header_image], tag.div(class: "content") { @content } ]) } else tag.public_send(tag_name, class: classes) { safe_join([ icon_el, @content ]) } end end |