Class: Voom::Presenters::DSL::Components::Button

Inherits:
EventBase
  • Object
show all
Includes:
Mixins::Padding, Mixins::Tooltips
Defined in:
lib/voom/presenters/dsl/components/button.rb

Direct Known Subclasses

Stepper::Step::Actions::StepperButton

Constant Summary collapse

BUTTON_TYPES =
%i(raised flat fab 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::Padding

#coerce_padding, #validate_padding

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(type: nil, **attribs_, &block) ⇒ Button

Returns a new instance of Button.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/voom/presenters/dsl/components/button.rb', line 14

def initialize(type: nil, **attribs_, &block)
  @button_type = type || ((attribs_[:icon] && !attribs_[:text]) ? :icon : nil) || :flat
  super(type: :button, **attribs_, &block)
  @color = attribs.delete(:color)
  @background_color = attribs.delete(:background_color)
  self.icon(attribs.delete(:icon), color: color) if attribs.key?(:icon)
  @text = attribs.delete(:text)
  @disabled = attribs.delete(:disabled) {false}
  @hidden = attribs.delete(:hidden) {false}
  @size = attribs.delete(:size)
  @full_width = attribs.delete(:full_width) {false}
  @wrap_text = attribs.delete(:wrap_text) {true}
  @position = Array(default_position).compact
  @disabled_on_post_finished = attribs.delete(:disabled_on_post_finished) {false}
  expand!
  @event_parent_id = self.parent(:form)&.id || id
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def background_color
  @background_color
end

#button_typeObject

Returns the value of attribute button_type.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def button_type
  @button_type
end

#colorObject

Returns the value of attribute color.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def color
  @color
end

#disabledObject

Returns the value of attribute disabled.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def disabled
  @disabled
end

#disabled_on_post_finishedObject

Returns the value of attribute disabled_on_post_finished.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def disabled_on_post_finished
  @disabled_on_post_finished
end

#full_widthObject

Returns the value of attribute full_width.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def full_width
  @full_width
end

#hiddenObject

Returns the value of attribute hidden.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def hidden
  @hidden
end

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

Returns the value of attribute icon.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def icon
  @icon
end

#positionObject

Returns the value of attribute position.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def position
  @position
end

#sizeObject

Returns the value of attribute size.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def size
  @size
end

#textObject

Returns the value of attribute text.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def text
  @text
end

#wrap_textObject

Returns the value of attribute wrap_text.



11
12
13
# File 'lib/voom/presenters/dsl/components/button.rb', line 11

def wrap_text
  @wrap_text
end

Instance Method Details

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



37
38
39
40
# File 'lib/voom/presenters/dsl/components/button.rb', line 37

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


42
43
44
45
# File 'lib/voom/presenters/dsl/components/button.rb', line 42

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