Class: Voom::Presenters::DSL::Components::Button
- Includes:
- Mixins::Padding, Mixins::Tooltips
- Defined in:
- lib/voom/presenters/dsl/components/button.rb
Direct Known Subclasses
Constant Summary collapse
- BUTTON_TYPES =
%i(raised flat fab icon)
Instance Attribute Summary collapse
-
#background_color ⇒ Object
Returns the value of attribute background_color.
-
#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.
-
#disabled_on_post_finished ⇒ Object
Returns the value of attribute disabled_on_post_finished.
-
#full_width ⇒ Object
Returns the value of attribute full_width.
-
#hidden ⇒ Object
Returns the value of attribute hidden.
-
#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.
-
#wrap_text ⇒ Object
Returns the value of attribute wrap_text.
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
- #image(image = nil, **attribs, &block) ⇒ Object
-
#initialize(type: nil, **attribs_, &block) ⇒ Button
constructor
A new instance of Button.
- #menu(**attributes, &block) ⇒ Object
Methods included from Mixins::Padding
#coerce_padding, #validate_padding
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(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} @event_parent_id = self.parent(:form)&.id || id end |
Instance Attribute Details
#background_color ⇒ Object
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_type ⇒ Object
Returns the value of attribute button_type.
11 12 13 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 11 def @button_type end |
#color ⇒ Object
Returns the value of attribute color.
11 12 13 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 11 def color @color end |
#disabled ⇒ Object
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_finished ⇒ Object
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_width ⇒ Object
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 |
#hidden ⇒ Object
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 |
#position ⇒ Object
Returns the value of attribute position.
11 12 13 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 11 def position @position end |
#size ⇒ Object
Returns the value of attribute size.
11 12 13 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 11 def size @size end |
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 11 def text @text end |
#wrap_text ⇒ Object
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 |
#menu(**attributes, &block) ⇒ Object
42 43 44 45 |
# File 'lib/voom/presenters/dsl/components/button.rb', line 42 def (**attributes, &block) return @menu if locked? @menu = Components::Menu.new(parent: self, position: , **attributes, &block) end |