Skip to content

Commit fb765b6

Browse files
committed
Update pdfjs-viewer documentation and add logo SVG asset
- Revised the description in the pdfjs-viewer documentation to clarify the functionality of the Try and Reset buttons. - Removed the 'try' attribute from the HTML example for the pdfjs-viewer element. - Added a new SVG logo asset to the project.
1 parent 9645ecf commit fb765b6

12 files changed

Lines changed: 315 additions & 74 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ Add `try` after the language of a code fence to give it a **▶ Try** button tha
3737

3838
- **HTML snippets** copy the attributes of their `<pdfjs-viewer-element>` onto the preview. `style`, `id`, `class` and the placeholder `src="/file.pdf"` are skipped.
3939
- **JavaScript snippets** run exactly as written. `document.querySelector('pdfjs-viewer-element')` returns the preview element.
40+
- Every Try button comes with a **Reset** button that puts the preview back to its defaults.
4041
- **`try=fresh`** replaces the preview with a new element first. Use it for settings that only apply when the viewer is built, such as `setViewerOptions` and the "before connect" attributes.

‎eleventy.config.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,26 @@ export default function (eleventyConfig) {
5252

5353
const inline = (text) => markdown.renderInline(text);
5454

55+
const tableCaptions = {
56+
document: "Document and navigation attributes",
57+
interface: "Interface attributes",
58+
files: "Runtime file attributes",
59+
resources: "PDF.js resource attributes",
60+
};
61+
5562
eleventyConfig.addShortcode("attributeTable", (group) => {
5663
const rows = attributes
5764
.filter((attr) => attr.group === group)
5865
.map(
5966
(attr) => `<tr id="attr-${attr.name}">
6067
<th scope="row"><a href="#attr-${attr.name}"><code>${attr.name}</code></a></th>
6168
<td>${inline(attr.description)}</td>
62-
<td class="default">${attr.default ? inline(attr.default) : `<span class="muted" aria-label="none">—</span>`}</td>
69+
<td class="default">${attr.default ? inline(attr.default) : `<span class="muted"><span aria-hidden="true">—</span><span class="visually-hidden">None</span></span>`}</td>
6370
<td><span class="update update-${attr.update}">${{ live: "Live", load: "Next load", init: "Before connect" }[attr.update]}</span></td>
6471
</tr>`
6572
)
6673
.join("");
67-
return `<div class="table-wrap"><table class="attributes"><thead><tr><th scope="col">Attribute</th><th scope="col">Description</th><th scope="col">Default</th><th scope="col">Updates</th></tr></thead><tbody>${rows}</tbody></table></div>`;
74+
return `<div class="table-wrap"><table class="attributes"><caption class="visually-hidden">${tableCaptions[group]}</caption><thead><tr><th scope="col">Attribute</th><th scope="col">Description</th><th scope="col">Default</th><th scope="col">Updates</th></tr></thead><tbody>${rows}</tbody></table></div>`;
6875
});
6976

7077
eleventyConfig.addShortcode("playground", () => {
@@ -89,7 +96,7 @@ export default function (eleventyConfig) {
8996
return `<div class="control"><label for="${id}"><code>${name}</code></label>${field}</div>`;
9097
})
9198
.join("");
92-
return `<form class="playground" data-playground aria-label="Attribute playground">${controls}<p class="playground-hint">Changes apply to the preview as you edit them.</p></form>`;
99+
return `<form class="playground" data-playground aria-label="Attribute playground"><p class="playground-hint">Each change applies to the live preview straight away.</p>${controls}</form>`;
93100
});
94101

95102
return {

‎src/_data/site.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
name: "missing elements",
2+
name: "Missing Elements",
33
url: "https://missing-elements.github.io",
44
github: "https://github.com/missing-elements",
55
elements: [

‎src/_includes/base.njk‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
<link rel="canonical" href="{{ site.url }}{{ page.url }}">
1313
<meta property="og:title" content="{{ title }}">
1414
<meta property="og:description" content="{{ description }}">
15-
<link rel="icon" href="/assets/icon.svg" type="image/svg+xml">
15+
<link rel="icon" href="/assets/logo.svg" type="image/svg+xml">
1616
<link rel="stylesheet" href="/assets/site.css">
1717
{%- block head %}{% endblock %}
1818
</head>
1919
<body class="{{ bodyClass }}">
2020
<a class="skip-link" href="#main">Skip to content</a>
2121
{{ content | safe }}
22+
<p class="visually-hidden" role="status" data-status="page"></p>
2223
<script type="module" src="/assets/site.js"></script>
2324
</body>
2425
</html>

‎src/_includes/pdfjs-viewer.njk‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,32 @@ bodyClass: docs-page
1111
</ol>
1212
{%- endmacro -%}
1313
<div class="docs">
14-
<nav class="toc" aria-label="On this page">
15-
<a class="toc-home" href="/">missing elements</a>
16-
{{ tocList(toc) }}
17-
</nav>
14+
<div class="toc">
15+
<nav aria-label="Site"><a class="brand toc-home" href="/"><img src="/assets/logo.svg" alt="" width="24" height="24">{{ site.name }}</a></nav>
16+
<nav aria-label="On this page">{{ tocList(toc) }}</nav>
17+
</div>
1818

1919
<main class="content" id="main">
2020
<header class="docs-header">
21+
<a class="brand docs-brand" href="/"><img src="/assets/logo.svg" alt="" width="24" height="24">{{ site.name }}</a>
2122
<div class="docs-header-row">
2223
<h1>pdfjs-viewer</h1>
23-
<button type="button" class="theme-toggle" data-theme-toggle hidden>
24-
<span class="when-light">Dark theme</span><span class="when-dark">Light theme</span>
25-
</button>
24+
<label class="theme-switch" data-theme-toggle hidden>
25+
<input type="checkbox" role="switch" aria-label="Dark theme">
26+
<span class="theme-switch-knob" aria-hidden="true"></span>
27+
<svg class="theme-switch-sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
28+
<svg class="theme-switch-moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z"/></svg>
29+
</label>
2630
</div>
2731
<p class="lead">A self-hostable PDF viewer web component, based on the <a href="https://mozilla.github.io/pdf.js/web/viewer.html">PDF.js default viewer</a>.</p>
2832
<ul class="meta">
29-
<li><a href="{{ pdfjsViewer.npm }}">v{{ pdfjsViewer.version }}</a></li>
30-
<li>PDF.js {{ pdfjsViewer.pdfjsVersion }}</li>
33+
<li><a href="{{ pdfjsViewer.npm }}">npm</a></li>
3134
<li><a href="{{ pdfjsViewer.repo }}">GitHub</a></li>
32-
<li><a href="{{ pdfjsViewer.repo }}/blob/master/LICENSE">MIT</a></li>
35+
<li><a href="{{ pdfjsViewer.repo }}/blob/master/LICENSE">MIT license</a></li>
3336
</ul>
3437
<details class="toc-inline">
3538
<summary>On this page</summary>
36-
{{ tocList(toc) }}
39+
<nav aria-label="On this page">{{ tocList(toc) }}</nav>
3740
</details>
3841
</header>
3942

@@ -44,17 +47,18 @@ bodyClass: docs-page
4447
</footer>
4548
</main>
4649

47-
<aside class="preview" id="preview" aria-label="Live preview" data-preview>
50+
<div class="preview" id="preview" role="complementary" aria-label="Live preview" data-preview>
4851
<div class="preview-bar">
4952
<span class="preview-title">Live preview</span>
50-
<button type="button" class="button" data-preview-reset>Reset</button>
53+
<button type="button" class="button" data-preview-reset aria-label="Reset preview">Reset</button>
5154
<button type="button" class="button preview-close" data-preview-close>Close</button>
5255
</div>
5356
<div class="preview-stage" data-preview-stage>
5457
<noscript><p class="preview-note">The preview needs JavaScript.</p></noscript>
5558
</div>
56-
<div class="preview-markup" aria-live="polite"><code data-preview-markup></code></div>
57-
</aside>
59+
<pre class="language-html preview-markup" data-label="Current markup" data-preview-markup-box><code class="language-html" data-preview-markup></code></pre>
60+
<p class="visually-hidden" role="status" data-status="preview"></p>
61+
</div>
5862
<button type="button" class="button preview-open" data-preview-open aria-controls="preview" aria-expanded="false" hidden>Preview</button>
5963
</div>
6064
<script type="module" src="/pdfjs-viewer/docs.js"></script>

‎src/assets/icon.svg‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/assets/logo.svg‎

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)