Skip to content

Commit bc3ee5a

Browse files
committed
Update README, site data, and styles; add E2E tests for home and build pages
1 parent ea370b3 commit bc3ee5a

6 files changed

Lines changed: 137 additions & 18 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The site of the [missing-elements](https://github.com/missing-elements) web comp
66

77
| Path | What it is | Source, and the detail |
88
| --- | --- | --- |
9-
| `/` | The project list | [src/index.njk](src/index.njk); the projects are in [src/_data/site.js](src/_data/site.js) |
9+
| `/` | The project list, the tools (the build page, which links the skill's page), and a footer of links | [src/index.njk](src/index.njk); the lists are in [src/_data/site.js](src/_data/site.js) |
1010
| `/pdfjs-viewer/` | The docs of `<pdfjs-viewer-element>`, with a live preview | [src/pdfjs-viewer/](src/pdfjs-viewer/); [docs/pdfjs-viewer.md](docs/pdfjs-viewer.md) |
1111
| `/h5p/skill/` | The skill's files, and a page that lists each at its full address | [src/h5p/skill/](src/h5p/skill/), copied by [eleventy.config.js](eleventy.config.js); [docs/h5p-skill.md](docs/h5p-skill.md) |
1212
| `/h5p/bundles/` | The skill's build tool and a library bundle per content type, for a chat that runs Node but cannot reach npm | written by [vite.config.ts](vite.config.ts); [docs/h5p-bundles.md](docs/h5p-bundles.md) |

‎e2e/home.spec.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
/*
4+
* The org home, /: a card for each element, one for each tool, the build page, and a footer of
5+
* links; and the build page links the skill's page at the whole address a person gives the chat.
6+
*/
7+
8+
const SKILL = 'https://missing-elements.github.io/h5p/skill/'
9+
10+
test('the home page links to the build page, and the build page to the skill’s page, and both answer', async ({ page, request }) => {
11+
await page.goto('/')
12+
await expect(page.getByRole('region', { name: 'Web components' }).getByRole('link', { name: 'pdfjs-viewer', exact: true })).toHaveAttribute('href', '/pdfjs-viewer/')
13+
await expect(page.getByRole('region', { name: 'Tools' }).getByRole('link', { name: 'Build an H5P activity', exact: true })).toHaveAttribute('href', '/h5p/build/')
14+
await expect(page.getByRole('navigation', { name: 'Useful links' }).getByRole('link', { name: 'pdfjs-viewer on npm' })).toHaveAttribute('href', 'https://www.npmjs.com/package/@missing-elements/pdfjs-viewer')
15+
expect((await request.get('/h5p/build/')).ok()).toBe(true)
16+
17+
await page.goto('/h5p/build/')
18+
await expect(page.getByRole('link', { name: SKILL, exact: true })).toHaveAttribute('href', SKILL)
19+
expect((await request.get('/h5p/skill/')).ok()).toBe(true)
20+
})

‎src/_data/site.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@ export default {
66
{
77
name: "pdfjs-viewer",
88
tag: "pdfjs-viewer-element",
9+
package: "@missing-elements/pdfjs-viewer",
910
description: "A self-hostable PDF viewer web component, based on the PDF.js viewer.",
1011
docs: "/pdfjs-viewer/",
1112
repo: "https://github.com/missing-elements/pdfjs-viewer",
1213
},
1314
{
1415
name: "h5p-offline-player",
16+
package: "@missing-elements/h5p-offline-player",
1517
description: "A browser-only H5P player as one web component. Self-hostable, and builds a fully offline PWA.",
1618
docs: "https://h5p-offline-player.vercel.app/",
1719
repo: "https://github.com/missing-elements/h5p-offline-player",
1820
},
1921
],
22+
// The tools on the home page, under the elements: pages built on them that run in the browser.
23+
// A tool's GitHub link is where it is explained. The build page links the skill's page itself.
24+
tools: [
25+
{
26+
name: "Build an H5P activity",
27+
description: "Make H5P activities with an AI chat and the h5p-author skill: paste the source it wrote, play it, and download a .h5p file for any H5P site. Nothing is uploaded.",
28+
page: "/h5p/build/",
29+
repo: "https://github.com/missing-elements/missing-elements.github.io/blob/main/docs/h5p-build-page.md",
30+
},
31+
],
2032
};

‎src/assets/site.css‎

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
2626
--radius: 6px;
2727
--preview-width: clamp(360px, 42vw, 760px);
28+
/* The pages of one wide column, the org home and the H5P build page. Their prose keeps --measure. */
29+
--page-width: 72rem;
30+
--measure: 60ch;
2831
}
2932

3033
@media (prefers-color-scheme: dark) {
@@ -535,22 +538,48 @@ tbody th a:hover code { text-decoration: underline; }
535538
}
536539

537540
/* Org home */
538-
.home { max-width: 44rem; margin: 0 auto; padding: 4rem 1rem; }
541+
.home { max-width: var(--page-width); margin: 0 auto; padding: 4rem clamp(1rem, 4vw, 3rem); }
539542
.home h1 { margin: 0 0 0.5rem; font-size: 2rem; }
540543
.brand-title { display: flex; align-items: center; gap: 0.75rem; }
541544
.brand-title img { width: 3rem; height: 3rem; }
542-
.home .lead { margin-bottom: 2rem; }
543-
.elements { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
544-
.elements li { margin: 0; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
545-
.elements h2 { margin: 0 0 0.25rem; padding: 0; border: 0; font-size: 1.125rem; }
545+
.home .lead { max-width: var(--measure); margin-bottom: 2rem; }
546+
/* A group of cards under its title, the size of a docs page's section title, without its rule. */
547+
.home section + section { margin-top: 3rem; }
548+
.home section > h2 { margin: 0 0 0.75rem; padding: 0; border: 0; font-size: 1.5rem; }
549+
.home section > p { max-width: var(--measure); margin: 0 0 1.25rem; color: var(--muted); }
550+
/* The cards two to a row where two fit, each as tall as its row, with its links at its foot. Every
551+
section has the same two columns, so a section of one card keeps it the width of the others. */
552+
.home section { container-type: inline-size; }
553+
.elements {
554+
display: grid;
555+
grid-template-columns: minmax(0, 1fr);
556+
gap: 1rem;
557+
margin: 0;
558+
padding: 0;
559+
list-style: none;
560+
}
561+
@container (width > 36rem) {
562+
.elements { grid-template-columns: repeat(2, minmax(0, 1fr)); }
563+
}
564+
.elements li { display: flex; flex-direction: column; margin: 0; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
565+
.elements h3 { margin: 0 0 0.25rem; font-size: 1.125rem; }
546566
.elements p { margin: 0 0 0.5rem; color: var(--muted); }
547-
.elements .links { display: flex; gap: 1rem; font-size: 0.875rem; }
567+
.elements .links { display: flex; gap: 1rem; margin-top: auto; font-size: 0.875rem; }
568+
/* The home page's footer: where else the elements are, in columns of links. */
569+
.site-footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.875rem; }
570+
.footer-links { display: flex; flex-wrap: wrap; gap: 1.5rem 4rem; }
571+
.footer-links h2 { margin: 0 0 0.5rem; padding: 0; border: 0; font-size: 0.875rem; }
572+
.footer-links ul { margin: 0; padding: 0; list-style: none; }
573+
.footer-links li + li { margin-top: 0.35rem; }
574+
.footer-links a { color: var(--muted); text-decoration: none; }
575+
.footer-links a:hover { color: var(--text); text-decoration: underline; }
548576

549577
/* The h5p-author skill's files, /h5p/skill/: whole addresses, which give way on a phone. */
550578
.skill-files a { overflow-wrap: anywhere; }
551579

552580
/* H5P build page, /h5p/build/ */
553581
.build {
582+
max-width: var(--page-width);
554583
--ok: var(--live);
555584
--bad: var(--t-tag);
556585
/* Masked, like the preview pane's icons, so they take a color like text does. */
@@ -560,6 +589,8 @@ tbody th a:hover code { text-decoration: underline; }
560589
.build-brand { margin-bottom: 1.25rem; font-size: 0.9375rem; }
561590
/* A longer heading than the docs' package names, so it gives way on a phone. */
562591
.build .docs-header h1 { font-size: clamp(1.75rem, 1.2rem + 3vw, 2.25rem); }
592+
/* Prose keeps a line a reader can follow; the source, the lists and what plays take the whole width. */
593+
.build p:not(.status) { max-width: var(--measure); }
563594

564595
/* The steps are a timeline: a marker for each, on a rail that runs on to the next. A step the page
565596
hides, as the files of a source that names none, is not on it, and the rail ends at the last shown. */

‎src/h5p/build/index.njk‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ csp: "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' da
2727
site takes. Nothing is uploaded: the package is built in your browser, from the libraries this
2828
site serves.
2929
</p>
30+
{#- The skill's page at its whole address, which a person gives the chat as it is. -#}
31+
<p>
32+
No source yet? Give the chat <a href="{{ site.url }}/h5p/skill/">{{ site.url }}/h5p/skill/</a>
33+
and ask it for an activity: the h5p-author skill there tells it how to write one.
34+
</p>
3035
</header>
3136

3237
{#- The steps are drawn as a timeline by site.css: a marker for each, on a rail that runs on to

‎src/index.njk‎

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,70 @@ layout: base.njk
33
title: Missing Elements
44
description: Standalone, self-hostable web components for viewing documents and content in the browser.
55
---
6+
{#- The cards and links are lists drawn without bullets, and Safari then reads one as a list only if it is told. -#}
67
<main class="home" id="main">
78
<h1 class="brand-title"><img src="/assets/logo.svg" alt="" width="48" height="48">Missing Elements</h1>
89
<p class="lead">Standalone, self-hostable web components for viewing documents and content in the browser.</p>
9-
<ul class="elements">
10-
{%- for element in site.elements %}
11-
<li>
12-
<h2><a href="{{ element.docs }}">{{ element.name }}</a></h2>
13-
<p>{{ element.description }}</p>
14-
<div class="links">
15-
<a href="{{ element.docs }}">Docs</a>
16-
<a href="{{ element.repo }}">GitHub</a>
10+
11+
<section aria-labelledby="elements-heading">
12+
<h2 id="elements-heading">Web components</h2>
13+
<ul class="elements" role="list">
14+
{%- for element in site.elements %}
15+
<li>
16+
<h3><a href="{{ element.docs }}">{{ element.name }}</a></h3>
17+
<p>{{ element.description }}</p>
18+
<div class="links">
19+
<a href="{{ element.docs }}">Docs</a>
20+
<a href="{{ element.repo }}">GitHub</a>
21+
</div>
22+
</li>
23+
{%- endfor %}
24+
</ul>
25+
</section>
26+
27+
<section aria-labelledby="tools-heading">
28+
<h2 id="tools-heading">Tools</h2>
29+
<p>Apps built on the elements, which run in your browser.</p>
30+
<ul class="elements" role="list">
31+
{%- for tool in site.tools %}
32+
<li>
33+
<h3><a href="{{ tool.page }}">{{ tool.name }}</a></h3>
34+
<p>{{ tool.description }}</p>
35+
<div class="links">
36+
<a href="{{ tool.page }}">Open</a>
37+
<a href="{{ tool.repo }}">GitHub</a>
38+
</div>
39+
</li>
40+
{%- endfor %}
41+
</ul>
42+
</section>
43+
44+
{#- Each element's name twice, under npm and under Issues: the hidden words say which, in a list of the page's links. -#}
45+
<footer class="site-footer">
46+
<nav class="footer-links" aria-label="Useful links">
47+
<div>
48+
<h2>npm</h2>
49+
<ul role="list">
50+
{%- for element in site.elements %}
51+
<li><a href="https://www.npmjs.com/package/{{ element.package }}">{{ element.name }}<span class="visually-hidden"> on npm</span></a></li>
52+
{%- endfor %}
53+
</ul>
1754
</div>
18-
</li>
19-
{%- endfor %}
20-
</ul>
55+
<div>
56+
<h2>GitHub</h2>
57+
<ul role="list">
58+
<li><a href="{{ site.github }}">The organization</a></li>
59+
<li><a href="{{ site.github }}/missing-elements.github.io">This site's source</a></li>
60+
</ul>
61+
</div>
62+
<div>
63+
<h2>Issues</h2>
64+
<ul role="list">
65+
{%- for element in site.elements %}
66+
<li><a href="{{ element.repo }}/issues">{{ element.name }}<span class="visually-hidden"> issues</span></a></li>
67+
{%- endfor %}
68+
</ul>
69+
</div>
70+
</nav>
71+
</footer>
2172
</main>

0 commit comments

Comments
 (0)