<script>
  if ('paintWorklet' in CSS && 'CSSUnitValue' in window) {
    // load this CodePen's JS file as the paint worklet
    CSS.paintWorklet.addModule('/lonekorean/pen/QmLpJJ.js');
  } else {
    document.querySelector('html').classList.add('no-support');
  }
</script>

<div class="container">
  <div class="slot">
    <div class="placeholder"></div>
  </div>
  <div class="slot">
    <div class="placeholder"></div>
  </div>
  <div class="slot">
    <div class="placeholder"></div>
  </div>
</div>

<div class="warning">
  <i class="fas fa-exclamation-triangle"></i><br>
  This Houdini demo requires the <strong>CSS Paint API</strong> and <strong>Typed OM</strong>.<br>
  Use <strong>Chrome</strong> and go to <strong>chrome://flags</strong> and enable <strong>Experimental Web Platform features</strong>.<br>
  Also make sure you're serving over <strong>https</strong> or <strong>localhost</strong>.
</div>
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0 20px;
  background-image: linear-gradient(to bottom, #70e1f5, #ffd194);
  font: 1rem/1.25 'Mukta Mahee', sans-serif;
}

.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 20px;
  align-items: center;
  height: 100%;
}

.slot {
  display: flex;
  justify-content: center;
}

.placeholder {
  background-image: paint(placeholder-box-props);

  background-color: #fff;
  width: 120px;
  height: 120px;
  max-height: 100vh;
  overflow: auto;
  resize: both;
}

.slot:nth-child(1) .placeholder {
  border: 2px solid #fd7e14;
}

.slot:nth-child(2) .placeholder {
  border: 6px solid #228be6;
}

.slot:nth-child(3) .placeholder {
  border: 1rem solid #e64980;
}

.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 PlaceholderBoxPropsPainter {
    static get inputProperties() {
      return ['border-top-width', 'border-top-color'];
    }

    paint(ctx, size, props) {
      // default values
      ctx.lineWidth = 2;
      ctx.strokeStyle = '#666';

      // set line width to top border width (if exists)
      let borderTopWidthProp = props.get('border-top-width');
      if (borderTopWidthProp) {
        ctx.lineWidth = borderTopWidthProp.value;
      }

      // set stroke style to top border color (if exists)
      let borderTopColorProp = props.get('border-top-color');
      if (borderTopColorProp) {
        ctx.strokeStyle = borderTopColorProp.toString();
      }

      // 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-props', PlaceholderBoxPropsPainter);
}

External CSS

  1. https://fonts.googleapis.com/css?family=Mukta+Mahee:400,700
  2. https://use.fontawesome.com/releases/v5.0.6/css/all.css

External JavaScript

This Pen doesn't use any external JavaScript resources.