Class: SdrViewComponents::Structure::HeaderComponent

Inherits:
BaseComponent
  • Object
show all
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

Instance Method Summary collapse

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 = 
  super()
end

Instance Attribute Details

#background_colorObject (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

#rosetteObject (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

#subtitleObject (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_logoObject (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
end

#titleObject (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

#variantObject (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_classesObject



44
45
46
# File 'app/components/sdr_view_components/structure/header_component.rb', line 44

def collapsible_navbar_classes
  merge_classes('navbar navbar-expand-md', VARIANT_NAVBAR_CLASS[variant])
end

#masthead_classesObject



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


48
49
50
# File 'app/components/sdr_view_components/structure/header_component.rb', line 48

def navbar_classes
  merge_classes('navbars ms-md-auto', VARIANT_NAVBAR_CLASS[variant])
end

#style_override_componentObject



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