<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ivan</title>
    <description>The latest articles on DEV Community by Ivan (@pinguxx).</description>
    <link>https://dev.to/pinguxx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg</url>
      <title>DEV Community: Ivan</title>
      <link>https://dev.to/pinguxx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pinguxx"/>
    <language>en</language>
    <item>
      <title>AI writes code fast, so I use skills to build the gates that catch the bugs unit tests miss</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Tue, 01 Dec 2026 13:41:00 +0000</pubDate>
      <link>https://dev.to/pinguxx/i-writes-code-fast-so-i-use-skills-to-build-the-gates-that-catch-the-bugs-unit-tests-miss-1eog</link>
      <guid>https://dev.to/pinguxx/i-writes-code-fast-so-i-use-skills-to-build-the-gates-that-catch-the-bugs-unit-tests-miss-1eog</guid>
      <description>&lt;h3&gt;
  
  
  Why green unit tests stopped giving me confidence
&lt;/h3&gt;

&lt;p&gt;When a coding agent can generate a new component or reactive helper in 20 seconds, writing code is no longer the bottleneck. The bottleneck is proving that the code holds up under cases nobody thought to write an example test for.&lt;/p&gt;

&lt;p&gt;When I built the micro-signal runtime and protocol adapters for &lt;code&gt;@wcomp/elementum&lt;/code&gt;, all 200+ unit tests were green and line coverage sat above 95%. Every happy path passed. Every regression test I wrote passed.&lt;/p&gt;

&lt;p&gt;Then I asked a harder question: what happens when two signals update inside a &lt;code&gt;batch()&lt;/code&gt; across an arbitrary dependency graph, or when one subscriber throws halfway through a flush, or when an async fetcher reads its own state?&lt;/p&gt;

&lt;p&gt;No example-based unit test answered those questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  The 4-skill workflow that replaced ad-hoc prompting
&lt;/h3&gt;

&lt;p&gt;Instead of asking a chat window to "write more tests" and hoping for the best, I installed my portable skill pack (&lt;code&gt;npx skills add pinguxx/skills --global&lt;/code&gt;) and ran four skills in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;spec&lt;/code&gt;:&lt;/strong&gt; Before touching code, the agent writes down measurable success criteria, explicit non-goals, and state boundaries. No implementation starts while requirements are vague.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;plan&lt;/code&gt;:&lt;/strong&gt; Turns the spec into a short file-level checklist with explicit invariants and the exact verification commands that must pass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;implement-plan&lt;/code&gt;:&lt;/strong&gt; Executes the approved plan step-by-step with tight feedback loops and zero scope creep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;formal-verification&lt;/code&gt;:&lt;/strong&gt; Targets the risky 5% of the codebase where a silent bug hurts most (reactive graphs, state machines, retry loops, untrusted input parsers) and generates an exhaustive, project-local verifier instead of more example tests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You do not need formal methods for a button or a CSS layout. You run &lt;code&gt;formal-verification&lt;/code&gt; on the modules where ordering, concurrency, or untrusted input can corrupt state silently.&lt;/p&gt;

&lt;h3&gt;
  
  
  What &lt;code&gt;formal-verification&lt;/code&gt; generated and caught
&lt;/h3&gt;

&lt;p&gt;Running &lt;code&gt;formal-verification&lt;/code&gt; against &lt;code&gt;@wcomp/elementum&lt;/code&gt; produced a zero-dependency Node script (&lt;code&gt;tools/verify-formal-invariants.js&lt;/code&gt;, run with &lt;code&gt;npm run verify:formal&lt;/code&gt;) that checks 6,162 states and graph topologies in under one second:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every 4-node reactive DAG topology (1,440 graphs) for glitch-free &lt;code&gt;computed()&lt;/code&gt; updates&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;batch()&lt;/code&gt; fault isolation when one subscriber throws&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AsyncSignal&lt;/code&gt; out-of-order race monotonicity and self-subscription freedom&lt;/li&gt;
&lt;li&gt;Untrusted A2UI graph depth, cycle, and URL scheme bounds&lt;/li&gt;
&lt;li&gt;Multi-instance &lt;code&gt;&amp;lt;el-toaster&amp;gt;&lt;/code&gt; active-deck exclusivity&lt;/li&gt;
&lt;li&gt;AG-UI multi-run &lt;code&gt;runId&lt;/code&gt; and JSON Patch path allowlist isolation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember that the unit test suite was already green at 95%+ line coverage. The very first run of &lt;code&gt;npm run verify:formal&lt;/code&gt; failed immediately on two real bugs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A throwing subscriber inside &lt;code&gt;batch()&lt;/code&gt; aborted the flush loop early and silently dropped updates for sibling subscribers.&lt;/li&gt;
&lt;li&gt;Reading an &lt;code&gt;AsyncSignal&lt;/code&gt; property inside its own fetcher created a self-subscription loop that re-triggered fetches endlessly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Neither bug appeared in normal usage. Both took less than 20 minutes to fix once the verifier printed the exact failing state.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to run this in your own repo
&lt;/h3&gt;

&lt;p&gt;Install the skill pack once globally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx skills add pinguxx/skills --global
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pick the one module in your repository that would hurt most if it failed silently, and invoke &lt;code&gt;formal-verification&lt;/code&gt; on it. Wire the generated script into CI next to &lt;code&gt;npm test&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As code generation gets cheaper, your highest-impact work shifts from typing implementations to defining invariants and running the skills that turn them into permanent CI gates.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Portable skills (&lt;code&gt;spec&lt;/code&gt;, &lt;code&gt;plan&lt;/code&gt;, &lt;code&gt;implement-plan&lt;/code&gt;, &lt;code&gt;formal-verification&lt;/code&gt;): &lt;a href="https://github.com/pinguxx/skills" rel="noopener noreferrer"&gt;https://github.com/pinguxx/skills&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Verifier in action (&lt;code&gt;npm run verify:formal&lt;/code&gt;): &lt;a href="https://github.com/pinguxx/Elementum" rel="noopener noreferrer"&gt;https://github.com/pinguxx/Elementum&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>claudecode</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Build an Accessible Web Component in 60 Lines With Zero Build Step and Headless Behaviors</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Sun, 29 Nov 2026 03:22:49 +0000</pubDate>
      <link>https://dev.to/pinguxx/build-an-accessible-web-component-in-60-lines-with-zero-build-step-and-headless-behaviors-49b3</link>
      <guid>https://dev.to/pinguxx/build-an-accessible-web-component-in-60-lines-with-zero-build-step-and-headless-behaviors-49b3</guid>
      <description>&lt;p&gt;Most UI libraries give you a fixed set of components. Eventually your app needs a custom widget that is not in the catalog, and you end up rewriting pointer handling, Escape key dismissal, ARIA attributes, dark mode, mobile hover guards, and event cleanup by hand.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;@wcomp/elementum&lt;/code&gt; (&lt;code&gt;v0.9.0&lt;/code&gt;), the same base class, micro-signals, and headless behaviors that power all 115 built-in elements are exported directly so you can build your own components in one file with zero build step.&lt;/p&gt;

&lt;p&gt;Here is a complete &lt;code&gt;&amp;lt;my-action-panel&amp;gt;&lt;/code&gt; component in plain ES module JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Elementum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;createPressBehavior&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;createDisclosureBehavior&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;createDismissableLayer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;triggerHaptic&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;announce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/behaviors'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyActionPanel&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Elementum&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;observedAttributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'label'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'disabled'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'open'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'haptic'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Actions'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;open&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="sb"&gt;`
    :host {
      display: inline-block;
      position: relative;
      font-family: var(--el-font-sans, system-ui, sans-serif);
    }

    button {
      padding: 8px 14px;
      border-radius: var(--el-radius-md, 8px);
      border: 1px solid var(--el-surface-border, #e2e8f0);
      background: var(--el-surface-card, #ffffff);
      color: var(--el-text-primary, #0f172a);
      cursor: pointer;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
      outline: none;
      transition: background-color 150ms ease, transform 100ms ease;
    }

    button:focus-visible {
      box-shadow: 0 0 0 3px var(--el-focus-ring, rgba(37, 99, 235, 0.4));
    }

    :host([data-pressed]) button {
      transform: scale(0.97);
    }

    @media (hover: hover) and (pointer: fine) {
      button:not([disabled]):hover {
        background: var(--el-surface-muted, #f3f4f6);
      }
    }

    @media (prefers-reduced-motion: reduce) {
      button {
        transition: none;
      }
      :host([data-pressed]) button {
        transform: none;
      }
    }

    .panel {
      margin-top: 8px;
      padding: 12px;
      border-radius: var(--el-radius-md, 8px);
      border: 1px solid var(--el-surface-border, #e2e8f0);
      background: var(--el-surface-elevated, #ffffff);
      color: var(--el-text-primary, #0f172a);
    }
  `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;attributeChanged&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_oldVal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newVal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'label'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newVal&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'Actions'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'disabled'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;boolAttr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'disabled'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'open'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;boolAttr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'open'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;rendered&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;trigger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'button'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;panel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.panel'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;createPressBehavior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;isDisabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;disclosure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createDisclosureBehavior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;initialOpen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;onOpenChange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;boolAttr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'haptic'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;triggerHaptic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHostState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'open'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isOpen&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'open'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'close'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isOpen&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nf"&gt;announce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isOpen&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'Panel opened'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Panel closed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;createDismissableLayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;onDismiss&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="sb"&gt;`
      &amp;lt;button type="button" part="trigger" ?disabled=${() =&amp;gt; this.disabled.value}&amp;gt;
        ${() =&amp;gt; this.label.value}
      &amp;lt;/button&amp;gt;
      &amp;lt;div class="panel" part="panel"&amp;gt;
        &amp;lt;slot&amp;gt;&amp;lt;/slot&amp;gt;
      &amp;lt;/div&amp;gt;
    `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'my-action-panel'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'my-action-panel'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MyActionPanel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Five patterns doing the heavy lifting
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fine-grained bindings with arrow functions.&lt;/strong&gt; Writing &lt;code&gt;${() =&amp;gt; this.label.value}&lt;/code&gt; inside &lt;code&gt;html&lt;/code&gt; updates only that text node when &lt;code&gt;label&lt;/code&gt; changes. The Shadow DOM does not re-render. Outside a component, you can also use &lt;code&gt;bindAttr&lt;/code&gt;, &lt;code&gt;bindClass&lt;/code&gt;, and &lt;code&gt;bindText&lt;/code&gt; from &lt;code&gt;@wcomp/elementum&lt;/code&gt; for surgical DOM updates in vanilla JS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic cleanup via &lt;code&gt;this.signal&lt;/code&gt;.&lt;/strong&gt; Every &lt;code&gt;Elementum&lt;/code&gt; instance provides an &lt;code&gt;AbortSignal&lt;/code&gt; that aborts in &lt;code&gt;disconnectedCallback()&lt;/code&gt;. Passing &lt;code&gt;signal: this.signal&lt;/code&gt; to &lt;code&gt;createPressBehavior&lt;/code&gt;, &lt;code&gt;createDisclosureBehavior&lt;/code&gt;, and &lt;code&gt;createDismissableLayer&lt;/code&gt; removes every listener on unmount with zero manual teardown code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Predictable light and dark mode with layered tokens.&lt;/strong&gt; Using &lt;code&gt;--el-surface-card&lt;/code&gt;, &lt;code&gt;--el-surface-elevated&lt;/code&gt;, &lt;code&gt;--el-text-primary&lt;/code&gt;, &lt;code&gt;--el-color-primary-text&lt;/code&gt;, and &lt;code&gt;--el-focus-ring&lt;/code&gt; makes the component follow &lt;code&gt;&amp;lt;html data-theme="dark"&amp;gt;&lt;/code&gt; across Chromium, Firefox, and Safari. Default tokens live inside &lt;code&gt;@layer elementum.tokens&lt;/code&gt;, so app-level overrides win without &lt;code&gt;!important&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile-first interaction defaults.&lt;/strong&gt; Gating &lt;code&gt;:hover&lt;/code&gt; inside &lt;code&gt;@media (hover: hover) and (pointer: fine)&lt;/code&gt; prevents sticky hover states on touchscreens, &lt;code&gt;touch-action: manipulation&lt;/code&gt; removes tap delay, and &lt;code&gt;triggerHaptic()&lt;/code&gt; adds coarse-pointer vibration that skips desktop and &lt;code&gt;prefers-reduced-motion: reduce&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standard DOM events and framework interop.&lt;/strong&gt; &lt;code&gt;this.emit('open', { open: true })&lt;/code&gt; dispatches a bubbling, composed &lt;code&gt;CustomEvent&lt;/code&gt;, so &lt;code&gt;addEventListener&lt;/code&gt;, React 18 and 19, Vue 3, Svelte 5, and Angular 19+ all receive it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  3. Adding native form participation
&lt;/h3&gt;

&lt;p&gt;If your custom element is a form control, add &lt;code&gt;static formAssociated = true&lt;/code&gt; and call &lt;code&gt;this.setFormValue(val)&lt;/code&gt; when the value changes. The base class handles &lt;code&gt;el.form&lt;/code&gt;, bidirectional &lt;code&gt;.checked&lt;/code&gt;, &lt;code&gt;.value&lt;/code&gt;, and &lt;code&gt;.disabled&lt;/code&gt; property reflection, &lt;code&gt;&amp;lt;button type="reset"&amp;gt;&lt;/code&gt; via &lt;code&gt;formResetCallback()&lt;/code&gt; (restoring &lt;code&gt;defaultChecked&lt;/code&gt; and &lt;code&gt;defaultValue&lt;/code&gt; captured on first connect), &lt;code&gt;&amp;lt;fieldset disabled&amp;gt;&lt;/code&gt; via &lt;code&gt;formDisabledCallback()&lt;/code&gt;, and &lt;code&gt;ElementInternals&lt;/code&gt; validity checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Try it live in StackBlitz
&lt;/h3&gt;

&lt;p&gt;You can edit &lt;code&gt;my-action-panel.js&lt;/code&gt;, toggle light and dark mode, and test Escape dismissal live in StackBlitz with zero setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open in StackBlitz: &lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/examples/custom-component-demo?file=my-action-panel.js" rel="noopener noreferrer"&gt;https://stackblitz.com/github/pinguxx/Elementum/tree/main/examples/custom-component-demo?file=my-action-panel.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live hosted demo: &lt;a href="https://elementum-sage.vercel.app/examples/custom-component-demo/" rel="noopener noreferrer"&gt;https://elementum-sage.vercel.app/examples/custom-component-demo/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Verify your markup before shipping
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;npx @wcomp/elementum check&lt;/code&gt; locally (or call &lt;code&gt;lint_accessibility&lt;/code&gt; on the hosted MCP server at &lt;code&gt;https://elementum-sage.vercel.app/mcp&lt;/code&gt;) to catch missing labels, &lt;code&gt;transition: all&lt;/code&gt;, &lt;code&gt;scale(0)&lt;/code&gt;, bare &lt;code&gt;100vh&lt;/code&gt;, hardcoded hex colors, and common API mistakes automatically.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full authoring guide: &lt;a href="https://github.com/pinguxx/Elementum/blob/main/docs/authoring-components.md" rel="noopener noreferrer"&gt;https://github.com/pinguxx/Elementum/blob/main/docs/authoring-components.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live component catalog (115 elements): &lt;a href="https://elementum-sage.vercel.app/examples/index.html" rel="noopener noreferrer"&gt;https://elementum-sage.vercel.app/examples/index.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>webcomponents</category>
      <category>a11y</category>
    </item>
    <item>
      <title>MCP, AG-UI, and A2UI: How the Three AI-UI Protocols Fit Together (With Live Zero-Dep Demos)</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Mon, 23 Nov 2026 16:18:00 +0000</pubDate>
      <link>https://dev.to/pinguxx/mcp-ag-ui-and-a2ui-how-the-three-ai-ui-protocols-fit-together-with-live-zero-dep-demos-2ga6</link>
      <guid>https://dev.to/pinguxx/mcp-ag-ui-and-a2ui-how-the-three-ai-ui-protocols-fit-together-with-live-zero-dep-demos-2ga6</guid>
      <description>&lt;p&gt;If you have been building AI interfaces in 2026, you have probably seen three acronyms show up in the same week: &lt;strong&gt;MCP&lt;/strong&gt;, &lt;strong&gt;AG-UI&lt;/strong&gt;, and &lt;strong&gt;A2UI&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A common question from frontend engineers is: &lt;em&gt;"Are these competing standards? Which one should I pick?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The short answer is &lt;strong&gt;they do not compete&lt;/strong&gt;. They solve three different layers of the AI-to-UI lifecycle:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;When It Runs&lt;/th&gt;
&lt;th&gt;What It Solves&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1. Build / Prompt Time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;MCP&lt;/strong&gt; (Model Context Protocol)&lt;/td&gt;
&lt;td&gt;While a coding agent writes your app&lt;/td&gt;
&lt;td&gt;Gives the agent verified component schemas, design tokens, and WCAG checks so it stops hallucinating props.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2. Runtime Event Stream&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;AG-UI&lt;/strong&gt; (Agent-User Interaction)&lt;/td&gt;
&lt;td&gt;While an agent executes a task&lt;/td&gt;
&lt;td&gt;Streams lifecycle events, reasoning steps, tool-call approvals (HITL), and RFC 6902 JSON Patch state deltas.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;3. Runtime Declarative UI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;A2UI&lt;/strong&gt; (Agent-to-UI)&lt;/td&gt;
&lt;td&gt;When an agent generates UI on the fly&lt;/td&gt;
&lt;td&gt;Streams structured JSON component trees into a locked client catalog with zero executable code and zero &lt;code&gt;innerHTML&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In &lt;strong&gt;&lt;code&gt;@wcomp/elementum@0.8.0&lt;/code&gt;&lt;/strong&gt;, we implemented all three layers on top of a single zero-dependency Web Components foundation (109 WCAG 2.2 AA components that work in React 18/19, Vue 3, Svelte 5, Next.js, and Vanilla HTML).&lt;/p&gt;

&lt;p&gt;Here is how each layer works in practice, with live browser demos you can inspect right now.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9udlqxude8hjl47c2m4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9udlqxude8hjl47c2m4.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 1: MCP (Verifiable Component Contract at Build Time)
&lt;/h3&gt;

&lt;p&gt;When an AI coding agent generates UI from memory, it invents attribute names, misses ARIA labels, and forgets responsive layouts.&lt;/p&gt;

&lt;p&gt;Elementum exposes its W3C Custom Elements Manifest (&lt;code&gt;custom-elements.json&lt;/code&gt;), design tokens, markup validator (&lt;code&gt;validate_component_usage&lt;/code&gt;), and static accessibility linter (&lt;code&gt;lint_accessibility&lt;/code&gt;) over a hosted Vercel Edge MCP endpoint (100/100 on &lt;code&gt;mcptry.com&lt;/code&gt;):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://elementum-sage.vercel.app/mcp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can configure any project (React, Next.js, Vue, Svelte, or Vanilla) in one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install @wcomp/elementum &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npx @wcomp/elementum init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or connect Claude Code directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http elementum https://elementum-sage.vercel.app/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our reproducible &lt;a href="https://github.com/pinguxx/Elementum/blob/main/benchmarks/agent-eval/RESULTS.md" rel="noopener noreferrer"&gt;4-Arm AI-Agent UI Benchmark&lt;/a&gt; scored in headless Chromium with &lt;code&gt;@axe-core/playwright&lt;/code&gt;, Elementum arms achieved &lt;strong&gt;0px desktop and mobile overflow&lt;/strong&gt; and &lt;strong&gt;0-1 severe WCAG violations&lt;/strong&gt;, compared to &lt;strong&gt;69px-585px mobile overflow&lt;/strong&gt; and &lt;strong&gt;5-8 severe WCAG violations&lt;/strong&gt; in conventional CSS and raw HTML baselines.&lt;/p&gt;




&lt;h3&gt;
  
  
  Layer 2: AG-UI (Runtime Execution, Tool Approvals &amp;amp; JSON Patch State)
&lt;/h3&gt;

&lt;p&gt;Once your app is deployed, users interact with live agents that think, call tools, request human approval, and update application state incrementally.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@wcomp/elementum/ag-ui&lt;/code&gt; provides a zero-dependency reactive store (&lt;code&gt;createAgUiStore&lt;/code&gt;) that consumes Server-Sent Events (SSE) and applies RFC 6902 JSON Patch &lt;code&gt;STATE_DELTA&lt;/code&gt; updates straight to Elementum micro-signals without Virtual DOM re-render cascades:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/tokens.css'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createAgUiStore&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/ag-ui'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createAgUiStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'STATE_DELTA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'replace'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'/progress'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live AG-UI Demo:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/examples/ag-ui.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/examples/ag-ui.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AG-UI Docs:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/docs.html#ag-ui-protocol" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/docs.html#ag-ui-protocol&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Layer 3: A2UI (Safe Declarative Agent UI at Runtime)
&lt;/h3&gt;

&lt;p&gt;Sometimes a fixed chat bubble is not enough. An agent helping a user rebook a flight or adjust a billing cap should render real seat chips, switches, meters, and confirmation buttons without executing untrusted HTML or JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@wcomp/elementum/a2ui&lt;/code&gt; (&lt;code&gt;createA2UiSurface&lt;/code&gt;) maps streaming A2UI JSONL messages (&lt;code&gt;dataModelUpdate&lt;/code&gt;, &lt;code&gt;surfaceUpdate&lt;/code&gt;, &lt;code&gt;beginRendering&lt;/code&gt;, &lt;code&gt;deleteSurface&lt;/code&gt;) onto a &lt;strong&gt;locked catalog&lt;/strong&gt; of native Elementum Web Components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/tokens.css'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createA2UiSurface&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/a2ui'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;surface&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createA2UiSurface&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;allowedTypes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Card'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Column'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ChoiceChip'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Button'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;onAction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Agent action:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;actionName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;surface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a2ui-host'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;surface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunkFromStream&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key security guarantees built in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Locked Catalog Allowlist&lt;/strong&gt;: Unregistered or disallowed node types (like script/iframe tags) are silently dropped and reported in &lt;code&gt;surface.blockedTypes.value&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero &lt;code&gt;innerHTML&lt;/code&gt;&lt;/strong&gt;: All text and labels bind via &lt;code&gt;textContent&lt;/code&gt; and fine-grained signal effects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inline Handler &amp;amp; URL Stripping&lt;/strong&gt;: &lt;code&gt;on*&lt;/code&gt; attributes and &lt;code&gt;javascript:&lt;/code&gt;/&lt;code&gt;data:&lt;/code&gt; URLs are rejected automatically.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live A2UI Playground (with progressive JSONL stream simulation):&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/examples/a2ui.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/examples/a2ui.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full A2UI Guide:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum/blob/main/docs/a2ui.md" rel="noopener noreferrer"&gt;docs/a2ui.md on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Explore the Full 4-Chapter Platform Story
&lt;/h3&gt;

&lt;p&gt;If you want to see how design tokens (Penpot/Figma), framework parity (React 19, Vue 3, Next.js DSD SSR, Vanilla HTML), and the 3 AI protocols fit together in one place, start here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Connected Platform Showcase:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/showcase.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/showcase.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Build 2-Line CDN:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;  &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@wcomp/elementum/tokens.css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@wcomp/elementum"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum" rel="noopener noreferrer"&gt;github.com/pinguxx/Elementum&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try &lt;code&gt;npm install @wcomp/elementum &amp;amp;&amp;amp; npx @wcomp/elementum init&lt;/code&gt; in a real project, I would genuinely love your first-attempt feedback as we harden the path toward &lt;code&gt;1.0.0&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>webcomponents</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Elementum: An AI-Native UI Platform with Built-in MCP, Agent Runtime &amp; 109 Zero-Dep Web Components</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Sun, 22 Nov 2026 18:51:25 +0000</pubDate>
      <link>https://dev.to/pinguxx/elementum-an-ai-native-ui-platform-with-built-in-mcp-agent-runtime-109-zero-dep-web-components-9oi</link>
      <guid>https://dev.to/pinguxx/elementum-an-ai-native-ui-platform-with-built-in-mcp-agent-runtime-109-zero-dep-web-components-9oi</guid>
      <description>&lt;p&gt;When you build modern web applications (especially AI-assisted or agentic ones), you usually end up wiring together half a dozen separate tools: a UI component library, a framework-specific wrapper layer, custom chat/streaming/tool-call widgets, an accessibility test harness, and ad-hoc instructions for your AI coding assistant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Elementum&lt;/strong&gt; (&lt;code&gt;@wcomp/elementum@0.7.0&lt;/code&gt;) brings all of those pieces together into one open-source, zero-dependency UI engineering platform built on standard Web Components.&lt;/p&gt;

&lt;p&gt;In this walkthrough, I'll cover what makes Elementum different, show real code examples you can run immediately in live Vercel demos or &lt;strong&gt;StackBlitz&lt;/strong&gt;, and share our automated 3-way comparison of building the exact same app in &lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Vue 3&lt;/strong&gt;, and &lt;strong&gt;Vanilla JS&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum" rel="noopener noreferrer"&gt;github.com/pinguxx/Elementum&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Interactive Showcase:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/" rel="noopener noreferrer"&gt;elementum-sage.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Agent Studio Demo:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/examples/agent-studio.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/examples/agent-studio.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component Catalog (109 elements):&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/examples/index.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/examples/index.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit &amp;amp; Verification Hub:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum/blob/main/AUDITS.md" rel="noopener noreferrer"&gt;AUDITS.md&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Built-in Model Context Protocol (MCP) Server (Stdio + Vercel Edge)
&lt;/h2&gt;

&lt;p&gt;Elementum ships with its own &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt; server (&lt;code&gt;2025-03-26&lt;/code&gt; / &lt;code&gt;2025-06-18&lt;/code&gt; compliant) so coding assistants like Claude Code, Cursor, Gemini CLI, and Copilot can inspect the library directly instead of guessing prop names or slot structures.&lt;/p&gt;

&lt;p&gt;Connect locally over stdio:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx elementum-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or connect directly to the hosted &lt;strong&gt;Vercel Edge&lt;/strong&gt; Streamable HTTP endpoint (zero cold starts):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://elementum-sage.vercel.app/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also install Elementum's agent skills directly into your toolchain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx skills@latest add pinguxx/Elementum --skill elementum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once connected, your AI assistant gets 10 read-only MCP tools to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Query structured component schemas (&lt;code&gt;get_component_doc&lt;/code&gt;) with cleanly separated &lt;code&gt;variants&lt;/code&gt;, &lt;code&gt;states&lt;/code&gt;, &lt;code&gt;props&lt;/code&gt;, &lt;code&gt;constraints&lt;/code&gt;, and &lt;code&gt;examples&lt;/code&gt; (plus &lt;code&gt;section&lt;/code&gt; filtering to keep context lean)&lt;/li&gt;
&lt;li&gt;Validate markup against closed enum variants and required parent/child constraints (&lt;code&gt;validate_component_usage&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Search W3C DTCG design tokens (&lt;code&gt;list_tokens&lt;/code&gt;) for light &amp;amp; dark themes&lt;/li&gt;
&lt;li&gt;Generate validated component snippets (&lt;code&gt;generate_snippet&lt;/code&gt;) and scaffold new components (&lt;code&gt;scaffold_component&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Run static WCAG 2.2 AA accessibility lint checks (&lt;code&gt;lint_accessibility&lt;/code&gt; / &lt;code&gt;validate_accessibility&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Semantic Agent Runtime (&lt;code&gt;@wcomp/elementum/agent&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Automating or testing Web Components inside Shadow DOM often requires fragile selectors. Elementum includes a lightweight, Shadow-DOM-piercing runtime bridge with two clean primitives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;snapshot(root)&lt;/code&gt;: builds a structured semantic accessibility tree across Shadow DOM boundaries&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;act(root, command)&lt;/code&gt;: executes semantic actions (&lt;code&gt;click&lt;/code&gt;, &lt;code&gt;type&lt;/code&gt;, &lt;code&gt;toggle&lt;/code&gt;, &lt;code&gt;open&lt;/code&gt;, &lt;code&gt;close&lt;/code&gt;) directly against live components
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/agent'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Inspect the live UI semantically (pierces Shadow DOM)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Drive the UI with semantic commands&lt;/span&gt;
&lt;span class="nf"&gt;act&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'textbox'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Agent Name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Atlas'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;act&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'switch'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Auto Approve'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'toggle'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;act&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'button'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Run Task'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'click'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes browser-use agents, automated UI evaluation, and end-to-end testing significantly cleaner.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Dedicated AI UI Primitives (+ Live Demo &amp;amp; StackBlitz)
&lt;/h2&gt;

&lt;p&gt;Rather than rebuilding chat composers, thought disclosures, and tool-execution logs from scratch, Elementum ships accessible AI primitives out of the box:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-prompt-input&amp;gt;&lt;/code&gt;: auto-expanding prompt composer with tool/model slots and Enter-to-submit&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-reasoning-card&amp;gt;&lt;/code&gt;: collapsible thought disclosure with active breathing pulse &amp;amp; duration timer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-tool-call&amp;gt;&lt;/code&gt;: AG-UI compatible tool call visualizer with collapsible JSON args, results, status badges, and Human-in-the-Loop (HITL) approvals&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-streaming-text&amp;gt;&lt;/code&gt;: smooth token-by-token streaming text with customizable cadence&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-sources&amp;gt;&lt;/code&gt;: grounding citation pills and expandable source cards for RAG apps&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;el-diff-viewer&amp;gt;&lt;/code&gt;: unified and side-by-side code diff viewer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a complete zero-build AI chat interface using these components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"chat-layout"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;el-reasoning-card&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"reasoning"&lt;/span&gt; &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Reasoning Process"&lt;/span&gt; &lt;span class="na"&gt;open&lt;/span&gt; &lt;span class="na"&gt;thinking&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Analyzing prompt and querying documentation...
  &lt;span class="nt"&gt;&amp;lt;/el-reasoning-card&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;el-tool-call&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"tool-call"&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"search_docs"&lt;/span&gt;
    &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"completed"&lt;/span&gt;
    &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'{"query": "asyncSignal AbortSignal"}'&lt;/span&gt;
    &lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'{"matches": 2, "status": "ok"}'&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&amp;lt;/el-tool-call&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;el-card&lt;/span&gt; &lt;span class="na"&gt;bordered&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;el-streaming-text&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"stream-output"&lt;/span&gt;
      &lt;span class="na"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"18"&lt;/span&gt;
      &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Elementum combines 109 zero-dependency Web Components with micro-signals, DSD SSR, and MCP tooling."&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;gt;&amp;lt;/el-streaming-text&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/el-card&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;el-sources&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"sources"&lt;/span&gt;
    &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Verified Sources"&lt;/span&gt;
    &lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'[{"title":"Elementum Docs","url":"https://elementum-sage.vercel.app/docs.html","domain":"elementum-sage.vercel.app"}]'&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&amp;lt;/el-sources&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;el-prompt-input&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"prompt-input"&lt;/span&gt;
    &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Ask the AI agent anything..."&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&amp;lt;/el-prompt-input&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Try the AI Chat Starter Live
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live Demo:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/starters/ai-chat/index.html" rel="noopener noreferrer"&gt;elementum-sage.vercel.app/starters/ai-chat/index.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open in StackBlitz:&lt;/strong&gt; &lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/ai-chat" rel="noopener noreferrer"&gt;stackblitz.com/github/pinguxx/Elementum/tree/main/starters/ai-chat&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Elementum also includes an &lt;strong&gt;AG-UI protocol adapter&lt;/strong&gt; (&lt;code&gt;@wcomp/elementum/ag-ui&lt;/code&gt;) with RFC 6902 JSON Patch state deltas so SSE streams from agent backends bind directly to reactive micro-signals.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Two-Way Penpot MCP Design Sync
&lt;/h2&gt;

&lt;p&gt;Design-to-code handoff is built directly into the platform using the open-source &lt;strong&gt;W3C Design Tokens Community Group (DTCG)&lt;/strong&gt; format:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code -&amp;gt; Penpot&lt;/strong&gt;: Sync W3C DTCG tokens and Master Components directly into an open Penpot file via MCP (&lt;code&gt;npm run penpot:mcp&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Penpot -&amp;gt; Code&lt;/strong&gt;: Compile exported Penpot tokens into &lt;code&gt;src/tokens.css&lt;/code&gt; (&lt;code&gt;npm run tokens:sync&lt;/code&gt;) or generate full validated Elementum applications (&lt;code&gt;npm run penpot:generate&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see the end-to-end result in our &lt;strong&gt;&lt;a href="https://elementum-sage.vercel.app/examples/ledgerflow.html" rel="noopener noreferrer"&gt;LedgerFlow fintech dashboard demo&lt;/a&gt;&lt;/strong&gt;, compiled from Penpot into 15 live Elementum components.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Pure Node.js Declarative Shadow DOM (DSD) SSR
&lt;/h2&gt;

&lt;p&gt;Elementum renders Shadow DOM on the server in &lt;strong&gt;pure Node.js&lt;/strong&gt; (no &lt;code&gt;jsdom&lt;/code&gt; or &lt;code&gt;happy-dom&lt;/code&gt; required) using standard &lt;code&gt;&amp;lt;template shadowrootmode="open"&amp;gt;&lt;/code&gt; markup for zero Cumulative Layout Shift (CLS):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;renderComponentToDSD&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/ssr'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;renderComponentToDSD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'el-button'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'primary'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Server Rendered Button'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;lt;el-button variant="primary"&amp;gt;&amp;lt;template shadowrootmode="open"&amp;gt;...&amp;lt;/template&amp;gt;Server Rendered Button&amp;lt;/el-button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live Next.js DSD SSR Demo:&lt;/strong&gt; &lt;a href="https://elementum-next-dsd.vercel.app" rel="noopener noreferrer"&gt;elementum-next-dsd.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source &amp;amp; StackBlitz:&lt;/strong&gt; &lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/next-app-router" rel="noopener noreferrer"&gt;Open Next.js App Router Starter&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. One Library Across React, Vue 3, Svelte 5 &amp;amp; Vanilla (3-Way Comparison)
&lt;/h2&gt;

&lt;p&gt;Because every component is a standard Custom Element with Form-Associated Custom Elements (&lt;code&gt;ElementInternals&lt;/code&gt;) and Constructable Stylesheets, you can use Elementum in any stack, including official strictly-typed React 18 &amp;amp; 19 wrappers via &lt;code&gt;@wcomp/elementum/react&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To test how consistent the developer experience is across frameworks, we built the &lt;strong&gt;exact same interactive Team Directory app&lt;/strong&gt; (using &lt;code&gt;&amp;lt;el-card&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-badge&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-button&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-theme-switch&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-select&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-table&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;el-dialog&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;el-toaster&amp;gt;&lt;/code&gt;) three times and automated the measurements via &lt;code&gt;npm run bench:frameworks&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;React (&lt;code&gt;@wcomp/elementum/react&lt;/code&gt;)&lt;/th&gt;
&lt;th&gt;Vue 3 (Native Custom Elements)&lt;/th&gt;
&lt;th&gt;Vanilla (Micro-Signals + CDN)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;App File&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/App.jsx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/App.vue&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;index.html&lt;/code&gt; (full app)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Non-Empty LOC (Total)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;103&lt;/strong&gt; (112)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;90&lt;/strong&gt; (101)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;98&lt;/strong&gt; (108, includes HTML shell)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;App Source (Raw / Gzip)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;4.20 KB / &lt;strong&gt;1.36 KB&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;3.86 KB / &lt;strong&gt;1.30 KB&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;4.54 KB / &lt;strong&gt;1.51 KB&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Build Step&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Vite&lt;/td&gt;
&lt;td&gt;Vite&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;None (0 build)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Live Demo&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://elementum-comparison-react.vercel.app" rel="noopener noreferrer"&gt;Live React App&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://elementum-comparison-vue.vercel.app" rel="noopener noreferrer"&gt;Live Vue 3 App&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://elementum-sage.vercel.app/starters/framework-comparison/vanilla/index.html" rel="noopener noreferrer"&gt;Live Vanilla App&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sandbox&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/framework-comparison/react" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/framework-comparison/vue" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/framework-comparison/vanilla" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  React (&lt;code&gt;@wcomp/elementum/react&lt;/code&gt;) Example
&lt;/h3&gt;

&lt;p&gt;The auto-generated React wrappers handle &lt;code&gt;forwardRef&lt;/code&gt;, boolean attributes, &lt;code&gt;useLayoutEffect&lt;/code&gt; pre-paint object/array prop sync (with automatic reset on prop removal), CustomEvent mapping, and strict TypeScript types (zero &lt;code&gt;[prop: string]: any&lt;/code&gt; escape hatches):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;ElButton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ElInput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ElTable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ElDialog&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@wcomp/elementum/react'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;TeamTable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onSelect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ElTable&lt;/span&gt;
      &lt;span class="n"&gt;selectable&lt;/span&gt;
      &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;onSelectionChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onSelect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;selected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Vue 3 Example
&lt;/h3&gt;

&lt;p&gt;Configure &lt;code&gt;isCustomElement: (tag) =&amp;gt; tag.startsWith('el-')&lt;/code&gt; in &lt;code&gt;vite.config.js&lt;/code&gt; and use components directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;el-card&lt;/span&gt; &lt;span class="na"&gt;bordered&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;slot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Vue 3 + Elementum&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;el-switch&lt;/span&gt; &lt;span class="na"&gt;:checked&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"enabled"&lt;/span&gt; &lt;span class="na"&gt;@change&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"onToggle"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      Enable notifications
    &lt;span class="nt"&gt;&amp;lt;/el-switch&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/el-card&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  All Interactive Starters (CI-Verified)
&lt;/h3&gt;

&lt;p&gt;All starter projects are build-verified in CI via &lt;code&gt;tools/verify-starters.js&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://elementum-sage.vercel.app/starters/vanilla-html/index.html" rel="noopener noreferrer"&gt;Vanilla HTML (Zero-Build CDN + Micro-Signals)&lt;/a&gt;&lt;/strong&gt; (&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/vanilla-html" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://elementum-sage.vercel.app/starters/ai-chat/index.html" rel="noopener noreferrer"&gt;AI Chat UI (Prompt, Reasoning, Tool Call, Streaming)&lt;/a&gt;&lt;/strong&gt; (&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/ai-chat" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://elementum-next-dsd.vercel.app" rel="noopener noreferrer"&gt;Next.js 16 App Router + DSD SSR&lt;/a&gt;&lt;/strong&gt; (&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/next-app-router" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/react-19" rel="noopener noreferrer"&gt;React 19 + TypeScript + Vite&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/vue-3" rel="noopener noreferrer"&gt;Vue 3 + Vite&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://stackblitz.com/github/pinguxx/Elementum/tree/main/starters/svelte-5" rel="noopener noreferrer"&gt;Svelte 5 (Runes) + Vite&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. Verification, Visual Regression &amp;amp; Audit Hub
&lt;/h2&gt;

&lt;p&gt;Every claim in Elementum is backed by an automated verification pipeline (&lt;code&gt;npm run verify:all&lt;/code&gt;), an auto-generated &lt;a href="https://github.com/pinguxx/Elementum/blob/main/QUALITY.md" rel="noopener noreferrer"&gt;&lt;code&gt;QUALITY.md&lt;/code&gt;&lt;/a&gt; matrix, and a permanent &lt;a href="https://github.com/pinguxx/Elementum/blob/main/AUDITS.md" rel="noopener noreferrer"&gt;&lt;code&gt;AUDITS.md&lt;/code&gt;&lt;/a&gt; hub:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;109 / 109 Production Verified (100%)&lt;/strong&gt;: Every registered Custom Element passes catalog schema checks, unit instantiation, real-browser Playwright E2E (Chromium, Firefox, WebKit), and &lt;code&gt;@axe-core/playwright&lt;/code&gt; WCAG 2.2 AA audits&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0 runtime dependencies&lt;/strong&gt; and &lt;strong&gt;2.24 KB&lt;/strong&gt; avg gzip per component across &lt;strong&gt;86&lt;/strong&gt; size-gated ESM entrypoints&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-theme Visual Regression&lt;/strong&gt;: Automated Playwright screenshot regression (&lt;code&gt;e2e/visual-regression.spec.js&lt;/code&gt;) across desktop/mobile and light/dark themes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real React 18 &amp;amp; React 19 consumer verification&lt;/strong&gt; (&lt;code&gt;npm run verify:react&lt;/code&gt;) packing the actual &lt;code&gt;.tgz&lt;/code&gt; tarball and running SSR, &lt;code&gt;StrictMode&lt;/code&gt;, &lt;code&gt;startTransition&lt;/code&gt;, &lt;code&gt;ElementInternals&lt;/code&gt; forms, and strict &lt;code&gt;tsc --noEmit --strict&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Starter CI Gate&lt;/strong&gt; (&lt;code&gt;tools/verify-starters.js&lt;/code&gt;) ensuring all framework starters install, typecheck, and build cleanly&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It Out
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install the package&lt;/span&gt;
npm install @wcomp/elementum

&lt;span class="c"&gt;# Or connect the MCP server to your coding agent&lt;/span&gt;
npx elementum-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're building AI interfaces, design systems, or framework-independent frontends, I'd love to hear your feedback, especially on what tools you'd like to see in the MCP server or the &lt;code&gt;@wcomp/elementum/agent&lt;/code&gt; runtime!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum" rel="noopener noreferrer"&gt;https://github.com/pinguxx/Elementum&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Showcase:&lt;/strong&gt; &lt;a href="https://elementum-sage.vercel.app/" rel="noopener noreferrer"&gt;https://elementum-sage.vercel.app/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP Endpoint:&lt;/strong&gt; &lt;code&gt;https://elementum-sage.vercel.app/mcp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit Hub:&lt;/strong&gt; &lt;a href="https://github.com/pinguxx/Elementum/blob/main/AUDITS.md" rel="noopener noreferrer"&gt;https://github.com/pinguxx/Elementum/blob/main/AUDITS.md&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webcomponents</category>
      <category>ai</category>
      <category>mcp</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 10, 3rd party libraries</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Fri, 07 Jun 2019 14:57:43 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b</guid>
      <description>&lt;p&gt;Part 10 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-5hdl-temp-slug-7285698"&gt;Custom elements with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-h5b-temp-slug-4579110"&gt;Customizing my custom elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-12g4-temp-slug-5472234"&gt;Testing!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;3rd party libraries&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fut1yw5zhfwlwkulfkk5e.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fut1yw5zhfwlwkulfkk5e.jpeg" width="798" height="305"&gt;&lt;/a&gt;&lt;/p&gt;
Photo by &lt;a href="https://unsplash.com/photos/C0koz3G1I4I?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Markus Spiske&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/block?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;



&lt;p&gt;Combining third-party libraries with your framework can often be challenging. Because hyperHTML is built on JavaScript standards, using it with other libraries is generally pain-free and easy. This is one of the chief beauties of hyper: it plays well with others.&lt;/p&gt;

&lt;p&gt;In part 4 we saw how to define and use intents. In part 2, we worked with components, and in part 5 we looked at custom elements.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you missed any of those parts, head back now and review them. We’ll build on what we learned there.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Today, we are going to use 3rd party libraries to spice up all three of these. Just load ‘n use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time 📅 and intents 😉
&lt;/h3&gt;

&lt;p&gt;To start, we are going to use &lt;a href="https://github.com/iamkun/dayjs" rel="noopener noreferrer"&gt;dayjs&lt;/a&gt;. Dayjs is a simpler and smaller alternative to &lt;a href="https://momentjs.com/" rel="noopener noreferrer"&gt;moment.js&lt;/a&gt;. If you’re looking for a datetime library with a smaller footprint, a familiar and logical API, dayjs is a great choice. Back in part 4 we had a date format intent that was printing a date in a specific format. It looked like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now lets update it to use dayjs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import dayjs from 'dayjs';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here’s our first attempt to use the intent:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-3rd-01?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;But we now have the full power of dayjs, so why stop here? We can add formatting options to our intent. Check this out:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-3rd-02?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you were expecting another step or two, prepare to be disappointed! That’s all there is to using dayjs inside your intents.&lt;/p&gt;
&lt;h3&gt;
  
  
  Emojis 😊 and Components ✔️
&lt;/h3&gt;

&lt;p&gt;We’ve already covered the basics of including 3rd party libraries. To add some fun to our components, we are going to convert some text strings to emojis using the &lt;a href="https://github.com/joypixels/emojify.js" rel="noopener noreferrer"&gt;emojify&lt;/a&gt; library. If you’re following along at home, go ahead and import the library into a new file.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Emojify will detect things like :) and 😄 and convert it to an emoji image. See this &lt;a href="https://www.webfx.com/tools/emoji-cheat-sheet/" rel="noopener noreferrer"&gt;cheat sheet&lt;/a&gt; for more information on what it can do.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s start with a simple component using &lt;code&gt;hyper.Component&lt;/code&gt;. This component is going to receive some text, and then &lt;code&gt;onclick&lt;/code&gt; we are going to use emojify to parse and show emojis. The magic happens in this line&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;emojify.replace(this.text);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This component is very simple. We pass in text when we construct the component, and save in two places: &lt;code&gt;this.text&lt;/code&gt; is what we will transform, and we’ll keep it around in &lt;code&gt;this._original&lt;/code&gt; so we can revert if we need to.&lt;/p&gt;

&lt;p&gt;That too, was easy! Nothing else to do. The full source code:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-3rd-03?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h3&gt;
  
  
  Charts 📊 and Custom Elements 🎉
&lt;/h3&gt;

&lt;p&gt;Lastly, we are going to create charts with the amazing library &lt;a href="https://gionkunz.github.io/chartist-js/index.html" rel="noopener noreferrer"&gt;chartist&lt;/a&gt;. Chartist allows us to easily create simple or advanced charts. Just give it data and options, start a new chart of the type you want, and voila! This chart element is not complicated, but it is more involved than the intent and component we made earlier. We’ll just hit the highlights of it here.&lt;/p&gt;

&lt;p&gt;As always, first load the package. For chartist to work, we also need to load some CSS.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "chartist/dist/chartist.css";
import Chartist from "chartist";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The only attribute we are going to observe is the type; everything else will be plain getters and setters. We’ll need a get/set for data and for options. We’ll also include a get/set for both called details to make it easy to update everything in one call.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;As you can see, we are calling update on every attribute change. This update function is going to either create a chart, or if we already have one, update it. Variables are created in the created() function and updated in render() .&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;All we’re doing here is creating and storing a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; in &lt;code&gt;this._el&lt;/code&gt;, and starting a chart instance.&lt;/p&gt;

&lt;p&gt;To use this element, we will have a custom-chart element in the page with the type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;custom-chart type="Line"&amp;gt;&amp;lt;/custom-chart&amp;gt;
&amp;lt;custom-chart type="Bar"&amp;gt;&amp;lt;/custom-chart&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then we can pass data and options to make it render the actual chart&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Full code for the element and example of usage&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-3rd-04?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;What? We’re already done with this part? There’s no crazy hoops to jump through to add 3rd-party libraries to hyperHTML? There’s no magic code dance we have to do? No library-author to ping for an update/change/bugfix? Nope. HyperHTML does a fantastic job of incorporating other libraries. And why would we expect anything different — hyper is standards-based vanilla JavaScript.&lt;/p&gt;

&lt;p&gt;Hopefully we’ve done a good job helping you see the power of combining hyperHTML with some of your favorite libraries. Let us know in the comments what amazing applications you create using hyperHTML.&lt;/p&gt;

&lt;p&gt;This is the last part of our series on hyperHTML. We will keep writing about hyperHTML in other posts, so let us know if there are topics you want to see covered. We hope you enjoyed this journey as much as we enjoyed writing it. Thanks for reading.&lt;/p&gt;




</description>
      <category>hyperhtml</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 9, routing</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Thu, 06 Jun 2019 15:17:09 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0</guid>
      <description>&lt;p&gt;Part 9 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-5hdl-temp-slug-7285698"&gt;Custom elements with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-h5b-temp-slug-4579110"&gt;Customizing my custom elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-12g4-temp-slug-5472234"&gt;Testing!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Handling routes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6l2ovklfs4xicimrcmm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6l2ovklfs4xicimrcmm.jpeg" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you missed any of the previous parts, now’s a good time to catch up on the ones you missed. Specifically, part 9 builds upon part 8. Recall that we built a table in part 8 and populated it with real data from the cryptocompare api. Now that we are retrieving real data, we can enhance our application even more. This application is a good candidate for routes. By using routes, we can turn it into a single page application or SPA. SPAs don’t need to reload the whole page every time we want to display different parts of the application.&lt;/p&gt;

&lt;p&gt;This is our application so far:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-03?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We are going to add a new tab to display the historical data for the selected coin in the dropdown. To do this, we are going to use state management, our elements, and route management.&lt;/p&gt;




&lt;h3&gt;
  
  
  Reorganization
&lt;/h3&gt;

&lt;p&gt;So far we have only used a few elements on the same page. While this is easy to manage, we now need better organization to handle routes and different elements working together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftlflk6iualxvaow6de7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftlflk6iualxvaow6de7a.png" width="205" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to create a folder called elements and move the ones we’ve already created into it. Same with intents. Don’t forget: since we changed the paths we need to update our import statements for all of them.&lt;/p&gt;

&lt;p&gt;Also, let’s create a components folder. We’ll use it soon.&lt;/p&gt;

&lt;p&gt;This is our code now&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-04?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Routing
&lt;/h3&gt;

&lt;p&gt;There are a ton of different options for routing and most likely your favorite framework has one… and hyper does as well. And yes it’s YAAT — Yet Another Andrea Tool. &lt;a href="https://github.com/WebReflection/hyperhtml-app" rel="noopener noreferrer"&gt;https://github.com/WebReflection/hyperhtml-app&lt;/a&gt;. You don’t need to use hyper to use this library, and it is similar to the Express framework in how you define the routes.&lt;/p&gt;




&lt;h4&gt;
  
  
  Route types
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;get(“/path/:param”, cb)&lt;/strong&gt;: GET requests to the specified path will be caught. Inside the callback cb, the param will be available as a property on the first argument. e.g: ctx.param&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;use(paths, cb)&lt;/strong&gt;: Adds middleware to the specified paths. This is similar to get, but it accepts an array of paths&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;delete(path, cb)&lt;/strong&gt;: Removes a callback from a path&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;param(name, cb)&lt;/strong&gt;: Allows you to specify a function to use once when a parameter name is passed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;navigate(path)&lt;/strong&gt;: Navigate to the path programatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For our current project, we are will mostly use get, but as you can see, hyperhtml-app has many options for you to use.&lt;/p&gt;

&lt;p&gt;To get started, let’s import the library and create a couple of routes. Because we’ll be adding an index route, we can get rid of the code inside our index.html and index.js files. We’ll replace it with this:&lt;/p&gt;

&lt;p&gt;New index.html&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;New index.js&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;When we spin up the server, clicking on the links shows our messages in the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcho622c1hilrruzfkpzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcho622c1hilrruzfkpzn.png" width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s do a quick recap. First, we created an application then we used get (or post or others) to define our paths and a callback. In a real app, the callback will return the view for that path, but for this simple demo, we used it to console.log some text.&lt;/p&gt;




&lt;h4&gt;
  
  
  Components
&lt;/h4&gt;

&lt;p&gt;That was pretty easy! But how about we use some components?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By the way, if you need help with components check out &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;part 2&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We are going to create a coins.js file that loads a couple of components.&lt;/p&gt;

&lt;p&gt;Let’s start by making two similar components, compare and info. The only difference between them will be that they display something different. Each of these component will be in their own file, Compare.js and Info.js. Take a look at the Compare component:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Our Info component will be the same, but inside the render() function it will show “Information” and a link to “/”.&lt;/p&gt;

&lt;p&gt;Now coins.js is going to get a bit more complex. First we are going to load both Compare and Info components&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Compare from "./compare";
import Info from "./info";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then in the constructor for the app we are going to create references to our components.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(app) {
 super();
 this.app = app;
 this.compare = new Compare();
 this.info = new Info();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We also going to create a wire to render them.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.tabc = hyper.wire(this, ":tabcontent")`&amp;lt;div&amp;gt;`;
 this.tabb = hyper.bind(this.tabc);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After adding the default state with coin and path as properties, add an update function that only updates the path for the state. After this we are going to add a &lt;code&gt;renderComponent&lt;/code&gt; function that will render the component based on the route&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;renderComponent() {
 this.tabb`&amp;lt;div&amp;gt;`; //needed for later
 if (this.state.path === "/") {
 this.tabb`${this.compare.update(this.state)}`;
 } else {
 this.tabb`${this.info.update(this.state)}`;
 }
 return this.tabc;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And render&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
 return this.html`
 &amp;lt;div id="app" class="container-fluid"&amp;gt;
 ${this.renderComponent()}
 &amp;lt;/div&amp;gt;
 `;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We also need to update index.js to render coins.js, and index.html to just have the body element. Take a look at the current state of the code:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-05?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;


&lt;h3&gt;
  
  
  Layout
&lt;/h3&gt;

&lt;p&gt;Now that we have our routes, we need to add the rest of the elements to our page. We’ll make a Search component that holds an input for selecting the coin, and some tabs to change between the views of the table and the coin information.&lt;/p&gt;


&lt;h4&gt;
  
  
  Search
&lt;/h4&gt;

&lt;p&gt;For the search we are going to show a “select coin” label along with the input. We won’t start with a coin selected, so at load this is the only thing we are going to show. Let’s take a look at the Search component:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;We have to load this new component in coins.js, and bring back our polyfill and elements to index.js&lt;/p&gt;

&lt;p&gt;index.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "document-register-element";
import './intents/intents.js';
import "./elements/Table.js";
import "./elements/Typeahead.js";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;coins.js:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Search from "./search";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then update coins to render search component&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;${Search.for(this, ":search").update(this.state)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;… and that uncovered a bug. Having an empty filter its creating an error in typeahead. Do you think you can find and fix this bug? Take a shot at it, but if you get stuck, see the latest code below&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-06?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;


&lt;h4&gt;
  
  
  Tabs
&lt;/h4&gt;

&lt;p&gt;For the Tabs component, we will show a couple of tabs that will serve as our app navigation:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;And in the same way as before, import it and render it in coins.js. Now we can see the two views when clicking on the tabs. Check out the code so far:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-07?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Complete application
&lt;/h3&gt;

&lt;p&gt;We are almost there! We need to bring our previous elements back to make them work all together.&lt;/p&gt;




&lt;h4&gt;
  
  
  Compare
&lt;/h4&gt;

&lt;p&gt;We have to load the data whenever the user selects a coin from our input. We’ll use the fetch api just like before. We also added a check before render so that we only render the compare table if we have an icon selected.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Back in coins.js, we now have to listen for the user selecting a coin from the input. Let’s add an &lt;code&gt;onchange&lt;/code&gt; to the base div&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="app" onchange="${this}" class="container-fluid"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Don’t forget about the event handler itself:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onchange(ev) {
 this.setState({coin: ev.target.value});
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This also uncovers a different bug in the table — columns are not defined when it tries to render. This is a more complex bug, so feel free to check the finished code for the fix.&lt;/p&gt;


&lt;h4&gt;
  
  
  Info
&lt;/h4&gt;

&lt;p&gt;The info tab will also fetch the details for the selected coin from cryptocompare, and then show the icon and the name/fullname with a link.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Since we are not showing the tab view until we select something, let’s also hide the tabs themselves by adding the following conditional in render:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (!this.state.coin) {
 return;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And done! For an exercise, try to follow how we are passing the properties down to each component with the update() function. To pass data back up, we are listening for the events on the top components :D&lt;/p&gt;

&lt;p&gt;See the complete code and application working:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-08?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This post took a while to create, but you know life happens. Hopefully you are still reading and as always, clap away and leave your comments and requests below. We are almost done with the series. We hope you like it so far!&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>hyperhtml</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 8, Async loading</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Wed, 05 Jun 2019 14:04:27 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96</guid>
      <description>&lt;p&gt;Part 8 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-5hdl-temp-slug-7285698"&gt;Custom elements with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-h5b-temp-slug-4579110"&gt;Customizing my custom elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-12g4-temp-slug-5472234"&gt;Testing!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Async loading, placeholder and a Typeahead with hyper&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbljwg9pnu55bh7btt80d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbljwg9pnu55bh7btt80d.jpeg" width="500" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a few common problems we deal with on a routine basis, when to brush our teeth, whether 3 day old pizza sitting on the counter is still good, and how to show users that something is happening when what is happening can’t be seen. And in a world driven by data, we often want to filter that data to only see what we want. We aren’t going to be able to help you with brushing your teeth or eating habits, but we can do something about the other problems.&lt;/p&gt;

&lt;p&gt;If you’ve been following this tutorial, you already know how powerful hyperHTML combined with custom elements can be. We’ll be able to asynchronously load data while showing placeholder information, and create a typeahead that can filter the date we receive.&lt;/p&gt;

&lt;p&gt;So let’s build a little app that solves these problems. For this part we are going to show a list of top 10 cryptocoins and the conversion to another currency. We will be using the &lt;a href="https://min-api.cryptocompare.com/" rel="noopener noreferrer"&gt;cryptocompare&lt;/a&gt; api, you can read the documentation &lt;a href="https://min-api.cryptocompare.com/documentation" rel="noopener noreferrer"&gt;here&lt;/a&gt;. You don’t need to learn the full API if you don’t want, just follow along.&lt;/p&gt;

&lt;p&gt;This is what we are going to build:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjfubmgyfdr4itp6isnvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjfubmgyfdr4itp6isnvi.png" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Filter on the top right to choose the rate to show.&lt;/p&gt;

&lt;p&gt;Table with the top 10 coins and the rate.&lt;/p&gt;

&lt;p&gt;Button to refresh the top 10.&lt;/p&gt;

&lt;p&gt;Let’s reuse some of our code from &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-h5b-temp-slug-4579110"&gt;part 6&lt;/a&gt;. Recall in part 6 we made a table with some random data and a few intents. We’ll build upon this table.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-13?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Typeahead
&lt;/h3&gt;

&lt;p&gt;Typeaheads are complex elements. For our current project, we’ll use a simplified typeahead. Normally we’d need a lot more code to make this element complete, but for now, a simplified version will work. Whenever the user focuses on the dropdown the list appears, you type and the list filters, click on one of the options and you get the option selected and at that moment we trigger and on change event.&lt;/p&gt;

&lt;p&gt;Be sure to review this code carefully, as we won’t go in depth about it here.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-01?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Notes on the typeahead code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We defined a get/set for options, to allow the user to pass options. We’re using an internal variable to store them. This helps avoid loops if we ever want to set options in our code.&lt;/li&gt;
&lt;li&gt;We’re using Bootstrap classes for styling. dropdown-menu-right will make sure the dropdown of our typeahead is visible on the screen.&lt;/li&gt;
&lt;li&gt;The open() and close() functions will set the state so when we next render, our typeahead will get the proper CSS class to show or hide. Remember, every time we call setState hyperHTML re-renders our element.&lt;/li&gt;
&lt;li&gt;We’re rendering an input that will be inside our element. This is very common thing to do with custom elements — to wrap a native element within our element. By doing this, it’s as if we are extending the native element with additional features.&lt;/li&gt;
&lt;li&gt;We don’t use (&lt;a href="https://viperhtml.js.org/hyperhtml/documentation/#essentials-7" rel="noopener noreferrer"&gt;or need!&lt;/a&gt;) partial attributes. That’s why we need to wrap the class inside a ${}.&lt;/li&gt;
&lt;li&gt;We map over any options we find and return a wire() for each one. Returning the wire() is important; otherwise, hyperHTML won’t be able to attach the DOM nodes.&lt;/li&gt;
&lt;li&gt;Events let us listen for clicks on the input and open the dropdown, and clicks on the body to close it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before we can use the typeahead, we need to import it in index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js
import "./Typeahead.js";

const input = document.querySelector("hyper-input");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And place the custom element in the HTML:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F19mieciu9xg7jyyggaw6.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F19mieciu9xg7jyyggaw6.jpeg" width="800" height="1049"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the basic typeahead out of the way, it’s time to fetch the list of coins. Cryptocompare FTW. We’ll do the fetch here in index.js, and pass parts of the response to our typeahead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const input = document.querySelector("hyper-input");

fetch(`https://min-api.cryptocompare.com/data/all/coinlist`)
 .then(b =&amp;gt; b.json())
 .then(data =&amp;gt; {
 input.options = data.Data;
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We should start options with an empty array so we don’t get undefined errors.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// typeahead.js
created() {
 this.options = [];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now let’s take a look at the table.&lt;/p&gt;
&lt;h3&gt;
  
  
  Table
&lt;/h3&gt;

&lt;p&gt;Cryptocompare has an endpoint to get a number of top coins by their total volume across all markets in the last 24 hours. We will use that one to set our table data, so let’s update index.js to do that.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch(`https://min-api.cryptocompare.com/data/top/totalvol?limit=10&amp;amp;tsym=USD`)
 .then(b =&amp;gt; b.json())
 .then(data =&amp;gt; {
 table.data = data.Data.map(coin =&amp;gt; coin.CoinInfo);
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The table is empty. We need to update the html to target the real attributes&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;hyper-table coin="USD"&amp;gt;
 &amp;lt;hyper-column label="ID" attribute="Id"&amp;gt;&amp;lt;/hyper-column&amp;gt;
 &amp;lt;hyper-column label="Name" attribute="FullName"&amp;gt;&amp;lt;/hyper-column&amp;gt;
 &amp;lt;hyper-column label="Rate" attribute="data" sortable="false"&amp;gt;&amp;lt;/hyper-column&amp;gt;
&amp;lt;/hyper-table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We don’t really have a data attribute, but we will see why soon.&lt;/p&gt;

&lt;p&gt;If we reload the page we see the table is empty and then all of a sudden we have the top 10 coins in the table. We should show some loading text so people know things are happening. A good place for this is inside the &lt;code&gt;&amp;lt;tbody&amp;gt;&lt;/code&gt; of our table element.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Now to get the rate, we have to make another call to the server. Just to make it cool we are going to call once for every row in the table. In real production code you probably want to make a call once for everything instead of individual calls.&lt;/p&gt;

&lt;p&gt;We added coin=”USD” to our table above. Since this is a value that can change, let’s put add an observed attribute called coin. When we start the app, it will start the hyper-input with this default value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static get observedAttributes() {
 return ["coin"];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In our &lt;code&gt;_renderCell&lt;/code&gt; function, let’s check if data is the attribute we are showing and then use the placeholder functionality of hyperHTML. This way we can show some loading text while fetch is loading, and afteward, the rate for the coin.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;There’s a lot going on in this code. We’ve primarily encountered wires that look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return wire()`&amp;lt;div class=${this.state.open}&amp;gt;&amp;lt;/div&amp;gt;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;However, in the above code, notice that we’re giving the wire a weak map and id: wire(item,&lt;code&gt;:col${item.Id}&lt;/code&gt;) Hyper will use this to more efficiently use and render the wires. Also, for this wire we are passing an object, instead of HTML. Note that the “any” property is a promise that returns a wire, and the “placeholder” property is a wire. Hyper will use what is in the placeholder property until the promise in any is fulfilled. Whenever fetch is done, we are o return the rate and hyper will remove the placeholder wire and update our element with the new information. Pretty cool!&lt;/p&gt;

&lt;p&gt;Success! We can see our table loading the coins then making 10 more requests to get the rate for each coin.&lt;/p&gt;
&lt;h3&gt;
  
  
  Putting it all Together
&lt;/h3&gt;

&lt;p&gt;The next step is to connect the input with the table, we will do that in index.js&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input.addEventListener("change", e =&amp;gt; {
 table.coin = input.value;
 table.render();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Everytime our input changes, we will update the table coin with the new value and the re-render the table, which will make the rate column make new requests with the new coin and show the new data :D.&lt;/p&gt;

&lt;p&gt;Oh no, we lose the sorting whenever we refresh the data… kind of makes sense since it’s new data. To fix that, let’s move the sorting piece outside our &lt;code&gt;headerclick&lt;/code&gt; to its own function, and whenever we add new data we will just re-sort.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Alright! Lastly, for our table we will put a last-updated time in the footer. We have a date intent already, but for this we want to show the time also. Making a dateTime intent will help us with that&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Very similar to our previous one but now we are showing the time too.&lt;/p&gt;

&lt;p&gt;In the set data function, we are going to add a date so we have it for the footer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set data() {
 this._last = Date.now()
 ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And of course the footer now looks like this&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzkr802k8o7rvdhozfnl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzkr802k8o7rvdhozfnl.jpeg" width="800" height="1050"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code so far&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-02?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Refresh
&lt;/h3&gt;

&lt;p&gt;Since the top 10 changes rather often, let’s add a refresh button. With this button, the table can be updated without refreshing the whole page.&lt;/p&gt;

&lt;p&gt;First, index.html, under the hyper-table add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="text-center"&amp;gt;&amp;lt;button class="btn btn-outline-secondary"&amp;gt;Refresh&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then in index.js, let’s wrap the fetch call for the table in a function called update. This way we can keep calling that every time we click the refresh button. We will also call it when we load the page so that we can get initial data to display.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;And that’s it! Clicking on refresh updates the table and we can see the new timestamp in the footer.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/advanced-app-03?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I tried to focus more on the new parts, but if you need a more in-depth explanation of any part let me know in the comments and we can extend that part. Thanks for reading.&lt;/p&gt;

&lt;p&gt;One last O Rly book :D&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faz35bnofu1y2rmrw5zgl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faz35bnofu1y2rmrw5zgl.jpeg" width="474" height="562"&gt;&lt;/a&gt;&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>hyperhtml</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 7, Testing</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Tue, 04 Jun 2019 16:27:08 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g</guid>
      <description>&lt;p&gt;Part 7 written by Trevor Ganus, &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-5hdl-temp-slug-7285698"&gt;Custom elements with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-h5b-temp-slug-4579110"&gt;Customizing my custom elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testing!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsxv2p96kvqjjzuegirdk.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsxv2p96kvqjjzuegirdk.jpeg" width="400" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m not a big fan of having 100% code coverage, etc, etc, etc. But if we are writing components, they probably need to be tested as much as possible. We won't go super deep into testing, but we do want to show a few ways you can test your components and elements.&lt;/p&gt;

&lt;p&gt;A small caveat before we begin: this post isn’t intended to cover everything you need to know about unit testing. Many other tutorials can teach you the basics of how to write code that tests well. Our goal is to show you how to use specific testing tools, with the understanding that you have a basic understanding of unit tests in general. With that out of the way, let’s get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  Enter Tressa
&lt;/h3&gt;

&lt;p&gt;Yup, YAAT — Yet Another Andrea Tool. Tressa is a very simple testing utility that we are going to use to test our stuff. It gives us the ability to do synchronized tests and asynchronous tests. It also comes with a basic assert function. Tressa requires consolemd, a module that lets us print using markdown to the console, which is pretty neat. Let’s see an example:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-01?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : we have to load tressa and consolemd with unpkg because for some reason stackblitz never finds echomd even if installed. Open the real console to see errors, the inner console from stackblitz doesn’t show them for some reason.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's dissect the code a bit to understand all the pieces&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tressa.title&lt;/code&gt; Starts a “section” of tests, by default title adds (“#”) for you&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tressa.end&lt;/code&gt; Ends the section of tests and returns the time spent on them&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tressa and tressa.assert&lt;/code&gt; This where you put your assertions with an optional comment as a second argument. You can use either one, there is no difference between them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tressa.log&lt;/code&gt; console out with markdown, useful to separate parts of your tests&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tressa.async&lt;/code&gt; Need to wait for an async operation? Use this wrapper. It returns a promise to test those cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see that tressa makes it very easy to test our code. Hopefully, you remember our table created with only &lt;code&gt;hyper.Component&lt;/code&gt;. If not, here’s a quick refresh:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-7?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Open the real console to see errors, the inner console from stackblitz doesn’t show them for some reason.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Components
&lt;/h3&gt;

&lt;p&gt;First let’s load consolemd and tressa. Then, let’s add a test for the footer component in our table. This component doesn’t really do much, so testing should be straightforward. Open the console to see the test results. If you are doing async tests, don’t forget to call the &lt;code&gt;done()&lt;/code&gt; callback when your test is finished.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-02?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Cool, let’s move on to the header component. For this one, let’s see if the &lt;code&gt;&amp;lt;thead&amp;gt;&lt;/code&gt; is getting icons when we pass the sorted property&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let’s also test the clicking on an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And now, all the code together:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-03?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;So far, our tests have been on components separated from the DOM. We instantiate the elements with the new keyword. Let’s wrap up the table testing with a test directly on the component already rendered:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-04?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We don’t need to write all the tests in this asynchronous way, but I like it since it separates sections of our tests better. Being familiar with the asynchronous tests now will help us later, when we write more complex tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjlveuunrwrbs2vk61b1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjlveuunrwrbs2vk61b1u.png" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Intents
&lt;/h3&gt;

&lt;p&gt;In our component project, we also have a couple of intents — one for icons and one for dates. Let’s test those now. For now, let’s remove the component testing so it’s easier to focus on the intents.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Well… we found our first bug. If we pass “a”, which is an icon that doesn’t exist in &lt;a href="https://octicons.github.com/" rel="noopener noreferrer"&gt;Octicons&lt;/a&gt;, we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: Cannot read property ‘toSVG’ of undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let’s fix the intent:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Sweet, our test passes with the updated code. Now let’s test the date intent:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Err… that last test shows batman! &lt;code&gt;NaN/NaN/NaN&lt;/code&gt;, let’s fix that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (!isNaN(newdate.getTime()) &amp;amp;&amp;amp; typeof newdate.getMonth === ‘function’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Yay! Let’s see the result:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-05?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr29hbyujixe7az5a976l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr29hbyujixe7az5a976l.jpeg" width="512" height="340"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Custom elements
&lt;/h3&gt;

&lt;p&gt;This is our table as a custom element:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-13?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Since we are already using the functions of the table, let’s rewrite those as tests. But first let’s add some utilities and then put all the tests in a single file.&lt;/p&gt;

&lt;p&gt;Let’s see if we are actually loading a table first:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;It’s there, cool! Notice we get the same result from &lt;code&gt;tressa()&lt;/code&gt; as when we were using &lt;code&gt;tressa.assert()&lt;/code&gt; in our previous tests. Now let’s test data:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;There are a couple of things we want to look at here. First, data will make a row appear, but since it doesn’t have any real data everything will be “-”… except date… lets update the intent to fix that with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let formatted = ‘-’,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Second, data is more real and we see that we have data in our rows and the footer is updated.&lt;/p&gt;

&lt;p&gt;Now let’s test the column functions: add/remove/update&lt;/p&gt;
&lt;h3&gt;
  
  
  Add
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Last but not least, sorting:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let’s see everything working together:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-testing-06?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Coverage
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjo24fejutdhxmuc6y15r.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjo24fejutdhxmuc6y15r.jpeg" width="320" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We tested our code, but what if we want to see how much was tested? For this, Istanbul is our friend. We can’t run Istanbul from stackblitz (that I’m aware of), but let’s create a project in github to run it, and that will generate a coverage report.&lt;/p&gt;

&lt;p&gt;For this kind of test we’ll need to have &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; and &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;npm&lt;/a&gt;installed. If you’re not familiar with these tools, &lt;a href="https://www.tutorialspoint.com/nodejs/nodejs_npm.htm" rel="noopener noreferrer"&gt;here is a great place to start&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, we need to change a couple of things. Code-wise we need to remove the tests from index.js and created a file called test.js (clever right?). Then, we need to remove all the imports except intents and table. With those changes, our index.js file looks like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We also will need to setup the test environment, since we are not going to use a browser for our tests. Instead, we are going to use &lt;a href="https://github.com/WebReflection/basicHTML" rel="noopener noreferrer"&gt;basicHTML&lt;/a&gt;. BasicHTML is a lightweight, dumb, and simple implementation of the HTML standard” — and yes it’s a YAAT.&lt;/p&gt;

&lt;p&gt;So our start of the test file looks like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We bring tressa, then basicHTML, and we set it up. We are also bringing sizzle so we can make complex queries (sizzle is the selector engine used by JQuery so it’s a powerful tool). Then we load hyperHTML, and finally our tests with index.js.&lt;/p&gt;

&lt;p&gt;Then, we setup our fake browser by making it ready and DOMContentLoaded. We can then add our table — just like regular HTML — by using a wire. That’s it! Let’s grab our table and run the same test we wrote previously.&lt;/p&gt;

&lt;p&gt;Now, to run all of this we need a bunch more of dev dependencies. Add this to the package.json file and &lt;code&gt;npm i&lt;/code&gt; away&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The first part is just our dependencies for the tests. We added a script for running our test — nyc is the istanbul cli. Lastly, we setup nyc so it loads babel to transpile our code, and we add a couple of handy reporters. The HTML reporter will make it so we can look at a pretty web page.&lt;/p&gt;

&lt;p&gt;Since we don’t need the classes to be transpiled lets add a .babelrc to customize the behavior.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;When testing we use Istanbul and we target firefox 52… why 52?? IDK, sounds like a good number and it was the old ESR :D.&lt;/p&gt;

&lt;p&gt;aaaand then fire up a console terminal, navigate to the folder with your package.json, and enter the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hopefully you will see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9n6qqib78xcc51bzenif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9n6qqib78xcc51bzenif.png" width="598" height="669"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the coverage folder and open index.html to see the report… almost 100%… mm what are we missing? Take a peek at the Table.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (ElOrObj.nodeName === "HYPER-COLUMN") {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apparently basicHTML is case sensitive. No problem, it’s an easy fix. Let’s do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (ElOrObj.nodeName &amp;amp;&amp;amp; ElOrObj.nodeName.toLowerCase() === "hyper-column") {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;npm test again, open the report… 100%&lt;/p&gt;

&lt;p&gt;Yay! We did it! You can clone the full project here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pinguxx/easyapps-7-test1" rel="noopener noreferrer"&gt;pinguxx/easyapps-7-test1&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Integration tests
&lt;/h3&gt;

&lt;p&gt;For integration testing, I really like &lt;a href="https://www.cypress.io/" rel="noopener noreferrer"&gt;cypress&lt;/a&gt;. It’s very easy to use and powerful. It lets us create unit, end-to-end, and integration tests. Cypress also gives you the ability to see the state of your web page/app at each stage of the tests.&lt;/p&gt;

&lt;p&gt;With integration testing, we are testing the page directly, so we need to add some things to make that happen. Time does not permit me to explain everything for this, but if you want a more detailed explanation, let me know and I can create a post detailing the process.&lt;/p&gt;

&lt;p&gt;The tl;dr; goes like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add cypress/rollup/babel and plugins to package.json&lt;/li&gt;
&lt;li&gt;Add test/build scripts in package.json&lt;/li&gt;
&lt;li&gt;run cypress for the first time&lt;/li&gt;
&lt;li&gt;build (babel/bundle) index.js with all the modules used&lt;/li&gt;
&lt;li&gt;start a local server http-server -p 8081&lt;/li&gt;
&lt;li&gt;create a new integration test, table_spec.js is what I called mine&lt;/li&gt;
&lt;li&gt;replicate tressa test and/or add more&lt;/li&gt;
&lt;li&gt;profit!!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkv3jwvdntnqofuet40ab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkv3jwvdntnqofuet40ab.png" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;
Test passed :D


&lt;p&gt;For more information, check out the &lt;a href="https://docs.cypress.io/guides/overview/why-cypress.html#In-a-nutshell" rel="noopener noreferrer"&gt;cypress docs&lt;/a&gt;. You can also clone and run the tests yourself with this project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pinguxx/easyapps-7-test2" rel="noopener noreferrer"&gt;pinguxx/easyapps-7-test2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m not the best at testing, but this shows a couple of ways to test our components and elements.&lt;/p&gt;

&lt;p&gt;As always, let us know your feedback and what else you want to see in this series. Thanks for reading!&lt;/p&gt;




</description>
      <category>hyperhtml</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 6, Customizing my custom elements</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Mon, 03 Jun 2019 17:52:19 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-1e73</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-1e73</guid>
      <description>&lt;p&gt;Part 6 written by Trevor Ganus, &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-5hdl-temp-slug-7285698"&gt;Custom elements with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Customizing my custom elements&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g"&gt;Testing!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxzi3jj2xmntzk4q4seun.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxzi3jj2xmntzk4q4seun.jpeg" width="500" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Recap
&lt;/h3&gt;

&lt;p&gt;In parts 1–5, we talked about the basics of hyperHTML. We also learned about an amazing feature called hyper.Component. We dove into “intents ” that let us extend hyperHTML and simplify our templates. While learning all this we created a simple table:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-7?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Finally, we learned the basics of custom elements and a nice little utility called hyperHTML-Element, which gives us some of the &lt;code&gt;hyper.Component&lt;/code&gt; features out of the box, and so much more.&lt;/p&gt;

&lt;p&gt;In part 6, we’re going to discover how we can convert our table from a component to a custom element. We’ll also see how easy it is to add functionality to our custom element, extending it to be even more useful. Using custom elements makes it so easy to reuse our code, a baby could do it — if the &lt;a href="https://www.amazon.com/HTML-Babies-Code-Sterling-Childrens/dp/1454921552" rel="noopener noreferrer"&gt;baby knew HTML&lt;/a&gt;, and &lt;a href="https://www.amazon.com/Javascript-Babies-Code-Sterling-Childrens/dp/1454921579" rel="noopener noreferrer"&gt;JavaScript&lt;/a&gt;, of course. Also, once we have a custom element, we don’t need hyperHTML anywhere else in our app unless we want it. This makes the custom elements plug-and-play with any framework. When was the last time a React component could say that?&lt;/p&gt;

&lt;h3&gt;
  
  
  Columns
&lt;/h3&gt;

&lt;p&gt;Let’s start thinking about the elements of the table: header, footer and body. For our case, header and footer are the important parts. We will generate the footer based on the data just like before.&lt;/p&gt;

&lt;p&gt;Let’s start with a custom element for the columns. This element will contain the information necessary to render:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the label (for the header)&lt;/li&gt;
&lt;li&gt;the attribute used for this column (from the data)&lt;/li&gt;
&lt;li&gt;if it’s sortable or not&lt;/li&gt;
&lt;li&gt;the type of data to display&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-07?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Simple right? We don’t even render anything, all the heavy lifting will be in the table itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table
&lt;/h3&gt;

&lt;p&gt;Now let’s generate a custom element with a simple table.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-08?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let’s first add a hyper-column to our HTML&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Then, we need to update our created function to read the columns and store them in an array that we can reuse later:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;(used &lt;code&gt;[].slice.call&lt;/code&gt; instead of &lt;code&gt;[…this.querySelectorAll(“hyper-column”)]&lt;/code&gt; because of an error using stackblitz)&lt;/p&gt;

&lt;p&gt;And lastly, let’s update our template to use the columns.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Well cool. But we are not really using data from anywhere… let’s fix that. We’ll add a data property.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We now need to update our &lt;code&gt;&amp;lt;tbody&amp;gt;&lt;/code&gt; part of the template to show one row for each item in the data.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;(if &lt;code&gt;wire(column, `col${item.id}`)&lt;/code&gt; looks unfamiliar to you, review &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;part 4&lt;/a&gt;!)&lt;/p&gt;

&lt;p&gt;Of course, we still need to pass data to the table. The index file is where we’ll do that.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let’s see our full code so far:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-09?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;To finish off the table, we need to add the rest of the columns. Notice, this is very similar to what we’ve done in previous parts of this tutorial!&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Intents
&lt;/h3&gt;

&lt;p&gt;Recall intents from &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;part 4&lt;/a&gt;? Let’s use intents to display icons and dates correctly. We happen to like the &lt;a href="https://octicons.github.com/" rel="noopener noreferrer"&gt;octicon&lt;/a&gt; library of icons, but you can feel free to bring your own icon set.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Then extract the rendering of the &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt;’s and &lt;code&gt;&amp;lt;th&amp;gt;&lt;/code&gt;’s for easier reading.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;(Note that, for user-provided values, you should be sure to use the ‘text’ type. Otherwise, use of ‘html’ could lead to potential HTML injection issues. Normally, hyperHTML will escape HTML used in expressions &lt;code&gt;${...}&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We are using state so let’s make sure we have a defaultState set:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And again update our template&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Much easier to follow :D.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-10?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  State &amp;amp; Events
&lt;/h3&gt;

&lt;p&gt;We need to be able to sort the data when a user clicks on the table header. Let’s add &lt;code&gt;onclick="${this}" data-call="headerClick"&lt;/code&gt; to our a tags so we can do this. We will also need to add the &lt;code&gt;headerClick&lt;/code&gt; function to handle the event.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Remember calling &lt;code&gt;setState&lt;/code&gt; will call &lt;code&gt;render()&lt;/code&gt;, so we don’t need to explicitly call &lt;code&gt;render()&lt;/code&gt; here. Let’s see our table with the sorting and icons working.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-11?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Footer
&lt;/h3&gt;

&lt;p&gt;Then at the bottom of the table, we will add our footer.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Nothing fancy here. Aaannddd we are done… or at least we replicated the component we had with custom elements. This is no small thing. Now, we can just use &lt;code&gt;&amp;lt;hyper-table&amp;gt;&lt;/code&gt; with some &lt;code&gt;&amp;lt;hyper-column&amp;gt;&lt;/code&gt; inside and you have a simple yet functional table.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-12?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft923sxj07sr18smf8nm9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft923sxj07sr18smf8nm9.jpeg" width="500" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Customization
&lt;/h3&gt;

&lt;p&gt;Every good table should be able to add/update/remove columns, right? Glad you asked! Let’s add some functions to our table that will allow us to do just that.&lt;/p&gt;

&lt;p&gt;First let’s add to our column element a new attribute called name. This will be used to update/remove columns. If no name is passed we’ll just use the attribute.&lt;/p&gt;

&lt;h4&gt;
  
  
  addColumn
&lt;/h4&gt;

&lt;p&gt;We will let the developer add a column by passing a new &lt;code&gt;&amp;lt;hyper-column&amp;gt;&lt;/code&gt;. We’ll also allow an object to be passed with the attributes needed. This will update our columns array.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h4&gt;
  
  
  removeColumn
&lt;/h4&gt;

&lt;p&gt;Based on the newly added name to the column, we can easily remove columns from the table. In theory we could use index instead of name, but I wanted to show that we can do either with the elements.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h4&gt;
  
  
  updateColumn
&lt;/h4&gt;

&lt;p&gt;Again using the name attribute, we can update the column details.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let’s see how it looks:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-13?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Well, that was easy, and we enhanced our table with very useful functionality!.&lt;/p&gt;

&lt;p&gt;Now you are a custom element/hyperHTML master :D. Or, at least you can start creating your own elements! In the next part we are going to add testing to our table element and maybe add the ability to filter the table display. Please send us your feedback to improve this tutorial.&lt;/p&gt;




</description>
      <category>hyperhtml</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 5, Custom elements</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Fri, 31 May 2019 14:50:46 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-13hc</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-13hc</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/easy-apps-with-hyperhtml/aplicaciones-f%C3%A1ciles-con-hyperhtml-5-402970bf26b4" rel="noopener noreferrer"&gt;Version en español&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part 5 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom elements with hyper&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-1e73"&gt;Customizing my custom elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g"&gt;Testing!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkt5i820cp977p20ryqy2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkt5i820cp977p20ryqy2.jpeg" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My very own tag
&lt;/h3&gt;

&lt;p&gt;If you’ve been developing web pages or apps for any amount of time, chances are you’ve seen custom components or HTML tags, especially if you’ve worked with one of the newer JavaScript frameworks. Whatever the name, these components usually all have a similar goal: encapsulate functions and logic into re-usable chunks of code. After a lot of discussion and development by the community, we finally brought these ideas under the canopy of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components" rel="noopener noreferrer"&gt;Web Components&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Web Components is a suite of different technologies allowing you to create reusable custom elements — with their functionality encapsulated away from the rest of your code — and utilize them in your web apps. — MDN&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In order to achieve this, the specification addresses the following technologies:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Custom elements&lt;/strong&gt; : A set of JavaScript APIs that lets you define the logic of the element. You can create a function like open() and then you can just call that function from the element document.querySelector(‘custom-dialog’).open().&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shadow Dom&lt;/strong&gt; : Utilizing the shadow DOM enables you to use other HTML elements inside your custom element, even other custom elements! Whatever code is inside the custom element with shadow DOM enabled will be rendered and styled separately. This can be both a bug and a feature, depending on your use case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTML templates&lt;/strong&gt; : Two tags &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;slot&amp;gt;&lt;/code&gt; let you write HTML inside the custom element, but they are not rendered or displayed until you activate them. &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;slot&amp;gt;&lt;/code&gt; can also be re-used for other things.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Not every one of these are ready to use in all browsers, and certain aspects are harder to polyfill than others, but we are getting close.&lt;/p&gt;

&lt;p&gt;For now we will concentrate on the basics of custom elements, but at the end we’ll show you how to use the shadow DOM. We’ll also see that hyperHTML can create highly efficient templates. We’ll be able to do everything with hyperHTML that &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; can, except for native use of &lt;code&gt;&amp;lt;slot&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &amp;lt;custom-element awesome=”true”&amp;gt;
&lt;/h4&gt;

&lt;p&gt;To get started making custom elements, we need need 3 things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A browser that supports custom elements, or a polyfill. We recommend using &lt;a href="https://github.com/WebReflection/document-register-element" rel="noopener noreferrer"&gt;document-register-element&lt;/a&gt;. This polyfill has been used in production for a while by projects like amp. Alternatively, Google also has a polyfill worth checking out.&lt;/li&gt;
&lt;li&gt;A class that extends the HTMLElement object. This class will contain all the logic for our element. We can also extend from a normal HTML element.&lt;/li&gt;
&lt;li&gt;Finally, we will need to “define” the element. This is how we’ll register our element in the browser, and give it a name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In 2 above, we mentioned that there are two ways to extend your custom element class, either by extending HTMLElement, or a build-in HTML tag like span. When we extend HTMLElement, our custom element will be autonomous. However, extending built-ins is a bit controversial, and while the specs describe how to do it, not all browsers are on board. We will see how do both, but for our use case in this blog we are only going to extend from HTMLElement.&lt;/p&gt;

&lt;p&gt;Enough jibber-jabber, show me the code!&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-01?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;(A tiny, huge thing in the index.html, since Stackblitz is automagically transpiling our code, we need to include the es5-adapter)&lt;/p&gt;

&lt;p&gt;Lets dissect the code a bit:&lt;/p&gt;

&lt;p&gt;First we name our class and extend HTMLElement. This will be an autonomous element. Then, we have a function called &lt;code&gt;connectedCallback()&lt;/code&gt;. &lt;code&gt;connectedCallback()&lt;/code&gt; will be called after the browser has appended the custom element to the document. We’ll talk more about the custom element lifecycle later on. Inside &lt;code&gt;connectedCallback()&lt;/code&gt; we are just adding text to our custom element.&lt;/p&gt;

&lt;p&gt;On line 9 we are defining our element name. Whatever name you choose, you must include a hyphen. In our case, to use this element in HTML we will use the tag &lt;code&gt;&amp;lt;custom-element&amp;gt;&amp;lt;/custom-element&amp;gt;&lt;/code&gt;. The define function also takes a second parameter which is the class describing the element.&lt;/p&gt;

&lt;p&gt;Internally, the browser keeps a registry of all the custom elements we define. One of the things we can do with the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry" rel="noopener noreferrer"&gt;CustomElementRegistry&lt;/a&gt; is wait for the elements to be defined. However, we can do a lot of other things. So be sure to take a look at the docs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvgfae4em27rzcg25n2np.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvgfae4em27rzcg25n2np.jpeg" width="325" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just for funz lets see how to extend a built-in:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-02?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  Life cycle
&lt;/h4&gt;

&lt;p&gt;Besides &lt;code&gt;connectedCallback()&lt;/code&gt; there are other lifecycle hooks we can use. Let’s see what they do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;connectedCallback&lt;/strong&gt; : called when your element is connected to the document DOM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;disconnectedCallback&lt;/strong&gt; : called when your element is detached from the DOM. You will be able to react to that disconnection in this function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;adoptedCallback&lt;/strong&gt; : is called when you move the element to a new page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;attributeChangedCallback&lt;/strong&gt; : this is called whenever attributes that you are monitoring change. Not every attribute on your custom element will automatically be monitored. To pick which attributes are, you will have to add another function:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static get observedAttributes() {return ['attr1', 'attr2']; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s see these functions in action in our custom-element:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-03?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is cool! We’re well on our way to having a powerful new element. But what about templating? With hyperHTML, we can render whatever we want inside the element and boom, custom elements with all the power of hyperHTML :D&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft7quybnexuubl7rtx5xg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft7quybnexuubl7rtx5xg.gif" width="220" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s make a few changes. Of course, we first need to load hyperHTML. Then we will bind to the current element with &lt;code&gt;this.html = bind(this);&lt;/code&gt; We also need a &lt;code&gt;render()&lt;/code&gt; function which will be charged with rendering the template. And finally, we need to update our &lt;code&gt;attributeChangedCallback()&lt;/code&gt; to change new attribute values to actual properties:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-04?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Enter hyperHTML-element
&lt;/h3&gt;

&lt;p&gt;There is a lot more to learn about custom elements, but fortunately the master &lt;a href="https://medium.com/u/cc83da4b8256" rel="noopener noreferrer"&gt;Andrea Giammarchi&lt;/a&gt; created another utility that abstracts much of the custom element API. It’s called &lt;a href="https://github.com/WebReflection/hyperHTML-element" rel="noopener noreferrer"&gt;hyperHTML-element&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is a class that you can extend instead of the HTMLElement, and it gives you a few new functions and properties.&lt;/p&gt;

&lt;h4&gt;
  
  
  Functions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Besides the regular &lt;code&gt;observedAttributes&lt;/code&gt; we now also have &lt;code&gt;booleanAttributes&lt;/code&gt;. This is where we’ll want to put the attributes that don’t need an actual value. For example, &lt;code&gt;&amp;lt;custom-element required&amp;gt;&lt;/code&gt;. “Required” either exists or it doesn’t, so it is a great candidate for being a boolean attribute.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;observedAttributes&lt;/code&gt; and &lt;code&gt;booleanAttributes&lt;/code&gt; both will also define getters and setters for every attribute observed. This means we no longer need to do &lt;code&gt;this[name] = newValue&lt;/code&gt; inside attributeChangedCallback.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;created&lt;/code&gt;. This is a new callback that will be invoked right before &lt;code&gt;connectedCallback&lt;/code&gt; or &lt;code&gt;attributeChangedCallback&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;defaultState()&lt;/code&gt;. Whenever you use this.state, the &lt;code&gt;defaultState()&lt;/code&gt; function returns an object that becomes, you guessed it, the default state.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setState&lt;/code&gt;. Updates the state object (you don’t need to define &lt;code&gt;defaultState&lt;/code&gt; to use &lt;code&gt;setState&lt;/code&gt;). &lt;code&gt;setState&lt;/code&gt; includes a little bonus: it will call &lt;code&gt;render()&lt;/code&gt; for you, so your element is automatically updated when you change its state!&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt;. This function should return the HTML you want to display inside your custom element.&lt;/li&gt;
&lt;li&gt;Event handlers. In your template, we can now pass ‘this’ to our event handlers: &lt;code&gt;&amp;lt;div onclick=${this}&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;. If we then define an &lt;code&gt;onclick&lt;/code&gt; function inside the element, it will get called with the proper context. You can also use data-call to call any function: &lt;code&gt;data-call=onAnyEvent onclick=${this}…&lt;/code&gt; in this case &lt;code&gt;onAnyEvent&lt;/code&gt; will be called when a user clicks. Even more cool, custom events are super easy: &lt;code&gt;onMyCustomEvent=${this}&lt;/code&gt; and you define a &lt;code&gt;onMyCustomEvent(e)&lt;/code&gt; function, done!&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;define()&lt;/code&gt;. This static method is just a helper. Instead of using &lt;code&gt;customElements.define&lt;/code&gt; you use this one &lt;code&gt;MyElement.define('my-element')&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All the hyperHTML functions, &lt;code&gt;bind&lt;/code&gt;, &lt;code&gt;component&lt;/code&gt; and &lt;code&gt;wire&lt;/code&gt;. The only hyper function we don’t get is define for intents, since we’re already using it to register the element. To define intents you will use &lt;code&gt;HyperHTMLElement.intent(…)&lt;/code&gt;. We looked at intents in another &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;part 4&lt;/a&gt; of this blog, so be sure to brush up on them if you need to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Observant readers will notice some of these functions are used in &lt;code&gt;hyper.Component&lt;/code&gt;. Hopefully you are familiar with some of them now :D&lt;/p&gt;

&lt;h4&gt;
  
  
  Properties
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;this.html&lt;/code&gt;. In our example above we did &lt;code&gt;this.html = bind(this);&lt;/code&gt; in the &lt;code&gt;constructor&lt;/code&gt;. With hyperHTML-elemet we now can use &lt;code&gt;this.html&lt;/code&gt; directly.&lt;/li&gt;
&lt;li&gt;state. State is an object that holds the…er…state of the element. It’s empty by default, or it will hold whatever object is returned by &lt;code&gt;defaultState&lt;/code&gt;, if you’ve defined that function.&lt;/li&gt;
&lt;li&gt;As mention before, every attribute in &lt;code&gt;observedAttributes&lt;/code&gt; and &lt;code&gt;booleanAttributes&lt;/code&gt; will have its getter and setter, so you can use &lt;code&gt;this.attr&lt;/code&gt; and the value will reflect the attribute. For example, &lt;code&gt;&amp;lt;my-element parent="your mom"/&amp;gt;&lt;/code&gt;, using &lt;code&gt;this.parent&lt;/code&gt; will give you the value, “your mom.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sweet! Let’s update our previous element to use all of these new features:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-05?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fovvgbadtxty148sp40sp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fovvgbadtxty148sp40sp.gif" width="500" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What about the shadow DOM?… oh yeah, it’s super easy:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/intermediate-ce-06?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Check line 8 &lt;code&gt;this.attachShadow({mode: ‘open’});&lt;/code&gt;, if you inspect the element you’ll see that the shadow DOM is there!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi3vir4m3wurrp5h4gxzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi3vir4m3wurrp5h4gxzy.png" width="466" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is more to learn about custom elements and web components in general. In the next part we will write some custom logic and update our table from &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;part 4&lt;/a&gt; to be a custom element. And as always, feedback is welcome!&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>hyperhtml</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 4, wire types and intents</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Thu, 30 May 2019 16:38:44 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/easy-apps-with-hyperhtml/aplicaciones-f%C3%A1ciles-con-hyperhtml-4-785f5d35f895" rel="noopener noreferrer"&gt;Version en español&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part 4 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;Moar about components and simple state management&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Wire types and custom definitions (intents)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-13hc"&gt;Custom elements with hyper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-1e73"&gt;Customizing my custom elements&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g"&gt;Testing!&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In previous parts of this tutorial, we’ve seen how to use components with hyperHTML. We built a simple table that could sort, but now it’s time to look at some additional features hyperHTML brings us. The feature we’ll look at next is the ability to customize wire(). With a custom wire() function, we’ll be able to transform our templates, or load parts of them asynchronously. Before we dive into this, let’s explore the standard wire() function a little more.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Built-in Types&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;HyperHTML wire() comes with two built-in types. Its default is html, but hyperHTML also supports svg. As we’ve seen, using the html type requires no additional work on our part. However, if we want to wire an svg node, we need to explicitly say so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hyperHTML.wire(data, 'svg')`&amp;lt;rect width=${data.width} height=${data.height} /&amp;gt;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second parameter passed to wire is the type. Let’s see the example running:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-types-svg?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Recall all the way back to &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;part 1&lt;/a&gt;. In our clock example, we used wire() two ways. First, we used it without a reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hyperHTML.wire()`…`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But then we also used it by passing an object to the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hyperHTML.wire(user)`…`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that first example we mentioned that the object passed to wire() will not be updated each time it renders. This is because by passing it to wire() we are creating a a relationship between wire and the contents of the object. This relationship does more than just speed up renders, we can also re-use this object in different places, with different templates. We might then give this object an id for each place we want to use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hyperHTML.wire(user, ':address')`…`
hyperHTML.wire(user, ':profile')`…`
hyperHTML.wire(user, ':login')`…`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-types-user?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We can also specify a type alongside the id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hyperHTML.wire(user, 'svg:avatar')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Content Values
&lt;/h4&gt;

&lt;p&gt;We also talked a bit about the different content values in &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;part 1&lt;/a&gt;. Let’s dive deeper into them now.&lt;/p&gt;

&lt;p&gt;Think about template literals. Inside a template literal we use ${…} to evaluate expressions. Whatever expression you pass into the ${…} will be added to your template depending on it’s evaluated type. For example, hyperHTML is injection-safe by default since passing strings will be injected to the template as &lt;code&gt;textContent.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Hola ${'&amp;lt;script src="http://badguy.com"&amp;gt;&amp;lt;/script&amp;gt;'}&amp;lt;/p&amp;gt; // whew, safe!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But you can also force it to be text. In order to do that, you have to pass an object to hyperHTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Hola ${{text: 'Mundo'}}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And yes, if you pass a node it will be appended:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Hola ${node}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or you can force it by passing an object, like above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Hola ${{html: '&amp;lt;strong&amp;gt;Mundo&amp;lt;/strong&amp;gt;'}}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even pass a promise! If you do pass a promise, then whenever the promise is resolved it will be resolved to any of the understood types. There is also a type, any. Any usually takes a promise, but can take any other type as well, and hyperHTML will try to match it.&lt;/p&gt;

&lt;p&gt;See them in action:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-values?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;But wait, that’s not all! You can also pass arrays! The only thing to keep in mind is the items in the array &lt;strong&gt;&lt;em&gt;must&lt;/em&gt;&lt;/strong&gt; be of the same type: strings or numbers or nodes, or even a list of promises. You’ll get unexpected results if your array is populated with different types.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-array?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We typically use promises when we don’t have data now, but are promised to have in the future. HyperHTML provides a placeholder that displays while the data is loading. Let’s see an example.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-placeholder?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  Attributes
&lt;/h4&gt;

&lt;p&gt;Element attributes can be regular attributes, booleans, or events. If you’re coming to hyperHTML from another framework, you might be expecting to use partial attributes, but &lt;a href="https://viperhtml.js.org/hyperhtml/documentation/#essentials-7" rel="noopener noreferrer"&gt;you don’t actually need them&lt;/a&gt;. There are two more attribute types we need to talk about — style and data. These attributes will help us easily build interfaces.&lt;/p&gt;

&lt;p&gt;The style attribute can take a string like any other attribute, or you can also pass an object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wire(ref)`&amp;lt;p style=${{fontSize: 32}}&amp;gt;${'BIG CONTENT'}&amp;lt;/p&amp;gt;`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The data attribute lets you pass raw JavaScript data to an element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wire(ref)`&amp;lt;p data=${user} /&amp;gt;`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s see them in action&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-attributes?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Custom types
&lt;/h3&gt;

&lt;p&gt;We can tap into that object functionality and create our custom render parts. And depending on the name, it will be interpreted as an attribute (if it has ‘-’), or as a new intent.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom intent
&lt;/h4&gt;

&lt;p&gt;To define a new type, we will use &lt;code&gt;hyperHTML.define()&lt;/code&gt;&amp;nbsp;. Convenient, right? Define() takes two parameters, a string name and a callback.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;define(intentName, callback)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The callback receives any interpolated data as parameters, and returns data that we’ll use in the display. The callback can return any of the known data types.&lt;/p&gt;

&lt;p&gt;For example, let’s define an intent for dates. Whenever we receive a date, we will return a nicely formatted date. Let’s also use an asynchronous intent:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-custom?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;HyperHTML will first try to match on any known intents like html, text or any. If it cannot find a match, it will try with the ones it has in its registry, that is, the ones defined with &lt;code&gt;hyperHTML.define()&lt;/code&gt;. If hyper finds it there, it will use your custom intent.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom attributes
&lt;/h4&gt;

&lt;p&gt;As mentioned before, if you define the intent with a ‘-’ in the name, it will be treated as an attribute. This means we can add any custom attribute to any element.&lt;/p&gt;

&lt;p&gt;Whoah. Seriously?&lt;/p&gt;

&lt;p&gt;Yep, you bet.&lt;/p&gt;

&lt;p&gt;In our next example, the callback will receive the node element and whatever value passed to the attribute. If you return something, it will be used as the value for the attribute. Be sure to note, that to make the custom attribute work you must use &lt;code&gt;${…}&lt;/code&gt; for the attribute value.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/wire-custom-attribute?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;With what we now know, let’s update our table from &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l"&gt;part 3&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-6?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We’ll add an svg icon, so we know what column is currently sorted and if it’s ascending or descending. Let’s also update our data array with more accurate user information, as well as a date so we can put our date intent to good use.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-7?file=intents.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We are using the &lt;a href="https://octicons.github.com/" rel="noopener noreferrer"&gt;Octicons&lt;/a&gt; icon pack. Now for the rest of the code. Be especially sure to take a look at the Header and the Table files.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-7?file=Header.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;Sweet! Now you know how powerful hyperHTML can be. This is pretty much everything there is to learn about the library itself, but we are going to tap into some other utilities provided by &lt;a href="https://medium.com/@WebReflection" rel="noopener noreferrer"&gt;Andrea Giammarchi&lt;/a&gt; to add more tools to our belt. With all these tools combined, we’ll be able to create awesome and high-performing web applications.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>hyperhtml</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Easy apps with hyperHTML — 3, components and state</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Wed, 29 May 2019 14:20:32 +0000</pubDate>
      <link>https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l</link>
      <guid>https://dev.to/pinguxx/easy-apps-with-hyperhtml-3-1m3l</guid>
      <description>&lt;h2&gt;
  
  
  Moar about components and simple state management
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://medium.com/easy-apps-with-hyperhtml/aplicaciones-f%C3%A1ciles-con-hyperhtml-3-fc4a0503f498" rel="noopener noreferrer"&gt;Version en español&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part 3 written by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__60874"&gt;
    &lt;a href="/pinguxx" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60874%2F62ed777d-99a3-400f-8c8c-4e84ddd60519.jpeg" alt="pinguxx image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/pinguxx"&gt;Ivan&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/pinguxx"&gt;standard geek&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div class="ltag__user ltag__user__id__171460"&gt;
    &lt;a href="/paritho" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F171460%2F77afa02d-8ec9-403a-8919-6d9e44bdda75.jpg" alt="paritho image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/paritho"&gt;Paul Thompson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/paritho"&gt;lover of dogs and javascript.

and coffee.

and writing.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-1-31cc"&gt;Introduction, wire/bind&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;Events and components&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Moar about components and simple state management&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-4-38k3"&gt;Wire types and custom definitions (intents)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-5-13hc"&gt;Custom elements with hyper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-6-1e73"&gt;Customizing my custom elements&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-7-5b9g"&gt;Testing!&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-8-async-loading-5d96"&gt;Async loading, placeholder and a Typeahead with hyper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-9-routing-59k0"&gt;Handling routes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-10-3rd-party-libraries-2n7b"&gt;3rd party libraries&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn4cj6necusdwcn049mr5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn4cj6necusdwcn049mr5.jpeg" width="500" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/pinguxx/easy-apps-with-hyperhtml-2-hbi"&gt;part 2&lt;/a&gt;, we used hyper Components to create a table that can be sorted. Before we add to our table, let’s review the code we previously wrote.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5?ctl=1" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Table components
&lt;/h3&gt;

&lt;p&gt;Did you notice there are parts of the code we can reuse? If we refactor our code, we can use parts for other tables and it will be easier to maintain those parts instead of updating the entire table for every change. These parts are great candidates for such a refactor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The main table definition&lt;/li&gt;
&lt;li&gt;  The header (row and columns)&lt;/li&gt;
&lt;li&gt;  Body (rows and columns)&lt;/li&gt;
&lt;li&gt;  Footer… well we don’t have a footer yet but we will add one just for fun&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at how we can change these parts to be more maintainable and reusable.&lt;/p&gt;

&lt;h4&gt;
  
  
  Table
&lt;/h4&gt;

&lt;p&gt;First, let’s create a Table.js file and move most of the code there. We won’t need to use bind() in this file, instead we’ll export our Table.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-1?file=Table.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Next, let’s update index.js to import our table. This is where we’ll use the bind() function. Recall that bind() works on existing domNodes like document.body. Also note how we’re passing information to the Table: through an object in the constructor.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-1?file=index.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h4&gt;
  
  
  Header
&lt;/h4&gt;

&lt;p&gt;Our Header class will extend Component as well.&lt;/p&gt;

&lt;p&gt;Let’s first move the &lt;code&gt;&amp;lt;thead&amp;gt;&lt;/code&gt; element of our table to render(), making it look like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In this template we have onclick listeners attached to our &lt;code&gt;&amp;lt;th&amp;gt;&lt;/code&gt; tags. Since we don’t want to manage the state in this class, we are going to dispatch a custom event called sort. This custom event will have some details about the sorting like the column we are sorting on and if it is ascending or descending.&lt;/p&gt;

&lt;p&gt;We are going to add an update function as well. By using this function, we can be sure we’re always rendering with the current data. If the data changes in the parent, our header will receive the new data. It will look like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Dispatch is a function provided by Component. It will create a custom event with a name based on the first parameter, and the details object based on the second parameter. This is a pretty useful function. Learn more about dispatch() in the &lt;a href="https://viperhtml.js.org/hyperhtml/documentation/#components-3" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. Our onclick event handler now looks like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And here’s the complete Header class:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-2?file=Header.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now let’s update Table to load the header component. Import again is our friend. Then, in place of the &lt;code&gt;&amp;lt;thead&amp;gt;&lt;/code&gt; mark-up in the render, let’s use the Header class &lt;code&gt;${Header.for(this).update(this.state)}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Component.for its a utility that helps you create components in render(). Instead of creating the component somewhere else, you can create it right there in the function itself. Header.for(object) will then tie the header to the object passed, in this case our current table class, then call update to re-render the header with the state, this will passed on every render. We will use other ways to instantiate the modules later on. Read more in the &lt;a href="https://viperhtml.js.org/hyperhtml/documentation/#components-3" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lastly, we will add an event listener called onsort to the table: &lt;code&gt;onsort="${this}"&lt;/code&gt;. This function will listen to the sorting event we dispatched from the Header. We need to change the &lt;code&gt;onclick&lt;/code&gt; function to &lt;code&gt;onsort&lt;/code&gt;, and we’ll also simplify it a little. The information about the sort is coming in the event detail object. We can then sort the array like before and update the state of the table. Remember, we are passing this state down to the Header class.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let’s take a look at the full code to this point:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-2?file=Table.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h4&gt;
  
  
  Body
&lt;/h4&gt;

&lt;p&gt;For our body component, let’s do the same thing — move the &lt;code&gt;tbody&lt;/code&gt; from the render function of the Table to a new component called Body. Body will have its own render function; we’ll put the &lt;code&gt;tbody&lt;/code&gt; code here:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Despite being the component that renders most of our table, this component is actually pretty compact. Let’s see the full file:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-3?file=Body.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Notice the line:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.props = props;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We’ll use this to pass data to the Body component. The information we pass will be the information shown in our Table.&lt;/p&gt;

&lt;p&gt;Now, let’s update Table to load the Body component, using import just like before:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { Body } from './Body';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this case, let’s mix it up a little bit. Instead of Component.for, let’s create a new Body in the constructor. We don’t need to pass data on instantiation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.body = new Body();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With that, we have a table that will work correctly. It will sort, but our data is not really changing (adding or removing). But what if the data does change? We can add the update function inside Body to receive data, just like in Header.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This way we always receive the latest data from the Table. Now, we call the update() function on the Body component directly:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.body.update(this.data)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s see how it looks.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-5-4?file=Table.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Footer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And as promised… we are going to add a little footer to our table. The footer will show the total number of records. Beside the html for the footer, there is nothing new in this class. Take a look:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-6?file=Footer.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We’ll update the Table component to load the Footer component. Let’s use Component.for and the update function since we always want to receive the latest data. Otherwise, our count of the items in the table will not be accurate.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Footer.for(this).update(this.data)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-6?file=Table.js" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Aaannddd we are done! We have our simple table with simple state management: we pass data down and events up. We could have used a state management library, Redux or Flux. For our Table, we don’t really need to use anything more complex than what we currently have.&lt;/p&gt;




&lt;p&gt;Before we move on to part 4, let’s explore a small library called &lt;a href="https://proppyjs.com/" rel="noopener noreferrer"&gt;ProppyJS&lt;/a&gt;. ProppyJS isn’t a state management library, but a library that allows us to compose properties. This is useful to compose props from various sources and use them in any component — in essence, we’re allowing ourselves a vast amount of freedom with our apps. With proppy, we could easily attach a redux store if we needed it later, when our component state gets more complex.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/basics-table-6-p?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We created a prop factory and we use that p everywhere. It condensed our code a lot, and now the header is updating the sort directly. Let us know in the comments if you have questions about implementing ProppyJS.&lt;/p&gt;




&lt;p&gt;We want these tutorials to be as awesome as they can be! If you have feedback, please be sure to leave it in the comments. Thanks for reading, and stay tuned for the next part where we’ll explore a powerful feature called “intents.” Intents will let us expand hyperHTML with custom definitions for our templates.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>hyperhtml</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
