diff --git a/.github/README.md b/.github/README.md
index 5b754f4a..a10fe88c 100644
--- a/.github/README.md
+++ b/.github/README.md
@@ -1,13 +1,23 @@
-
-
+
+
+
+
+
+Screenshots
+
+
+
+
-
-
+
+
+
+
# Photon
Photon is a web app for the fediverse with helpful features and a nice UX.
diff --git a/.github/capture_screenshots.py b/.github/capture_screenshots.py
new file mode 100644
index 00000000..818099a0
--- /dev/null
+++ b/.github/capture_screenshots.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+
+import pathlib
+from playwright.sync_api import TimeoutError as PlaywrightTimeoutError, sync_playwright
+
+SITE = "https://phtn.app"
+OUT_DIR = pathlib.Path(__file__).parent / "screenshots"
+
+MOBILE_USER_AGENT = (
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) "
+ "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1"
+)
+
+SCREENSHOTS = [
+ {"out": "compact-light.png", "path": "/", "width": 1280, "height": 800, "scheme": "light", "view": "compact", "wait": "article"},
+ {"out": "compact-dark.png", "path": "/", "width": 1280, "height": 800, "scheme": "dark", "view": "compact", "wait": "article"},
+ {"out": "cozy-light.png", "path": "/", "width": 1280, "height": 800, "scheme": "light", "view": "cozy", "wait": "article"},
+ {"out": "cozy-dark.png", "path": "/", "width": 1280, "height": 800, "scheme": "dark", "view": "cozy", "wait": "article"},
+ {"out": "mobile-light.png", "path": "/explore/communities", "width": 390, "height": 844, "scheme": "light", "mobile": True, "wait": "a[href^='/c/']"},
+ {"out": "mobile-dark.png", "path": "/explore/communities", "width": 390, "height": 844, "scheme": "dark", "mobile": True, "wait": "a[href^='/c/']"},
+]
+
+
+def capture(browser, shot):
+ mobile = shot.get("mobile", False)
+ context = browser.new_context(
+ viewport={"width": shot["width"], "height": shot["height"]},
+ device_scale_factor=2,
+ is_mobile=mobile,
+ has_touch=mobile,
+ user_agent=MOBILE_USER_AGENT if mobile else None,
+ )
+
+ # seed photon's color scheme and feed layout before the app boots
+ context.add_init_script(
+ f"localStorage.setItem('colorScheme', {shot['scheme']!r});"
+ f"localStorage.setItem('settings', JSON.stringify({{ view: {shot.get('view', 'compact')!r} }}));"
+ )
+
+ page = context.new_page()
+ page.goto(f"{SITE}{shot['path']}", wait_until="domcontentloaded")
+
+ try:
+ page.wait_for_selector(shot["wait"], timeout=30000)
+ page.wait_for_load_state("networkidle", timeout=15000)
+ page.evaluate("document.fonts.ready")
+ except PlaywrightTimeoutError:
+ pass
+
+ page.wait_for_timeout(1500)
+ page.screenshot(path=str(OUT_DIR / shot["out"]))
+ print(f"Wrote {shot['out']}")
+ context.close()
+
+
+def main():
+ OUT_DIR.mkdir(parents=True, exist_ok=True)
+
+ with sync_playwright() as p:
+ # full chromium for correct kerning
+ browser = p.chromium.launch(channel="chromium")
+
+ try:
+ for shot in SCREENSHOTS:
+ capture(browser, shot)
+ finally:
+ browser.close()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.github/screenshots/compact-dark.png b/.github/screenshots/compact-dark.png
new file mode 100644
index 00000000..e08bd961
Binary files /dev/null and b/.github/screenshots/compact-dark.png differ
diff --git a/.github/screenshots/compact-light.png b/.github/screenshots/compact-light.png
new file mode 100644
index 00000000..b3ff41fa
Binary files /dev/null and b/.github/screenshots/compact-light.png differ
diff --git a/.github/screenshots/cozy-dark.png b/.github/screenshots/cozy-dark.png
new file mode 100644
index 00000000..98e961bc
Binary files /dev/null and b/.github/screenshots/cozy-dark.png differ
diff --git a/.github/screenshots/cozy-light.png b/.github/screenshots/cozy-light.png
new file mode 100644
index 00000000..4f1d072c
Binary files /dev/null and b/.github/screenshots/cozy-light.png differ
diff --git a/.github/screenshots/mobile-dark.png b/.github/screenshots/mobile-dark.png
new file mode 100644
index 00000000..08a92140
Binary files /dev/null and b/.github/screenshots/mobile-dark.png differ
diff --git a/.github/screenshots/mobile-light.png b/.github/screenshots/mobile-light.png
new file mode 100644
index 00000000..e05bca0e
Binary files /dev/null and b/.github/screenshots/mobile-light.png differ
diff --git a/.github/workflows/screenshot.yml b/.github/workflows/screenshot.yml
new file mode 100644
index 00000000..3926925c
--- /dev/null
+++ b/.github/workflows/screenshot.yml
@@ -0,0 +1,31 @@
+name: Update README screenshots
+
+on:
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+jobs:
+ screenshots:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+
+ - uses: actions/setup-python@v6
+ with:
+ python-version: "3.14"
+
+ - name: Install Playwright and Chromium
+ run: |
+ pip install playwright
+ python -m playwright install --with-deps chromium
+
+ - name: Capture screenshots
+ run: python .github/capture_screenshots.py
+
+ - name: Commit and push
+ uses: stefanzweifel/git-auto-commit-action@v7
+ with:
+ commit_message: Update README screenshots
+ file_pattern: .github/screenshots/*.png
diff --git a/.gitignore b/.gitignore
index 223fd889..995e7e76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,6 @@ playwright-report
test-results
.vscode
*TS.md
+
+# Used for automated screenshot workflow
+.github/__pycache__/
\ No newline at end of file