# Infusion

#
Installation

Infusion is built using the static site engine, Hugo, and NPM. The codebase is available to download on Github. Let’s get everything installed step-by-step.

## Install Hugo

First you need to install Hugo globally.

### OSX users

If you are a Mac user and have Homebrew on your system, installing Hugo is simple:

    brew install hugo

Alternatively, you can manually install Hugo from a package. You can verify the installation was successful by typing:

    hugo version

### Windows users

Installing on Windows is a bit more involved than on OSX. The authors of Hugo provide a guide with instructions for technical and less technical users.

It’s also best you install a Windows Subsystem for running Linux, and therefore bash (Infusion incorporates some bash commands in its scripts). Microsoft offer a complete guide.

## Install Node & NPM

It is likely you already have Node and NPM installed on your system. If so, you can skip this step. Otherwise, refer to NPM’s own guide, which includes a video tutorial.

## Get the files

Infusion is hosted on Github. To start using it, you’ll need to get the files from there. If you are comfortable with the command line, just fork the github.com/ThePacielloGroup/infusion repository, then do a `git clone` to your local system. Replace `[your username]` in the following:

    git clone https://github.com/[your username]/infusion.git

If the command line is not your thing, use Github’s web interface to fork github.com/ThePacielloGroup/infusion and choose Open in Desktop from Clone or download (see figure 1, below).

The Github web interface

If you do not have a version of the Github desktop client installed, follow the prompts after clicking Open in Desktop.

Once you have your local copy of the files, move to the root of that folder and in your terminal run an npm installation:

    npm install

Now it’s time to consult the
Setup pattern.

#
Setup

By now, you should have followed the
Installation instructions. You should have Hugo and Node installed, and a local copy of a forked version of Infusion. You should also have run `npm install` in the root of that codebase.

## “Cleaning” the content folder

Before you can start writing documentation, there are a few things still to do in order to get set up. At the moment, your version of Infusion is a facsimile of the original, containing all the content you’re reading right now. We want to delete that content and replace it with some starter content. There’s a simple `clean` command for this.

If you are contributing to an existing Infusion library, do not run the following command. It will delete all of the patterns in that library. The `clean` command is just for libraries that you are starting from scratch.

      npm run clean

This will leave your `content` folder with just an `_index.md` file and a `patterns` folder containing a single demonstration pattern file. Individual content pages in Infusion are referred to as “patterns” — think pattern libraries). Find out more about these in
Project structure.

## The config file

You’ll also want to name your project and configure one or two other things in the `config.toml` file that’s found at the root of your project. Here’s how that file looks:

    languageCode = "en-us"
    title = "Infusion"
    baseURL = "https://thepaciellogroup.github.io/infusion/"
    theme = "infusion"

    [params]
      description = "Documentation for the **Infusion** documentation builder. This documentation is constructed using the builder itself."
      codePenUser = "Heydon"

- title — This is the project’s name, like “Megacorp 5000 Pattern Library” or “Assplosion.js Documentation”. For Infusion’s own version of Infusion, the `title` is simply Infusion :-)
- baseURL — This is the root of the live site. Typically you will publish the site to Github Pages, so this should be the base URL for your Github Pages site.
- theme — This is the theme the library is using. Don’t change this from “infusion”.
- description — This is a short description of your documentation project and comes under the logo. You can include markdown syntax here, like **Infusion** in the above example for making the name of the library bold.
- codePenUser — If you want to embed codePens in your pattern files, you need to supply a codePen username here.

## The Web App Manifest

Infusion projects work as progressive web applications, meaning users can save them to their home screen and read them offline. The web app manifest, found at the root of the `static` folder, defines names and icons for the app. You’ll probably want to open `/static/manifest.json` and personalize the `name` and `short_name` values.

    {
     "name": "Infusion Documentation Builder",
     "short_name": "Infusion Docs",
     "icons": [
      {...

Infusion’s Docs, with `short_name` displayed, available from the homescreen of a Samsung/Android phone.

The `short_name` value refers to the text that appears under the icon on your homescreen. As the name suggests, it should be as short as possible to fit well (12 characters or fewer is ideal).

## Including a logo

In the `images/static` folder, you’ll find a `logo.svg` file. Replace this file with your own company or project logo, under the same file name. Currently, only SVG is supported this easily because SVG is the superior format for logos. However, if you must use a different format, you can open up the `themes/infusion/layouts/_default/baseof.html` file and edit the image reference:

    <a class="logo" href="/" aria-label="{{ .Site.Title }} pattern library home page">
      <img src="{{ "images/logo.svg" | absURL }}" alt="">
    </a>

Now that your logo is in place, everything should be ready. Where next? You can learn about
Project structure to help you get writing, or find out how to serve the site locally and on Github Pages in
Serving.

#
Serving

## Serving locally

While you’re creating content for your project, you’ll probably want to see what the finished product looks like. Fortunately, Infusion is easy to serve locally using the `serve` command:

    npm run serve

This will serve your working project from `localhost:1313`. Whenever you make changes to your files, the site will automatically rebuild. No need to refresh the web page!

## Publishing on Github Pages

Infusion creates a `/docs` folder containing the latest version of your site whenever you do an `npm run build` or a `git commit`. So long as you forked the Infusion repository when making your own version (see
Setup), whenever you push to master, you will also be updating the site found at your Github Pages URL.

This URL will be in the following format:

    [your user name].github.io/[your library repo name]

You’ll also need to add this value to your `config.toml` file as the `baseURL`. For Infusion’s own documentation it looks like the following. Just overwrite it.

    baseURL = "https://thepaciellogroup.github.io/infusion/"

If you created a new repo’ manually (without forking) you will find the `docs` folder is not automatically setup as the publishing source. This folder can be made the source for your Github Pages site by selecting it under Settings → Github Pages → Source in the web interface.

#
Printing

Infusion’s output site includes a one-page
Print version of the generated library, available at `/print-version`. So, if your library base URL is `https://yourName.github.io/your-library`, you can print the whole library — to PDF if wanted — from the following address:

    https://yourName.github.io/your-library/print-version

Print styles are also provided for individual pattern pages so, if you wanted to print off a single pattern document, you can!

#
Updating Infusion

The core of Infusion’s functionality is in its Hugo theme, also called Infusion. This is found in the theme folder.

- content
- docs
- lib
- snippets
- static
- themes
  - infusion

Do not “hack the core”. If you have any issues with Infusion, please report them to the Infusion Github repository and they will be dealt with ASAP.

Infusion is undergoing constant development, so keep an eye out for new releases. To update to a new version of Infusion, simply run the `update` command from inside your local project folder.

    npm run update

This will save a timestamped backup of the current version, and download the latest version. Your theme folder will now look something like the following.

- themes
  - infusion
  - infusion-old-1503389765972

If you experience breaking changes and are having trouble fixing them, you can rename the old folder and revert to using it. In the meantime, you can submit an issue with the “help” tag describing your problem.

The described update process relies on SVN because Github does not support downloading individual repository folders. If you have a Mac, SVN should be installed already. If not, or if you are on Windows, you can either install SVN or download the latest Infusion theme folder manually, using the Github web interface.

#
Help

Should you need assistance using Infusion, you have a couple of options:

- Create a topic on the official Google Groups forum
- Write an issue at the Github repository, using the provided tag “help”

#
Project structure

Before you can set about making documentation, you need to know where everything goes. The simplest folder structure looks like this:

- content
  - _index.md
  - print-version.md
  - patterns
    - name-of-my-pattern.md
    - name-of-my-other-pattern.md

- /content - This is where all of your content lives. You won’t need to visit any other folders very frequently.
- _index.md — This is the content file for your home page.
- print-version.md — This is a placeholder for the single-page / print-friendly version of you library. Leave this file as it is.
- /patterns — This is the folder where individual content files are kept. Infusion refers to each individual documentation file/page as a “pattern”.

## Subsections

You may have noticed that this site’s navigation is divided partly into subsections, with labels like “Writing”. Infusion (or, rather, Hugo) allows you to create such subsections by simply nesting folders under the `/patterns` folder. In the following example, I have a subsection about different types of “popup” pattern.

- content
  - _index.md
  - patterns
    - name-of-my-pattern.md
    - name-of-my-other-pattern.md
    - popups
      - _index.md
      - popup-menu.md
      - tooltips.md

Subfolders like `/popups` must each have an `_index.md` file. This file doesn’t need any content except the TOML metadata defining the title (name) of that subsection:

    +++
    title = "Popup windows"
    +++

This title is what labels the subsection in the navigation, not the folder name (`/popups`, in this case). For each subfolder you create, you must also create one of these `_index.md` files. The `/patterns` folder itself does not need one, however.

Infusion does not currently support sub-subsections. You can only create child folders under `/patterns`.

Now that you know where to put everything, it’s time to talk about how to actually write individual patterns. Don’t worry, it’s pretty straightforward. Turn to
Markdown & metadata.

#
Markdown & metadata

In Infusion everything is documented using markdown, as a “pattern”. To create a new pattern file, just add a file with the `.md` extension to the `content/patterns` folder. It’s recommended you use “kebab case” to name the file (words separated by hyphens). For example, a pattern with the title “Menu button” should probably have the filename `menu-button`. Then you get a nice clean URL: `username.github.io/your-library/patterns/menu-button`.

If you’re not familiar with writing markdown, there are a number of tutorials available. One of the best is Mastering Markdown offered by Github. There’s also a nice cheatsheet here.

## The metadata

Like many static site generators, Hugo lets you add metadata to its markdown files. Hugo’s brand of metadata is called TOML (although YAML is also accepted). The only thing you have to put in the TOML is a `title` — like this:

    +++
    title = "Menu button"
    +++

The title automatically becomes the page’s main `<h1>` heading. The highest heading level you should use in the body of your markdown file is therefore `<h2>`.

### Tags

If you like, you can also tag the pattern so that it turns up in lists of similar content. You add tags in an array format. Note that all the TOML data is found at the top of the markdown file, between the `+++` lines.

    +++
    title = "Menu button"
    tags = ["interactive", "popup", "javascript"]
    +++

This will create links to pages listing content tagged with the same terms using the URL schema `/tag/[tag name]`. Some example tags links are provided for this page, which you can see listed under the main heading.

### Weight

By default, patterns are listed alphabetically in the navigation. However, sometimes you might like to change the order around. This is possible by adding a `weight` parameter. To make my menu button pattern appear at the top of its subsection, I would give it a `weight` of `1`:

    +++
    title = "Menu button"
    tags = ["interactive", "popup", "javascript"]
    weight = 1
    +++

The `weight` parameter should be an integer, not a string, so don’t use scare quotes around the value!

#
Expandable sections

In some cases, where there is a lot of content, it’s helpful to collapse certain sections. That way, readers get an overview of what’s in the content and can choose where to focus in. Infusion provides a shortcode method for creating expandable sections which generates accessible markup using `aria-expanded`.

The `expandable` shortcode takes three parameters:

- label — This is the label for the the section heading.
- level — This is the heading level (e.g. `level="2"` for an `<h2>`) that will contain the label. If you omit a level parameter, no heading is used; it’s just a button.
- open — Include this and give it a value of “true” or “yes” to make the section expanded on page load.

Here’s what the code might look like for a simple expandable section containing markdown:

    {{% expandable label="A section of dummy text" level="2" %}}
    Here is some markdown including [a link](https://twitter.com/heydonworks). Donec erat est, feugiat a est sed, aliquet pharetra ipsum. Vivamus in arcu leo. Praesent feugiat, purus a molestie ultrices, libero massa iaculis ante, sit amet accumsan leo eros vel ligula.
    {{% /expandable %}}

Let’s look at what that outputs:

##

Here is some markdown including a link. Donec erat est, feugiat a est sed, aliquet pharetra ipsum. Vivamus in arcu leo. Praesent feugiat, purus a molestie ultrices, libero massa iaculis ante, sit amet accumsan leo eros vel ligula.

Successive collapsible sections fit snugly together. The second of the following two has `open="true"`.

##

Mauris eget elit ut neque venenatis placerat id nec libero. Nunc accumsan cursus elit nec iaculis. Proin id rutrum magna, a aliquet sem. Sed et tortor id sem eleifend porta vitae eget elit. Cras sodales porta malesuada. Suspendisse at odio ac tortor.

##

Ut vulputate enim ut lorem iaculis, vel faucibus metus iaculis. Aliquam erat volutpat. Aliquam luctus orci vel consectetur dignissim. Nullam et efficitur lorem, et ornare est. Sed tristique porttitor justo, quis malesuada velit. Nullam et elit finibus, sollicitudin velit placerat, ultricies dui.

Unfortunately, it is not currently possible to include shortcodes inside other shortcodes, using the “`%`” notation (which is designated for markdown content). If you use the angle brackets notation (illustrated below) it is possible, but markdown will no longer be permitted. You will have to code HTML inside such a section manually.

    {{<expandable label="A section of dummy text" level="2">}}
    <p>Here is a pattern reference shortcode: {{% pattern "Writing inline demos" %}}.</p>
    {{</expandable>}}

When you go to print a pattern from your library, some print styles take care of collapsible sections, making them appear expanded and like any other section.

#
Notes & warnings

Infusion acknowledges that simple markdown is limiting when it comes to writing compelling documentation, so it provides a number of “shortcodes”. Shortcodes offer a simple syntax for including rich content. For example, Infusion provides shortcodes for including notes and warnings.

## Notes

You may wish to pick out some content in your pattern’s documentation as a note — an aside to the main thrust of the pattern’s description. This is possible using the following syntax:

    {{% note %}}
    This is a note! It's something the reader may like to know about but is supplementary to the main content. Use notes when something may be interesting but not critical.
    {{% /note %}}

Notes render like this:

This is a note! It’s something the reader may like to know about but is supplementary to the main content. Use notes when something may be interesting but not critical.

## Warnings

Warnings are like notes, but with more urgency.

    {{% warning %}}
    This is a warning! It's about something the reader should be careful to do or to avoid doing. Use warnings when something could go wrong.
    {{% /warning %}}

Warnings render like this:

This is a warning! It’s about something the reader should be careful to do or to avoid doing. Use warnings when something could go wrong.

#
References

## Cross-references

Infusion identifies the main content files in your documentation as patterns, and they’re kept in the content/ patterns folder. It’s easy to cross-reference patterns using the `pattern` shortcode. For example, I can reference the
Notes & warnings pattern. Here’s what the markdown looks like, including the shortcode:

    I can reference the {{% pattern "Notes & warnings" %}} pattern here.

This saves you having to worry about pathing and decorates the generated link with a bookmark icon, identifying the link as a pattern reference visually.

The title argument you supply to the shortcode must be exactly the same as the referenced pattern’s `title` metadata value and is case sensitive.

## WCAG References

WCAG 2.0 is the de facto standard for accessible interfaces. When writing about inclusive interfaces, sometimes you’ll want to refer to WCAG to highlight which success criteria the pattern meets.

Instead of having to copy and paste content and links to WCAG, Infusion provides a shortcode mechanism that lets you simply list the success criteria by number:

    {{% wcag include="1.2.1, 1.3.1, 4.1.2" %}}

This generates a list of references that includes the names of each criterion and links to them directly. Like this:

- 2.1.1 Keyboard (level A)
- 4.1.2 Name, Role, Value (level A)

You don’t have to leave spaces after the comma separators. They are optional.

### Full descriptions

Sometimes, you’ll want to include the full descriptions of the success criteria inline. This is possible by setting `descriptions` to `true`:

    {{% wcag include="1.3.1, 4.1.2" descriptions="true" %}}

Here’s the more verbose output:

- 2.1.1 Keyboard (level A): All functionality of the content is operable through a keyboard interface without requiring specific timings for individual keystrokes, except where the underlying function requires input that depends on the path of the user's movement and not just the endpoints
- 4.1.2 Name, Role, Value (level A): For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies.

## Inclusive Design Principle references

Some inclusive design concepts are not reducible to success or fail criteria. This is why The Paciello Group wrote the Inclusive Design Principles. These can be listed by name.

    {{% principles include="Add value, Be consistent" descriptions="true" %}}

Here’s the output with `descriptions="true"`:

- Be consistent : Use familiar conventions and apply them consistently.

  Familiar interfaces borrow from well-established patterns. These should be used consistently within the interface to reinforce their meaning and purpose. This should be applied to functionality, behavior, editorial, and presentation. You should say the same things in the same way and users should be able to do the same things in the same way.

- Add value : Consider the value of features and how they improve the experience for different users.

  Features should add value to the user experience by providing efficient and diverse ways to find and interact with content. Consider device features such as voice, geolocation, camera and vibration API's, and how integration with connected devices or a second screen could provide choice.

#
Snippets

A lot of the time, your larger documentation patterns will share some common techniques and utilities. For this reason, Infusion lets you save snippets of markdown in a snippets folder, alongside the main content folder.

The example `visually-hidden.md` snippet describes the CSS needed to create content that is visually hidden but still available to screen readers. Since this is a technique/utility you are likely to use often, it’s nice to be able to just drop a snippet into your markdown content. The `snippet` shortcode lets you do exactly that:

    {{% snippet file="visually-hidden.md" %}}

To make your snippets truly reusable, try to write them in such a way that they make sense independent of surrounding text, a little bit like this note does.

#
Tables of contents

Pattern pages in Infusion that have two or more subheadings (`<h2>`s) automatically get a table of contents: a list of links to the main subsections for the page. This feature is made accessible as a navigation region with the “Table of contents” label and uses an ordered list. The table of contents markup for the
Setup page looks something like this:

    <nav class="toc" aria-labelledby="toc-heading">
      <h2 id="toc-heading">Table of contents</h2>
      <ol>
        <li>
          <a href="#cleaning-the-content-folder">“Cleaning” the content folder</a>
        </li>
        <li>
          <a href="#the-setup-command">The setup command</a>
        </li>
        <li>
          <a href="#the-config-file">The config file</a>
        </li>
        <li>
          <a href="#including-a-logo">Including a logo</a>
        </li>
      </ol>
    </nav>

Tables of content are a neat way to break down the content of the page and give users a navigable overview. However, they may not be to your taste. Never fear, you can turn tables of content off by adding `toc = false` to the TOML metadata for your pattern:

    +++
    title = "My page with a few headings"
    toc = false
    +++

#
Including images

From time to time, you’ll be wanting to include images illustrating the documented pattern in hand. Images live in the static folder, which is a sibling of the `/content` folder you’ll be mostly working in.

- content
- static
  - images
    - logo.png
    - menu-button.gif

When you first make a copy of Infusion, Infusion’s own logo will be included. You should replace this with your own company or project logo.

The path to the `/images` folder should begin with a forward slash, so include that when referencing images in your markdown.

    ![Global Megacorp Ltd](/images/logo.png)

## Figures

Sometimes you will want to include a caption with your illustration. This is what the `<figure>` and `<figcaption>` elements are for. However, Infusion doesn’t ask you to code all that manually. A special shortcode is provided, which takes a `caption` parameter. Note that the image markdown is provided between the opening and closing shortcode tags, and that you can use markdown syntax in the `caption` value.

    {{% figure caption="A design system that uses a bad code example as a **single source of truth** only serves to proliferate bad code." %}}
    ![Diagram of a design pattern represented by a turd emoji begetting three bad implementations](/images/bad_design_system.png)
    {{% /figure %}}

This will output the following. Note the automatically incremented Figure number.

A design system that uses a bad code example as a single source of truth only serves to proliferate bad code.

The generated markup includes special provisions for assistive technology support:

    <figure role="group" aria-describedby="caption-5fbafefe946c724e7a5d3d2d447a8684">
      <p><img src="http://localhost:1313/images/bad_design_system.png" alt="Diagram of a design pattern represented by a turd emoji begetting three bad implementations"></p>
      <figcaption id="caption-5fbafefe946c724e7a5d3d2d447a8684">
        A design system that uses a bad code example as a <strong>single source of truth</strong> only serves to proliferate bad code.
      </figcaption>
    </figure>

#
Including videos

Infusion has a lot of its own shortcodes, but you can still use Hugo’s built in shortcodes. These include a simple shortcode for including YouTube videos in your content. The shortcode takes just one parameter — the video’s `id`.

    {{<youtube w7Ft2ymGmfc>}}

#
Code blocks

Markdown already supports code samples both inline (using single backticks like `some code here`) and in blocks. Infusion will syntax highlight HTML, CSS, and JavaScript if you provide the correct language in the formulation of the block.

So, this…

    ```html
    <button aria-pressed="false">toggle me</button>
    ```

… will result in this:

    <button aria-pressed="false">toggle me</button>

Note that the syntax highlighting uses a greyscale theme. Infusion is careful not to use color as part of its own design, because these colors may clash with those of the design being illustrated and discussed.

## Line-numbered code blocks

In addition to the basic markdown support, Infusion provides a mechanism to display code blocks with line numbers. This is via the `codeBlock` shortcode. Here is the code for a block of JavaScript with line numbers:

    {{<codeBlock lang="js" numbered="true">}}
    var toggle = demo.querySelector('[aria-pressed]');

    toggle.addEventListener('click', (e) => {
      let pressed = e.target.getAttribute('aria-pressed') === 'true';
      e.target.setAttribute('aria-pressed', !pressed);
    });
    {{</codeBlock>}}

The output will look like the following. Now you can refer to particular bits of the code by line number, like the arrow function on line `3`.

    var toggle = demo.querySelector('[aria-pressed]');

    toggle.addEventListener('click', (e) => {
      let pressed = e.target.getAttribute('aria-pressed') === 'true';
      e.target.setAttribute('aria-pressed', !pressed);
    });

To preserve the wrapping inside code blocks, horizontal scrolling is implemented. To make sure scrolling is keyboard accessible, code blocks are focusable. An `aria-label` is provided to identify the code block to screen reader users.

#
Demo embedding

Sometimes just pictures of the pattern you’re documenting aren’t enough. Interactive patterns benefit from live demos, so that readers can test their functionality.

## CodePen

Infusion offers a couple of ways to do this. The first is by embedding CodePen demos into the content. The `codePen` shortcode takes just one argument: the codePen’s `ID`.

    {{% codePen VpVNKW %}}

This will embed the identified codePen into the content wherever you placed the shortcode, with the result view showing by default:

The compiled site will output an error if your `config.toml` does not include your CodePen username (in the `codePenUser` parameter). This is needed to construct the embed URL.

## jsBin

You can embed JS Bins just like CodePens, supplying a single `id` parameter.

    {{% jsBin juwowaq %}}

However, you can also have finer control over which panes are displayed. Use two parameters: one for the `id` and another, `show`, listing the panes you want to include.

    {{% jsBin id="juwowaq" show="css,output" %}}

The options for the `show` parameter are:

- html
- css
- js
- console
- output

(Note that, under some circumstances, the `html` pane is added whether you select it or not.)

## Inline demos

Infusion also supports the ability to write inline demos directly in markdown files. See
Writing inline demos.

#
Writing inline demos

There are some issues with , like them not working offline. They also come with CodePen branding, which will clash with the pattern you’re trying to illustrate.

Infusion offers another option: a special `demo` shortcode that allows you to write HTML, CSS, and JavaScript directly into the markdown file. The outputted demo is encapsulated using Shadow DOM, so you don’t have to worry about broken styles and global JS.

Here’s the example code for an inline demo of a toggle button:

    {{<demo>}}
    <button aria-pressed="false">Toggle Me</button>
    <style>
    button {
        background: DarkCyan;
        color: white;
        border: 0;
        font-size: 1.5rem;
        padding: 0.5em 1em;
        border-right: 5px solid #000;
        border-bottom: 5px solid #000;
    }

    [aria-pressed="true"] {
      border: 0;
      border-top: 5px solid #000;
      border-left: 5px solid #000;
    }
    </style>
    <script>
    var toggle = demo.querySelector('[aria-pressed]');

    toggle.addEventListener('click', (e) => {
      let pressed = e.target.getAttribute('aria-pressed') === 'true';
      e.target.setAttribute('aria-pressed', !pressed);
    });
    </script>
    {{</demo>}}

Note the `demo.querySelector` on line `21`. Infusion automatically provides `demo`, representing the root node of the demo. It’s like the `document` keyword but for a demo’s subtree.

Here’s a live demo of… the demo:

## Launch in a separate window

The “Launch in separate window” button takes the demo code and pushes it to a new browser window. This serves two purposes:

- It provides a fallback for browsers that do not support Shadow DOM encapsulation (a warning message will replace the inline demo).
- It creates an isolated test case for the demo, allowing you to run browser extensions and bookmarklets on the the demo code and just the demo code.

## Captioned demos

It’s possible to give your demo a caption using an accessible `<figure>` and `<figcaption>` structure. All you need to do is supply a `caption` attribute. For example:

    {{<demo caption="A basic button element">}}
    <!-- demo code here -->
    {{</demo>}}

Along with the standard `figure` shortcodes (described in
Including images), demo figures are numbered automatically according to their order in the page. You can use markdown syntax in the caption text value.

## Background colors

Sometimes your component will be expected to appear in a context where the parent element has a background color. You can add a backgroundColor for your demo block using the `backgroundColor` attribute. Any valid CSS color value is acceptable:

    {{<demo backgroundColor="hsla(163, 100%, 50%, 0.43)">}}
    <!-- demo code here -->
    {{</demo>}}

#
Color palettes

There’s no reason why your Infusion-powered pattern library has to be all about functionality. You can include style guide-like information such as color palettes too. The `colors` shortcode makes it easy to exhibit colors and their values together. Just supply a comma-separated list of CSS color values.

    {{% colors "#111111, #cccccc, #ffffff" %}}

The result is a one row strip showing each color supplied in order. The colors for Infusion are greyscale:

- #111111
- #CCCCCC
- #FFFFFF

If you’re wondering whether you need to put a space after the commas in the shortcode, don’t worry: `"#254f7b, #579a6d, #666666"` and `"#254f7b,#579a6d,#666666"` are both accepted. Any CSS color value is acceptable, not just hex colors.

#
Command line

Your pattern documentation may need to include commands for installing packages or using CLIs. Infusion offers the `cmd` shortcode for making code blocks look like terminal commands.

Here’s how you write it:

    {{<cmd>}}
    npm run start
    {{</cmd>}}

And here’s how it looks:

    npm run start

The `cmd` shortcode currently only supports single commands. If you want to show multiple, successive commands use separate `cmd` blocks.

#
File trees

Representing folder/file structures is simple and accessible in Infusion. Which is just as well, because some components may need to conform to a certain folder structure.

The file tree is described using a markdown nested list structure:

    {{% fileTree %}}
    * Level 1 folder
        * Level 2 file
        * Level 2 folder
            * Level 3 file
            * Level 3 folder
                * Level 4 file
            * Level 3 folder
                * Level 4 file
                * Level 4 file
            * Level 3 file
        * Level 2 folder
            * Level 3 file
            * Level 3 file
            * Level 3 file
        * Level 2 file
    * Level 1 file
    {{% /fileTree %}}

This is drawn in the following fashion, but preserves the underlying nested list structure for assistive technologies such as screen readers:

- Level 1 folder
  - Level 2 file
  - Level 2 folder
    - Level 3 file
    - Level 3 folder
      - Level 4 file
    - Level 3 folder
      - Level 4 file
      - Level 4 file
    - Level 3 file
  - Level 2 folder
    - Level 3 file
    - Level 3 file
    - Level 3 file
  - Level 2 file
- Level 1 file

The only reliable way to nest unordered lists in markdown is to indent the nested item by exactly four spaces. Using tabs or less than four spaces are unreliable methods.

#
Tested using...

When you’re an inclusive designer, it’s pertinent to do some testing. Following specs is one thing, but you need to verify that your component works okay for users.

Infusion provided a `tested` shortcode that lets you show which browsers and assistive technologies you’ve tried your design out in. Here’s an example. Note the commas and “+” signs.

    {{% tested using="Firefox + JAWS, Chrome, Safari iOS + Voiceover, Edge" %}}

This outputs:

Tested using | Firefox with JAWS | Chrome | Safari iOS with Voiceover | Edge

The value for the `using` attribute follows a specific format: each testing setup is separated by a comma (with a space if you like, but it’s not mandatory). If you want to add an assistive technology (or any other “add on”) this needs to follow a “+”. This additional part can be anything, like “A VR headset I borrowed”, but there are only a few browser terms available. These are case sensitive, so you need to write them as below:

- Firefox
- Chrome
- Safari
- IE
- Edge
- Opera
- Chrome Android
- Firefox Android
- Safari iOS

Obviously, this is not a comprehensive list and more may be added over time. But it covers most of the main browsers for pairing with other software — at least for testing purposes.