Class: Voom::Presenters::DSL::Components::Chip
- Includes:
- Mixins::Tooltips
- Defined in:
- lib/voom/presenters/dsl/components/chip.rb
Defined Under Namespace
Classes: Icon
Instance Attribute Summary collapse
-
#chipset_variant ⇒ Object
readonly
Returns the value of attribute chipset_variant.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#icons ⇒ Object
readonly
Returns the value of attribute icons.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from EventBase
Attributes included from Mixins::Event
Attributes inherited from Base
#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type
Instance Method Summary collapse
- #icon(icon = nil, **attribs, &block) ⇒ Object
-
#initialize(**attribs_, &block) ⇒ Chip
constructor
A new instance of Chip.
- #menu(**attributes, &block) ⇒ Object
- #text(*text, **attribs, &block) ⇒ Object
Methods included from Mixins::Tooltips
Methods included from Mixins::Event
Methods inherited from Base
Methods included from Pluggable
#include_plugins, #plugin, #plugin_module
Methods included from Mixins::YieldTo
Methods included from Serializer
Methods included from Lockable
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} @chipset_variant = self.parent(:chipset)&.variant.to_s end |
Instance Attribute Details
#chipset_variant ⇒ Object (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 |
#color ⇒ Object (readonly)
Returns the value of attribute color.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7 def color @color end |
#icons ⇒ Object (readonly)
Returns the value of attribute icons.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7 def icons @icons end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7 def name @name end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/chip.rb', line 7 def selected @selected end |
#value ⇒ Object (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 |
#menu(**attributes, &block) ⇒ Object
33 34 35 36 |
# File 'lib/voom/presenters/dsl/components/chip.rb', line 33 def (**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 |