From 25418c5db2d5f6a7c7f422541c443909a8bf6b5a Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Tue, 14 Apr 2026 20:09:30 +0200 Subject: [PATCH] feat: add star nudge toast after every 5 rule copies Show a dismissible toast (bottom-right, 20s auto-hide) nudging users to star the GitHub repo. Fires every 5 copies via a sessionStorage counter. CopyButton dispatches a copy-success custom event; StarToast listens for it and manages display logic. --- site/src/components/CopyButton.astro | 2 + site/src/components/StarToast.astro | 66 ++++++++++++++++++++++++++++ site/src/layouts/BaseLayout.astro | 2 + 3 files changed, 70 insertions(+) create mode 100644 site/src/components/StarToast.astro diff --git a/site/src/components/CopyButton.astro b/site/src/components/CopyButton.astro index a9aa149..5a2e54e 100644 --- a/site/src/components/CopyButton.astro +++ b/site/src/components/CopyButton.astro @@ -86,5 +86,7 @@ const btnId = `copy-btn-${targetId}`; copyLabel?.classList.remove('hidden'); copiedLabel?.classList.add('hidden'); }, 2000); + + window.dispatchEvent(new CustomEvent('copy-success')); }); diff --git a/site/src/components/StarToast.astro b/site/src/components/StarToast.astro new file mode 100644 index 0000000..941a5c7 --- /dev/null +++ b/site/src/components/StarToast.astro @@ -0,0 +1,66 @@ +--- +import { GITHUB_URL } from '../data/site'; +--- + + + + + diff --git a/site/src/layouts/BaseLayout.astro b/site/src/layouts/BaseLayout.astro index 243d1d7..ee04246 100644 --- a/site/src/layouts/BaseLayout.astro +++ b/site/src/layouts/BaseLayout.astro @@ -2,6 +2,7 @@ import '../styles/global.css'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; +import StarToast from '../components/StarToast.astro'; import SEO from '../components/SEO.astro'; import { SITE_ORIGIN, AUTHOR_NAME } from '../data/site'; @@ -96,5 +97,6 @@ const canonical = canonicalUrl ?? `${SITE_ORIGIN}${base}${Astro.url.pathname.rep