class NfgUi::Components::Patterns::PageHeader

PageHeader doc coming soon

Public Instance Methods

data() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 16
def data
  sticky ? super.merge!(toggle: 'sticky-div') : super
end
full_width() click to toggle source

Supplies a slightly smaller design-system approved column structure when set to false (as used in Evo), by default. DMS, however requires a simple 'col' (full width) layout and will have :full_width set to true manually while both apps co-exist with slightly different page layouts.

# File lib/nfg_ui/components/patterns/page_header.rb, line 25
def full_width
  options.fetch(:full_width, false)
end
render() { |: body)| ... } click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 47
def render
  html_options[:class] ||= ''
  html_options[:class] << ' container-fluid'

  content_tag(:div, html_options) do
    content_tag(:div, class: 'row') do
      content_tag(:div, class: column_structure_css_classes) do
        content_tag(:div, class: 'row align-items-center') do
          concat(content_tag(:div, class: 'col py-2') {
            NfgUi::Components::Patterns::Media.new({}, view_context).render do
              capture do
                concat(NfgUi::Components::Elements::MediaObject.new({}, view_context).render {
                  content_tag(:div, class: 'mt-lg-1 mr-2 h3') do
                    NfgUi::Components::Foundations::Icon.new({ traits: [resource_theme_icon], class: "text-#{resource_theme_color} mr-0" }, view_context).render
                  end
                })
                concat(NfgUi::Components::Elements::MediaBody.new({}, view_context).render {
                  content_tag(:h1) do
                    if subtitle
                      concat(content_tag(:span, title, class: 'mr-2'))
                      concat(content_tag(:small, subtitle, class: 'text-muted'))

                    else
                      concat(title)
                    end
                  end
                })
              end
            end
          })
          if body
            concat(content_tag(:div, class: 'col-12 col-md-auto py-2') {
              NfgUi::Components::Patterns::ButtonToolbar.new({ class: 'align-items-center' }, view_context).render do
                (block_given? ? yield : body)
              end
            })
          end
        end
      end
    end
  end
end
resource_theme_icon() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 38
def resource_theme_icon
  # Prefer :icon in options over resource_theme_icon autolookup
  # #icon is made available by Iconable,
  # effectively allowing `icon: 'example'` to overwrite
  # the auto resource_theme_icon version.
  return icon if icon.present?
  super
end
sticky() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 29
def sticky
  return if Rails.env.test? || browser.mobile?
  options.fetch(:sticky, true)
end
subtitle() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 34
def subtitle
  options.fetch(:subtitle, nil)
end

Private Instance Methods

column_structure_css_classes() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 92
def column_structure_css_classes
  "col #{'col-xl-11 mx-auto' unless full_width}".squish
end
non_html_attribute_options() click to toggle source
# File lib/nfg_ui/components/patterns/page_header.rb, line 96
def non_html_attribute_options
  super.push(:subtitle, :full_width, :sticky)
end