Class: Www::LeadFormModalComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Www::LeadFormModalComponent
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper, IconHelper, Turbo::FramesHelper
- Defined in:
- app/components/www/lead_form_modal_component.rb
Overview
Lazy-loading contact form modal component
Displays a compact CTA card/button/link that opens a modal with the contact form.
The form content (including turnstile and uppy) is loaded via Turbo Frame only
when the modal opens, reducing initial page load.
Constant Summary collapse
- VARIANTS =
Variants.
%w[card button link modal_only].freeze
Constants included from IconHelper
IconHelper::CUSTOM_ICON_MAP, IconHelper::CUSTOM_SVG_DIR, IconHelper::DEFAULT_FAMILY
Instance Method Summary collapse
- #button_variant? ⇒ Boolean
- #card_variant? ⇒ Boolean
- #form_content_url ⇒ Object
- #frame_id ⇒ Object
-
#initialize(modal_id: nil, header_title: "Hi, I'm Rae!", header_intro: "Tell me about your project and I'll connect you with the right expert.", button_text: 'Send Message', button_icon: 'envelope', button_class: 'btn btn-primary btn-lg', link_class: nil, show_upload: true, business_focused: false, submit_label: 'Send Message', application_type: nil, about_project: nil, variant: :card) ⇒ LeadFormModalComponent
constructor
A new instance of LeadFormModalComponent.
- #link_variant? ⇒ Boolean
- #modal_only_variant? ⇒ Boolean
Methods included from IconHelper
#account_nav_icon, #fa_icon, #star_rating_html
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(modal_id: nil, header_title: "Hi, I'm Rae!", header_intro: "Tell me about your project and I'll connect you with the right expert.", button_text: 'Send Message', button_icon: 'envelope', button_class: 'btn btn-primary btn-lg', link_class: nil, show_upload: true, business_focused: false, submit_label: 'Send Message', application_type: nil, about_project: nil, variant: :card) ⇒ LeadFormModalComponent
Returns a new instance of LeadFormModalComponent.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/www/lead_form_modal_component.rb', line 36 def initialize( modal_id: nil, header_title: "Hi, I'm Rae!", header_intro: "Tell me about your project and I'll connect you with the right expert.", button_text: 'Send Message', button_icon: 'envelope', button_class: 'btn btn-primary btn-lg', link_class: nil, show_upload: true, business_focused: false, submit_label: 'Send Message', application_type: nil, about_project: nil, variant: :card ) super() @modal_id = modal_id || "lead-form-modal-#{SecureRandom.hex(4)}" @header_title = header_title @header_intro = header_intro @button_text = @button_icon = @button_class = @link_class = link_class @show_upload = show_upload @business_focused = business_focused @submit_label = submit_label @application_type = application_type @about_project = about_project @variant = fetch_or_fallback(variant.to_s, VARIANTS, 'card') end |
Instance Method Details
#button_variant? ⇒ Boolean
90 91 92 |
# File 'app/components/www/lead_form_modal_component.rb', line 90 def @variant == 'button' end |
#card_variant? ⇒ Boolean
86 87 88 |
# File 'app/components/www/lead_form_modal_component.rb', line 86 def card_variant? @variant == 'card' end |
#form_content_url ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/components/www/lead_form_modal_component.rb', line 67 def form_content_url url_params = { show_upload: @show_upload, business_focused: @business_focused, submit_label: @submit_label, frame_id: frame_id } url_params[:application_type] = @application_type if @application_type.present? url_params[:header_title] = @header_title if @header_title.present? url_params[:header_intro] = @header_intro if @header_intro.present? url_params[:about_project] = @about_project if @about_project.present? helpers.contact_form_content_path(url_params) end |
#frame_id ⇒ Object
82 83 84 |
# File 'app/components/www/lead_form_modal_component.rb', line 82 def frame_id "#{@modal_id}-frame" end |
#link_variant? ⇒ Boolean
94 95 96 |
# File 'app/components/www/lead_form_modal_component.rb', line 94 def link_variant? @variant == 'link' end |
#modal_only_variant? ⇒ Boolean
98 99 100 |
# File 'app/components/www/lead_form_modal_component.rb', line 98 def modal_only_variant? @variant == 'modal_only' end |