-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from Light-it-labs/feature/86dr2w52q/add-loadi…
…ng-for-jotforms-iframes [FEATURE][86dr2w52q] Weird behaviour on loading forms of Jotforms
- Loading branch information
Showing
14 changed files
with
272 additions
and
262 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
apps/eo_web/dist/assets/main-0d348634.css → apps/eo_web/dist/assets/main-f7238d96.css
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
|
||
import { jotformScript } from "~/helpers/jotform_script"; | ||
import { useMount } from "~/hooks/useMount"; | ||
|
||
interface JotformFrameProps { | ||
formId: string | number; | ||
searchParam?: URLSearchParams; | ||
} | ||
|
||
const Iframe = ({ formId, searchParam }: JotformFrameProps) => { | ||
const ref = useRef<HTMLIFrameElement>(null); | ||
useMount(() => { | ||
jotformScript(formId); | ||
setTimeout(() => { | ||
if (ref?.current) { | ||
ref.current.style.opacity = "100"; | ||
} | ||
}, 1700); | ||
}, [formId, searchParam]); | ||
|
||
return ( | ||
<iframe | ||
ref={ref} | ||
src={`https://form.jotform.com/${formId}?${ | ||
searchParam ? searchParam.toString() : "" | ||
}`} | ||
id={`JotFormIFrame-${formId}`} | ||
title="" | ||
onLoad={() => { | ||
window.parent.scrollTo(0, 0); | ||
}} | ||
allow="geolocation; microphone; camera" | ||
allowFullScreen={true} | ||
className="h-full w-full min-w-full border-none opacity-0" | ||
></iframe> | ||
); | ||
}; | ||
|
||
const Loading = () => { | ||
const [showLoading, setShowLoading] = useState(true); | ||
useEffect(() => { | ||
setTimeout(() => { | ||
setShowLoading(false); | ||
}, 1200); | ||
}); | ||
|
||
return ( | ||
<> | ||
{showLoading && ( | ||
<div | ||
className="right-[calc(50%-20px)] top-1/2 h-12 w-12 animate-spin rounded-full border-4 border-gray-200 border-t-gray-1000" | ||
style={{ | ||
position: "absolute", | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export const JotformFrame = ({ formId, searchParam }: JotformFrameProps) => { | ||
return ( | ||
<> | ||
<Loading /> | ||
<Iframe formId={formId} searchParam={searchParam} /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.