@wtfalch/email 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,20 +12,25 @@
|
|
|
12
12
|
* - `wide` — mailboxes, list and message side by side. Selecting a
|
|
13
13
|
* conversation reveals it; there is nothing to navigate to.
|
|
14
14
|
* - `medium` — the mailboxes collapse to a rail of icons, and the list and
|
|
15
|
-
* the message share what is left. Below
|
|
16
|
-
* (1150px) a 3-column layout puts the reading measure under 45 characters,
|
|
15
|
+
* the message share what is left. Below 1150px a 3-column layout puts the reading measure under 45 characters,
|
|
17
16
|
* which is where prose stops being readable, and the mailbox names are the
|
|
18
17
|
* least valuable of the three.
|
|
19
|
-
* - `narrow` — one at a time, with the mailboxes in a drawer.
|
|
20
|
-
* `@wtfalch/design`'s `medium` breakpoint (860px), where the list's
|
|
18
|
+
* - `narrow` — one at a time, with the mailboxes in a drawer. Below 860px, where the list's
|
|
21
19
|
* two-line row can no longer hold a sender, a time and a subject without
|
|
22
20
|
* the subject truncating to nothing.
|
|
23
21
|
*
|
|
24
|
-
* The widths
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* **The two widths live here, not in `@wtfalch/design`.** They used to be
|
|
23
|
+
* read from its `PANE_QUERIES.wide` and `.medium`. Design 0.18.0 moved to
|
|
24
|
+
* Tailwind's sm-2xl scale and dropped both names, and the peer range here is
|
|
25
|
+
* `>=0.16.0`, so a host on a newer design got `matchMedia(undefined)`, which
|
|
26
|
+
* never matches: every window was `narrow`, and the two- and three-pane
|
|
27
|
+
* layouts were unreachable. These widths come from measuring this layout,
|
|
28
|
+
* not from the design system's scale, so they belong to this file.
|
|
28
29
|
*/
|
|
30
|
+
export declare const PANE_QUERIES: {
|
|
31
|
+
readonly wide: "(min-width: 1150px)";
|
|
32
|
+
readonly medium: "(min-width: 860px)";
|
|
33
|
+
};
|
|
29
34
|
export type Panes = 'wide' | 'medium' | 'narrow';
|
|
30
35
|
/**
|
|
31
36
|
* The current layout, updated as the window changes.
|
|
@@ -1,14 +1,46 @@
|
|
|
1
|
-
import { MEDIA_QUERIES } from '@wtfalch/design';
|
|
2
1
|
import { useEffect, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* How many panes fit.
|
|
4
|
+
*
|
|
5
|
+
* A mail client is three columns on a desk and one column on a phone, and the
|
|
6
|
+
* difference is not a matter of styling: at one column the list and the
|
|
7
|
+
* message are the *same* space, so which of them is on screen becomes state
|
|
8
|
+
* the shell has to hold. CSS can narrow a column and cannot answer that, which
|
|
9
|
+
* is why this is a hook and not a media query in the stylesheet.
|
|
10
|
+
*
|
|
11
|
+
* Three, not a continuum:
|
|
12
|
+
*
|
|
13
|
+
* - `wide` — mailboxes, list and message side by side. Selecting a
|
|
14
|
+
* conversation reveals it; there is nothing to navigate to.
|
|
15
|
+
* - `medium` — the mailboxes collapse to a rail of icons, and the list and
|
|
16
|
+
* the message share what is left. Below 1150px a 3-column layout puts the reading measure under 45 characters,
|
|
17
|
+
* which is where prose stops being readable, and the mailbox names are the
|
|
18
|
+
* least valuable of the three.
|
|
19
|
+
* - `narrow` — one at a time, with the mailboxes in a drawer. Below 860px, where the list's
|
|
20
|
+
* two-line row can no longer hold a sender, a time and a subject without
|
|
21
|
+
* the subject truncating to nothing.
|
|
22
|
+
*
|
|
23
|
+
* **The two widths live here, not in `@wtfalch/design`.** They used to be
|
|
24
|
+
* read from its `PANE_QUERIES.wide` and `.medium`. Design 0.18.0 moved to
|
|
25
|
+
* Tailwind's sm-2xl scale and dropped both names, and the peer range here is
|
|
26
|
+
* `>=0.16.0`, so a host on a newer design got `matchMedia(undefined)`, which
|
|
27
|
+
* never matches: every window was `narrow`, and the two- and three-pane
|
|
28
|
+
* layouts were unreachable. These widths come from measuring this layout,
|
|
29
|
+
* not from the design system's scale, so they belong to this file.
|
|
30
|
+
*/
|
|
31
|
+
export const PANE_QUERIES = {
|
|
32
|
+
wide: '(min-width: 1150px)',
|
|
33
|
+
medium: '(min-width: 860px)',
|
|
34
|
+
};
|
|
3
35
|
function read() {
|
|
4
36
|
/* Server rendering, and jsdom without the shim, both land here. `wide` is
|
|
5
37
|
the right default for both: it is the layout with no hidden state, so a
|
|
6
38
|
render that never gets a second chance still shows everything. */
|
|
7
39
|
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
8
40
|
return 'wide';
|
|
9
|
-
if (window.matchMedia(
|
|
41
|
+
if (window.matchMedia(PANE_QUERIES.wide).matches)
|
|
10
42
|
return 'wide';
|
|
11
|
-
if (window.matchMedia(
|
|
43
|
+
if (window.matchMedia(PANE_QUERIES.medium).matches)
|
|
12
44
|
return 'medium';
|
|
13
45
|
return 'narrow';
|
|
14
46
|
}
|
|
@@ -25,10 +57,7 @@ export function usePanes() {
|
|
|
25
57
|
useEffect(() => {
|
|
26
58
|
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
27
59
|
return;
|
|
28
|
-
const queries = [
|
|
29
|
-
window.matchMedia(MEDIA_QUERIES.wide),
|
|
30
|
-
window.matchMedia(MEDIA_QUERIES.medium),
|
|
31
|
-
];
|
|
60
|
+
const queries = [window.matchMedia(PANE_QUERIES.wide), window.matchMedia(PANE_QUERIES.medium)];
|
|
32
61
|
const update = () => setPanes(read());
|
|
33
62
|
for (const query of queries)
|
|
34
63
|
query.addEventListener('change', update);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtfalch/email",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "The wtfalch estate: reading a mailbox over JMAP, and administering the Stalwart server it lives on. Two entries with no code in common.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|