These docs are for an outdated version of the graphics rig that will be retired in 2022.
Some features described in these docs may already be deprecated.
If you're starting a new project, check out the new Graphics Kit.
We've reworked our ai2html script a bit. Now it will/can:
➽ Get the ai2html script here
➽ Get the ai2html graphics template here.
The default template has five artboards. You can remove artboards as you please. Caveat being you can't remove from the smallest up but only from the largest down. So you can't remove xs and keep sm, md and lg. But you can remove lg and md, and keep xs and sm.
The latest Illustrator template can be found in the style-ai-templates repo.
1) Make sure you have the ai2html script installed (linked above).
To install, save the ai2html_newrig.js file in the Scripts folder for Adobe Illustrator. The path will be something like...
- Applications/
- Adobe Illustrator 2020/
- Presets/
- en_US/
- Scipts/
- ai2html.js
NOTE: You’ll need to close and reopen Illustrator in order for it to show up in Illustrator’s dropdown menu.
2) Build your graphic element in Illustrator and customize the layout across each artboard. You can find the Illustrator web template in ai-templates/ai2html/ directory of the style-ai-templates repo (It’s also linked above).
Use the "Base Styles" toolbox as a reference point for typography and style elements like arrow types, axis lines and labels. Hint: The eye dropper tool is your friend here.
3) When you’re ready to place your artwork, run the ai2hml script from Illustrator File > Scripts > ai2html
.
This will write your files to a local filepath to be included in your ejs files. The filepath will be ...src/html/your-project-name.ejs. The background images for the graphic will be saved to the .../src/static/img/ directory and will automatically work when you place the graphic in the page.
Simply include the .ejs file in your working markup. For example, if your main article markup is in the article.ejs file, you might include your graphic like so:
<section class='graphic'>
<%- include('your-project-name.ejs'); %>
</section>
The graphics rig's well widths (wide, wider, etc.) correspond to the ai2html Illustrator template's artboards. To appropriately size the ai2html graphic, add the class that corresponds with the widest artboard you want to show.
Corresponding classes for each Illustrator artboard size:
wider
wide
narrow
narrower
For example, if your widest artboard is the SM artboard (meaning you’re not using the MD, LG or XL artboards), your section tag would include the class ‘narrow’. Like this:
<section class='graphic narrow'>
<%- include('your-project-name.ejs'); %>
</section>
If you don't want to make a version of the graphic for every size artboard, you can use the skip-
class so that artboard size/well width won't display on the page. Here's what the section tag would look like for a wide (LG) graphic that skips the narrow well.
<section class='graphic wide skip-narrow'>
<%- include('your-project-name.ejs'); %>
</section>
Here is an example of the skip class in action.
Note: You only need to "skip" well sizes smaller than the max width you are showing. So if your widest well is wide
(the LG artboard), you don't need to "skip" the XL artboard. Larger artboards are excluded when you set the initial width of the well with the wider
, wide
, narrow
and narrower
classes.
Add this CSS to the very top of your main.scss (before the import statement)
$graphic-narrower: 350px;
$graphic-narrow: 560px;
$well-regular: 635px;
$well-wide: 730px;
$well-wider: 1110px;
Unless you're using bootstrap, your graphic will default to scaling constantly when resizing the screen. This may be what you want! But if not...
If you don't want your graphic to consitantly scale but rather "snap" to a specific size, you can add the snap
class. This is great for the consistent label positioning and sizing, but it can lead to undesirably large margins in some contexts. Ex:
<section class='graphic snap'>
<%- include('your-project-name.ejs'); %>
</section>
Here is an example of the snap class in action.