diff --git a/apps/extension/entrypoints/options/options.css b/apps/extension/entrypoints/options/options.css index c16519d1..fc7fbe4f 100644 --- a/apps/extension/entrypoints/options/options.css +++ b/apps/extension/entrypoints/options/options.css @@ -7,8 +7,8 @@ body { background: var(--ground); } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px 24px; } .field { display: flex; flex-direction: column; gap: 6px; } .strong { font-weight: 500; } -.field input, .field select { height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); } -.field select { padding: 0 10px; } +.field input, .field select { height: 40px; padding-left: 12px; border-radius: 8px; border: 1px solid var(--line-strong); background-color: var(--surface); } +.field input { padding-right: 12px; } .account { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 8px; background: var(--rail); } .account input { flex: 1; min-width: 0; height: 32px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 8px; } .links { display: flex; gap: 12px; } diff --git a/apps/extension/entrypoints/popup/popup.css b/apps/extension/entrypoints/popup/popup.css index e34b482f..babce532 100644 --- a/apps/extension/entrypoints/popup/popup.css +++ b/apps/extension/entrypoints/popup/popup.css @@ -20,7 +20,8 @@ body { width: 360px; } .queued-dot { width: 10px; height: 10px; flex: none; border-radius: 5px; background: #9A5536; } .chip-static { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--chip); font-size: 12px; } -.popup { max-height: 460px; display: flex; flex-direction: column; overflow: hidden; } +/* As tall as Chrome lets a popup be (600): with Lists above the tags, 460 put Later, Archive and Open under a scroll. */ +.popup { max-height: 600px; display: flex; flex-direction: column; overflow: hidden; } /* The wordmark opens Pluck; the cog opens Options. */ .bar { height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 12px; border-bottom: 1px solid var(--line); } .home { display: flex; align-items: center; height: 28px; padding: 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ink); } @@ -36,8 +37,7 @@ body { width: 360px; } .body { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; flex: 1; overflow-y: auto; } .field { display: flex; flex-direction: column; gap: 6px; } .label { font-size: 12px; color: var(--ink2); } -input[type="text"], select { height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; } -select { padding: 0 8px; } +input[type="text"] { height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; } .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; } .field > .chips { margin-top: 0; } /* the Lists: chips under their own label, with no field between */ .chip { height: 28px; padding: 0 10px; border-radius: 14px; border: 0; background: var(--chip); font-size: 12px; } diff --git a/apps/extension/lib/base.css b/apps/extension/lib/base.css index 7cb88e44..dbdd0ff3 100644 --- a/apps/extension/lib/base.css +++ b/apps/extension/lib/base.css @@ -11,6 +11,14 @@ * { box-sizing: border-box; } body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-ui); font-size: 14px; line-height: 20px; } button, input, select { font: inherit; color: inherit; } +/* One select, as on the web (apps/web/app/globals.css): the native arrow sat flush with the right edge, so the + chevron is drawn, 12 in from it. Rules after this one set `background-color` and one side's padding, never the + shorthands, which would wipe it. */ +select { + appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%238A9284' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); + background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 12px; +} button { cursor: pointer; } button:disabled { cursor: default; opacity: 0.45; } a { color: var(--ink); } diff --git a/apps/extension/package.json b/apps/extension/package.json index bdade10f..63b4fb66 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -2,7 +2,7 @@ "name": "@pluck/extension", "description": "The Pluck browser extension: pluck the page you are on, a link, an image or a selection.", "repository": { "type": "git", "url": "https://github.com/codu-code/pluck.git", "directory": "apps/extension" }, - "version": "0.2.5", + "version": "0.2.6", "private": true, "license": "Apache-2.0", "type": "module", diff --git a/apps/extension/store/1-pluck-this-page.png b/apps/extension/store/1-pluck-this-page.png index fb22f400..87945f96 100644 Binary files a/apps/extension/store/1-pluck-this-page.png and b/apps/extension/store/1-pluck-this-page.png differ diff --git a/apps/extension/store/2-your-inbox.png b/apps/extension/store/2-your-inbox.png index d6e51568..fdff45f0 100644 Binary files a/apps/extension/store/2-your-inbox.png and b/apps/extension/store/2-your-inbox.png differ diff --git a/apps/extension/store/3-the-reader.png b/apps/extension/store/3-the-reader.png index 3b15b95a..9ee6e028 100644 Binary files a/apps/extension/store/3-the-reader.png and b/apps/extension/store/3-the-reader.png differ diff --git a/apps/extension/store/listing.md b/apps/extension/store/listing.md index 8d1a277f..e9d48d71 100644 --- a/apps/extension/store/listing.md +++ b/apps/extension/store/listing.md @@ -1,6 +1,6 @@ # Chrome Web Store listing -What to paste into each field of the developer dashboard. The zip is `pnpm --filter @pluck/extension zip` (`.output/pluckextension--chrome.zip`); build it without `PLUCK_LOCAL`. Images are in this folder. +What to paste into each field of the developer dashboard. The zip is `pnpm --filter @pluck/extension zip` (`.output/pluckextension--chrome.zip`); build it without `PLUCK_LOCAL`. Images are in this folder; the three screenshots are taken from the real extension and web app by `node scripts/store-chrome.mjs` (its header says what it needs), so make them again when either changes. ## Store listing diff --git a/packages/extract/fixtures/pages/store/field-notes.html b/packages/extract/fixtures/pages/store/field-notes.html new file mode 100644 index 00000000..a56886a6 --- /dev/null +++ b/packages/extract/fixtures/pages/store/field-notes.html @@ -0,0 +1,34 @@ + + + + + +The case for a shorter reading list + + + + + + +
Field Notes
+
+
+ Essay +

The case for a shorter reading list

+

By Sam Rowe · 8 min read

+

Most of what we keep to read later, we never read. The list grows by a dozen links a week and shrinks by two, and after a year it is less a list than a record of good intentions.

+

The fix is not a better way to file things. It is a habit of letting things go: keep what you plucked this week close, move the rest out of sight, and trust that anything important will come back.

+

A short list is one you can finish. A list you can finish is one you will open.

+
+
+ + diff --git a/scripts/store-chrome.mjs b/scripts/store-chrome.mjs new file mode 100644 index 00000000..444432e9 --- /dev/null +++ b/scripts/store-chrome.mjs @@ -0,0 +1,90 @@ +// The Chrome Web Store's three screenshots (1280 × 800), taken from the real extension and the real web app, so the +// listing shows them as they ship: 1 the popup over a page it has just plucked, 2 the Inbox, 3 the reader. +// +// Needs a local server running a production build (`next dev` draws its own badge on the page) with a demo library +// (`node scripts/demo-seed.mjs `, which prints the key; a fresh one each time, since a page already +// in the library is not plucked again), the fixture pages (`pnpm stack`), and the extension built for a local server: +// PLUCK_LOCAL=1 pnpm --filter @pluck/extension build +// Usage: node scripts/store-chrome.mjs +// Writes apps/extension/store/1-pluck-this-page.png, 2-your-inbox.png and 3-the-reader.png. +import { writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { chromium } from "@playwright/test"; + +const root = join(import.meta.dirname, ".."); +const [server, email, key] = process.argv.slice(2); +if (!server || !email || !key) throw new Error("Usage: node scripts/store-chrome.mjs "); +const MAILPIT = "http://127.0.0.1:8035"; +const PAGE = `${process.env.PLUCK_FIXTURES ?? "http://127.0.0.1:4180"}/store/field-notes.html`; +const EXTENSION = join(root, "apps/extension/.output/chrome-mv3"); +const out = (name) => join(root, "apps/extension/store", name); +const size = { width: 1280, height: 800 }; + +const context = await chromium.launchPersistentContext("", { + channel: "chromium", viewport: size, args: [`--disable-extensions-except=${EXTENSION}`, `--load-extension=${EXTENSION}`], +}); +const sw = context.serviceWorkers()[0] ?? (await context.waitForEvent("serviceworker")); +const extId = new URL(sw.url()).host; +await sw.evaluate(async ({ key, server }) => { + await chrome.storage.local.set({ settings: { server, defaultKind: "guess", sendContent: true, transcripts: true }, apiKey: key, seenTips: true }); +}, { key, server }); + +// Sign the browser in as the same person, through the real email link. +const page = context.pages()[0] ?? (await context.newPage()); +const sent = Date.now(); +await page.request.post(`${server}/api/auth/sign-in/magic-link`, { headers: { origin: server }, data: { email, callbackURL: "/inbox" } }); +let link; +for (let i = 0; i < 40 && !link; i++) { + const { messages } = await (await fetch(`${MAILPIT}/api/v1/search?query=${encodeURIComponent(`to:"${email}"`)}`)).json(); + const fresh = messages.find((m) => new Date(m.Created).getTime() >= sent - 1000); + if (fresh) link = (await (await fetch(`${MAILPIT}/api/v1/message/${fresh.ID}`)).json()).Text.match(/https?:\/\/\S+/)?.[0]; + else await new Promise((r) => setTimeout(r, 250)); +} +if (!link) throw new Error("no sign-in email arrived"); +await page.goto(link.replace("/signin/link?", "/api/auth/magic-link/verify?")); +const api = async (path, data) => (await page.request[data ? "post" : "get"](`${server}${path}`, data ? { data } : undefined)).json(); +await api("/api/v1/tags", { name: "reading" }); + +// 1. The page, and the popup that has just plucked it, with a List and a tag tapped on. +await page.goto(PAGE); +const behind = await page.screenshot({ type: "png" }); +const tabId = await sw.evaluate(async (url) => (await chrome.tabs.query({ url }))[0].id, PAGE); +const popup = await context.newPage(); +await popup.setViewportSize({ width: 360, height: 600 }); +await popup.goto(`chrome-extension://${extId}/popup.html?tab=${tabId}`); +await popup.getByRole("status").filter({ hasText: "Plucked" }).waitFor(); +await popup.getByRole("group", { name: "Lists" }).getByRole("button").first().click(); +await popup.getByRole("button", { name: "reading", exact: true }).click(); +await popup.getByRole("button", { name: "reading", exact: true }).and(popup.locator("[aria-pressed=true]")).waitFor(); +await popup.mouse.move(0, 599); +const card = await popup.locator(".popup").screenshot({ type: "png" }); +await popup.close(); +const data = (png) => `data:image/png;base64,${png.toString("base64")}`; +await page.setContent( + `` + + // Where Chrome hangs a popup: under the toolbar, at the right. Its own border and shadow, as the browser draws them. + ``, +); +writeFileSync(out("1-pluck-this-page.png"), await page.screenshot({ type: "png" })); + +// 2. The Inbox, the pointer on the page just plucked so its row shows what can be done with it. Not at once: a row +// plucked in the last few seconds is drawn as just landed, and the library was seeded a moment ago. +await page.waitForTimeout(6000); +// A demo link with nothing to say for itself shows its address on its row, and here that is a local one: out of the picture. +for (const i of (await api("/api/v1/items?status=inbox&limit=50")).items) + if (i.url && !i.excerpt) await page.request.patch(`${server}/api/v1/items/${i.id}`, { data: { status: "archived" } }); +await page.goto(`${server}/inbox`); +const row = page.getByRole("listitem").first(); +await row.waitFor(); +await row.hover(); +writeFileSync(out("2-your-inbox.png"), await page.screenshot({ type: "png" })); + +// 3. The reader, on that page. +const { items } = await api("/api/v1/items?status=inbox&limit=1"); +await page.goto(`${server}/items/${items[0].id}`); +await page.getByRole("article").waitFor(); +await page.mouse.move(640, 700); +writeFileSync(out("3-the-reader.png"), await page.screenshot({ type: "png" })); + +await context.close(); +console.log("Three Chrome Web Store screenshots written to apps/extension/store.");