Class: FoxTail::TriggerBaseComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- Base
- BaseComponent
- FoxTail::TriggerBaseComponent
- Includes:
- Concerns::HasStimulusController, Concerns::Identifiable
- Defined in:
- app/components/fox_tail/trigger_base_component.rb
Direct Known Subclasses
CollapsibleTriggerComponent, ColorThemeTriggerComponent, DismissibleTriggerComponent, DrawerTriggerComponent, DropdownTriggerComponent, ModalTriggerComponent, PasswordInputTriggerComponent, PopoverTriggerComponent, TooltipTriggerComponent
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #block? ⇒ Boolean
- #call ⇒ Object
-
#initialize(id_or_selector, selector_or_attributes = {}, html_attributes = {}, &block) ⇒ TriggerBaseComponent
constructor
A new instance of TriggerBaseComponent.
- #render? ⇒ Boolean
- #stimulus_controller_options ⇒ Object
Methods inherited from BaseComponent
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
Constructor Details
#initialize(id_or_selector, selector_or_attributes = {}, html_attributes = {}, &block) ⇒ TriggerBaseComponent
Returns a new instance of TriggerBaseComponent.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 11 def initialize(id_or_selector, selector_or_attributes = {}, html_attributes = {}, &block) if selector_or_attributes.is_a? Hash html_attributes = selector_or_attributes selector_or_attributes = id_or_selector else __id_argument_deprecated_warning html_attributes[:id] = id_or_selector end super(html_attributes) @selector = selector_or_attributes @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 7 def block @block end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
7 8 9 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 7 def selector @selector end |
Instance Method Details
#before_render ⇒ Object
29 30 31 32 33 34 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 29 def before_render super generate_unique_id html_attributes[:class] = html_class end |
#block? ⇒ Boolean
25 26 27 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 25 def block? !!block end |
#call ⇒ Object
40 41 42 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 40 def call block? ? view_context.capture(self, &block) : content end |
#render? ⇒ Boolean
36 37 38 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 36 def render? content? || block? end |
#stimulus_controller_options ⇒ Object
44 45 46 47 48 49 |
# File 'app/components/fox_tail/trigger_base_component.rb', line 44 def { selector: selector, trigger_type: trigger_type } end |