Class: SdrViewComponents::Structure::HeaderComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Structure::HeaderComponent
- Defined in:
- app/components/sdr_view_components/structure/header_component.rb
Overview
Component for rendering page header.
Constant Summary collapse
- VARIANT_MASTHEAD_CLASS =
{ light: 'bg-light', dark: 'bg-dark sky-dark', white: 'border-bottom' }.freeze
- VARIANT_NAVBAR_CLASS =
{ light: 'bg-light', dark: 'bg-dark sky-dark' }.freeze
Instance Attribute Summary collapse
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
-
#rosette ⇒ Object
readonly
Returns the value of attribute rosette.
-
#subtitle ⇒ Object
readonly
Returns the value of attribute subtitle.
-
#sul_logo ⇒ Object
readonly
Returns the value of attribute sul_logo.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #collapsible_navbar_classes ⇒ Object
-
#initialize(title:, subtitle: nil, variant: :light, background_color: nil, rosette: true, sul_logo: nil) ⇒ HeaderComponent
constructor
param title [String] The main application title text (Required).
- #masthead_classes ⇒ Object
- #navbar_classes ⇒ Object
- #style_override_component ⇒ Object
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(title:, subtitle: nil, variant: :light, background_color: nil, rosette: true, sul_logo: nil) ⇒ HeaderComponent
param title [String] The main application title text (Required). param subtitle [String, nil] An optional subtitle text. param variant [Symbol] One of :light, :dark, :white - determines color scheme. param background_color [String, nil] Optional RGB color value for background (i.e. ‘1, 104, 149’).
Used only when variant is :dark.
param rosette [Boolean] Whether to show the rosette logo. param sul_logo [String, nil] Optional URL for SUL logo image. (polychrome, stacked-lg, stacked-mobile)
28 29 30 31 32 33 34 35 36 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 28 def initialize(title:, subtitle: nil, variant: :light, background_color: nil, rosette: true, sul_logo: nil) # rubocop:disable Metrics/ParameterLists @title = title @subtitle = subtitle @variant = variant @background_color = background_color @rosette = rosette @sul_logo = sul_logo super() end |
Instance Attribute Details
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def background_color @background_color end |
#rosette ⇒ Object (readonly)
Returns the value of attribute rosette.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def rosette @rosette end |
#subtitle ⇒ Object (readonly)
Returns the value of attribute subtitle.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def subtitle @subtitle end |
#sul_logo ⇒ Object (readonly)
Returns the value of attribute sul_logo.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def sul_logo @sul_logo end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def title @title end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
38 39 40 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 38 def variant @variant end |
Instance Method Details
#collapsible_navbar_classes ⇒ Object
44 45 46 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 44 def merge_classes('navbar navbar-expand-md', VARIANT_NAVBAR_CLASS[variant]) end |
#masthead_classes ⇒ Object
40 41 42 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 40 def masthead_classes merge_classes('masthead', VARIANT_MASTHEAD_CLASS[variant]) end |
#navbar_classes ⇒ Object
48 49 50 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 48 def merge_classes('navbars ms-md-auto', VARIANT_NAVBAR_CLASS[variant]) end |
#style_override_component ⇒ Object
52 53 54 55 56 |
# File 'app/components/sdr_view_components/structure/header_component.rb', line 52 def style_override_component return SdrViewComponents::Structure::StyleOverrideLightComponent.new unless variant == :dark SdrViewComponents::Structure::StyleOverrideDarkComponent.new(background_color:) end |