Skip to content

Commit cef1925

Browse files
committed
Add QrCode component
1 parent b56c7f3 commit cef1925

10 files changed

Lines changed: 558 additions & 312 deletions

File tree

_TODO.md

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,25 @@ xdg-open ".cache/playwright/lighthouse-reports/run Lighthouse audit on homepage-
99

1010
## Print
1111

12-
- Improve print layout by hiding header and footer for articles
12+
1. Add a QR code at the bottom of printed pages so it's easier for someone to navigate to from a printed page. We have a QrCode component.
1313

14-
```typescript
15-
window.addEventListener('beforeprint', (event) => {
16-
console.log('Before print dialog opens, run this script.')
17-
// Example: change content or hide elements
18-
document.getElementById('hide-on-print').style.display = 'none'
19-
})
20-
21-
window.addEventListener('afterprint', (event) => {
22-
console.log('After print dialog closes, run this script to revert changes.')
23-
// Example: revert changes
24-
document.getElementById('hide-on-print').style.display = ''
25-
// You can also use this event to send an AJAX request to a server for print tracking.
26-
})
27-
```
28-
29-
Or listen for changes:
30-
31-
```typescript
32-
if (window.matchMedia) {
33-
var mediaQueryList = window.matchMedia('print');
34-
mediaQueryList.addListener(function(mql) {
35-
if (mql.matches) {
36-
// Equivalent to onbeforeprint
37-
console.log('Entering print mode (before print dialog)');
38-
} else {
39-
// Equivalent to onafterprint
40-
console.log('Exiting print mode (after print dialog)');
41-
}
42-
});
43-
}
44-
```
45-
46-
- Add a QR code at the bottom of printed pages so it's easier for someone to navigate to from a printed page. npm install qr-code-styling is added as a package.
47-
48-
- Need a layout alternative to Markup that formats for print. It needs to handle TOC differently as a full-width page. Need a fixed header format that adds article title, subtitle, and date.
49-
50-
- Need to make sure that on print, when we have a tabbed code block with multiple languages, only the first language is printed and the other language tabs are hidden. The styling should be different for print for the code block. Maybe move other language code tabs to an appendix and add a link to them.
14+
2. Need to make sure that on print, when we have a tabbed code block with multiple languages, only the first language is printed and the other language tabs are hidden. The styling should be different for print for the code block. Maybe move other language code tabs to an appendix and add a link to them.
5115

5216
[This article](https://excessivelyadequate.com/posts/print.html) shows how to control the following properties in Chrome's Print Properties dialog box from CSS: Layout, Paper size, Margins, Headers and footers, and Background graphics. Headers and footers is the checkbox that by default is enabled and adds information on printed pages. It also shows how to use Chrome from the terminal in headless mode to output a PDF file from an HTML page.
5317

54-
For printed pages, your header should shift from a navigation tool to a document identifier. Since users cannot click links or icons on paper, these elements are "cruft" that waste space and ink.
18+
3. For printed pages, your header should shift from a navigation tool to a document identifier. Since users cannot click links or icons on paper, these elements are "cruft" that waste space and ink.
19+
20+
2. Need a layout alternative to Markup that formats for print. It should hide Table Of Contents. Need a fixed header format that adds article title, subtitle, and date.
5521

56-
1. Recommended Print Header Format
22+
__Recommended Print Header Format__
5723

5824
A professional print header typically includes only these three elements:
5925

6026
- Brand Identity: A high-contrast version of your logo or the site name in plain text for brand recognition.
6127
- Document Title: The main title of the page (usually the <h1>), ensuring the reader knows exactly what the document is.
6228
- Source URL: A small, plain-text URL so the reader can find the live version later.
6329

64-
2. Elements to Remove
30+
__Elements to Remove__
6531

6632
Hide any interactive or screen-specific components using display: none; in your @media print block:
6733

@@ -70,7 +36,7 @@ Hide any interactive or screen-specific components using display: none; in your
7036
- Breadcrumbs: While useful on-screen for site hierarchy, they often look like cluttered, disconnected text on paper. Most designers remove them to keep the focus on the primary content.
7137
- Social Media & CTA Buttons: "Sign In" or "Follow Us" buttons are irrelevant in print.
7238

73-
3. Expand External Links For Print:
39+
__Expand External Links For Print__
7440

7541
We can't (yet) directly interface with a printed page to explore links, so link URLs should be visible on the printed version of the Web page. To keep the page relatively clean, I prefer to expand only outbound links in articles, and suppress internal ones. If you've used relative URLs on your website for local links, you can easily do this through an attribute selector and `:after` pseudo classes, thus preventing internal links and links around images from being printed:
7642

@@ -117,6 +83,41 @@ Requirements: You must provide sufficient margins (e.g.,` margin: { top: '50px',
11783

11884
Styling: You must use inline CSS within your `headerTemplate` or `footerTemplate` strings, as they cannot access your external stylesheet.
11985

86+
87+
Maybe something like this to check if we're on the playwright PDF generation run and set the light theme:
88+
89+
```typescript
90+
window.addEventListener('beforeprint', (event) => {
91+
console.log('Before print dialog opens, run this script.')
92+
// Example: change content or hide elements
93+
document.getElementById('hide-on-print').style.display = 'none'
94+
})
95+
96+
window.addEventListener('afterprint', (event) => {
97+
console.log('After print dialog closes, run this script to revert changes.')
98+
// Example: revert changes
99+
document.getElementById('hide-on-print').style.display = ''
100+
// You can also use this event to send an AJAX request to a server for print tracking.
101+
})
102+
```
103+
104+
Or listen for changes:
105+
106+
```typescript
107+
if (window.matchMedia) {
108+
var mediaQueryList = window.matchMedia('print');
109+
mediaQueryList.addListener(function(mql) {
110+
if (mql.matches) {
111+
// Equivalent to onbeforeprint
112+
console.log('Entering print mode (before print dialog)');
113+
} else {
114+
// Equivalent to onafterprint
115+
console.log('Exiting print mode (after print dialog)');
116+
}
117+
});
118+
}
119+
```
120+
120121
## ToolTips
121122

122123
Need a tooltip component for consistency.
@@ -135,12 +136,10 @@ These have tooltips, how are they being generated?
135136

136137
- Improve `<abbr>` styling: https://codepen.io/ire/pen/NoqWpm
137138

138-
## HubSpot Signup Issues
139+
## HubSpot Signup Issues / Gated Content (Downloads)
139140

140141
- Add people who sign up for newsletter, download, or fill out contact form to Hubspot tracking. Need to configure it to remove them if they do the GDPR remove me. Also remove them from the newsletter.
141142

142-
## Downloads / Gated Content
143-
144143
- We need a gating system, where the user gets a token to be able to download a PDF and the token is checked before downloading. If a reader has already given their email address - newsletter signup, contact form, download registration, then the download CTA on short form articles should show the PDF download button instead of trying to collect email addresses again.
145144

146145
- We had this copyright statement for articles, it should be in the front matter of PDFs:

axe-results-incomplete.json

Whitespace-only changes.

axe-results-violations.json

Whitespace-only changes.

0 commit comments

Comments
 (0)