Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1 class="title">Polyomino Control Web Component</h1>
<h2 class="subtitle">
  <a target="_blank" href="https://github.com/cemulate/web-component-polyomino"><span class="tag is-link">Github</span></a>
  <a target="_blank" href="https://npmjs.com/web-component-polyomino"><span class="tag is-danger">NPM</span></a>
</h2>
<section class="section">
  <div class="container">
    <h3 class="title">Create or edit</h3>
    <p>Interactively create or edit polyominos and polyomino-shaped regions. Use the mouse to click cells or "paint" by dragging. (Click to see the values change below!)</p>
    <br>
    <p>
      <polyomino-control id="poly1" size="5" mode="create" value="[[1,1],[1,2],[1,3],[2,2]]"></polyomino-control>
      <polyomino-control id="poly2" size="5" mode="create-region" value="[[1,0],[2,0],[3,0],[1,1],[2,1],[3,1]]"></polyomino-control>
    </p>
    <br>
    <p>
      <code>document.getElementById('poly1').value == <span id="poly1value"></span></code><br>
      <code>document.getElementById('poly2').value == <span id="poly2value"></span></code>
    </p>
  </div>
</section>
<hr>
<section id="display-row" class="section">
  <div class="container">
    <h2 class="title">Display</h2>
    <p>Display static polyominos</p><br>
    <p>
      <polyomino-control mode="display" size=4 value="[[0,0],[0,1],[1,0],[1,1]]"></polyomino-control>
      <polyomino-control mode="display" size=4 value="[[0,0],[0,1],[0,2],[0,3]]"></polyomino-control>
      <polyomino-control mode="display" size=4 value="[[0,0],[1,0],[1,1],[1,2]]"></polyomino-control>
      <polyomino-control mode="display" size=4 value="[[0,0],[1,0],[1,1],[2,1]]"></polyomino-control>
    </p>
  </div>
</section>
<hr>
<section class="section">
  <div class="container">
    <h2 class="title">Display Multiple</h2>
    <p>Display multiple polyominos together with automatically contrasting colors</p>
    <p>
      <polyomino-control id="poly3" mode="display-multiple" size=4 value="[ [], [[0,0],[0,1],[0,2],[1,1]], [[1,2],[2,2],[2,1],[2,0],[1,0]]]"></polyomino-control>
    </p>
  </div>
</section>

              
            
!

CSS

              
                body { margin: 20px }
code { color: black }

polyomino-control {
  display: inline-block;
}

#poly1 {
  margin-right: 20px;
  width: 300px;
  height: 300px;
}

#poly2 {
  margin-right: 20px;
  width: 300px;
  height: 300px;
  background-color: lightgray;
}

#display-row polyomino-control {
  margin-right: 20px;
  width: 80px;
  height: 80px;
  --cell-color: red;
}

#poly3 {
  width: 200px;
  height: 200px;
}
              
            
!

JS

              
                const el = document.getElementById.bind(document);
function updateLive() {
    el('poly1value').innerHTML = JSON.stringify(el('poly1').value);
    el('poly2value').innerHTML = JSON.stringify(el('poly2').value);
}

updateLive();
el('poly1').addEventListener('change', updateLive);
el('poly2').addEventListener('change', updateLive);
              
            
!
999px

Console