diff --git a/.github/workflows/preview-branch-cloudflare.yml b/.github/workflows/preview-branch-cloudflare.yml new file mode 100644 index 0000000..758b4e2 --- /dev/null +++ b/.github/workflows/preview-branch-cloudflare.yml @@ -0,0 +1,110 @@ +name: Preview branch (Cloudflare) + +on: + push: + branches-ignore: + - main + +permissions: + contents: read + pull-requests: read + +concurrency: + group: preview-branch-cloudflare-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + preview: + runs-on: ubuntu-latest + env: + BRANCH: ${{ github.ref_name }} + + steps: + - name: Check out code + uses: actions/checkout@v5 + + - name: Check for an open pull request + id: pr + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + number=$(gh pr list \ + --head "$BRANCH" \ + --state open \ + --json number \ + --jq '.[0].number // empty') + echo "number=$number" >> "$GITHUB_OUTPUT" + + - name: Skip branch preview when a PR preview owns it + if: steps.pr.outputs.number != '' + run: | + echo "Open PR #${{ steps.pr.outputs.number }} already deploys this branch's preview." + + - name: Set up Node.js + if: steps.pr.outputs.number == '' + uses: actions/setup-node@v5 + with: + node-version: "24" + cache: npm + + - name: Install dependencies + if: steps.pr.outputs.number == '' + run: npm ci + + - name: Type check + if: steps.pr.outputs.number == '' + run: npm run typecheck + + - name: Run tests + if: steps.pr.outputs.number == '' + run: npm test + + - name: Compute preview alias + if: steps.pr.outputs.number == '' + id: alias + run: | + alias=$(printf '%s' "$BRANCH" \ + | tr '[:upper:]' '[:lower:]' \ + | sed -E 's/[^a-z0-9-]+/-/g; s/^-+|-+$//g' \ + | cut -c1-40) + if [ -z "$alias" ]; then + alias="branch-$(git rev-parse --short HEAD)" + fi + echo "value=$alias" >> "$GITHUB_OUTPUT" + + - name: Upload preview version + if: steps.pr.outputs.number == '' + id: upload + run: | + npx wrangler versions upload \ + --config platforms/cloudflare/wrangler.toml \ + --preview-alias "${{ steps.alias.outputs.value }}" \ + --var "APP_VERSION:branch-$(git rev-parse --short HEAD)" \ + --message "Branch $BRANCH @ $(git rev-parse --short HEAD)" \ + | tee wrangler-upload.log + url=$(sed -n 's/.*Version Preview Alias URL: \(https:[^[:space:]]*\).*/\1/p' wrangler-upload.log | head -1) + if [ -z "$url" ]; then + url=$(grep -oE 'https://[^[:space:]]*workers\.dev[^[:space:]]*' wrangler-upload.log | head -1) + fi + if [ -z "$url" ]; then + echo "::error::Could not find a preview URL in wrangler output." + exit 1 + fi + echo "url=$url" >> "$GITHUB_OUTPUT" + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + - name: Write preview summary + if: steps.pr.outputs.number == '' + run: | + { + echo "### Cloudflare branch preview" + echo "" + echo "- **Branch:** \`$BRANCH\`" + echo "- **Commit:** \`${{ github.sha }}\`" + echo "- **Preview:** ${{ steps.upload.outputs.url }}" + echo "" + echo "This is a Worker *version* preview — it shares the production D1 database, so it reads/writes real data; it does not receive cron-triggered refreshes." + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/preview-cloudflare.yml b/.github/workflows/preview-cloudflare.yml index 7ea3250..66141ad 100644 --- a/.github/workflows/preview-cloudflare.yml +++ b/.github/workflows/preview-cloudflare.yml @@ -33,8 +33,13 @@ jobs: - name: Compute preview alias id: alias + env: + PR_BRANCH: ${{ github.head_ref }} run: | - alias=$(echo "${{ github.head_ref }}" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/^-+|-+$//g') + alias=$(printf '%s' "$PR_BRANCH" \ + | tr '[:upper:]' '[:lower:]' \ + | sed -E 's/[^a-z0-9-]+/-/g; s/^-+|-+$//g' \ + | cut -c1-40) echo "value=$alias" >> "$GITHUB_OUTPUT" - name: Upload preview version @@ -43,7 +48,7 @@ jobs: npx wrangler versions upload \ --config platforms/cloudflare/wrangler.toml \ --preview-alias "${{ steps.alias.outputs.value }}" \ - --var APP_VERSION:pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) \ + --var "APP_VERSION:pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" \ --message "PR #${{ github.event.pull_request.number }}" \ | tee wrangler-upload.log url=$(grep -oE 'https://[^[:space:]]*workers\.dev[^[:space:]]*' wrangler-upload.log | head -1) diff --git a/README.md b/README.md index 801c774..ca3b928 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

feedreader logo -  reader +  reader 

@@ -16,7 +16,7 @@ License: MIT

-![feedreader social card](web-static/og-image.png) +![feedreader social card](web-static/og-image.png?v=3) --- @@ -62,7 +62,7 @@ npx lighthouse https://reader.boringcode.dev --view - source filters - real source icons in filters, dialog rows, and card metadata - RSS-based app icon/favicon branding - - dark/light mode + - seven themes — Auto (follows the device), Ink, Paper, Sepia, Terminal, Glacier, and Ember — with a visual swatch picker - inline expanding search - reader settings dialog for theme, density, and source visibility - iPhone landscape safe-area handling so content stays clear of the notch and Dynamic Island @@ -335,12 +335,15 @@ Presentation-layer note: - `Reading` — Article preview, bookmarks, and AI personalization - `Sources` — visible sources - tabs support click, arrow keys, Home, and End; validation jumps to `Sources` or `Reading` when that tab needs attention -- theme and density options are shown in a 2-column layout to reduce dialog height +- themes are shown as a 2-column swatch grid; density options sit below in a 2-column row +- the selected theme is applied when the dialog is saved, and the settings form scrolls internally on short screens - clicking the dialog backdrop closes it - background page scrolling is locked while the dialog is open - selected sources are stored in `localStorage` under `feedreader.sources` - selected density is stored in `localStorage` under `feedreader.uiDensity` -- selected theme is stored in `localStorage` under `feedreader.theme` +- selected theme is stored in `localStorage` under `feedreader.theme`; valid values are `system` (default), `dark`, `light`, `sepia`, `terminal`, `glacier`, and `ember` +- `system` resolves to the device's current light/dark preference and follows changes live; existing `dark`/`light` preferences keep working +- an inline pre-paint theme init script applies the stored preference before the stylesheet loads, avoiding a light/dark flash - article preview is off by default and stored in `localStorage` under `feedreader.articlePreviewEnabled` - bookmark controls are off by default and stored in `localStorage` under `feedreader.bookmarksEnabled`; enabling them shows the bookmark controls and Saved filter, and disabling them hides those controls without deleting saved items - source-specific filters render as **real icon-only buttons** @@ -360,6 +363,8 @@ Presentation-layer note: - when enabled in Reader settings, clicking any card (including its title) loads a reader view in a right-hand panel instead of opening a new tab - `Cmd`/`Ctrl`/`Shift`-clicking a title still opens the article in a new tab - the panel shows the extracted title, byline, publication date/reading time, rich text with validated inline links/emphasis/inline code, image blocks with captions and intrinsic dimensions, and semantic tables; images load directly from the source with lazy loading and no referrer; `Open source` opens the original page +- consecutive list items render as one list and prose uses the full preview width; figures are capped in height so a single image cannot dominate the panel +- previews are source-aware: GitHub README previews drop the `GitHub - ` title prefix and decorative SVG/badge images, while Hugging Face paper previews render the abstract, authors, arXiv/PDF/project/GitHub links, and citing model, dataset, space, and collection lists instead of community comment chrome - Hacker News items also show a **Comments** action inside the preview and card `…` dialogs; other sources omit it - each card’s `…` dialog includes an **Open source** action that opens the article directly without opening the preview - **Share** uses the device/browser share sheet when available and falls back to copying the article link; it is available in both the card and preview `…` dialogs @@ -421,6 +426,8 @@ npm run db:migrate:local - CI runs on pull requests and `main` pushes. - CI checks type safety, unit tests, and a local D1 migration smoke run. +- Pull requests get a Cloudflare version preview commented on the PR. +- Non-`main` branch pushes get an automatic per-branch preview alias in the Actions run summary; branches with an open PR defer to the PR preview. - Deploy runs on `main` pushes and manual dispatch. - Deploy validates Cloudflare credentials, re-runs verification, applies remote D1 migrations, and deploys the Worker. diff --git a/core/preview.ts b/core/preview.ts index f076659..7c8f009 100644 --- a/core/preview.ts +++ b/core/preview.ts @@ -214,7 +214,7 @@ export function extractArticlePreview( ): ArticlePreview { const document = parseHtmlDocument(html); - const title = firstNonEmpty( + const rawTitle = firstNonEmpty( metaContent(document, [ 'meta[property="og:title"]', 'meta[name="twitter:title"]', @@ -222,6 +222,8 @@ export function extractArticlePreview( normalizeText(document.querySelector("h1")?.textContent), normalizeText(document.querySelector("title")?.textContent), ); + const title = sanitizePreviewTitle(rawTitle, pageUrl); + const isPaperPage = isHuggingFacePaperPage(pageUrl); const siteName = metaContent(document, ['meta[property="og:site_name"]']) || hostLabel(pageUrl); @@ -233,9 +235,18 @@ export function extractArticlePreview( ]), normalizeText(document.querySelector('[rel="author"]')?.textContent), normalizeText(document.querySelector('[class*="byline"]')?.textContent), + isPaperPage ? extractHuggingFacePaperByline(document) : "", ), ); const publishedAt = extractPublishedAt(document); + // Read paper resources and citation lists before nav/header cleanup drops + // the containers they live in. + const paperLinks = isPaperPage + ? extractHuggingFacePaperLinks(document, pageUrl) + : []; + const paperCitations = isPaperPage + ? extractHuggingFacePaperCitations(document, pageUrl) + : []; for (const selector of NOISE_SELECTORS) { document.querySelectorAll(selector).forEach((element) => { @@ -243,8 +254,17 @@ export function extractArticlePreview( }); } - const root = pickContentRoot(document); + const root = isPaperPage + ? (pickHuggingFacePaperRoot(document) ?? pickContentRoot(document)) + : pickContentRoot(document); const blocks = root ? extractBlocks(root, title, pageUrl) : []; + if (paperLinks.length > 0) { + blocks.push({ + type: "paragraph", + segments: [{ text: "Read the full paper: " }, ...paperLinks], + }); + } + blocks.push(...paperCitations); if (blocks.length === 0) { const description = normalizeText( metaContent(document, [ @@ -444,6 +464,11 @@ function collectInlineSegments( } } +/** + * Resolves relative links and returns only public http(s) URLs. + * `normalizePreviewUrl` rejects javascript:, data:, credentials, non-standard + * ports, and private/link-local hosts, so callers never see unsafe schemes. + */ function resolveInlineHref(raw: string | null, pageUrl: string): string { const trimmed = (raw ?? "").trim(); if (trimmed === "") return ""; @@ -569,6 +594,7 @@ function extractImageBlock( } if (resolved === "") return null; if (isAvatarImageSrc(resolved)) return null; + if (isDecorativeImageSrc(resolved)) return null; const caption = normalizeText( image.closest("figure")?.querySelector("figcaption")?.textContent, @@ -652,6 +678,26 @@ function isAvatarImageSrc(rawUrl: string): boolean { return false; } +/** + * README badges and wordmarks dominate a reader view when they are stretched + * to the panel width. They are interface chrome, not article figures. + */ +function isDecorativeImageSrc(rawUrl: string): boolean { + let url: URL; + try { + url = new URL(rawUrl); + } catch { + return false; + } + if (/\.svgz?$/i.test(url.pathname)) return true; + const host = url.hostname.toLowerCase().replace(/^www\./, ""); + return ( + host === "img.shields.io" || + host === "badgen.net" || + host === "badge.fury.io" + ); +} + function resolveSrcsetUrl(srcset: string | null, pageUrl: string): string { const raw = (srcset ?? "").trim(); if (raw === "") return ""; @@ -682,6 +728,149 @@ function parseImageDimension(raw: string | null): number | undefined { return parsed; } +/** + * Source pages often prefix the article title with their own site chrome + * ("GitHub - ", "Paper page - "). Strip only on the matching host so a real + * article title that happens to start with those words is left alone. + */ +function sanitizePreviewTitle(rawTitle: string, pageUrl: string): string { + const title = rawTitle.trim(); + let url: URL; + try { + url = new URL(pageUrl); + } catch { + return title; + } + const host = url.hostname.toLowerCase().replace(/^www\./, ""); + let cleaned = title; + if (host === "github.com") { + cleaned = cleaned.replace(/^GitHub\s*[-–—]\s*/i, ""); + } else if (host === "huggingface.co" && url.pathname.startsWith("/papers/")) { + cleaned = cleaned.replace(/^Paper page\s*[-–—]\s*/i, ""); + } + return cleaned.trim() || title; +} + +function isHuggingFacePaperPage(pageUrl: string): boolean { + try { + const url = new URL(pageUrl); + return ( + url.hostname.toLowerCase().replace(/^www\./, "") === "huggingface.co" && + url.pathname.startsWith("/papers/") + ); + } catch { + return false; + } +} + +/** + * Paper pages mix the abstract with a community thread and citation cards in + * one document. Start at the "Abstract" section so the reader view keeps the + * paper itself instead of the surrounding discussion chrome. + */ +function extractHuggingFacePaperByline(document: Document): string { + const nodes = Array.from(document.querySelectorAll(".author, h2")); + const abstractIndex = nodes.findIndex( + (element) => + element.tagName === "H2" && + normalizeText(element.textContent).toLowerCase() === "abstract", + ); + const stop = abstractIndex === -1 ? nodes.length : abstractIndex; + const names: string[] = []; + for (const node of nodes.slice(0, stop)) { + if (!node.classList.contains("author")) continue; + const name = normalizeText(node.textContent).replace(/\s*,\s*$/, ""); + if (name !== "" && !names.includes(name)) names.push(name); + } + if (names.length === 0) return ""; + return names.length <= 3 + ? names.join(", ") + : `${names.slice(0, 3).join(", ")}, et al.`; +} + +function extractHuggingFacePaperLinks( + document: Document, + pageUrl: string, +): PreviewSegment[] { + const heading = findHuggingFaceAbstractHeading(document); + const container = heading?.parentElement?.nextElementSibling; + const anchors = container + ? Array.from(container.querySelectorAll("a[href]")) + : []; + const parts: PreviewSegment[] = []; + for (const anchor of anchors) { + const label = normalizeText(anchor.textContent); + // resolveInlineHref only emits public http(s) URLs. + const href = resolveInlineHref(anchor.getAttribute("href"), pageUrl); + if (href === "") continue; + let text = ""; + if (/^View arXiv page/i.test(label)) text = "arXiv abstract"; + else if (/^View PDF/i.test(label)) text = "PDF"; + else if (/^Project page/i.test(label)) text = "Project page"; + else if (/^GitHub\b/i.test(label)) text = "GitHub"; + if (text === "") continue; + if (parts.length > 0) parts.push({ text: " · " }); + parts.push({ text, href }); + } + return parts; +} + +function extractHuggingFacePaperCitations( + document: Document, + pageUrl: string, +): PreviewBlock[] { + const blocks: PreviewBlock[] = []; + const headings = Array.from(document.querySelectorAll("h2, h3")).filter( + (element) => { + const text = normalizeText(element.textContent); + return ( + /^(Models|Datasets|Spaces) citing this paper/i.test(text) || + /^Collections including this paper/i.test(text) + ); + }, + ); + for (const heading of headings) { + const title = normalizeText(heading.textContent); + const container = heading.nextElementSibling; + if (!container) continue; + const items: PreviewSegment[] = []; + for (const anchor of Array.from(container.querySelectorAll("a[href]"))) { + // resolveInlineHref only emits public http(s) URLs. + const href = resolveInlineHref(anchor.getAttribute("href"), pageUrl); + if (href === "") continue; + const label = normalizeText( + anchor.querySelector("h4")?.textContent ?? anchor.textContent, + ); + if (label === "") continue; + items.push({ text: label, href }); + } + if (items.length === 0) continue; + blocks.push({ type: "heading", text: title }); + for (const item of items) { + blocks.push({ type: "list", segments: [item] }); + } + } + return blocks; +} + +function findHuggingFaceAbstractHeading(document: Document): Element | null { + return ( + Array.from(document.querySelectorAll("h2")).find( + (element) => + normalizeText(element.textContent).toLowerCase() === "abstract", + ) ?? null + ); +} + +function pickHuggingFacePaperRoot(document: Document): Element | null { + const heading = findHuggingFaceAbstractHeading(document); + const parent = heading?.parentElement ?? null; + if (!parent || parent === document.body || parent.tagName === "MAIN") { + return null; + } + return parent; +} + function pickContentRoot(document: Document): Element | null { const articles = Array.from(document.querySelectorAll("article")); let bestArticle: Element | null = null; diff --git a/core/render.ts b/core/render.ts index 304f783..55b9d48 100644 --- a/core/render.ts +++ b/core/render.ts @@ -65,6 +65,45 @@ function renderErrorBanner(error: ErrorView): string { return `
${escapeHtml(error.label)}: ${escapeHtml(error.error)}
`; } +interface ThemeChoice { + value: string; + label: string; + description: string; +} + +const themeChoices: ThemeChoice[] = [ + { value: "system", label: "Auto", description: "Follows device" }, + { value: "dark", label: "Ink", description: "Dark" }, + { value: "light", label: "Paper", description: "Light" }, + { value: "sepia", label: "Sepia", description: "Warm" }, + { value: "terminal", label: "Terminal", description: "High contrast" }, + { value: "glacier", label: "Glacier", description: "Cool light" }, + { value: "ember", label: "Ember", description: "Warm dark" }, +]; + +function renderThemeOption(choice: ThemeChoice, checked: boolean): string { + const swatchClass = `theme-swatch theme-swatch--${choice.value}`; + return ``; +} + function renderCard(card: CardView): string { const briefAttrs = [ card.briefPrefix @@ -139,19 +178,20 @@ export function renderIndexPage(data: PageData): string { - - - + + + - + - - + + + -
+

Reader settings

-

Theme

+

Auto follows your device's light or dark setting.

-
- - +
+ ${themeChoices.map((choice, index) => renderThemeOption(choice, index === 1)).join("\n ")}

UI density

-
+
-
- diff --git a/platforms/cloudflare/src/index.ts b/platforms/cloudflare/src/index.ts index af7ec32..a3bd50b 100644 --- a/platforms/cloudflare/src/index.ts +++ b/platforms/cloudflare/src/index.ts @@ -140,7 +140,7 @@ async function handleHome( ); const querySource = source === "all" ? "" : source; const canonicalUrl = `${url.origin}${url.pathname}${url.search}`; - const socialImageUrl = `${url.origin}/og-image.png?v=2`; + const socialImageUrl = `${url.origin}/og-image.png?v=3`; const appVersion = currentAppVersion(env); const { items, hasNext } = await feedItems( @@ -260,8 +260,9 @@ async function handlePreview( * `.invalid` is reserved by RFC 2606 for exactly this kind of placeholder * use, so it's guaranteed not to collide with a real host. */ function previewCacheRequest(target: string): Request { - // v4 invalidates previews cached before contributor avatars were filtered. - const raw = `preview:v4:${target}`; + // v9 adds paper resource/citation sections; v8 added arXiv links and v7 + // covered author bylines. + const raw = `preview:v9:${target}`; const url = `https://feedreader-internal.invalid/preview-cache?k=${encodeURIComponent(raw)}`; return new Request(url, { method: "GET" }); } diff --git a/web-static/manifest-assets/screenshot-mobile.png b/web-static/manifest-assets/screenshot-mobile.png index 50a54e4..c5ec46d 100644 Binary files a/web-static/manifest-assets/screenshot-mobile.png and b/web-static/manifest-assets/screenshot-mobile.png differ diff --git a/web-static/manifest-assets/screenshot-tablet.png b/web-static/manifest-assets/screenshot-tablet.png index 2d3f92e..2031134 100644 Binary files a/web-static/manifest-assets/screenshot-tablet.png and b/web-static/manifest-assets/screenshot-tablet.png differ diff --git a/web-static/manifest-assets/screenshot-wide-mobile.png b/web-static/manifest-assets/screenshot-wide-mobile.png index 9ddb4d6..486f852 100644 Binary files a/web-static/manifest-assets/screenshot-wide-mobile.png and b/web-static/manifest-assets/screenshot-wide-mobile.png differ diff --git a/web-static/manifest-assets/screenshot-wide.png b/web-static/manifest-assets/screenshot-wide.png index ef83980..5bc474c 100644 Binary files a/web-static/manifest-assets/screenshot-wide.png and b/web-static/manifest-assets/screenshot-wide.png differ diff --git a/web-static/og-image.png b/web-static/og-image.png index b4767da..f5bee46 100644 Binary files a/web-static/og-image.png and b/web-static/og-image.png differ diff --git a/web-static/service-worker.js b/web-static/service-worker.js index 517aa75..3c35ebe 100644 --- a/web-static/service-worker.js +++ b/web-static/service-worker.js @@ -1,14 +1,15 @@ -const SHELL_CACHE = "reader-shell-v108"; +const SHELL_CACHE = "reader-shell-v122"; const ITEMS_CACHE = "reader-items-v24"; const CORE_ASSETS = [ "/", - "/static/style.css?v=102", - "/static/app.js?v=87", + "/static/style.css?v=114", + "/static/app.js?v=96", + "/static/theme-init.js?v=1", "/static/source-icons/hackernews.svg", "/static/source-icons/github.svg", "/static/source-icons/huggingface.svg", "/favicon.svg?v=8", - "/site.webmanifest?v=15", + "/site.webmanifest?v=17", "/apple-touch-icon.png?v=8", "/icon-192.png?v=8", "/icon-512.png?v=8", diff --git a/web-static/site.webmanifest b/web-static/site.webmanifest index 501d896..29d5a19 100644 --- a/web-static/site.webmanifest +++ b/web-static/site.webmanifest @@ -11,8 +11,8 @@ "display_override": ["window-controls-overlay", "standalone"], "orientation": "any", "launch_handler": { "client_mode": "focus-existing" }, - "background_color": "#111e2c", - "theme_color": "#111e2c", + "background_color": "#0e141b", + "theme_color": "#0e141b", "categories": ["news", "productivity", "developer"], "prefer_related_applications": false, "icons": [ @@ -43,21 +43,21 @@ ], "screenshots": [ { - "src": "/manifest-assets/screenshot-wide.png?v=4", + "src": "/manifest-assets/screenshot-wide.png?v=5", "sizes": "1440x1120", "type": "image/png", "form_factor": "wide", "label": "Reader desktop feed view" }, { - "src": "/manifest-assets/screenshot-wide-mobile.png?v=4", + "src": "/manifest-assets/screenshot-wide-mobile.png?v=5", "sizes": "1440x1120", "type": "image/png", "form_factor": "wide", "label": "Reader mobile feed view" }, { - "src": "/manifest-assets/screenshot-mobile.png?v=5", + "src": "/manifest-assets/screenshot-mobile.png?v=6", "sizes": "430x932", "type": "image/png", "form_factor": "narrow", diff --git a/web-static/static/app.js b/web-static/static/app.js index ede3f6e..56220f1 100644 --- a/web-static/static/app.js +++ b/web-static/static/app.js @@ -125,7 +125,6 @@ const searchInput = document.querySelector("[data-search-input]"); const searchSourceInput = document.querySelector("[data-search-source]"); const refreshButton = document.querySelector("[data-refresh-button]"); - const themeToggle = document.querySelector("[data-theme-toggle]"); const installButton = document.querySelector("[data-install-button]"); const installDialog = document.querySelector("[data-install-dialog]"); const installDialogCloseButtons = Array.from( @@ -159,6 +158,15 @@ const bookmarksEnabledStorageKey = "feedreader.bookmarksEnabled"; const bookmarksLimit = 500; const themeStorageKey = "feedreader.theme"; + const themePreferences = [ + "system", + "dark", + "light", + "sepia", + "terminal", + "glacier", + "ember", + ]; const interestsStorageKey = "feedreader.interests"; const aiPersonalizationStorageKey = "feedreader.aiPersonalizationEnabled"; const articlePreviewStorageKey = "feedreader.articlePreviewEnabled"; @@ -176,6 +184,7 @@ : cardsGrid?.dataset.currentSource || "all"; let selectedSources = loadSelectedSources(); let uiDensity = loadUIDensity(); + let themePreference = loadThemePreference(); let visitedLinks = loadVisitedLinks(); let bookmarks = loadBookmarks(); let bookmarksEnabled = loadBookmarksEnabled(); @@ -698,6 +707,25 @@ } } + function normalizeThemePreference(rawValue) { + return themePreferences.includes(rawValue) ? rawValue : "system"; + } + + function resolveTheme(preference) { + if (preference !== "system") return preference; + return window.matchMedia?.("(prefers-color-scheme: light)")?.matches + ? "light" + : "dark"; + } + + function loadThemePreference() { + try { + return normalizeThemePreference(localStorage.getItem(themeStorageKey)); + } catch { + return "system"; + } + } + function persistSelectedSources() { localStorage.setItem( sourceConfigStorageKey, @@ -760,12 +788,14 @@ function syncThemeOptions() { themeOptions.forEach((option) => { - option.checked = option.value === root.dataset.theme; + option.checked = option.value === themePreference; }); } function currentThemeSelection() { - return themeOptions.find((option) => option.checked)?.value || "dark"; + return ( + themeOptions.find((option) => option.checked)?.value || themePreference + ); } function syncDialogOpenState(isOpen) { @@ -854,6 +884,8 @@ const panel = document.getElementById(tab.getAttribute("aria-controls")); if (panel) panel.hidden = !selected; } + const panels = selectedTab.closest(".config-tab-panels"); + if (panels) panels.scrollTop = 0; if (focus) selectedTab.focus(); } @@ -1373,10 +1405,28 @@ return wrap; }; + const appendPreviewListGroup = (items) => { + const list = document.createElement("ul"); + list.className = "preview-panel-list-group"; + for (const item of items) { + const element = document.createElement("li"); + if (Array.isArray(item.segments)) { + renderPreviewSegments(element, item.segments); + if (element.childNodes.length === 0) continue; + } else { + if (typeof item.text !== "string" || item.text === "") continue; + element.textContent = item.text; + } + list.appendChild(element); + } + if (list.childNodes.length > 0) previewContent.appendChild(list); + }; + const renderPreviewBlocks = (blocks) => { if (!previewContent) return; previewContent.replaceChildren(); - for (const block of blocks) { + for (let index = 0; index < blocks.length; index += 1) { + const block = blocks[index]; if (!block || typeof block !== "object") continue; if (block.type === "image") { if (typeof block.src !== "string" || !isHttpUrl(block.src)) continue; @@ -1429,6 +1479,19 @@ continue; } + if (block.type === "list") { + const items = [block]; + while ( + index + 1 < blocks.length && + blocks[index + 1]?.type === "list" + ) { + index += 1; + items.push(blocks[index]); + } + appendPreviewListGroup(items); + continue; + } + const tagName = block.type === "heading" ? "h3" @@ -1438,9 +1501,6 @@ ? "pre" : "p"; const element = document.createElement(tagName); - if (block.type === "list") { - element.classList.add("preview-panel-list"); - } if (Array.isArray(block.segments)) { renderPreviewSegments(element, block.segments); if (element.childNodes.length === 0) continue; @@ -1613,7 +1673,7 @@ setPreviewStatus("Loading preview…"); previewScroll?.scrollTo({ top: 0 }); - fetch(`/api/preview?url=${encodeURIComponent(url)}&v=4`, { + fetch(`/api/preview?url=${encodeURIComponent(url)}&v=9`, { headers: { Accept: "application/json" }, signal: controller.signal, }) @@ -1884,22 +1944,24 @@ }); } - const applyTheme = (theme) => { - root.dataset.theme = theme; - localStorage.setItem(themeStorageKey, theme); - syncThemeColor(); - if (themeToggle) { - themeToggle.setAttribute( - "aria-label", - `Switch to ${theme === "dark" ? "light" : "dark"} mode`, - ); - themeToggle.setAttribute( - "title", - theme === "dark" ? "Switch to light mode" : "Switch to dark mode", - ); + const applyTheme = (preference, { persist = true } = {}) => { + themePreference = normalizeThemePreference(preference); + root.dataset.theme = resolveTheme(themePreference); + if (persist) { + localStorage.setItem(themeStorageKey, themePreference); } + syncThemeOptions(); + syncThemeColor(); }; + window + .matchMedia?.("(prefers-color-scheme: light)") + ?.addEventListener?.("change", () => { + if (themePreference === "system") { + applyTheme("system", { persist: false }); + } + }); + const setRefreshButtonLoading = (active) => { if (!refreshButton) return; refreshButton.disabled = active; @@ -2206,6 +2268,7 @@ syncThemeOptions(); syncPersonalizationOptions(); syncArticlePreviewOption(); + configDialog?.querySelector(".config-tab-panels")?.scrollTo({ top: 0 }); if (typeof configDialog?.showModal === "function" && !configDialog.open) { configDialog.showModal(); syncDialogOpenState(true); @@ -2312,14 +2375,14 @@ return; } const normalizedDensity = normalizeUIDensity(nextDensity); - const normalizedTheme = nextTheme === "light" ? "light" : "dark"; + const normalizedTheme = normalizeThemePreference(nextTheme); const sourcesChanged = normalizedSources.length !== selectedSources.length || normalizedSources.some( (value, index) => value !== selectedSources[index], ); const densityChanged = normalizedDensity !== uiDensity; - const themeChanged = normalizedTheme !== root.dataset.theme; + const themeChanged = normalizedTheme !== themePreference; const interestsChanged = normalizedInterests !== interests; const personalizationEnabledChanged = nextPersonalizationEnabled !== aiPersonalizationEnabled; @@ -2666,12 +2729,6 @@ }); } - if (themeToggle) { - themeToggle.addEventListener("click", () => { - applyTheme(root.dataset.theme === "dark" ? "light" : "dark"); - }); - } - const installScreenshotVariant = isIPadDevice() ? "tablet" : isMobileDevice() @@ -2761,8 +2818,7 @@ if (document.visibilityState === "visible") checkForUpdate(); }, updateCheckIntervalMs); - const savedTheme = localStorage.getItem(themeStorageKey); - applyTheme(savedTheme === "light" ? "light" : "dark"); + applyTheme(themePreference, { persist: false }); applyUIDensity(uiDensity, { persist: false }); syncConfigOptions(); diff --git a/web-static/static/style.css b/web-static/static/style.css index c55c61a..a7ea064 100644 --- a/web-static/static/style.css +++ b/web-static/static/style.css @@ -1,49 +1,135 @@ -:root { +:root, +:root[data-theme='dark'] { color-scheme: dark; - --bg: #111e2c; - --bg-top: #111e2c; - --surface: #11161d; - --surface-raised: #161b22; - --border: #2d333b; - --text: #e6edf3; - --muted: #8b949e; - --accent: #58a6ff; - --accent-soft: rgba(88, 166, 255, 0.14); - --shadow: 0 12px 32px rgba(0, 0, 0, 0.18); + --bg: #0e141b; + --bg-top: #121a23; + --bg-glow: rgba(251, 146, 60, 0.08); + --surface: #121b24; + --surface-raised: #17212c; + --border: #293746; + --border-strong: #3b4d5f; + --text: #e9eef4; + --muted: #93a3b4; + --accent: #fb923c; + --accent-soft: rgba(251, 146, 60, 0.13); + --danger: #f87171; + --warning: #fbbf24; + --backdrop: rgba(3, 7, 11, 0.62); + --shadow: 0 18px 44px rgba(0, 0, 0, 0.24); + --github-filter: invert(1) brightness(1.15); + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-display: + 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, + ui-serif, serif; + --font-mono: + ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace; --control-height: 2.2rem; + --preview-panel-padding: 0.75rem; --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); - font-family: - Inter, - ui-sans-serif, - system-ui, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - sans-serif; + font-family: var(--font-ui); } :root[data-theme='light'] { color-scheme: light; - --bg: #e1ebf7; - --bg-top: #e1ebf7; - --surface: #ffffff; - --surface-raised: #f6f8fa; - --border: #d0d7de; - --text: #1f2328; - --muted: #57606a; - --accent: #0969da; - --accent-soft: rgba(9, 105, 218, 0.1); - --shadow: 0 10px 28px rgba(31, 35, 40, 0.08); - --control-height: 2.2rem; - font-family: - Inter, - ui-sans-serif, - system-ui, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - sans-serif; + --bg: #f7f3ec; + --bg-top: #fbf8f2; + --bg-glow: rgba(184, 67, 26, 0.07); + --surface: #fffdf8; + --surface-raised: #f3eee4; + --border: #ded5c6; + --border-strong: #c8bcaa; + --text: #221f1a; + --muted: #6b6257; + --accent: #b8431a; + --accent-soft: rgba(184, 67, 26, 0.1); + --danger: #b42318; + --warning: #9a6700; + --backdrop: rgba(34, 31, 26, 0.34); + --shadow: 0 14px 34px rgba(34, 31, 26, 0.08); + --github-filter: none; +} + +:root[data-theme='sepia'] { + color-scheme: light; + --bg: #efe4d0; + --bg-top: #f5ecdc; + --bg-glow: rgba(79, 98, 58, 0.08); + --surface: #f8efdd; + --surface-raised: #eadfc9; + --border: #d6c7ac; + --border-strong: #bfae8f; + --text: #2e2418; + --muted: #6f5f49; + --accent: #4f623a; + --accent-soft: rgba(79, 98, 58, 0.12); + --danger: #9f2d20; + --warning: #8a5a00; + --backdrop: rgba(46, 36, 24, 0.34); + --shadow: 0 14px 34px rgba(46, 36, 24, 0.1); + --github-filter: none; +} + +:root[data-theme='terminal'] { + color-scheme: dark; + --bg: #050b07; + --bg-top: #07110b; + --bg-glow: rgba(52, 211, 153, 0.08); + --surface: #0a130d; + --surface-raised: #0f1c14; + --border: #1d3325; + --border-strong: #2a4a35; + --text: #d7ffe3; + --muted: #7fae8e; + --accent: #34d399; + --accent-soft: rgba(52, 211, 153, 0.12); + --danger: #ff7b72; + --warning: #e3b341; + --backdrop: rgba(0, 0, 0, 0.7); + --shadow: 0 18px 44px rgba(0, 0, 0, 0.4); + --github-filter: invert(1) brightness(1.15); +} + +:root[data-theme='glacier'] { + color-scheme: light; + --bg: #e8f0f4; + --bg-top: #f1f7fa; + --bg-glow: rgba(15, 118, 110, 0.08); + --surface: #f9fcfd; + --surface-raised: #eaf2f5; + --border: #c9dce3; + --border-strong: #a9c4ce; + --text: #15262e; + --muted: #516a75; + --accent: #0f766e; + --accent-soft: rgba(15, 118, 110, 0.1); + --danger: #b42318; + --warning: #9a6700; + --backdrop: rgba(21, 38, 46, 0.28); + --shadow: 0 14px 34px rgba(21, 38, 46, 0.09); + --github-filter: none; +} + +:root[data-theme='ember'] { + color-scheme: dark; + --bg: #17100d; + --bg-top: #1c1410; + --bg-glow: rgba(251, 146, 60, 0.1); + --surface: #201612; + --surface-raised: #291c16; + --border: #3a2a22; + --border-strong: #523c30; + --text: #f5e9e2; + --muted: #b09a8e; + --accent: #fbbf24; + --accent-soft: rgba(251, 191, 36, 0.12); + --danger: #ff8a80; + --warning: #fbbf24; + --backdrop: rgba(10, 5, 2, 0.65); + --shadow: 0 18px 44px rgba(0, 0, 0, 0.34); + --github-filter: invert(1) brightness(1.15); } * { @@ -64,6 +150,17 @@ body { min-height: 100vh; padding-left: var(--safe-left); padding-right: var(--safe-right); + background-image: radial-gradient( + 72rem 34rem at 50% -12rem, + var(--bg-glow), + transparent 70% + ); + background-repeat: no-repeat; +} + +::selection { + background: var(--accent-soft); + color: var(--text); } button, @@ -87,7 +184,7 @@ button { display: flex; flex-direction: column; gap: 0.5rem; - padding: max(0.85rem, env(safe-area-inset-top)) 0 0.7rem; + padding: max(0.95rem, env(safe-area-inset-top)) 0 0.55rem; } .header-top { @@ -95,8 +192,12 @@ button { align-items: center; justify-content: space-between; gap: 0.75rem; + padding-bottom: 0.55rem; + border-bottom: 1px solid + color-mix(in srgb, var(--border) 72%, transparent); } + .header-actions { display: inline-flex; flex-wrap: wrap; @@ -111,7 +212,7 @@ button { justify-content: center; width: var(--control-height); height: var(--control-height); - color: #d29922; + color: var(--warning); } .brand { @@ -119,15 +220,21 @@ button { display: inline-flex; align-items: center; gap: 0.55rem; - font-size: clamp(1.2rem, 2.6vw, 1.55rem); - font-weight: 700; - letter-spacing: -0.02em; + font-family: var(--font-display); + font-size: clamp(1.3rem, 2.6vw, 1.65rem); + font-weight: 600; + letter-spacing: -0.035em; +} + +.brand > span::after { + content: '.'; + color: var(--accent); } .brand-mark { - width: 1.45rem; - height: 1.45rem; - border-radius: 0.35rem; + width: 1.35rem; + height: 1.35rem; + border-radius: 0.32rem; flex: 0 0 auto; } @@ -172,8 +279,8 @@ button { .icon-button, .view-more, .search-clear { - border: 1px solid var(--border); - background: var(--surface); + border: 1px solid transparent; + background: transparent; color: var(--muted); cursor: pointer; transition: 140ms ease; @@ -186,15 +293,20 @@ button { height: var(--control-height); min-height: var(--control-height); min-width: 3.1rem; - padding: 0 0.78rem; - border-radius: 999px; - font-size: 0.88rem; + padding: 0 0.62rem; + border-radius: 0.55rem; + font-family: var(--font-mono); + font-size: 0.72rem; + font-weight: 600; + letter-spacing: 0.07em; + text-transform: uppercase; } .filter-button--icon { min-width: var(--control-height); width: var(--control-height); padding: 0; + border-radius: 999px; } .filter-button--for-you { @@ -213,8 +325,8 @@ button { .view-more:hover, .search-clear:hover { color: var(--text); - background: color-mix(in srgb, var(--accent) 10%, var(--surface)); - border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); + background: var(--accent-soft); + border-color: transparent; } .item-title a:hover { @@ -223,7 +335,7 @@ button { } .filter-button.is-active:hover { - border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); + border-color: transparent; } .filter-button:focus-visible, @@ -235,9 +347,9 @@ button { } .filter-button.is-active { - color: var(--text); + color: var(--accent); background: var(--accent-soft); - border-color: color-mix(in srgb, var(--accent) 44%, var(--border)); + border-color: transparent; } .icon-button { @@ -248,7 +360,7 @@ button { height: var(--control-height); padding: 0; border-radius: 999px; - box-shadow: var(--shadow); + box-shadow: none; } .icon-button[disabled] { @@ -263,19 +375,19 @@ button { height: var(--control-height); padding: 0 0.85rem; border-radius: 999px; - border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--border)); - background: var(--accent-soft); + border: 1px solid var(--border); + background: transparent; color: var(--text); - font-size: 0.86rem; + font-size: 0.84rem; font-weight: 500; cursor: pointer; - box-shadow: var(--shadow); + box-shadow: none; transition: 140ms ease; } .pill-button:hover { - background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft)); - border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); + background: var(--accent-soft); + border-color: transparent; } .pill-button:focus-visible { @@ -289,9 +401,9 @@ button { .search-toggle.is-active, .search-clear { - color: var(--text); + color: var(--accent); background: var(--accent-soft); - border-color: color-mix(in srgb, var(--accent) 44%, var(--border)); + border-color: transparent; } .search-form { @@ -318,15 +430,16 @@ button { .search-input { height: var(--control-height); min-height: var(--control-height); - border-radius: 999px; - border: 1px solid var(--border); - background: var(--surface); + border-radius: 0; + border: 0; + border-bottom: 1px solid var(--border); + background: transparent; color: var(--text); - box-shadow: var(--shadow); + box-shadow: none; flex: 1 1 18rem; width: 18rem; min-width: 0; - padding: 0 0.86rem; + padding: 0 0.25rem; font-size: 16px; } @@ -336,7 +449,7 @@ button { .search-input:focus { outline: none; - border-color: color-mix(in srgb, var(--accent) 44%, var(--border)); + border-bottom-color: var(--accent); } .interests-input { @@ -421,9 +534,9 @@ button { } .config-dialog { - width: min(30rem, calc(100vw - 1.5rem)); + width: min(32rem, calc(100vw - 1.5rem)); border: 1px solid var(--border); - border-radius: 1rem; + border-radius: 1.1rem; padding: 0; color: var(--text); background: var(--surface-raised); @@ -431,8 +544,9 @@ button { } .config-dialog::backdrop { - background: rgba(0, 0, 0, 0.45); - backdrop-filter: blur(2px); + background: rgba(0, 0, 0, 0.55); + background: var(--backdrop); + backdrop-filter: blur(6px); } .config-dialog-form { @@ -440,6 +554,27 @@ button { flex-direction: column; gap: 1rem; padding: 1rem; + max-height: calc(100dvh - 2rem); + overflow-y: auto; +} + +.config-dialog-form--settings { + overflow: hidden; +} + +.config-dialog-form--settings > .config-dialog-header, +.config-dialog-form--settings > .config-dialog-copy, +.config-dialog-form--settings > .config-tabs, +.config-dialog-form--settings > .config-dialog-footer-row { + flex: 0 0 auto; +} + +.config-tab-panels { + flex: 1 1 auto; + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; + padding-bottom: 0.25rem; } .config-dialog-header { @@ -497,7 +632,7 @@ button { .config-tab[aria-selected='true'] { background: var(--accent-soft); - color: var(--text); + color: var(--accent); } .config-tab:focus-visible { @@ -569,12 +704,6 @@ button { gap: 0.65rem; } -.config-section-row { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 1rem; -} - .config-section-header { display: flex; flex-direction: column; @@ -583,9 +712,10 @@ button { .config-section-title { margin: 0; - font-size: 0.88rem; - font-weight: 700; - letter-spacing: 0.01em; + font-family: var(--font-mono); + font-size: 0.72rem; + font-weight: 600; + letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); } @@ -607,10 +737,6 @@ button { gap: 0.55rem; } -.config-options--choice-grid { - gap: 0.5rem; -} - .config-option { display: flex; align-items: center; @@ -726,6 +852,194 @@ button { color: var(--accent); } +.config-options--theme-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 0.5rem; +} + +.theme-option { + position: relative; + display: block; + cursor: pointer; +} + +.theme-option input { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0 0 0 0); + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} + +.theme-option-body { + display: flex; + align-items: center; + gap: 0.6rem; + min-height: 3.4rem; + padding: 0.5rem 0.58rem; + border: 1px solid var(--border); + border-radius: 0.8rem; + background: var(--surface); + transition: 140ms ease; +} + +.theme-option:hover .theme-option-body { + border-color: var(--border-strong); +} + +.theme-option:has(input:focus-visible) .theme-option-body { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +.theme-option:has(input:checked) .theme-option-body { + border-color: color-mix(in srgb, var(--accent) 52%, var(--border)); + background: color-mix(in srgb, var(--accent-soft) 44%, var(--surface)); +} + +.theme-swatch { + position: relative; + display: block; + flex: 0 0 auto; + width: 2.9rem; + height: 1.9rem; + overflow: hidden; + border: 1px solid var(--swatch-border); + border-radius: 0.42rem; + background: var(--swatch-bg); +} + +.theme-swatch-line { + position: absolute; + left: 0.42rem; + right: 0.42rem; + height: 2px; + border-radius: 999px; + background: var(--swatch-text); + opacity: 0.9; +} + +.theme-swatch-line--title { + top: 0.5rem; + right: 0.95rem; + height: 3px; +} + +.theme-swatch-line--meta { + top: 0.9rem; + right: 1.3rem; + opacity: 0.42; +} + +.theme-swatch-dot { + position: absolute; + right: 0.36rem; + bottom: 0.32rem; + width: 0.42rem; + height: 0.42rem; + border-radius: 999px; + background: var(--swatch-accent); +} + +.theme-swatch--system { + background: linear-gradient(115deg, #f7f3ec 0 50%, #0e141b 50% 100%); + --swatch-border: #6f6559; + --swatch-text: #fb923c; + --swatch-accent: #fb923c; +} + +.theme-swatch--dark { + --swatch-bg: #0e141b; + --swatch-border: #293746; + --swatch-text: #e9eef4; + --swatch-accent: #fb923c; +} + +.theme-swatch--light { + --swatch-bg: #fffdf8; + --swatch-border: #ded5c6; + --swatch-text: #221f1a; + --swatch-accent: #b8431a; +} + +.theme-swatch--sepia { + --swatch-bg: #f8efdd; + --swatch-border: #d6c7ac; + --swatch-text: #2e2418; + --swatch-accent: #4f623a; +} + +.theme-swatch--terminal { + --swatch-bg: #050b07; + --swatch-border: #1d3325; + --swatch-text: #d7ffe3; + --swatch-accent: #34d399; +} + +.theme-swatch--glacier { + --swatch-bg: #f9fcfd; + --swatch-border: #c9dce3; + --swatch-text: #15262e; + --swatch-accent: #0f766e; +} + +.theme-swatch--ember { + --swatch-bg: #201612; + --swatch-border: #3a2a22; + --swatch-text: #f5e9e2; + --swatch-accent: #fbbf24; +} + +.theme-option-label { + display: flex; + flex: 1 1 auto; + flex-direction: column; + gap: 0.08rem; + min-width: 0; +} + +.theme-option-title { + color: var(--text); + font-size: 0.86rem; + font-weight: 600; + line-height: 1.25; +} + +.theme-option-copy { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.03em; + line-height: 1.3; + text-transform: uppercase; +} + +.theme-option-check { + display: inline-flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + width: 1rem; + height: 1rem; + color: var(--accent); + opacity: 0; + transition: opacity 140ms ease; +} + +.theme-option-check svg { + width: 100%; + height: 100%; +} + +.theme-option:has(input:checked) .theme-option-check { + opacity: 1; +} + .is-dialog-open, body.is-dialog-open { overflow: hidden; @@ -821,8 +1135,8 @@ body.is-dialog-open { } .toast.is-error { - background: color-mix(in srgb, var(--surface) 88%, #f85149 12%); - border-color: color-mix(in srgb, #f85149 40%, var(--border)); + background: color-mix(in srgb, var(--surface) 88%, var(--danger) 12%); + border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); } .toast.is-loading { @@ -831,8 +1145,8 @@ body.is-dialog-open { } .toast.is-offline { - background: color-mix(in srgb, var(--surface) 88%, #d29922 12%); - border-color: color-mix(in srgb, #d29922 42%, var(--border)); + background: color-mix(in srgb, var(--surface) 88%, var(--warning) 12%); + border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); } .toast.is-loading::before { @@ -859,18 +1173,6 @@ body.is-dialog-open { } } -.theme-icon-sun { - display: none; -} - -:root[data-theme='light'] .theme-icon-sun { - display: block; -} - -:root[data-theme='light'] .theme-icon-moon { - display: none; -} - .page-body { padding-bottom: calc(0.35rem + env(safe-area-inset-bottom)); } @@ -904,7 +1206,7 @@ body.is-dialog-open { align-items: flex-start; justify-content: space-between; gap: 0.5rem; - padding: 0.55rem 0.6rem 0.55rem 0.75rem; + padding: var(--preview-panel-padding); } .preview-panel-header-info { @@ -1057,13 +1359,15 @@ body.is-dialog-open { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; - padding: 0.8rem 0.85rem 0.9rem; + padding: var(--preview-panel-padding); } .preview-panel-title { margin: 0 0 0.4rem; - font-size: 1.04rem; - line-height: 1.35; + font-family: var(--font-display); + font-size: 1.18rem; + font-weight: 600; + line-height: 1.3; } .preview-panel-byline { @@ -1101,8 +1405,11 @@ body.is-dialog-open { .preview-panel-image { display: block; - max-width: 100%; + width: auto; height: auto; + max-width: 100%; + max-height: 26rem; + object-fit: contain; border-radius: 0.65rem; background: var(--surface-raised); } @@ -1120,7 +1427,7 @@ body.is-dialog-open { z-index: 1; display: flex; gap: 0.5rem; - padding: 0.6rem 0.7rem; + padding: var(--preview-panel-padding); } .preview-panel-header::after, @@ -1224,13 +1531,15 @@ body.is-dialog-open { .preview-panel-content p, .preview-panel-content blockquote { - font-size: 0.9rem; - line-height: 1.56; + font-family: var(--font-display); + font-size: 0.98rem; + line-height: 1.62; } .preview-panel-content h3 { margin-top: 0.25rem; - font-size: 0.95rem; + font-family: var(--font-display); + font-size: 1.02rem; line-height: 1.35; } @@ -1313,15 +1622,22 @@ body.is-dialog-open { border-bottom: none; } -.preview-panel-list { - position: relative; - padding-left: 0.95rem; +.preview-panel-list-group { + display: flex; + flex-direction: column; + gap: 0.35rem; + margin: 0; + padding-left: 1.1rem; + font-family: var(--font-display); + font-size: 0.98rem; + line-height: 1.55; } -.preview-panel-list::before { - content: '•'; - position: absolute; - left: 0.2rem; +.preview-panel-list-group li { + padding-left: 0.1rem; +} + +.preview-panel-list-group li::marker { color: var(--accent); } @@ -1339,10 +1655,14 @@ body.is-dialog-open { margin: 0 0 0.7rem; padding: 0.25rem 0.7rem; border-radius: 999px; - border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border)); + border: 1px solid transparent; background: var(--accent-soft); - color: var(--text); - font-size: 0.8rem; + color: var(--accent); + font-family: var(--font-mono); + font-size: 0.66rem; + font-weight: 600; + letter-spacing: 0.06em; + text-transform: uppercase; } .personalized-indicator-icon { @@ -1356,8 +1676,8 @@ body.is-dialog-open { .empty-state { padding: 0.8rem 0.9rem; border-radius: 0.9rem; - border: 1px solid color-mix(in srgb, #f85149 30%, var(--border)); - background: color-mix(in srgb, #f85149 7%, var(--surface)); + border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); + background: color-mix(in srgb, var(--danger) 7%, var(--surface)); color: var(--muted); } @@ -1369,7 +1689,7 @@ body.is-dialog-open { .cards-grid { display: grid; grid-template-columns: 1fr; - gap: 0.55rem; + border-top: 1px solid var(--border); } .cards-grid.is-loading { @@ -1380,37 +1700,39 @@ body.is-dialog-open { .item-card { display: flex; flex-direction: column; - gap: 0.46rem; - padding: 0.72rem 0.78rem; - border-radius: 0.95rem; - border: 1px solid var(--border); - background: linear-gradient( - 180deg, - color-mix(in srgb, var(--surface-raised) 94%, transparent), - var(--surface) - ); - box-shadow: var(--shadow); + gap: 0.36rem; + padding: 0.84rem 0.35rem 0.9rem; + border-radius: 0; + border: 0; + border-bottom: 1px solid var(--border); + background: transparent; + box-shadow: none; cursor: pointer; transition: - border-color 140ms ease, - transform 140ms ease, + background 140ms ease, box-shadow 140ms ease; } .item-card:hover { - border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); + background: linear-gradient( + 90deg, + color-mix(in srgb, var(--accent) 7%, transparent), + transparent 64% + ); } .item-card:active { - transform: scale(0.992); + background: var(--accent-soft); } .item-card:focus-within { outline: none; - border-color: color-mix(in srgb, var(--accent) 44%, var(--border)); - box-shadow: - var(--shadow), - 0 0 0 2px var(--accent-soft); + background: linear-gradient( + 90deg, + color-mix(in srgb, var(--accent) 9%, transparent), + transparent 64% + ); + box-shadow: inset 2px 0 0 var(--accent); } .item-card.is-hidden { @@ -1418,10 +1740,12 @@ body.is-dialog-open { } .item-card.is-previewing { - border-color: color-mix(in srgb, var(--accent) 64%, var(--border)); - box-shadow: - var(--shadow), - 0 0 0 2px var(--accent-soft); + background: linear-gradient( + 90deg, + color-mix(in srgb, var(--accent) 10%, transparent), + transparent 64% + ); + box-shadow: inset 2px 0 0 var(--accent); } .item-card.is-previewing .item-title a, @@ -1437,16 +1761,24 @@ body.is-dialog-open { } .item-index { - display: inline; - margin-right: 0.3rem; - font-size: 0.8rem; - font-weight: 700; + display: block; + font-family: var(--font-mono); + font-size: 0.68rem; + font-weight: 500; + font-variant-numeric: tabular-nums; + letter-spacing: 0.06em; + color: var(--accent); } .item-title { + display: grid; + grid-template-columns: 2.35rem minmax(0, 1fr); + align-items: baseline; margin: 0; - font-size: 0.96rem; - line-height: 1.35; + font-family: var(--font-display); + font-size: clamp(1.02rem, 1.4vw, 1.24rem); + font-weight: 600; + line-height: 1.26; } .item-title a { @@ -1462,9 +1794,10 @@ body.is-dialog-open { .item-brief { margin: 0; + padding-left: 2.35rem; color: var(--muted); - font-size: 0.87rem; - line-height: 1.45; + font-size: 0.88rem; + line-height: 1.5; } .item-brief-text { @@ -1479,7 +1812,11 @@ body.is-dialog-open { display: flex; align-items: center; gap: 0.35rem; - font-size: 0.76rem; + padding-left: 2.35rem; + font-family: var(--font-mono); + font-size: 0.66rem; + letter-spacing: 0.04em; + text-transform: uppercase; word-break: break-word; } @@ -1663,32 +2000,50 @@ body.is-dialog-open { gap: 0.35rem; } -:root[data-ui-density='compact'] .cards-grid { - gap: 0.42rem; -} - :root[data-ui-density='compact'] .item-card { - gap: 0.34rem; - padding: 0.5rem 0.56rem; - border-radius: 0.82rem; + gap: 0.3rem; + padding: 0.64rem 0.25rem 0.7rem; + border-radius: 0; } :root[data-ui-density='compact'] .item-index { - font-size: 0.76rem; + font-size: 0.62rem; } :root[data-ui-density='compact'] .item-title { - font-size: 0.91rem; - line-height: 1.3; + grid-template-columns: 2rem minmax(0, 1fr); + font-size: 0.97rem; + line-height: 1.24; } :root[data-ui-density='compact'] .item-brief { + padding-left: 2rem; font-size: 0.82rem; - line-height: 1.38; + line-height: 1.42; } :root[data-ui-density='compact'] .item-host { - font-size: 0.72rem; + padding-left: 2rem; + font-size: 0.6rem; +} + +:root[data-ui-density='compact'] .theme-option-body { + gap: 0.5rem; + min-height: 3rem; + padding: 0.42rem 0.5rem; +} + +:root[data-ui-density='compact'] .theme-swatch { + width: 2.5rem; + height: 1.7rem; +} + +:root[data-ui-density='compact'] .theme-option-title { + font-size: 0.82rem; +} + +:root[data-ui-density='compact'] .theme-option-copy { + font-size: 0.58rem; } :root[data-ui-density='compact'] .config-dialog-form { @@ -1713,10 +2068,6 @@ body.is-dialog-open { gap: 0.5rem; } -:root[data-ui-density='compact'] .config-section-row { - gap: 0.65rem; -} - :root[data-ui-density='compact'] .config-section-header { gap: 0.2rem; } @@ -1783,7 +2134,9 @@ body.is-dialog-open { } .site-footer { - padding: 0.55rem 0 0; + margin-top: 0.55rem; + padding: 0.85rem 0 0.2rem; + border-top: 1px solid var(--border); } .site-footer p { @@ -1793,7 +2146,9 @@ body.is-dialog-open { justify-content: center; gap: 0.4rem; color: var(--muted); - font-size: 0.78rem; + font-family: var(--font-mono); + font-size: 0.66rem; + letter-spacing: 0.04em; line-height: 1.4; text-align: center; width: 100%; @@ -1826,9 +2181,9 @@ body.is-dialog-open { border-radius: 0.2rem; } -:root[data-theme='dark'] .footer-github-mark, -:root[data-theme='dark'] .source-icon-image--github { - filter: invert(1) brightness(1.18); +.footer-github-mark, +.source-icon-image--github { + filter: var(--github-filter, none); } .view-more { @@ -1840,7 +2195,11 @@ body.is-dialog-open { min-height: var(--control-height); padding: 0 1rem; border-radius: 999px; - font-size: 0.9rem; + border-color: var(--border); + font-family: var(--font-mono); + font-size: 0.7rem; + letter-spacing: 0.06em; + text-transform: uppercase; } .refresh-button.is-loading .theme-icon { @@ -1888,21 +2247,20 @@ body.is-dialog-open { } .preview-panel-header { - padding-top: max(0.85rem, env(safe-area-inset-top)); - padding-left: max(0.75rem, var(--safe-left)); - padding-right: max(0.6rem, var(--safe-right)); - } - - .preview-panel-scroll { - padding-left: max(0.85rem, var(--safe-left)); - padding-right: max(0.85rem, var(--safe-right)); - padding-bottom: max(0.9rem, env(safe-area-inset-bottom)); + padding: + max(var(--preview-panel-padding), env(safe-area-inset-top)) + max(var(--preview-panel-padding), var(--safe-right)) + var(--preview-panel-padding) + max(var(--preview-panel-padding), var(--safe-left)); } + .preview-panel-scroll, .preview-panel-footer { - padding-left: max(0.7rem, var(--safe-left)); - padding-right: max(0.7rem, var(--safe-right)); - padding-bottom: max(0.6rem, env(safe-area-inset-bottom)); + padding: + var(--preview-panel-padding) + max(var(--preview-panel-padding), var(--safe-right)) + max(var(--preview-panel-padding), env(safe-area-inset-bottom)) + max(var(--preview-panel-padding), var(--safe-left)); } } @@ -1949,14 +2307,23 @@ body.is-dialog-open { } @media (max-width: 560px) and (orientation: portrait) and (display-mode: standalone) { - .page-header, - .preview-panel-header { - padding-top: calc(max(0.85rem, env(safe-area-inset-top)) + 0.75rem); + :root { + /* Keeps the top row clear of the iOS status-bar blur. */ + --standalone-header-top: calc( + max(0.85rem, env(safe-area-inset-top)) + 0.75rem + ); } - /* Compact density sets its own page-header padding with higher specificity. */ + .page-header, :root[data-ui-density='compact'] .page-header { - padding-top: calc(max(0.85rem, env(safe-area-inset-top)) + 0.75rem); + padding-top: var(--standalone-header-top); + } + + /* The brand mark's taller line box sits a few pixels below the page-header + padding. Match that offset so the preview source icon clears the same + status-bar blur instead of sitting under it. */ + .preview-panel-header { + padding-top: calc(var(--standalone-header-top) + 0.25rem); } } @@ -2001,13 +2368,34 @@ body.is-dialog-open { } } +@media (max-width: 360px) { + .theme-option-body { + gap: 0.48rem; + min-height: 3rem; + padding: 0.4rem 0.48rem; + } + + .theme-swatch { + width: 2.5rem; + height: 1.7rem; + } + + .theme-option-title { + font-size: 0.8rem; + } + + .theme-option-copy { + font-size: 0.56rem; + } +} + @media (max-width: 560px) { :root { --control-height: 2rem; } .shell { - width: calc(100% - 0.8rem); + width: calc(100% - 1.5rem); } .controls-row { @@ -2060,10 +2448,33 @@ body.is-dialog-open { } .config-dialog { - width: min(100vw - 1rem, 100%); + width: min(100vw - 1.5rem, 100%); + max-width: calc(100vw - 1.5rem); } .cards-grid { grid-template-columns: 1fr; } + + .item-card { + padding: 0.8rem 0 0.85rem; + } + + .item-actions { + margin-right: 0; + } + + .item-title { + grid-template-columns: 1.85rem minmax(0, 1fr); + font-size: 1rem; + } + + .item-brief, + .item-host { + padding-left: 1.85rem; + } + + .brand { + font-size: 1.35rem; + } } diff --git a/web-static/static/theme-init.js b/web-static/static/theme-init.js new file mode 100644 index 0000000..ecd9e4f --- /dev/null +++ b/web-static/static/theme-init.js @@ -0,0 +1,25 @@ +// Applies the stored theme before first paint so the page never flashes the +// server-rendered default. Keep this file synchronous and dependency-free. +(() => { + const themes = ["dark", "light", "sepia", "terminal", "glacier", "ember"]; + try { + const stored = localStorage.getItem("feedreader.theme"); + const preference = stored === null ? "system" : stored; + const resolved = + preference === "system" + ? window.matchMedia("(prefers-color-scheme: light)").matches + ? "light" + : "dark" + : themes.includes(preference) + ? preference + : "dark"; + document.documentElement.dataset.theme = resolved; + + const density = localStorage.getItem("feedreader.uiDensity"); + if (density === "compact") { + document.documentElement.dataset.uiDensity = "compact"; + } + } catch { + // localStorage can be unavailable in private or restricted contexts. + } +})();