Class: ShadcnPhlexcomponents::FormHint

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/form/form_hint.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #default_attributes, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(message = nil, aria_id: nil, **attributes) ⇒ FormHint

Returns a new instance of FormHint.



14
15
16
17
18
# File 'lib/shadcn_phlexcomponents/components/form/form_hint.rb', line 14

def initialize(message = nil, aria_id: nil, **attributes)
  @message = message
  @id = aria_id ? "#{aria_id}-description" : nil
  super(**attributes)
end

Instance Method Details

#view_template ⇒ Object



20
21
22
23
24
25
26
# File 'lib/shadcn_phlexcomponents/components/form/form_hint.rb', line 20

def view_template(&)
  if @message
    p(id: @id, **@attributes) { @message }
  else
    p(id: @id, **@attributes, &)
  end
end