Class: StimulusPlumbers::Form::Fields::Label::Floating

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/form/fields/label/floating.rb

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Instance Method Details

#render(text:, for_id:, id:, type:, required:, error:, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stimulus_plumbers/form/fields/label/floating.rb', line 8

def render(text:, for_id:, id:, type:, required:, error:, &block)
  html_options  = merge_html_options(theme.resolve(:form_field_floating_group, type: type))
  label_options = merge_html_options(theme.resolve(:form_field_floating_label, type: type, error: error))
  mark_options  = required && merge_html_options(
    { aria: { hidden: true } },
    theme.resolve(:form_field_required_mark)
  )
  template.(:div, **html_options) do
    template.safe_join(
      [
        template.capture(&block),
        render_label(text, mark_options, for: for_id, id: id, **label_options)
      ]
    )
  end
end