JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<script>
if ('paintWorklet' in CSS) {
// load this CodePen's JS file as the paint worklet
CSS.paintWorklet.addModule('/lonekorean/pen/wmwJQX.js');
} else {
document.querySelector('html').classList.add('no-support');
}
</script>
<header class="placeholder"></header>
<div class="content-wrapper">
<main>
<h1>Awesome Mockup</h1>
<p>This uses placeholder boxes created with the CSS Paint API. Neat! You can resize them by dragging their bottom right corners.</p>
<div class="row">
<div class="placeholder"></div>
<div class="placeholder"></div>
<div class="placeholder"></div>
</div>
<p>That's all. Thanks!</p>
</main>
<aside>
<div class="placeholder"></div>
</aside>
</div>
<div class="warning">
<i class="fas fa-exclamation-triangle"></i><br>
This Houdini demo requires the <strong>CSS Paint API</strong>.<br>
Use <strong>Chrome</strong>.<br>
Also make sure you're serving over <strong>https</strong> or <strong>localhost</strong>.
</div>
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 20px;
color: #666;
background-color: #eee;
font: 1rem/1.25 'Mukta Mahee', sans-serif;
}
.placeholder {
background-image: paint(placeholder-box);
background-color: #fff;
max-width: 100%;
border: 2px solid #666;
overflow: auto;
resize: both;
}
header {
width: 600px;
height: 100px;
margin: 0 auto;
}
.content-wrapper {
display: flex;
width: 600px;
margin: 40px auto 0;
font-size: 1.25rem;
line-height: 1;
}
main {
width: 440px;
}
h1 {
margin: 0;
font-weight: normal;
}
p {
line-height: 1.25;
}
.row {
margin: 0 10px 0 -10px;
}
.row::after {
content: '';
display: block;
clear: both;
}
main .placeholder {
float: left;
width: 100px;
height: 100px;
margin: 10px;
}
aside {
width: 140px;
margin-left: 20px;
}
aside .placeholder {
width: 140px;
height: 320px;
margin: 0 auto;
}
.warning {
display: none;
position: absolute;
top: 10px;
left: 10px;
right: 10px;
padding: 20px;
border-top: 4px dashed #e8590c;
background-color: #ffe8cc;
color: #e8590c;
text-align: center;
}
.no-support .warning {
display: block;
}
.warning .fas {
margin-bottom: 1rem;
font-size: 1.5rem;
}
/*
This CodePen's JS file has been "hijacked" to serve as the paint worklet file. The if check below ensures the code only runs when referenced as such. JavaScript for the page is at the top of the HTML. I'm only doing this to squeeze everything into one CodePen.
IMPORTANT: If you fork, update the CodePen JS file path in the HTML.
ALSO IMPORTANT: If you edit code here, disable cache and reload. Live preview won't pick up changes in the paint worklet.
*/
if (typeof registerPaint !== 'undefined') {
class PlaceholderBoxPainter {
paint(ctx, size) {
ctx.lineWidth = 2;
ctx.strokeStyle = '#666';
// draw line from top left to bottom right
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(size.width, size.height);
ctx.stroke();
// draw line from top right to bottom left
ctx.beginPath();
ctx.moveTo(size.width, 0);
ctx.lineTo(0, size.height);
ctx.stroke();
}
}
registerPaint('placeholder-box', PlaceholderBoxPainter);
}
Also see: Tab Triggers