Explainer pieces
An explainer is the page that says how a demo works, the one the strip’s “How it works” link opens. These are its layout and its pieces: steps, panels, tables and code blocks.
The steps, panels, tables and code blocks are each drawn inside an explainer, at the sizes and width one gives them. Each piece is shown twice: live in your theme, marked Live, and as a preview in the other. Under each name is the code behind it. To see the other theme live, choose Light or Dark next to Theme, at the top of the page. The layout of a whole explainer is a picture in both themes, since a live copy would give this page a second main heading.
The layout
The layout is a picture here. How the design kit works, this site’s own explainer, is a live one.
An explainer's opening and its first section
The code behind it:
class="dk-explainer"withdk-explainer-header dk-explainer-lead dk-button dk-button-accent dk-explainer-numberLightDark, a picture
How Example works
Example holds stock for each order, so two customers never buy the same last unit.
What happens when an order comes in
An order names a product and how many it wants, then waits its turn behind any other order for the same product.
What usually goes wrong
Two orders for the last unit arrive at once, and only the first to hold it goes through.
LightDark, a picture
How Example works
Example holds stock for each order, so two customers never buy the same last unit.
What happens when an order comes in
An order names a product and how many it wants, then waits its turn behind any other order for the same product.
What usually goes wrong
Two orders for the last unit arrive at once, and only the first to hold it goes through.
The code, An explainer's opening and its first section
Markup, An explainer's opening and its first section<div class="dk-explainer-header"><a href="../">Example</a></div> <div class="dk-explainer"> <h1>How Example works</h1> <p class="dk-explainer-lead"> Example holds stock for each order, so two customers never buy the same last unit. </p> <p><a class="dk-button dk-button-accent" href="../">Open the demo</a></p> <section> <p class="dk-explainer-number" aria-hidden="true">01</p> <h2>What happens when an order comes in</h2> <p> An order names a product and how many it wants, then waits its turn behind any other order for the same product. </p> <h3>What usually goes wrong</h3> <p> Two orders for the last unit arrive at once, and only the first to hold it goes through. </p> </section> </div>
What the tests check for The layout
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
e2e/explainer.spec.tsx, in a browser
Steps
The steps of a flow
The code behind it:
class="dk-steps"withdk-steps-title dk-steps-note dk-steps-arrow- The order names a product. It says how many it wants.
- It waits its turn. Behind any order for the same product.
LightDark, preview only
- The order names a product. It says how many it wants.
- It waits its turn. Behind any order for the same product.
The code, The steps of a flow
Markup, The steps of a flow<ol class="dk-steps" role="list"> <li> <strong class="dk-steps-title">The order names a product.</strong> <span class="dk-steps-note">It says how many it wants.</span> </li> <li> <span class="dk-steps-arrow" aria-hidden="true">↓</span> <strong class="dk-steps-title">It waits its turn.</strong> <span class="dk-steps-note">Behind any order for the same product.</span> </li> </ol>
What the tests check for Steps
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
e2e/explainer.spec.tsx, in a browser
Panels
A panel
The code behind it:
class="dk-panel"withdk-panel-titleHow the numbers were taken
Each strategy ran three times on the same laptop with the same orders, and the table shows the middle run.
LightDark, preview only
How the numbers were taken
Each strategy ran three times on the same laptop with the same orders, and the table shows the middle run.
The code, A panel
Markup, A panel<div class="dk-panel"> <p class="dk-panel-title">How the numbers were taken</p> <p> Each strategy ran three times on the same laptop with the same orders, and the table shows the middle run. </p> </div>
What the tests check for Panels
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
e2e/explainer.spec.tsx, in a browser
Tables
A table of figures
The code behind it:
class="dk-table"withdk-table-title dk-table-scroll dk-table-numberOrders a second under each strategy
Scenario Orders a second Slowest 1%, ms Hot product, row lock 700 48.5 LightDark, preview only
Orders a second under each strategy
Scenario Orders a second Slowest 1%, ms Hot product, row lock 700 48.5 The code, A table of figures
Markup, A table of figures<p class="dk-table-title" id="bench-title">Orders a second under each strategy</p> <div class="dk-table-scroll" role="region" aria-labelledby="bench-title" tabindex="0"> <table class="dk-table" aria-labelledby="bench-title"> <thead> <tr> <th scope="col">Scenario</th> <th scope="col" class="dk-table-number">Orders a second</th> <th scope="col" class="dk-table-number">Slowest 1%, ms</th> </tr> </thead> <tbody> <tr> <th scope="row">Hot product, row lock</th> <td class="dk-table-number">700</td> <td class="dk-table-number">48.5</td> </tr> </tbody> </table> </div>
What the tests check for Tables
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
e2e/explainer.spec.tsx, in a browser
Code blocks
A block of code
The code behind it:
class="dk-code"withdk-code-titleThe statement that holds the stock
UPDATE stock SET held = held + 1 WHERE product_id = $1 AND held < on_hand;LightDark, preview only
The statement that holds the stock
UPDATE stock SET held = held + 1 WHERE product_id = $1 AND held < on_hand;The code, A block of code
Markup, A block of code<p class="dk-code-title" id="lock-title">The statement that holds the stock</p> <pre class="dk-code" role="region" aria-labelledby="lock-title" tabindex="0" translate="no" ><code>UPDATE stock SET held = held + 1 WHERE product_id = $1 AND held < on_hand;</code></pre>
What the tests check for Code blocks
These are the design kit’s own tests for this part, by the file each is in. They come from the source on GitHub as it was when this page was built, so they can be newer than the version named in the footer. Each file name opens that file as it was then.
e2e/explainer.spec.tsx, in a browser