@em1mn/consent-form
v0.9.8
Published
To use, include React and React DOM [CDN links](https://reactjs.org/docs/cdn-links.html):
Downloads
230
Keywords
Readme
To use, include React and React DOM CDN links:
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
Then include lib.${library}.umd.js
:
<script crossorigin src="https://unpkg.com/@em1mn/[email protected]/dist/lib.${library}.umd.js"></script>
Finally, add a <div>
with an appropriate id and load the form (remember to replace ${library}
):
<body>
<div id="fantastic-id"></div>
<script>
function initLib() {
if (!window.${library}) {
return;
}
document.removeEventListener("readystatechange", initLib);
const container = document.getElementById("fantastic-id");
const consentIds = [1, 2, 3, 4];
const graphQLEndpoint = "https://somegraphql.server/graphql";
const privacyLink = "/privacy";
const onSubmit = () => {
//window.location.href = "/thanks";
console.log("Submitted");
};
const onError = (error) => {
console.error(error);
};
const config = {
container,
consentIds,
onSubmit,
onError,
//privacyLink,
graphQLEndpoint,
};
${library}.Gull.contactForm.init(config);
/*
Alternatively
container.addEventListener("onSubmit", onSubmit);
container.addEventListener("onError", onError);
*/
}
document.addEventListener("readystatechange", initLib);
</script>
</body>