# Tool

The page of a tool in two parts: the settings and what they make, side by side when both fit and one above the other on a phone.

### Known issues
None known.

### Copy the markup
The settings are a `<form>` and come first; the result is a `<section>` with its actions on top. Two short fields share a row, and the options rarely changed are folded:

Tool markup
```html
<div class="luz-tool">
  <form class="luz-tool__settings o-stack" aria-labelledby="settings-title">
    <h2 id="settings-title">Settings</h2>
    <div class="o-grid o-grid--split">
      <div class="luz-field">
        <label class="luz-field__label" for="country">Country</label>
        <select class="luz-select" id="country">…</select>
      </div>
      <div class="luz-field">
        <label class="luz-field__label" for="rows">Rows</label>
        <input class="luz-input" id="rows" type="number" value="20" min="1" max="1000">
      </div>
    </div>
    <details>
      <summary>More options</summary>
      <fieldset class="luz-fieldset">…</fieldset>
    </details>
  </form>
  <section class="luz-tool__result o-stack" aria-labelledby="result-title">
    <div class="o-row">
      <h2 id="result-title">Result</h2>
      <button class="luz-btn luz-btn--primary" type="button">Download CSV</button>
      <button class="luz-btn luz-btn--ghost" type="button">Copy</button>
    </div>
    <p role="status">20 rows for Spain</p>
    <div class="luz-table-wrap" role="region" aria-label="Rows made" tabindex="0">
      <table class="luz-table">…</table>
    </div>
  </section>
</div>
```

### Variants and options
No modifier. A block and its two parts.

- `.luz-tool`: The block: a row that wraps, xl between the columns and lg between the rows
- `.luz-tool__settings`: The settings, first: about 18rem wide while the result is beside them, the whole width below
- `.luz-tool__result`: What the settings make: it takes what is left of the row, and goes below the settings when it would be narrower than half of it

### How it works
CSS from `components/tool.css` of `@luz-ds/catalog`: a flexible row that wraps, with no media query. No JavaScript.

- The two parts sit side by side while the result keeps half the row beside 18rem of settings, from about 640px of room. Below that, the result wraps under the settings, in the order of the markup.
- It answers to the room it has, not to the window: inside an app with a sidebar, or with larger text, it stacks sooner.
- A wide table never widens the result: it scrolls inside its `.luz-table-wrap`.
- What fills the result and answers the settings is your script; the pattern only places the two parts.

### Without JavaScript
The layout does not change: it is CSS. A tool that computes in the browser says in a `<noscript>` that it needs its script, and keeps its heading, its text and its form readable.

### Keyboard and ARIA
- **Order:** the order of the source, which the layout does not change: the settings, then the result and its actions.
- **Landmarks:** name the form and the section by their headings with `aria-labelledby`, and give the table wrapper a name of its own, so no two regions share one.
- **Answers:** a `role="status"` line in the result says what was made, so a screen reader hears the answer to a change of the settings.

### When to use
Use it for a page that is a tool: the visitor sets a few things and takes a result away, again and again.

- A generator, a converter, a calculator or a formatter.
- The hero of a landing page whose product is used in the page.

### When not to use
Do not use it for a form that is sent and answered later, such as a sign-up: that is one column.

- A view of figures and data takes the [dashboard](https://luzds.com/docs/catalog/dashboard/).
- A navigation beside the content is the [sidebar](https://luzds.com/docs/catalog/sidebar/), not the settings column.
