Class: Daisy::DataInput::FilterComponent::FilterResetComponent

Inherits:
RadioButtonComponent show all
Defined in:
app/components/daisy/data_input/filter_component.rb

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary

Attributes inherited from RadioButtonComponent

#checked, #disabled, #id, #name, #required, #value

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from RadioButtonComponent

#call, #setup_component

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Constructor Details

#initialize(**kws) ⇒ FilterResetComponent

Initialize a new filter reset component.

Parameters:

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • disabled (Boolean)

    Whether the reset button is disabled. Defaults to false.



86
87
88
89
90
# File 'app/components/daisy/data_input/filter_component.rb', line 86

def initialize(**kws)
  super(**kws)

  @skip_styling = true
end

Instance Method Details

#before_renderObject

Setup the component before rendering.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/components/daisy/data_input/filter_component.rb', line 95

def before_render
  # Make sure to pull the default name from the parent
  @name = config_option(:name, loco_parent.name)
  @id = config_option(:id, "#{loco_parent.id}_reset")

  # Call parent setup first
  super

  # Add square styling
  add_css(:component, "where:btn where:btn-square filter-reset")

  # Set type to reset
  add_html(:component, { type: "radio", id: @id })
end