Module: Bh::FormBuilder::Buttons

Included in:
Bh::FormBuilder
Defined in:
lib/bh/form_builder/buttons.rb

Overview

What a form is sent with, and what else it offers to press.

Constant Summary collapse

PILL =

What a button wears: the large pill in the primary color, solid or outlined.

'btn btn-lg rounded-5 theme-primary'
SPACE =

What clears a button of the field or the button above it.

'mt-3 md:mt-4'

Instance Method Summary collapse

Instance Method Details

#button(value = nil, options = {}) ⇒ Object

A button is the builder's too: solid where it submits, which is what one does unless told type: :button, and outlined where it does not. A disabled one given a title says why on hover — Available soon — from a wrapper around it, since a disabled button hears no mouse; the wrapper then takes the button's place in the column.



22
23
24
25
26
27
28
29
30
31
# File 'lib/bh/form_builder/buttons.rb', line 22

def button(value = nil, options = {}, &)
  return button(nil, value, &) if value.is_a? Hash

  wrapped = options[:disabled] && options[:title]
  fill = options[:type].to_s == 'button' ? 'btn-outline' : 'btn-solid'
  classes = @template.class_names PILL, fill, (SPACE unless wrapped)
  button = super(value, with_classes(options.except(:title), classes), &)

  wrapped ? tooltipped(button, options[:title]) : button
end

#submit(value = nil, options = {}) ⇒ Object

A submit is the builder's button, solid.



14
15
16
# File 'lib/bh/form_builder/buttons.rb', line 14

def submit(value = nil, options = {})
  super(value, with_classes(options, "#{PILL} btn-solid #{SPACE}"))
end