Class: Voom::Presenters::DSL::Components::Button
- Includes:
- Mixins::Tooltips
- Defined in:
- lib/voom/presenters/dsl/components/button.rb
Constant Summary collapse
- BUTTON_TYPES =
%i(raised flat fab icon)
Instance Attribute Summary collapse
-
#button_type ⇒ Object
Returns the value of attribute button_type.
-
#color ⇒ Object
Returns the value of attribute color.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#icon(icon = nil, **attribs, &block) ⇒ Object
Returns the value of attribute icon.
-
#position ⇒ Object
Returns the value of attribute position.
-
#size ⇒ Object
Returns the value of attribute size.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from EventBase
Attributes included from Mixins::Event
Attributes inherited from Base
#attributes, #context, #id, #type
Instance Method Summary collapse
-
#initialize(type: nil, **attribs_, &block) ⇒ Button
constructor
A new instance of Button.
- #menu(**attributes, &block) ⇒ Object
Methods included from Mixins::Tooltips
Methods included from Mixins::Event
Methods inherited from Base
Methods included from Mixins::YieldTo
Methods included from Serializer
Methods included from Lockable
Constructor Details
#initialize(type: nil, **attribs_, &block) ⇒ Button
Returns a new instance of Button.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 15 def initialize(type: nil, **attribs_, &block) @button_type = h(type) || ((attribs_[:icon]&&!attribs_[:text]) ? :icon : nil) || :flat super(type: :button, **attribs_, &block) self.icon(attribs.delete(:icon)) if attribs.key?(:icon) @text = attribs.delete(:text) @color = attribs.delete(:color) @disabled = attribs.delete(:disabled) || false @size = attribs.delete(:size) @position = Array(attribs.delete(:position)).compact @event_parent_id = self.parent(:form)&.id || id end |
Instance Attribute Details
#button_type ⇒ Object
Returns the value of attribute button_type.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def @button_type end |
#color ⇒ Object
Returns the value of attribute color.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def color @color end |
#disabled ⇒ Object
Returns the value of attribute disabled.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def disabled @disabled end |
#icon(icon = nil, **attribs, &block) ⇒ Object
Returns the value of attribute icon.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def icon @icon end |
#position ⇒ Object
Returns the value of attribute position.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def position @position end |
#size ⇒ Object
Returns the value of attribute size.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def size @size end |
#text ⇒ Object
Returns the value of attribute text.
13 14 15 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 13 def text @text end |
Instance Method Details
#menu(**attributes, &block) ⇒ Object
36 37 38 39 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 36 def (**attributes, &block) return @menu if locked? @menu = Components::Menu.new(parent: self, position: , context: context, **attributes, &block) end |