-
-
Notifications
You must be signed in to change notification settings - Fork 207
Description
I'd like to propose a change in the way figures are described by authors in the markdown and rendered internally.
In css.md, the corresponding markdown (using embedded HTML) for the figure above is:
<figure>
<a href="/static/images/2019/css/fig12.png">
<img src="/static/images/2019/css/fig12.png" alt="Figure 12. Adoption of flexbox." aria-labelledby="fig12-caption" aria-describedby="fig12-description" width="600" height="371" data-width="600" data-height="371" data-seamless data-frameborder="0" data-scrolling="no" data-iframe="https://docs.google.com/spreadsheets/d/e/2PACX-1vQO5CabwLwQ5Lj1_9bbEFnFM1qEqCorymaBHrcaNiMSJ7sYDKHUI5iish5VAS-SxN447UTW-1-5-OjE/pubchart?oid=2021161093&format=interactive">
</a>
<div id="fig12-description" class="visually-hidden">Bar chart showing 49% of desktop pages and 52% of mobile pages using flexbox.</div>
<figcaption id="fig12-caption">Figure 12. Adoption of flexbox.</figcaption>
</figure>One thing I'd like to improve is the figure numbering. The figure ID is automatically generated, but we're still manually writing Figure 12 in the <figcaption> and managing the IDs needed for the accessible description. Can all of this be automated? I'd also like to make all figure numbers unique and prefixed by chapter number. So rather than Figure 12 this would be Figure 2.12.
The fig12.png image shouldn't be named according to its figure number. These names aren't descriptive and must be kept in sync with the figure ordering in the chapter. Instead, we should name figure images descriptively, like flexbox-adoption.png. We should use this name as the <figure id> and permalink so that reordering figures wouldn't make old links obsolete.
I would also love to see all figures accompanied by links to their metadata like the corresponding SQL file and results sheet. This would enable anyone to see how the metrics were calculated and run it themselves. This requires some design choices like how to provide these links unobtrusively and accessibly. My idea is a menu in the corner of the figure, similar to the HTTP Archive metrics:
Rather than generating figure numbers in the build process, I wonder if this could be done entirely in the templates. For example, could authors include a Jinja macro like this:
{%
figure(
# Figure ID corresponding to the `png` image and `sql` file name.
'flexbox-adoption',
# Figure caption.
'Adoption of flexbox.',
# Detailed figure description.
'Bar chart showing 49% of desktop pages and 52% of mobile pages using flexbox.',
# Embedded Sheets URL. (maybe we can add the base of this URL to the chapter yaml and only include the relevant IDs?)
'https://docs.google.com/spreadsheets/d/e/2PACX-1vQO5CabwLwQ5Lj1_9bbEFnFM1qEqCorymaBHrcaNiMSJ7sYDKHUI5iish5VAS-SxN447UTW-1-5-OjE/pubchart?oid=2021161093&format=interactive',
# Tab ID in Sheets for this metric's results. For example `/edit#gid=1861654265`.
'1861654265',
# Optional width and height if non-standard (600x371).
600, 371
)
%}There are other kinds of figures, like big numbers:
<figure>
<div class="big-number">2%</div>
<figcaption>Figure 13. Percent of websites using grid.</figcaption>
</figure>Even though the markup for this figure is much simpler, I would love to see another macro to standardize the boilerplate across all chapters so that the developers have more centralized control over how these are generated. We could have a macro like this:
{%
figure_big_number(
# Figure ID corresponding to the `sql` file name.
'grid-adoption',
# The big number.
'2%',
# Figure caption.
'Percent of websites using grid.',
# Tab ID in Sheets for this metric's results.
'1459448594'
)
%}We should build some customizability into these macros. For example, we needed to adjust the appearance of the z-index "really big number" figure. Perhaps there could be an optional parameter for a classname to be added to the figure. This could be used to adjust the font size as in the z-index example, create "alternate" themes for the big numbers so that they're not all the same color, etc.
We also need to support other types of figures: tables, images, and videos. The 2019 Mobile Web chapter uses all three in the first three figures.
<figure>
<table>
<tr>
<th>Connection type</th>
<td><a href="https://www.gsma.com/r/mobileeconomy/">2G or 3G</a></td>
</tr>
<tr>
<th>Latency</th>
<td>300 - 400ms</td>
</tr>
<tr>
<th>Bandwidth</th>
<td>0.4 - 1.6Mbps</td>
</tr>
<tr>
<th>Phone</th>
<td><a href="https://www.gsmarena.com/samsung_galaxy_s6-6849.php">Galaxy S6</a> — <a href="https://www.notebookcheck.net/A11-Bionic-vs-7420-Octa_9250_6662.247596.0.html">4x slower</a> than iPhone 8 (Octane V2 score)</td>
</tr>
</table>
<figcaption>Figure 1. Technical profile of a typical mobile user.</figcaption>
</figure>I think it's ok to include the <figure> HTML although it may be nice to use markdown tables when possible. It may be harder to get the <th> elements right for both horizontal and vertical using only markdown. But we should have a solution to abstract away the figure numbering and IDing. For example:
<figure id="technical-profile">
<table>
<tr>
<th>Connection type</th>
<td><a href="https://www.gsma.com/r/mobileeconomy/">2G or 3G</a></td>
</tr>
<tr>
<th>Latency</th>
<td>300 - 400ms</td>
</tr>
<tr>
<th>Bandwidth</th>
<td>0.4 - 1.6Mbps</td>
</tr>
<tr>
<th>Phone</th>
<td><a href="https://www.gsmarena.com/samsung_galaxy_s6-6849.php">Galaxy S6</a> — <a href="https://www.notebookcheck.net/A11-Bionic-vs-7420-Octa_9250_6662.247596.0.html">4x slower</a> than iPhone 8 (Octane V2 score)</td>
</tr>
</table>
<figcaption>{{ figure_number() }} Technical profile of a typical mobile user.</figcaption>
</figure>I've added id="technical-profile" to the <figure> and {{ figure_number() }} to the <figcaption>. The figure_number Jinja macro could generate a monotonically increasing figure number using shared state with the other figure macros. I'd love to hear any ideas to remove even more of the figure/figcaption boilerplate.
Summary
- Figure markup is a dark art that should be abstracted away so that authors can focus on the content.
- Numeric figure IDs are brittle and should be replaced with descriptive, human readable IDs.
- Figure numbers should be entirely automated.
- We should include more meta resources with figures to connect the results back to the source.
cc @HTTPArchive/developers


