HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta content="utf-8" http-equiv="encoding" />
<title>Check Components Sandbox</title>
<!-- initialize onboard SDK, in production this is hosted on a CDN -->
<script src="https://cdn.checkhq.com/component-initialize.js"></script>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet" />
</head>
<body>
<div id="page" class="flex flex-col items-center justify-center w-screen h-screen text-gray-700">
<div id="modalElement" class="modal">
<div class="modal-content">
<div id="component-holder" style="flex-grow: 1; height: 100%"></div>
</div>
</div>
<form class="flex flex-col lg:w-1/2 rounded-lg max-w-xl bg-white rounded shadow-lg p-12" name="componentSetup" id="componentSetup" onsubmit="return false;">
<div class="mb-8">
<label for="api_key" class="block text-gray-700 text-sm font-bold mb-2">
Sandbox API Key
</label>
<input id="api_key" name="api_key" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" type="text" />
<div class="text-sm mt-2 text-gray-400">
Don't have one? Request a Check API key <u><a href="https://www.checkhq.com/contact">here</a></u>.
</div>
</div>
<div class="mb-8">
<label for="entity_id" class="block text-gray-700 text-sm font-bold mb-2">
Entity ID:
</label>
<input id="entity_id" name="entity_id" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" type="text" />
<div class="text-sm mt-2 text-gray-400">
(ex: "com_OkWFqNJLCjbfs2THoYKH", "emp_ahSPGYzHeca2Pe2nWo6b")
</div>
</div>
<label for="component" class="block text-gray-700 text-sm font-bold mb-2">Choose a Component:</label>
<select class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500" name="component" id="component">
<option value="onboard">Employee Onboarding</option>
<option value="ssn_setup">Employee SSN Setup</option>
<option value="withholdings_setup">Employee Withholdings Setup</option>
<option value="payment_setup">Employee Payment Setup</option>
<option value="paystubs">Employee Paystub</option>
<option value="post_tax_deductions">Employee Post-tax Deductions</option>
<option value="benefits">Employee Benefits</option>
<option value="onboard">Company Onboarding</option>
<option value="payment_setup">Company Payment Setup</option>
<option value="company_reports">Company Reports</option>
<option value="filing_authorization">Company Filing Authorization</option>
<option value="details">Company KYB</option>
<option value="accounting_integration">
Company Accounting Integration
</option>
<option value="run_payroll">
Run Payroll
</option>
</select>
<div class="flex mt-12 items-center justify-between">
<button id="generateComponent" style="background-color: #0070ff" class="mx-auto w-full sm:w-1/3 hover:bg-blue-700 text-white font-bold py-2 sm:px-4 rounded focus:outline-none focus:shadow-outline" type="button">
<div id="btnSpinner" class="spinner"></div>
<div id="btnText">Generate</div>
</button>
</div>
</form>
<a href="http://checkhq.com/" target="_blank">
<img class="h-8 mt-4" src="https://public-component-assets.s3.amazonaws.com/powered-by-check-badge.svg" alt="Powered by Check" />
</a>
</div>
</body>
</html>
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 40px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0, 0, 0); /* Fallback color */
background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
}
.modal-content {
background-color: #fefefe;
position: absolute;
left: 50%;
top: 50%;
padding: 10px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
border-radius: 20px;
width: 80%;
height: 90%;
max-height: 700px;
max-width: 900px;
}
.spinner {
display: none;
margin: auto;
height: 25px;
width: 25px;
border: 3px solid rgba(255, 255, 255, 0.2);
border-top-color: rgba(255, 255, 255, 0.8);
border-radius: 50%;
animation: rotation 0.6s infinite linear;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
// Get the whole page
let page = document.getElementById("page");
// Get the modal
let componentModal = document.getElementById("modalElement");
// Get the button
let btn = document.getElementById("generateComponent");
// Get the button elements
let btnSpinner = document.getElementById("btnSpinner");
let btnText = document.getElementById("btnText");
// Define global Component handler
let handler = undefined;
// When the user clicks anywhere outside of the modal, close it
page.onclick = function (event) {
if (event.target == componentModal && handler) {
handler.close();
componentModal.style.display = "none";
}
};
// Spinner for button
function spinnerOn() {
btnSpinner.style.display = "block";
btnText.style.display = "none";
}
function spinnerOff() {
btnSpinner.style.display = "none";
btnText.style.display = "block";
}
// When the user clicks the button, generate the component
btn.onclick = async function () {
spinnerOn();
let componentUrl = await generateComponentURL(
document.forms["componentSetup"]["entity_id"].value,
document.forms["componentSetup"]["component"].value,
document.forms["componentSetup"]["api_key"].value
);
if (componentUrl) {
launchComponent(componentUrl);
} else {
spinnerOff();
alert("Invalid, please correct fields to continue.");
}
};
async function urlFromResponse(response) {
if (!response.ok) return false;
const body = await response.json();
return body["url"];
}
async function generateComponentURL(entity_id, component_type, api_key) {
const entity_prefix = entity_id.substring(0, 3);
let entity_type = "";
if (entity_prefix === "emp") {
entity_type = "employees";
} else if (entity_prefix === "com") {
entity_type = "companies";
} else {
return false;
}
// ----------------------------------------------
// For the purposes of this demo we set up a cloud function that
// makes calls to Check's API directly without authentication.
// STRONG DISCLAIMER: This approach SHOULD NOT be used in production.
// Calls to Check's API should always be authenticated by your backend first.
// -----------------------------------------------
const requestPath = `https://cors-anywhere.herokuapp.com/https://sandbox.checkhq.com/${entity_type}/${entity_id}/${
component_type == "onboard" ? `onboard` : `components/${component_type}`
}`;
response = await fetch(requestPath, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer " + api_key
},
body: JSON.stringify({
signer_name: "signer_name",
signer_title: "signer_title",
email: "signer@example.com"
})
});
return urlFromResponse(response);
}
async function launchComponent(componentUrl) {
try {
handler = CheckComponent.create({
link: componentUrl,
onClose: () => console.log("onClose"),
onEvent: (event, data) => {
console.log(`Event: ${event} with data: `, data);
}
});
handler.open();
const embeddedComponentElement = document.getElementById(
"check-component-embedded-div"
);
if (embeddedComponentElement) {
const componentHolder = document.getElementById("component-holder");
componentHolder.appendChild(embeddedComponentElement);
setTimeout(() => {
spinnerOff();
componentModal.style.display = "block";
}, 2000); // launch modal
return handler;
}
} catch (err) {
console.error(err);
}
}
Also see: Tab Triggers