mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
web: add a Ko-fi donation button
A small pill in the bottom right corner, in Ko-fi's own red rather than the theme colors so it reads as what it is. It sits above the feedback button where that one exists and takes its place where it does not; the offset follows the instance rather than the dialog, so opening feedback does not make it jump. Unlike the feedback button this is not limited to the maintainer's own instance - it ships in every build, the Docker image included. Since that means self-hosters carry someone else's donation link, there is a way out: VITE_DONATE_URL= (empty) drops the button, any other value retargets it, and the Dockerfile passes it through as --build-arg DONATE_URL. The "keep" sentinel there is not decoration - an unset and an empty build arg are indistinguishable inside RUN, so without it "not passed" would silently mean "remove". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
fa4daf7831
commit
6ebc3e22e0
5 files changed
+90
-1
No files matched your search
@@ -3739,6 +3739,47 @@
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Spenden-Pille. Bewusst nicht in den Theme-Farben: sie soll auffallen, ohne
|
||||
gross zu sein - Ko-fi-Rot, feste Hoehe, Text nur als Beiwerk zum Symbol. */
|
||||
.ts-donate-fab {
|
||||
position: fixed;
|
||||
right: 1.25rem;
|
||||
bottom: 5.5rem;
|
||||
z-index: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
height: 2.25rem;
|
||||
padding: 0 0.85rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
background: #ff5e5b;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
|
||||
transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
|
||||
}
|
||||
|
||||
/* Ueber dem Feedback-Button (3rem hoch, bottom: 5.5rem) statt darauf. */
|
||||
.ts-donate-fab-stacked {
|
||||
bottom: 9.25rem;
|
||||
}
|
||||
|
||||
.ts-donate-fab:hover {
|
||||
background: #ff4b47;
|
||||
transform: scale(1.06);
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.ts-donate-fab-icon {
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.ts-feedback-bubble {
|
||||
position: relative;
|
||||
max-width: 13rem;
|
||||
|
||||
@@ -96,6 +96,13 @@ const FEEDBACK_URL = import.meta.env.DEV
|
||||
? `${import.meta.env.VITE_GATEWAY_URL.replace(/\/$/, "").replace(/^ws(s?):\/\//, "http$1://")}/api/feedback`
|
||||
: `${window.location.protocol}//${window.location.host}/api/feedback`;
|
||||
|
||||
// Ko-fi page of the project (.github/FUNDING.yml). Unlike the feedback button
|
||||
// below this is not limited to the maintainer's own instance: it ships in
|
||||
// every build, the Docker image included. Self-hosters who would rather not
|
||||
// carry someone else's donation link can build with VITE_DONATE_URL= (empty)
|
||||
// to drop the button, or point it somewhere else.
|
||||
const DONATE_URL = import.meta.env.VITE_DONATE_URL ?? "https://ko-fi.com/moepchi";
|
||||
|
||||
// This file's frontend is deployed as multiple Cloudflare Pages projects
|
||||
// from the same repo/build (see mem:deployment) - only the maintainer's own
|
||||
// production instance talks to a gateway they actually operate and read
|
||||
@@ -2111,6 +2118,27 @@ function FeedbackFab({ onOpen }: { onOpen: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Small donation pill, pinned above the feedback button (or in its place where
|
||||
* that one is not shown - see `stacked`).
|
||||
*/
|
||||
function DonateFab({ stacked }: { stacked: boolean }) {
|
||||
const t = useT();
|
||||
if (!DONATE_URL) return null;
|
||||
return (
|
||||
<a
|
||||
className={`ts-donate-fab${stacked ? " ts-donate-fab-stacked" : ""}`}
|
||||
href={DONATE_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={t("donate.title")}
|
||||
>
|
||||
<span className="ts-donate-fab-icon" aria-hidden="true">☕</span>
|
||||
{t("donate.label")}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
type FeedbackCategory = "bug" | "idea" | "other";
|
||||
|
||||
function FeedbackDialog({ onClose }: { onClose: () => void }) {
|
||||
@@ -9328,6 +9356,11 @@ function AppInner() {
|
||||
<FeedbackFab onOpen={() => setFeedbackOpen(true)} />
|
||||
)}
|
||||
|
||||
{/* Sits above the feedback button where that exists, and takes its spot
|
||||
where it does not - the offset follows the instance, not the dialog,
|
||||
so opening feedback does not make the pill jump. */}
|
||||
<DonateFab stacked={IS_OWN_HOSTED_INSTANCE} />
|
||||
|
||||
{feedbackOpen && <FeedbackDialog onClose={() => setFeedbackOpen(false)} />}
|
||||
|
||||
{favoritesDialogMode && (
|
||||
|
||||
@@ -48,6 +48,9 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"menu.extras.feedback": "Feedback geben",
|
||||
"feedback.fab.nudge": "Was denkst du über WebSpeak3? Feedback ist willkommen!",
|
||||
|
||||
"donate.label": "Spenden",
|
||||
"donate.title": "WebSpeak3 auf Ko-fi unterstützen",
|
||||
|
||||
"pwa.updateAvailable": "Neue Version verfügbar",
|
||||
"pwa.reload": "Neu laden",
|
||||
|
||||
@@ -686,6 +689,9 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"menu.extras.feedback": "Send Feedback",
|
||||
"feedback.fab.nudge": "What do you think of WebSpeak3? Feedback welcome!",
|
||||
|
||||
"donate.label": "Donate",
|
||||
"donate.title": "Support WebSpeak3 on Ko-fi",
|
||||
|
||||
"pwa.updateAvailable": "New version available",
|
||||
"pwa.reload": "Reload",
|
||||
|
||||
|
||||
Reference in new issue
Block a user