From 54b8ce3018e4a4f18837f29f2c20d8b16f45dd38 Mon Sep 17 00:00:00 2001 From: Hyejin Yoon <0327jane@gmail.com> Date: Fri, 13 Sep 2024 08:52:01 +0900 Subject: [PATCH] fix: add cloud form & fix css (#11362) --- .../{Hero => DemoForm}/hubspotFormStyles.css | 38 ++++---- .../src/pages/cloud/DemoForm/index.jsx | 94 +++++++++++++++++++ .../pages/cloud/DemoForm/styles.module.scss | 55 +++++++++++ docs-website/src/pages/cloud/Hero/index.js | 73 +------------- .../src/pages/cloud/Hero/styles.module.scss | 40 +------- docs-website/src/pages/cloud/index.js | 35 ++++--- .../src/pages/cloud/styles.module.scss | 69 ++++++++++++++ 7 files changed, 254 insertions(+), 150 deletions(-) rename docs-website/src/pages/cloud/{Hero => DemoForm}/hubspotFormStyles.css (58%) create mode 100644 docs-website/src/pages/cloud/DemoForm/index.jsx create mode 100644 docs-website/src/pages/cloud/DemoForm/styles.module.scss diff --git a/docs-website/src/pages/cloud/Hero/hubspotFormStyles.css b/docs-website/src/pages/cloud/DemoForm/hubspotFormStyles.css similarity index 58% rename from docs-website/src/pages/cloud/Hero/hubspotFormStyles.css rename to docs-website/src/pages/cloud/DemoForm/hubspotFormStyles.css index 4baa4fd042..9d0488bf80 100644 --- a/docs-website/src/pages/cloud/Hero/hubspotFormStyles.css +++ b/docs-website/src/pages/cloud/DemoForm/hubspotFormStyles.css @@ -1,28 +1,23 @@ -#hubspotForm { - text-align: left; +.hs-input { + width: 100% !important; } -#hubspotForm .input { - margin: 0; -} - -#hubspotForm .hs-form input, -#hubspotForm .hs-form select, -#hubspotForm .hs-form textarea { +.hs-form input, +.hs-form select, +.hs-form textarea { border: .5px solid #DDD; background-color: #FFF; padding: .75rem 1rem; margin: 0.4rem auto; border-radius: 8px; font-size: 16px; - width: 100%; } -#hubspotForm .hs-form ::placeholder { +.hs-form ::placeholder { font-style: Manrope; } -#hubspotForm .hs-form input[type="submit"] { +.hs-form input[type="submit"] { background-color: #1990FF; color: #fff; border: none; @@ -34,45 +29,46 @@ width: 100px; } -#hubspotForm .hs-form input[type="submit"]:hover { +.hs-form input[type="submit"]:hover { background-color: #0056b3; /* Button hover color */ } /* hide the label */ -#hubspotForm .hs-form label span { +.hs-form label span { display: none; } /* error labels */ -#hubspotForm .hs-form .hs-error-msgs { +.hs-form .hs-error-msgs { font-size: 15px; color: red; list-style-type: none; padding: 0; + text-align: left; } -#hubspotForm .hs-form .error { +.hs-form .error { border: red 1.5px solid !important; } /* customize placeholder style */ -#hubspotForm .hs-form input::placeholder, -#hubspotForm .hs-form textarea::placeholder, -#hubspotForm .hs-form textarea { +.hs-form input::placeholder, +.hs-form textarea::placeholder, +.hs-form textarea { font-size: 16px; font-weight: 400; font-family: sans-serif; color: gray; } -#hubspotForm .hs-form .hs_firstname { +.hs-form .hs_firstname { padding-right: 0.5rem; } -#hubspotForm .hs-form .hs_lastname { +.hs-form .hs_lastname { padding-left: 0.5rem; } diff --git a/docs-website/src/pages/cloud/DemoForm/index.jsx b/docs-website/src/pages/cloud/DemoForm/index.jsx new file mode 100644 index 0000000000..28777e722e --- /dev/null +++ b/docs-website/src/pages/cloud/DemoForm/index.jsx @@ -0,0 +1,94 @@ +import React, { useEffect } from 'react'; +import clsx from "clsx"; +import Link from "@docusaurus/Link"; +import styles from "./styles.module.scss"; +import ScrollingCustomers from '../CompanyLogos'; +import './hubspotFormStyles.css'; + +const DemoForm = ({ formId }) => { + useEffect(() => { + const formContainerId = `hubspotForm-${formId}`; + + const initializeHubspotForm = () => { + if (!document.querySelector(`#${formContainerId} .hs-form`)) { + window.hbspt.forms.create({ + region: "na1", + portalId: "14552909", + formId: "ed2447d6-e6f9-4771-8f77-825b114a9421", + target: `#${formContainerId}`, + }); + + setTimeout(() => { + const emailInput = document.querySelector(`#${formContainerId} .hs_email .input > input`); + const firstNameInput = document.querySelector(`#${formContainerId} .hs_firstname .input > input`); + const lastNameInput = document.querySelector(`#${formContainerId} .hs_lastname .input > input`); + const phoneInput = document.querySelector(`#${formContainerId} .hs_phone .input > input`); + const additionalInfoInput = document.querySelector(`#${formContainerId} .hs_additional_info .input > textarea`); + + if (emailInput) emailInput.placeholder = 'Company Email'; + if (firstNameInput) firstNameInput.placeholder = 'First Name'; + if (lastNameInput) lastNameInput.placeholder = 'Last Name'; + if (phoneInput) phoneInput.placeholder = 'Phone Number'; + if (additionalInfoInput) additionalInfoInput.placeholder = 'How can we help?'; + + const selectNoEElement = document.getElementById(`number_of_employees-ed2447d6-e6f9-4771-8f77-825b114a9421`); + if (selectNoEElement) { + const disabledOption = selectNoEElement.querySelector('option[disabled]'); + if (disabledOption) { + disabledOption.text = "Select Number of Employees"; + disabledOption.value = ""; + } + } + const selectfamiliarityElement = document.getElementById(`familiarity_with_acryl_datahub-ed2447d6-e6f9-4771-8f77-825b114a9421`); + if (selectfamiliarityElement) { + const disabledOption = selectfamiliarityElement.querySelector('option[disabled]'); + if (disabledOption) { + disabledOption.text = "How familiar are you with DataHub?"; + disabledOption.value = ""; + } + } + }, 1000); // Delay to ensure the form is fully loaded + + window.hero = new RevenueHero({ routerId: '982' }); + window.hero.schedule('hsForm_ed2447d6-e6f9-4771-8f77-825b114a9421'); + } + }; + + if (!window.hbspt) { + const script = document.createElement('script'); + script.src = "//js.hsforms.net/forms/embed/v2.js"; + script.async = true; + script.type = 'text/javascript'; + document.body.appendChild(script); + + script.onload = () => { + initializeHubspotForm(); + }; + } else { + initializeHubspotForm(); + } + + return () => { + const hubspotForm = document.querySelector(`#${formContainerId} .hs-form`); + if (hubspotForm) { + hubspotForm.remove(); + } + }; + }, [formId]); + + return ( +