Class: Voom::Presenters::DSL::Components::Chip

Inherits:
EventBase show all
Includes:
Mixins::Tooltips
Defined in:
lib/voom/presenters/dsl/components/chip.rb

Defined Under Namespace

Classes: Icon

Instance Attribute Summary collapse

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

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

Instance Method Summary collapse

Methods included from Mixins::Tooltips

#tooltip

Methods included from Mixins::Event

#event

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

Returns a new instance of Chip.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/voom/presenters/dsl/components/chip.rb', line 9

def initialize(**attribs_, &block)
  super(type: :chip,
        **attribs_, &block)
  @icons = []
  self.text(attribs.delete(:text)) if attribs.key?(:text)
  self.icon(attribs.delete(:icon)) if attribs.key?(:icon)
  @color = attribs.delete(:color)
  @name = attribs.delete(:name)
  @value = attribs.delete(:value)
  @selected = attribs.delete(:selected){false}
  expand!
  @chipset_variant = self.parent(:chipset)&.variant.to_s
end

Instance Attribute Details

#chipset_variantObject (readonly)

Returns the value of attribute chipset_variant.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def chipset_variant
  @chipset_variant
end

#colorObject (readonly)

Returns the value of attribute color.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def color
  @color
end

#iconsObject (readonly)

Returns the value of attribute icons.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def icons
  @icons
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def name
  @name
end

#selectedObject (readonly)

Returns the value of attribute selected.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def selected
  @selected
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7

def value
  @value
end

Instance Method Details

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



28
29
30
31
# File 'lib/voom/presenters/dsl/components/chip.rb', line 28

def icon(icon=nil, **attribs, &block)
  @icons << Icon.new(parent: self, icon: icon,
                     **attribs, &block)
end


33
34
35
36
# File 'lib/voom/presenters/dsl/components/chip.rb', line 33

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

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



23
24
25
26
# File 'lib/voom/presenters/dsl/components/chip.rb', line 23

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