Class: Voom::Presenters::DSL::Components::Header

Inherits:
Base
  • Object
show all
Defined in:
lib/voom/presenters/dsl/components/header.rb

Constant Summary collapse

VALID_PLACEMENTS =
%i[static fixed].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ Header

Returns a new instance of Header.



10
11
12
13
14
15
16
17
# File 'lib/voom/presenters/dsl/components/header.rb', line 10

def initialize(**attribs_, &block)
  super(type: :header,
        **attribs_, &block)
  self.title(attribs.delete(:title)) if attribs.key?(:title)
  @image = attribs.delete(:image)
  @placement = validate_placement(attribs.delete(:placement) { :static })
  expand!
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/voom/presenters/dsl/components/header.rb', line 6

def image
  @image
end

#placementObject

Returns the value of attribute placement.



6
7
8
# File 'lib/voom/presenters/dsl/components/header.rb', line 6

def placement
  @placement
end

#title(*text, **attribs, &block) ⇒ Object

Returns the value of attribute title.



6
7
8
# File 'lib/voom/presenters/dsl/components/header.rb', line 6

def title
  @title
end

Instance Method Details

#button(icon = nil, **attributes, &block) ⇒ Object



19
20
21
22
# File 'lib/voom/presenters/dsl/components/header.rb', line 19

def button(icon=nil, **attributes, &block)
  return @button if locked?
  @button = Components::Button.new(icon: icon, parent: self, **attributes, &block)
end


24
25
26
27
28
# File 'lib/voom/presenters/dsl/components/header.rb', line 24

def menu(**attribs, &block)
  return @menu if locked?
  @menu = Components::Menu.new(parent: self,
                   **attribs, &block)
end


30
31
32
33
34
# File 'lib/voom/presenters/dsl/components/header.rb', line 30

def nav(**attribs, &block)
  return @nav if locked?
  @nav = Components::Menu.new(parent: self,
                               **attribs, &block)
end