class Voom::Presenters::DSL::Components::Button
Constants
- BUTTON_TYPES
Attributes
background_color[RW]
color[RW]
disabled[RW]
disabled_on_post_finished[RW]
full_width[RW]
icon[RW]
position[RW]
size[RW]
text[RW]
wrap_text[RW]
Public Class Methods
new(type: nil, **attribs_, &block)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
image(image = nil, **attribs, &block)
click to toggle source
# 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
Private Instance Methods
default_position()
click to toggle source
# File lib/voom/presenters/dsl/components/button.rb, line 49 def default_position attribs.delete(:position){button_type == :fab ? %i(top right) : nil} end