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
@@ -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 && (
|
||||
|
||||
Reference in new issue
Block a user