Class: Voom::Presenters::DSL::Components::UnorderedList::ListItem

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

Instance Attribute Summary

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) ⇒ ListItem

Returns a new instance of ListItem.



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

def initialize(**attribs_, &block)
  super(type: :list_item, **attribs_, &block)
  self.text(attribs.delete(:text)) if attribs.key?(:text)
  self.icon(attribs.delete(:icon)) if attribs.key?(:icon)
  self.unordered_list(attribs.delete(:unordered_list)) if attribs.key?(:unordered_list)
  expand!
end

Instance Method Details

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



35
36
37
38
# File 'lib/voom/presenters/dsl/components/unordered_list.rb', line 35

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

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



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

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

#unordered_list(**attribs, &block) ⇒ Object



40
41
42
43
# File 'lib/voom/presenters/dsl/components/unordered_list.rb', line 40

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