@casomoltd/tooling 0.34.0 → 0.34.2

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.
package/README.md CHANGED
@@ -15,7 +15,7 @@ Shared linting, formatting, commit config, and CLI tools for Casomo Ltd's repos.
15
15
  | `@casomoltd/tooling/knip` | Knip config for unused exports/dependencies |
16
16
  | `@casomoltd/tooling/jscpd` | Copy-paste detection config |
17
17
  | `@casomoltd/tooling/readability` | `scoreText()` — readability scoring for page content |
18
- | `@casomoltd/tooling/buttondown` | For a repo using the `buttondown` command: the shared email blocks and skins (`createEmailBlocks`, `emailBaseCss`, `composeWebSkin`), `tokenReader()`, `loadSettings()` and `buildPayload()`, and `EMAIL_CHROME_HIDES` ([docs/buttondown.md](docs/buttondown.md)) |
18
+ | `@casomoltd/tooling/buttondown` | For a repo using the `buttondown` command: the shared email blocks and skins (`createEmailBlocks`, `emailBaseCss`, `composeWebSkin`), `tokenReader()`, `loadSettings()` and `buildPayload()`, and `EMAIL_CHROME_HIDES` and `WEB_CHROME_HIDES` ([docs/buttondown.md](docs/buttondown.md)) |
19
19
 
20
20
  ### Bin commands
21
21
 
@@ -6,7 +6,8 @@
6
6
  *
7
7
  * A repo configures it under `buttondown` in its `casomo.config.mjs`:
8
8
  *
9
- * import {EMAIL_CHROME_HIDES} from "@casomoltd/tooling/buttondown";
9
+ * import {EMAIL_CHROME_HIDES, WEB_CHROME_HIDES}
10
+ * from "@casomoltd/tooling/buttondown";
10
11
  *
11
12
  * export default {
12
13
  * buttondown: {
@@ -16,7 +17,9 @@
16
17
  * tokens: [["--color-accent", "--color-brand-accent"]], // target, source
17
18
  * extra: [["--radius", "0"]], // uncommented lines after them
18
19
  * asserts: {"--radius-lg": "0"}, // tokens the skins depend on
19
- * allowedHides: {...EMAIL_CHROME_HIDES, ".selector": "why"},
20
+ * allowedHides: {...EMAIL_CHROME_HIDES, ...WEB_CHROME_HIDES, // the
21
+ * second for a repo that composes its web skin
22
+ * ".selector": "why"},
20
23
  * linkClasses: {onDark: "on-dark"}, // each needs an `a.<class>` rule
21
24
  * ownLinks: ["/rss"], // hrefs that are not socials
22
25
  * paletteFiles: ["buttondown/assets/icon.svg"],
@@ -47,6 +50,8 @@ export const END = "/* END TOKENS */";
47
50
  export const EMAIL_CHROME_HIDES = {
48
51
  ".social-links": "the web footer's links, duplicated in an email",
49
52
  ".newsletter-masthead": "replaced by the repo's own header band",
53
+ ".transactional-email-header":
54
+ "the icon, subject and name above a transactional email's own bands",
50
55
  ".newsletter-icon": "the icon slot above the repo's own mark",
51
56
  ".email-preamble": "the forwarding prompt between title and prose",
52
57
  ".colophon": "the sender-and-date line under the hidden masthead",
@@ -54,6 +59,25 @@ export const EMAIL_CHROME_HIDES = {
54
59
  ".powered-by-icon": "the logo tile above the kept attribution line",
55
60
  };
56
61
 
62
+ /**
63
+ * Buttondown's controls on the hosted pages that send a reader somewhere
64
+ * worse than the site does. `composeWebSkin` hides them, so a repo that
65
+ * composes its web skin spreads this into `allowedHides`, as it does
66
+ * EMAIL_CHROME_HIDES. The manage-link hide assumes the archive is on a
67
+ * custom domain, where that link's buttondown.com address asks a signed-in
68
+ * reader to sign in again; on buttondown.com it is their only manage link.
69
+ */
70
+ export const WEB_CHROME_HIDES = {
71
+ "a.sniper-link-button":
72
+ "a button to the reader's mail provider, in the form's place and in the"
73
+ + " sign-up dialog; their inbox is theirs to go to",
74
+ [".subscribe:has(span.confirmation-email-message)"
75
+ + " #subscribe-form a.archive__button"]:
76
+ "a signed-in reader's manage link, which goes to buttondown.com and asks"
77
+ + " them to sign in again; the header's Account link opens the same"
78
+ + " settings on the site's domain",
79
+ };
80
+
57
81
  const API = "https://api.buttondown.com/v1";
58
82
 
59
83
  /** The API's own path prefix, which every request path sits under. */
@@ -59,6 +59,10 @@ export type Check = (context: CheckContext) => Promise<string[]>;
59
59
  * bands: spread into `allowedHides` to allow hiding it. */
60
60
  export const EMAIL_CHROME_HIDES: Readonly<Record<string, string>>;
61
61
 
62
+ /** Hosted-page controls the composed web skin hides; spread into
63
+ * `allowedHides` by a repo that uses `composeWebSkin`. */
64
+ export const WEB_CHROME_HIDES: Readonly<Record<string, string>>;
65
+
62
66
  export function loadSettings(root?: string): Promise<Settings>;
63
67
 
64
68
  export function buildPayload(settings: Settings): Promise<Payload>;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export {
6
6
  buildPayload, EMAIL_CHROME_HIDES, loadSettings, tokenReader,
7
+ WEB_CHROME_HIDES,
7
8
  } from "./engine.mjs";
8
9
  export {colophonLinks} from "./colophon.mjs";
9
10
  export {createEmailBlocks, TABLE} from "./email-blocks.mjs";
@@ -6,7 +6,7 @@ import {readFileSync} from "node:fs";
6
6
  import {
7
7
  BODY_SIZE, PARAGRAPH_MARGIN, requireTheme,
8
8
  } from "./email-blocks.mjs";
9
- import {EMAIL_CHROME_HIDES, preludeEnd} from "./engine.mjs";
9
+ import {EMAIL_CHROME_HIDES, preludeEnd, WEB_CHROME_HIDES} from "./engine.mjs";
10
10
 
11
11
  /** The shared web rules: base-web.css, which reads every value from the
12
12
  * variables the site's TOKENS block defines. */
@@ -14,6 +14,12 @@ const WEB_BASE = readFileSync(
14
14
  new URL("./base-web.css", import.meta.url), "utf8",
15
15
  );
16
16
 
17
+ /** WEB_CHROME_HIDES as rules. Important, so a site's own rules for the
18
+ * same elements can't show them unless those are important too. */
19
+ const WEB_HIDES = Object.keys(WEB_CHROME_HIDES)
20
+ .map((selector) => `${selector} { display: none !important; }`)
21
+ .join("\n");
22
+
17
23
  /**
18
24
  * The web skin: the site's stylesheet with the shared rules inserted after
19
25
  * its opening comments and `@import`s, which must come before any rule,
@@ -22,7 +28,8 @@ const WEB_BASE = readFileSync(
22
28
  export function composeWebSkin(site) {
23
29
  const at = preludeEnd(site);
24
30
  const head = site.slice(0, at);
25
- return `${head}${head ? "\n\n" : ""}${WEB_BASE}\n${site.slice(at)}`;
31
+ return `${head}${head ? "\n\n" : ""}${WEB_BASE}\n${WEB_HIDES}\n`
32
+ + site.slice(at);
26
33
  }
27
34
 
28
35
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casomoltd/tooling",
3
- "version": "0.34.0",
3
+ "version": "0.34.2",
4
4
  "description": "Casomo's shared dev config: ESLint, Prettier, commitlint, knip & jscpd presets and dev CLIs (git hooks, readability, screenshots, design specs)",
5
5
  "license": "MIT",
6
6
  "repository": {