Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

fix: mobile burger menu, lazy load videos on marketing page, minor css fixes (#207)

Vlad Sazonau10b3fb299156
diff --git a/.github/demos/qr-code-and-multi-page-pdf.gif b/.github/demos/qr-code-and-multi-page-pdf.gif
new file mode 100644
index 0000000..866ef2f
Binary files /dev/null and b/.github/demos/qr-code-and-multi-page-pdf.gif differ
diff --git a/.github/demos/tax-custom.gif b/.github/demos/tax-custom.gif
new file mode 100644
index 0000000..8f5a592
Binary files /dev/null and b/.github/demos/tax-custom.gif differ
diff --git a/.npmrc b/.npmrc
index 6a510ed..f942dbf 100644
--- a/.npmrc
+++ b/.npmrc
@@ -2,4 +2,9 @@ save-exact=true
# this specifies the number of minutes that must pass after a version is published before pnpm will install it (to prevent supply chain attacks)
# https://pnpm.io/settings#minimumreleaseage
-minimum-release-age=4320 # 3 days,
\ No newline at end of file
+
+minimum-release-age=4320 # 3 days,
+
+# https://pnpm.io/supply-chain-security
+block-exotic-subdeps=true
+trust-policy=no-downgrade
\ No newline at end of file
diff --git a/e2e/about.test.ts b/e2e/about.test.ts
index 81c507f..69cd64f 100644
--- a/e2e/about.test.ts
+++ b/e2e/about.test.ts
@@ -1,13 +1,13 @@
-import {
- GITHUB_URL,
- TWITTER_URL,
- VIDEO_DEMO_FALLBACK_IMG,
- VIDEO_DEMO_URL,
-} from "@/config";
+/* eslint-disable playwright/no-conditional-expect */
+/* eslint-disable playwright/no-conditional-in-test */
+import { GITHUB_URL, TWITTER_URL, VIDEO_DEMO_FALLBACK_IMG } from "@/config";
import { expect, test } from "@playwright/test";
test.describe("About page", () => {
- test("should display about page content in English", async ({ page }) => {
+ test("should display about page content in English", async ({
+ page,
+ isMobile,
+ }) => {
await page.goto("/en/about");
// Verify the page is loaded
@@ -21,11 +21,59 @@ test.describe("About page", () => {
/* CHECK HEADER ELEMENTS */
- // Check language switcher button in header
- const languageSwitcher = header.getByRole("button", {
- name: "Switch language",
- });
- await expect(languageSwitcher).toBeVisible();
+ if (isMobile) {
+ // Mobile: burger button visible, nav links and language switcher hidden in header
+ await expect(
+ header.getByRole("button", { name: "Open menu" }),
+ ).toBeVisible();
+
+ await expect(
+ header.getByRole("button", { name: "Switch language" }),
+ ).toBeHidden();
+
+ await expect(
+ header.getByRole("link", { name: "Features", exact: true }),
+ ).toBeHidden();
+ } else {
+ // Desktop: nav links and language switcher visible inline, burger button hidden
+ await expect(
+ header.getByRole("button", { name: "Switch language" }),
+ ).toBeVisible();
+
+ const featuresLink = header.getByRole("link", {
+ name: "Features",
+ exact: true,
+ });
+
+ await expect(featuresLink).toBeVisible();
+ await expect(featuresLink).toHaveAttribute("href", "#features");
+
+ const faqLink = header.getByRole("link", { name: "FAQ", exact: true });
+
+ await expect(faqLink).toBeVisible();
+ await expect(faqLink).toHaveAttribute("href", "#faq");
+
+ const changelogLink = header.getByRole("link", {
+ name: "Changelog",
+ exact: true,
+ });
+
+ await expect(changelogLink).toBeVisible();
+ await expect(changelogLink).toHaveAttribute("href", "/changelog");
+
+ const githubLink = header.getByRole("link", {
+ name: "View on GitHub",
+ exact: true,
+ });
+
+ await expect(githubLink).toBeVisible();
+ await expect(githubLink).toHaveAttribute("href", GITHUB_URL);
+
+ // hidden on desktop
+ await expect(
+ header.getByRole("button", { name: "Open menu" }),
+ ).toBeHidden();
+ }
// check app link button in header
await expect(
@@ -64,15 +112,7 @@ test.describe("About page", () => {
await expect(video).toHaveAttribute("muted");
await expect(video).toHaveAttribute("loop");
await expect(video).toHaveAttribute("playsinline");
- await expect(video).toHaveAttribute("preload", "auto");
- await expect(video).toHaveAttribute("autoplay");
-
- const videoSource = video.locator("source");
- await expect(videoSource).toHaveAttribute(
- "src",
- `${VIDEO_DEMO_URL}#t=0.001`,
- );
- await expect(videoSource).toHaveAttribute("type", "video/mp4");
+ await expect(video).toHaveAttribute("preload", "none");
// Check Features section
const featuresSection = page.locator("#features");
@@ -335,25 +375,30 @@ test.describe("About page", () => {
).toBeVisible();
});
- test("should handle language switching", async ({ page }) => {
+ test("should handle language switching", async ({ page, isMobile }) => {
// Start with English
await page.goto("/en/about");
await expect(page).toHaveURL("/en/about");
- // Switch to French
+ // On mobile, open the mobile menu first
+ if (isMobile) await page.getByRole("button", { name: "Open menu" }).click();
+
+ // Then switch to French
await page
.getByRole("button", { name: "Switch language", exact: true })
.click();
await page.getByText("Français").click();
+ await expect(page).toHaveURL("/fr/about");
+
const header = page.getByRole("banner");
+
await expect(
header.getByRole("link", {
name: "Ouvrir",
exact: true,
}),
).toBeVisible();
- await expect(page).toHaveURL("/fr/about");
});
test("should navigate to app when clicking Go to App button", async ({
@@ -373,4 +418,105 @@ test.describe("About page", () => {
await headerGoToAppButton.click();
await expect(page).toHaveURL("/?template=default");
});
+
+ test("should show desktop nav links in header (ON MOBILE TEST WILL BE SKIPPED)", async ({
+ page,
+ isMobile,
+ }) => {
+ // skip test on mobile
+ // eslint-disable-next-line playwright/no-skipped-test
+ test.skip(isMobile, "Desktop nav only exists on desktop viewport");
+
+ await page.goto("/en/about");
+
+ const header = page.getByRole("banner");
+
+ await expect(
+ header.getByRole("link", { name: "Features", exact: true }),
+ ).toBeVisible();
+
+ await expect(
+ header.getByRole("link", { name: "FAQ", exact: true }),
+ ).toBeVisible();
+
+ await expect(
+ header.getByRole("link", { name: "Changelog", exact: true }),
+ ).toBeVisible();
+
+ await expect(
+ header.getByRole("link", { name: "View on GitHub", exact: true }),
+ ).toBeVisible();
+
+ await expect(
+ header.getByRole("button", { name: "Switch language" }),
+ ).toBeVisible();
+
+ // hidden on desktop
+ await expect(
+ header.getByRole("button", { name: "Open menu" }),
+ ).toBeHidden();
+ });
+
+ test("should show mobile menu with nav links and language switcher (ON DESKTOP TEST WILL BE SKIPPED)", async ({
+ page,
+ isMobile,
+ }) => {
+ // skip test on desktop
+ // eslint-disable-next-line playwright/no-skipped-test
+ test.skip(!isMobile, "Mobile menu only exists on mobile viewport");
+
+ await page.goto("/en/about");
+
+ const header = page.getByRole("banner");
+ const burgerButton = header.getByRole("button", { name: "Open menu" });
+
+ // Burger button visible on MOBILE, nav links and language switcher not visible in header
+ await expect(burgerButton).toBeVisible();
+
+ await expect(
+ header.getByRole("link", { name: "Features", exact: true }),
+ ).toBeHidden();
+
+ await expect(
+ header.getByRole("button", { name: "Switch language" }),
+ ).toBeHidden();
+
+ // Open the mobile menu
+ await burgerButton.click();
+
+ const sheet = page.getByRole("dialog", { name: "Mobile Menu" });
+
+ const featuresLink = sheet.getByRole("link", {
+ name: "Features",
+ exact: true,
+ });
+ await expect(featuresLink).toBeVisible();
+ await expect(featuresLink).toHaveAttribute("href", "#features");
+
+ const faqLink = sheet.getByRole("link", { name: "FAQ", exact: true });
+ await expect(faqLink).toBeVisible();
+ await expect(faqLink).toHaveAttribute("href", "#faq");
+
+ const changelogLink = sheet.getByRole("link", {
+ name: "Changelog",
+ exact: true,
+ });
+ await expect(changelogLink).toBeVisible();
+ await expect(changelogLink).toHaveAttribute("href", "/changelog");
+
+ const githubLink = sheet.getByRole("link", {
+ name: "View on GitHub",
+ exact: true,
+ });
+ await expect(githubLink).toBeVisible();
+ await expect(githubLink).toHaveAttribute("href", GITHUB_URL);
+
+ await expect(
+ sheet.getByRole("button", { name: "Switch language" }),
+ ).toBeVisible();
+
+ // Close the menu and verify burger button is accessible again
+ await sheet.getByRole("button", { name: "Close menu" }).click();
+ await expect(burgerButton).toBeVisible();
+ });
});
diff --git a/knip.ts b/knip.ts
index 09b42db..f026c7f 100644
--- a/knip.ts
+++ b/knip.ts
@@ -6,7 +6,6 @@ const config: KnipConfig = {
"shadcn",
"@radix-ui/react-separator",
"@types/ua-parser-js",
- "cmdk",
"eslint-plugin-react-hooks",
"file-saver",
"jszip",
diff --git a/messages/de.json b/messages/de.json
index 4962a02..778f468 100644
--- a/messages/de.json
+++ b/messages/de.json
@@ -60,7 +60,7 @@
"links": {
"features": "Funktionen",
"github": "GitHub",
- "changelog": "Änderungsprotokoll"
+ "changelog": "Änderungen"
},
"createdBy": "Erstellt von"
},
diff --git a/messages/es.json b/messages/es.json
index 3388816..1515f3a 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -60,7 +60,7 @@
"links": {
"features": "Características",
"github": "GitHub",
- "changelog": "Registro de cambios"
+ "changelog": "Novedades"
},
"createdBy": "Creado por"
},
diff --git a/messages/fr.json b/messages/fr.json
index 0235d5b..ddc58da 100644
--- a/messages/fr.json
+++ b/messages/fr.json
@@ -52,7 +52,7 @@
"links": {
"features": "Fonctionnalités",
"github": "GitHub",
- "changelog": "Journal des modifications"
+ "changelog": "Nouveautés"
},
"createdBy": "Créé par"
},
diff --git a/messages/it.json b/messages/it.json
index ffea876..9cefc6a 100644
--- a/messages/it.json
+++ b/messages/it.json
@@ -52,7 +52,7 @@
"links": {
"features": "Funzionalità",
"github": "GitHub",
- "changelog": "Registro delle modifiche"
+ "changelog": "Novità"
},
"createdBy": "Creato da"
},
diff --git a/messages/nl.json b/messages/nl.json
index bed90d9..6f9b606 100644
--- a/messages/nl.json
+++ b/messages/nl.json
@@ -52,7 +52,7 @@
"links": {
"features": "Functies",
"github": "GitHub",
- "changelog": "Wijzigingslogboek"
+ "changelog": "Nieuw"
},
"createdBy": "Gemaakt door"
},
diff --git a/messages/pt.json b/messages/pt.json
index 1545549..7d52e51 100644
--- a/messages/pt.json
+++ b/messages/pt.json
@@ -60,7 +60,7 @@
"links": {
"features": "Recursos",
"github": "GitHub",
- "changelog": "Registro de alterações"
+ "changelog": "Novidades"
},
"createdBy": "Criado por"
},
diff --git a/messages/ru.json b/messages/ru.json
index f3eca90..559da39 100644
--- a/messages/ru.json
+++ b/messages/ru.json
@@ -60,7 +60,7 @@
"links": {
"features": "Возможности",
"github": "GitHub",
- "changelog": "Журнал изменений"
+ "changelog": "Что нового"
},
"createdBy": "Создано"
},
diff --git a/messages/uk.json b/messages/uk.json
index c5f148e..1f474b5 100644
--- a/messages/uk.json
+++ b/messages/uk.json
@@ -60,7 +60,7 @@
"links": {
"features": "Можливості",
"github": "GitHub",
- "changelog": "Журнал змін"
+ "changelog": "Що нового"
},
"createdBy": "Створено"
},
diff --git a/package.json b/package.json
index 18563bc..aa6bcfa 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,8 @@
"private": true,
"packageManager": "[email protected]+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
"pnpm": {
- "minimumReleaseAge": 4320
+ "minimumReleaseAge": 4320,
+ "trustPolicy": "no-downgrade"
},
"scripts": {
"dev": "next dev",
diff --git a/src/app/[locale]/about/components/github-star-cta-header.tsx b/src/app/[locale]/about/components/github-star-cta-header.tsx
deleted file mode 100644
index 3cbfc96..0000000
--- a/src/app/[locale]/about/components/github-star-cta-header.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { fetchGithubStars } from "@/actions/fetch-github-stars";
-import { GitHubStarCTA } from "@/components/github-star-cta";
-
-export async function GithubStarCtaMarketingPageHeader() {
- const githubStarsCount = await fetchGithubStars();
-
- return (
- <div className="overflow-hidden duration-500 animate-in fade-in slide-in-from-top-4">
- <GitHubStarCTA githubStarsCount={githubStarsCount} />
- </div>
- );
-}
diff --git a/src/app/[locale]/about/components/header.tsx b/src/app/[locale]/about/components/header.tsx
new file mode 100644
index 0000000..eb88371
--- /dev/null
+++ b/src/app/[locale]/about/components/header.tsx
@@ -0,0 +1,123 @@
+"use client";
+
+import { BlackAnimatedGoToAppBtn } from "@/components/animated-go-to-app-btn";
+import { GithubIcon } from "@/components/etc/github-logo";
+import { GITHUB_URL } from "@/config";
+import { cn } from "@/lib/utils";
+import { type Locale } from "next-intl";
+import Link from "next/link";
+import { useState } from "react";
+import { LanguageSwitcher } from "./language-switcher";
+import { Logo } from "./logo";
+import { MobileMenu } from "./mobile-menu";
+
+export interface HeaderProps {
+ locale: Locale;
+ translations: {
+ navLinks: {
+ features: string;
+ faq: string;
+ github: string;
+ githubUrl: string;
+ };
+ switchLanguageText: string;
+ goToAppText: string;
+ startInvoicingButtonText: string;
+ changelogLinkText: string;
+ };
+}
+export function Header({ locale, translations }: HeaderProps) {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <header className="sticky top-0 z-50 w-full border-b bg-white shadow-sm">
+ <div className="flex items-center justify-center">
+ <div className="container h-16 px-4 md:px-6">
+ <div className="flex h-full items-center justify-between gap-4">
+ {/* Logo - hidden from header when sheet is open */}
+ <div
+ className={cn(open && "pointer-events-none invisible")}
+ aria-hidden={open ? true : undefined}
+ tabIndex={open ? -1 : undefined}
+ >
+ <Logo />
+ </div>
+
+ {/* Right side actions */}
+ <div className="flex items-center gap-1">
+ {/* Desktop nav */}
+ <nav className="hidden items-center justify-end gap-1 lg:flex">
+ <a
+ href="#features"
+ className="rounded-md px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.navLinks.features}
+ </a>
+ <a
+ href="#faq"
+ className="rounded-md px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.navLinks.faq}
+ </a>
+
+ <Link
+ href="/changelog"
+ className="rounded-md px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.changelogLinkText}
+ </Link>
+ <Link
+ href={GITHUB_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ aria-label="View on GitHub"
+ >
+ <GithubIcon className="size-4" />
+ {translations.navLinks.github}
+ </Link>
+ </nav>
+
+ {/* Language switcher -- desktop only */}
+ <div className="hidden lg:block">
+ <LanguageSwitcher
+ locale={locale}
+ buttonText={translations.switchLanguageText}
+ />
+ </div>
+
+ {/* CTA button - hidden from header on mobile when sheet is open */}
+ <div
+ className={cn(
+ open &&
+ "pointer-events-none invisible lg:pointer-events-auto lg:visible",
+ )}
+ aria-hidden={open ? true : undefined}
+ >
+ <BlackAnimatedGoToAppBtn>
+ {translations.goToAppText}
+ </BlackAnimatedGoToAppBtn>
+ </div>
+
+ {/* Burger menu -- mobile only; hidden when sheet is open (X is inside sheet) */}
+ <div
+ className={cn(
+ "relative lg:hidden",
+ open && "pointer-events-none invisible",
+ )}
+ aria-hidden={open ? true : undefined}
+ >
+ <MobileMenu
+ open={open}
+ onOpenChange={setOpen}
+ locale={locale}
+ translations={translations}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </header>
+ );
+}
diff --git a/src/app/[locale]/about/components/language-switcher.tsx b/src/app/[locale]/about/components/language-switcher.tsx
index a25cd69..692bb36 100644
--- a/src/app/[locale]/about/components/language-switcher.tsx
+++ b/src/app/[locale]/about/components/language-switcher.tsx
@@ -38,11 +38,13 @@ type LanguageLabel = (typeof MAP_LOCALE_TO_LANGUAGE)[SupportedLocale];
interface LanguageSwitcherProps {
locale: SupportedLocale;
buttonText: string;
+ onSelect?: () => void;
}
export function LanguageSwitcher({
locale,
buttonText,
+ onSelect,
}: LanguageSwitcherProps) {
const [isPending, startTransition] = useTransition();
const router = useRouter();
@@ -82,6 +84,7 @@ export function LanguageSwitcher({
<DropdownMenuItem
key={itemLocale}
onClick={() => {
+ onSelect?.();
startTransition(() => {
const pathnameWithoutLocale = pathname.replace(
`/${locale}`,
diff --git a/src/app/[locale]/about/components/logo.tsx b/src/app/[locale]/about/components/logo.tsx
new file mode 100644
index 0000000..03a9672
--- /dev/null
+++ b/src/app/[locale]/about/components/logo.tsx
@@ -0,0 +1,35 @@
+"use client";
+
+import { FinalProjectLogo } from "@/components/etc/final-project-logo";
+import { ProjectLogoDescription } from "@/components/project-logo-description";
+import { useTranslations } from "next-intl";
+
+export function Logo() {
+ const t = useTranslations("About");
+
+ return (
+ <div>
+ <div className="flex items-center gap-1.5 md:gap-2">
+ <FinalProjectLogo className="size-6 md:size-7" />
+
+ {/* show app logo and description on desktop */}
+ <div className="hidden sm:block">
+ <ProjectLogoDescription>{t("tagline")}</ProjectLogoDescription>
+ </div>
+
+ {/* show only app name on mobile (to save space) */}
+ <div className="block sm:hidden">
+ <p className="text-balance text-center text-xl font-bold text-zinc-800 sm:mt-0 sm:text-2xl lg:mr-5 lg:text-left">
+ <a
+ href="https://easyinvoicepdf.com"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ EasyInvoicePDF
+ </a>
+ </p>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/app/[locale]/about/components/mobile-menu.tsx b/src/app/[locale]/about/components/mobile-menu.tsx
new file mode 100644
index 0000000..18bfd0c
--- /dev/null
+++ b/src/app/[locale]/about/components/mobile-menu.tsx
@@ -0,0 +1,156 @@
+"use client";
+
+import { GithubIcon } from "@/components/etc/github-logo";
+import { BlackAnimatedGoToAppBtn } from "@/components/animated-go-to-app-btn";
+import { Button } from "@/components/ui/button";
+import {
+ Sheet,
+ SheetClose,
+ SheetContent,
+ SheetTitle,
+ SheetTrigger,
+} from "@/components/ui/sheet";
+import type { Locale } from "next-intl";
+import Link from "next/link";
+import { ArrowRightIcon, Menu, X } from "lucide-react";
+import { LanguageSwitcher } from "./language-switcher";
+import { Logo } from "./logo";
+import type { HeaderProps } from "@/app/[locale]/about/components/header";
+
+interface MobileMenuProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ locale: Locale;
+ translations: HeaderProps["translations"];
+}
+
+export function MobileMenu({
+ open,
+ onOpenChange,
+ locale,
+ translations,
+}: MobileMenuProps) {
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetTrigger asChild>
+ <Button
+ size="icon"
+ variant="ghost"
+ className="rounded-full shadow-none"
+ aria-label="Open menu"
+ >
+ <Menu size={20} />
+ </Button>
+ </SheetTrigger>
+
+ <SheetContent
+ side="top"
+ animation="fade"
+ className="bottom-0 top-0 flex flex-col border-b-0 bg-white px-0 py-0"
+ showCloseButton={false}
+ >
+ <SheetTitle className="sr-only">Mobile Menu</SheetTitle>
+
+ {/* Faux header row mirroring the page header */}
+ <header className="w-full border-b bg-white shadow-sm">
+ <div className="flex items-center justify-center">
+ <div className="container h-16 px-4 md:px-6">
+ <div className="flex h-full items-center justify-between gap-4">
+ <Logo />
+ <div className="flex items-center gap-1">
+ <BlackAnimatedGoToAppBtn>
+ {translations.goToAppText}
+ </BlackAnimatedGoToAppBtn>
+ <SheetClose asChild>
+ <Button
+ size="icon"
+ variant="ghost"
+ className="rounded-full shadow-none"
+ aria-label="Close menu"
+ >
+ <X size={20} />
+ </Button>
+ </SheetClose>
+ </div>
+ </div>
+ </div>
+ </div>
+ </header>
+
+ <nav className="container flex flex-col gap-1 px-6 py-4 md:px-10">
+ <SheetClose asChild>
+ <a
+ href="#features"
+ className="flex items-center rounded-lg px-4 py-4 text-lg font-medium text-slate-700 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.navLinks.features}
+ </a>
+ </SheetClose>
+ <SheetClose asChild>
+ <a
+ href="#faq"
+ className="flex items-center rounded-lg px-4 py-4 text-lg font-medium text-slate-700 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.navLinks.faq}
+ </a>
+ </SheetClose>
+ <SheetClose asChild>
+ <Link
+ href="/changelog"
+ className="flex items-center rounded-lg px-4 py-4 text-lg font-medium text-slate-700 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ >
+ {translations.changelogLinkText}
+ </Link>
+ </SheetClose>
+ <SheetClose asChild>
+ <Link
+ href={translations.navLinks.githubUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center gap-3 rounded-lg px-4 py-4 text-lg font-medium text-slate-700 transition-colors hover:bg-slate-100 hover:text-slate-900"
+ aria-label="View on GitHub"
+ >
+ <GithubIcon className="size-5" />
+ {translations.navLinks.github}
+ </Link>
+ </SheetClose>
+
+ {/* Start Invoicing CTA Button */}
+ <div className="w-fit pt-2" onClick={() => onOpenChange(false)}>
+ <Button
+ size="lg"
+ variant="outline"
+ className={
+ "group relative overflow-hidden bg-zinc-900 px-5 py-6 text-lg text-white transition-all duration-300 hover:scale-[1.02] hover:bg-zinc-800 hover:text-white active:scale-[0.98] sm:px-8"
+ }
+ asChild
+ >
+ <Link
+ href="/?template=default"
+ scroll={false}
+ className="flex items-center"
+ >
+ <ArrowRightIcon className="mr-2 size-6 group-hover:scale-110" />
+
+ {translations.startInvoicingButtonText}
+ </Link>
+ </Button>
+ </div>
+ </nav>
+
+ <div className="mt-auto border-t border-slate-200 px-6 pb-6 pt-5">
+ <div className="flex items-center gap-2 px-2">
+ <span className="text-sm text-slate-700">
+ {translations.switchLanguageText}
+ </span>
+ <LanguageSwitcher
+ locale={locale}
+ buttonText={translations.switchLanguageText}
+ onSelect={() => onOpenChange(false)}
+ />
+ </div>
+ </div>
+ </SheetContent>
+ </Sheet>
+ );
+}
diff --git a/src/app/[locale]/about/page.tsx b/src/app/[locale]/about/page.tsx
index 3334868..429fb55 100644
--- a/src/app/[locale]/about/page.tsx
+++ b/src/app/[locale]/about/page.tsx
@@ -1,5 +1,5 @@
-import { GithubIcon } from "@/components/etc/github-logo";
// import { ProjectLogo } from "@/components/etc/project-logo";
+import { GithubIcon } from "@/components/etc/github-logo";
import { Footer } from "@/components/footer";
import {
BlackGoToAppButton,
@@ -7,9 +7,8 @@ import {
} from "@/components/go-to-app-button-cta";
import { Button } from "@/components/ui/button";
-import { BlackAnimatedGoToAppBtn } from "@/components/animated-go-to-app-btn";
import { TooltipProvider } from "@/components/ui/tooltip";
-import { Video } from "@/components/video";
+import { AutoPlayVideo, ManualPlayVideo } from "@/components/video";
import {
GITHUB_URL,
MARKETING_FEATURES_CARDS,
@@ -23,12 +22,8 @@ import { useTranslations, type Locale } from "next-intl";
import { setRequestLocale } from "next-intl/server";
import Link from "next/link";
import { type Graph } from "schema-dts";
-import { LanguageSwitcher } from "./components/language-switcher";
import { GithubStarCtaMarketingPageBody } from "@/app/[locale]/about/components/github-star-cta-body";
-import { GithubStarCtaMarketingPageHeader } from "@/app/[locale]/about/components/github-star-cta-header";
-import { FinalProjectLogo } from "@/components/etc/final-project-logo";
-import { ProjectLogoDescription } from "@/components/project-logo-description";
-// import { ProjectLogoDescription } from "@/components/project-logo-description";
+import { Header } from "./components/header";
// statically generate the pages for all locales
export function generateStaticParams() {
@@ -52,6 +47,20 @@ export default function AboutPage({ params }: { params: { locale: Locale } }) {
const newsletterErrorMessage = tNewsletter("error");
const newsletterEmailLanguageInfo = tNewsletter("emailLanguageInfo");
+ const navLinks = {
+ features: t("footer.links.features"),
+ faq: "FAQ",
+ github: t("footer.links.github"),
+ githubUrl: GITHUB_URL,
+ };
+
+ const switchLanguageText = t("buttons.switchLanguage");
+ const goToAppText = t("buttons.goToApp");
+
+ const startInvoicingButtonText = t("buttons.startInvoicing");
+
+ const changelogLinkText = t("footer.links.changelog");
+
return (
<TooltipProvider>
<script
@@ -62,7 +71,17 @@ export default function AboutPage({ params }: { params: { locale: Locale } }) {
}}
/>
<div className="flex min-h-screen flex-col bg-slate-50">
- <Header locale={locale} />
+ <Header
+ locale={locale}
+ // we need to pass the translations to the header to avoid stale translations issue during language switching
+ translations={{
+ navLinks,
+ switchLanguageText,
+ goToAppText,
+ startInvoicingButtonText,
+ changelogLinkText,
+ }}
+ />
<main>
<HeroSection />
<FeaturesSection />
@@ -148,36 +167,6 @@ export default function AboutPage({ params }: { params: { locale: Locale } }) {
);
}
-function Header({ locale }: { locale: Locale }) {
- const t = useTranslations("About.buttons");
-
- return (
- <header className="sticky top-0 z-50 w-full border-b bg-white shadow-sm">
- <div className="flex items-center justify-center">
- <div className="container h-auto px-4 py-2 sm:h-16 sm:py-0 md:px-6">
- <div className="flex h-full flex-row flex-wrap items-center justify-between gap-2">
- <div className="w-[53%] sm:w-auto">
- <Logo />
- </div>
- <div className="flex items-center sm:mt-0 sm:gap-2">
- {/** show only on desktop */}
- <div className="hidden sm:block">
- <GithubStarCtaMarketingPageHeader />
- </div>
- <LanguageSwitcher
- locale={locale}
- buttonText={t("switchLanguage")}
- />
-
- <BlackAnimatedGoToAppBtn>{t("goToApp")}</BlackAnimatedGoToAppBtn>
- </div>
- </div>
- </div>
- </div>
- </header>
- );
-}
-
function HeroSection() {
const t = useTranslations("About");
@@ -203,13 +192,31 @@ function HeroSection() {
<div className="flex justify-center xl:justify-start">
<p className="text-pretty px-4 text-center text-base text-slate-600 md:max-w-[500px] md:text-lg lg:px-0 xl:text-left xl:text-lg">
- {t.rich("hero.description", {
- span: (chunks) => (
- <span className="bg-yellow-300 px-0.5 font-bold text-slate-900 dark:bg-yellow-600">
- {chunks}
- </span>
- ),
- })}
+ {(() => {
+ let colorIndex = 0;
+
+ return t.rich("hero.description", {
+ span: (chunks) => {
+ const colors = [
+ "bg-yellow-300 dark:bg-yellow-600 text-slate-900 dark:text-slate-900",
+ "bg-blue-500 dark:bg-blue-500 text-white dark:text-white",
+ "bg-purple-500 dark:bg-purple-500 text-white dark:text-white",
+ ] as const;
+
+ // Get the current color from the array using modulo to cycle through colors
+ // colorIndex starts at 0 and increments with each <span> element
+ const color = colors[colorIndex % colors.length];
+ // Increment for the next span element
+ colorIndex++;
+
+ return (
+ <span className={`${color} px-0.5 font-bold`}>
+ {chunks}
+ </span>
+ );
+ },
+ });
+ })()}
</p>
</div>
</div>
@@ -255,10 +262,11 @@ function HeroSection() {
</div>
{/* Video container */}
<div className="relative aspect-video w-full">
- <Video
+ <AutoPlayVideo
src={VIDEO_DEMO_URL}
- fallbackImg={VIDEO_DEMO_FALLBACK_IMG}
+ posterImg={VIDEO_DEMO_FALLBACK_IMG}
testId="hero-about-page-video"
+ description="How to create an invoice and download it as a PDF in Easy Invoice"
/>
</div>
</div>
@@ -278,7 +286,7 @@ function FeaturesSection() {
id="features"
className="mt-6 flex w-full items-center justify-center bg-slate-50 py-4 lg:py-8 xl:mt-16 xl:py-16"
>
- <div className="container">
+ <div className="container lg:max-w-[53rem] xl:max-w-[1280px] 2xl:max-w-[1536px]">
{/* Features section title and description */}
<div className="flex flex-col items-center justify-center space-y-8 px-4 text-center md:px-6">
<div className="space-y-5">
@@ -314,7 +322,8 @@ function FeaturesSection() {
isEven ? "xl:flex-row" : "xl:flex-row-reverse", // swap the video and text content for even index
)}
>
- <div className="mb-[-5px] flex-1 px-8 pt-6 xl:mb-0 xl:py-4">
+ {/* text content */}
+ <div className="mb-[-5px] max-w-[700px] flex-1 px-8 pt-6 md:pt-7 xl:mb-0 xl:py-4">
<h3 className="text-balance pb-4 text-xl font-semibold leading-tight tracking-tight text-slate-900 sm:text-2xl">
{title}
</h3>
@@ -323,7 +332,8 @@ function FeaturesSection() {
</p>
</div>
- <div className="relative w-full max-w-[800px] px-2 pb-3 lg:p-0 xl:mx-0">
+ {/* video container */}
+ <div className="relative w-full max-w-[800px] px-2 pb-3 lg:px-0 lg:pb-4 xl:mx-0 xl:pb-0">
{/* Mac OS Frame around the video */}
<div className="relative overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg md:rounded-2xl md:shadow-xl">
{/* Browser chrome bar */}
@@ -338,9 +348,20 @@ function FeaturesSection() {
</div>
{/* Video container */}
<div className="relative aspect-[16.6/8.9] h-full w-full lg:aspect-[16.99/9.1]">
- <Video
+ {/* Auto play video for desktop */}
+ <AutoPlayVideo
+ className="hidden xl:block"
src={feature.videoSrc}
- fallbackImg={feature.videoFallbackImg}
+ posterImg={feature.videoFallbackImg}
+ description={feature.videoDescription}
+ testId={`${feature.translationKey}-demo-video`}
+ />
+ {/* Manual play video for mobile for better UX */}
+ <ManualPlayVideo
+ className="xl:hidden"
+ src={feature.videoSrc}
+ posterImg={feature.videoFallbackImg}
+ description={feature.videoDescription}
testId={`${feature.translationKey}-demo-video`}
/>
</div>
@@ -482,36 +503,6 @@ function CtaSection() {
);
}
-function Logo() {
- const t = useTranslations("About");
-
- return (
- <div>
- <div className="flex items-center gap-1.5 md:gap-2">
- <FinalProjectLogo className="size-6 md:size-7" />
-
- {/* show app logo and description on desktop */}
- <div className="hidden sm:block">
- <ProjectLogoDescription>{t("tagline")}</ProjectLogoDescription>
- </div>
-
- {/* show only app name on mobile (to save space) */}
- <div className="block sm:hidden">
- <p className="text-balance text-center text-xl font-bold text-zinc-800 sm:mt-0 sm:text-2xl lg:mr-5 lg:text-left">
- <a
- href="https://easyinvoicepdf.com"
- target="_blank"
- rel="noopener noreferrer"
- >
- EasyInvoicePDF
- </a>
- </p>
- </div>
- </div>
- </div>
- );
-}
-
const JSON_LD: Graph = {
"@context": "https://schema.org",
"@graph": [
diff --git a/src/app/globals.css b/src/app/globals.css
index 2390356..f53011e 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -23,7 +23,8 @@ body {
position: absolute;
inset: -1px;
padding: 1px;
- -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
+ -webkit-mask-image:
+ linear-gradient(#000, #000), linear-gradient(#000, #000);
mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
-webkit-mask-clip: content-box, border-box;
mask-clip: content-box, border-box;
@@ -38,8 +39,14 @@ body {
width: 500px;
height: 500px;
transform-origin: 0 0;
- background: conic-gradient(transparent 0%, #7d5bfff2 10%, #7d5bff59, transparent 20%);
- filter: drop-shadow(0 0 6px rgba(125, 91, 255, 0.7)) drop-shadow(0 0 14px rgba(125, 91, 255, 0.45));
+ background: conic-gradient(
+ transparent 0%,
+ #7d5bfff2 10%,
+ #7d5bff59,
+ transparent 20%
+ );
+ filter: drop-shadow(0 0 6px rgba(125, 91, 255, 0.7))
+ drop-shadow(0 0 14px rgba(125, 91, 255, 0.45));
}
}
@@ -47,4 +54,15 @@ body {
:root {
--radius: 0.5rem;
}
+
+ /* Custom text selection styling
+ * ::selection targets text highlighted by the user
+ * background-color: Sets the highlight color to brand purple (rgba(125, 91, 255))
+ * color: Sets the selected text color to white (#ffffff) for contrast
+ * This creates a branded selection experience across the entire site
+ */
+ ::selection {
+ background-color: rgba(125, 91, 255);
+ color: #ffffff;
+ }
}
diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx
new file mode 100644
index 0000000..2d954cf
--- /dev/null
+++ b/src/components/ui/sheet.tsx
@@ -0,0 +1,186 @@
+"use client";
+
+import * as React from "react";
+import * as SheetPrimitive from "@radix-ui/react-dialog";
+import { cva, type VariantProps } from "class-variance-authority";
+import { X } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+
+const Sheet = SheetPrimitive.Root;
+
+const SheetTrigger = SheetPrimitive.Trigger;
+
+const SheetClose = SheetPrimitive.Close;
+
+const SheetPortal = SheetPrimitive.Portal;
+
+const SheetOverlay = React.forwardRef<
+ React.ElementRef<typeof SheetPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <SheetPrimitive.Overlay
+ className={cn(
+ "fixed inset-0 z-50",
+
+ className,
+ )}
+ {...props}
+ ref={ref}
+ />
+));
+SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
+
+const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg", {
+ variants: {
+ side: {
+ top: "inset-x-0 top-0 border-b",
+ bottom: "inset-x-0 bottom-0 border-t",
+ left: "inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
+ right: "inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
+ },
+ animation: {
+ slide: "",
+ fade: "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ },
+ },
+ compoundVariants: [
+ {
+ side: "top",
+ animation: "slide",
+ class:
+ "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
+ },
+ {
+ side: "bottom",
+ animation: "slide",
+ class:
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
+ },
+ {
+ side: "left",
+ animation: "slide",
+ class:
+ "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
+ },
+ {
+ side: "right",
+ animation: "slide",
+ class:
+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
+ },
+ ],
+ defaultVariants: {
+ side: "right",
+ animation: "slide",
+ },
+});
+
+interface SheetContentProps
+ extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
+ VariantProps<typeof sheetVariants> {
+ overlayClassName?: string;
+ showCloseButton?: boolean;
+ skipOverlayAnimation?: boolean;
+}
+
+const SheetContent = React.forwardRef<
+ React.ElementRef<typeof SheetPrimitive.Content>,
+ SheetContentProps
+>(
+ (
+ {
+ side = "right",
+ animation = "slide",
+ className,
+ children,
+ overlayClassName,
+ showCloseButton = true,
+ ...props
+ },
+ ref,
+ ) => (
+ <SheetPortal>
+ <SheetOverlay className={overlayClassName} />
+ <SheetPrimitive.Content
+ ref={ref}
+ className={cn(sheetVariants({ side, animation }), className)}
+ {...props}
+ >
+ {showCloseButton && (
+ <SheetPrimitive.Close className="focus:ring-ring data-[state=open]:bg-secondary absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ )}
+ {children}
+ </SheetPrimitive.Content>
+ </SheetPortal>
+ ),
+);
+SheetContent.displayName = SheetPrimitive.Content.displayName;
+
+const SheetHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col space-y-2 text-center sm:text-left",
+ className,
+ )}
+ {...props}
+ />
+);
+SheetHeader.displayName = "SheetHeader";
+
+const SheetFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
+ className,
+ )}
+ {...props}
+ />
+);
+SheetFooter.displayName = "SheetFooter";
+
+const SheetTitle = React.forwardRef<
+ React.ElementRef<typeof SheetPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <SheetPrimitive.Title
+ ref={ref}
+ className={cn("text-lg font-semibold text-foreground", className)}
+ {...props}
+ />
+));
+SheetTitle.displayName = SheetPrimitive.Title.displayName;
+
+const SheetDescription = React.forwardRef<
+ React.ElementRef<typeof SheetPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <SheetPrimitive.Description
+ ref={ref}
+ className={cn("text-muted-foreground text-sm", className)}
+ {...props}
+ />
+));
+SheetDescription.displayName = SheetPrimitive.Description.displayName;
+
+export {
+ Sheet,
+ SheetPortal,
+ SheetOverlay,
+ SheetTrigger,
+ SheetClose,
+ SheetContent,
+ SheetHeader,
+ SheetFooter,
+ SheetTitle,
+ SheetDescription,
+};
diff --git a/src/components/video.tsx b/src/components/video.tsx
index 6364e51..fdc415e 100644
--- a/src/components/video.tsx
+++ b/src/components/video.tsx
@@ -1,91 +1,279 @@
"use client";
+import { useEffect, useId, useRef, useState } from "react";
import { useInView } from "react-intersection-observer";
-import { useCallback, useEffect, useRef } from "react";
+import { cn } from "@/lib/utils";
+import { Play } from "lucide-react";
-interface VideoProps {
+interface SharedVideoProps extends React.ComponentPropsWithRef<"div"> {
src: string;
- fallbackImg: string;
+ posterImg?: string;
+ description?: string;
+ loop?: boolean;
+ prefersReducedMotion?: boolean;
+ renderReducedMotionFallback?: () => React.ReactNode;
testId?: string;
}
-export const Video = ({ src, fallbackImg, testId = "" }: VideoProps) => {
- const [inViewRef, inView] = useInView({
+interface AutoPlayVideoProps extends SharedVideoProps {
+ paused?: boolean;
+}
+
+/**
+ * AutoPlayVideo component that automatically plays video when in viewport.
+ *
+ * @example
+ * ```tsx
+ * <AutoPlayVideo
+ * src="/video.mp4"
+ * posterImg="/poster.jpg"
+ * description="Product demo video"
+ * testId="demo-video"
+ * />
+ * ```
+ */
+export function AutoPlayVideo({
+ className,
+ src,
+ posterImg,
+ description = "",
+ paused = false,
+ loop = true,
+ prefersReducedMotion = false,
+ renderReducedMotionFallback,
+ testId = "",
+ ...props
+}: AutoPlayVideoProps) {
+ const videoRef = useRef<HTMLVideoElement | null>(null);
+ const [srcAdded, setSrcAdded] = useState(false);
+ const descriptionID = useId();
+
+ const { ref, inView } = useInView({
threshold: 0.5,
+ rootMargin: "50px",
});
- const videoRef = useRef<HTMLVideoElement>(null);
-
- const setRefs = useCallback(
- (node: HTMLVideoElement | null) => {
- // Ref's from useRef needs to have the node assigned to `current`
- // @ts-expect-error - fix later
- videoRef.current = node;
- // Callback refs, like the one from `useInView`, is a function that takes the node as an argument
- inViewRef(node);
-
- if (node) {
- node.addEventListener("click", function () {
- if (this.paused) {
- void this.play().catch(() => {
- // Ignore play errors - they are expected when the video is removed
- });
- } else {
- void this.pause();
- }
+
+ function pauseVideo() {
+ videoRef.current?.pause();
+ }
+
+ // Attempts to play the video with retry logic for autoplay restrictions
+ // Some browsers block autoplay until user interaction, so we retry once after 100ms
+ function playVideo() {
+ const video = videoRef.current;
+ if (!video || paused) return;
+ video.play().catch(() => {
+ // Retry once if initial play fails (common with autoplay policies)
+ setTimeout(() => {
+ void video.play().catch(() => {
+ // if play fails again, do nothing
});
- }
- },
- [inViewRef],
+ }, 100);
+ });
+ }
+
+ // Lazy-load video source when component enters viewport
+ // This improves initial page load performance by deferring video loading
+ useEffect(() => {
+ if (inView) setSrcAdded(true);
+ }, [inView]);
+
+ // Control video playback based on viewport visibility and paused state
+ // - If paused prop is true, pause the video
+ // - If in viewport and not paused, play the video
+ // - If out of viewport, pause to save resources
+ useEffect(() => {
+ if (!srcAdded) return;
+
+ if (paused) pauseVideo();
+ else if (inView && !paused) playVideo();
+ else pauseVideo();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [inView, srcAdded, paused, prefersReducedMotion]);
+
+ // Add click handler to toggle play/pause on user interaction
+ // This provides manual control over autoplay videos
+ useEffect(() => {
+ const video = videoRef.current;
+ if (!video) return;
+
+ function handleClick() {
+ if (video?.paused) playVideo();
+ else video?.pause();
+ }
+
+ video.addEventListener("click", handleClick);
+ return () => video.removeEventListener("click", handleClick);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ return (
+ <div
+ ref={ref}
+ className={cn("absolute left-0 top-0 h-full w-full", className)}
+ {...props}
+ >
+ {prefersReducedMotion &&
+ typeof renderReducedMotionFallback === "function" ? (
+ renderReducedMotionFallback()
+ ) : (
+ <>
+ {description ? (
+ <p id={descriptionID} className="sr-only">
+ {description}
+ </p>
+ ) : null}
+ <video
+ ref={videoRef}
+ aria-describedby={description ? descriptionID : undefined}
+ className="h-full w-full cursor-pointer"
+ autoPlay
+ muted
+ loop={loop}
+ playsInline
+ preload="none"
+ poster={posterImg}
+ data-testid={testId}
+ >
+ {srcAdded ? (
+ <source src={`${src}#t=0.001`} type="video/mp4" />
+ ) : null}
+ </video>
+ </>
+ )}
+ </div>
);
+}
+
+type ManualPlayVideoProps = SharedVideoProps;
+
+/**
+ * ManualPlayVideo component displays a video that requires user interaction to play.
+ *
+ * This component is designed for **mobile and touch devices** where autoplay may not be desired
+ * or supported. It ensures only one video plays at a time by listening to custom
+ * "video-play" events and pausing other videos when a new one starts.
+ *
+ * @example
+ * ```tsx
+ * <ManualPlayVideo
+ * src="/videos/demo.mp4"
+ * posterImg="/images/poster.jpg"
+ * testId="demo-video"
+ * />
+ * ```
+ */
+export function ManualPlayVideo({
+ className,
+ src,
+ posterImg,
+ description = "",
+ loop = true,
+ prefersReducedMotion = false,
+ renderReducedMotionFallback,
+ testId = "",
+ ...props
+}: ManualPlayVideoProps) {
+ const descriptionID = useId();
+ const videoId = useId();
+
+ const videoRef = useRef<HTMLVideoElement | null>(null);
+
+ const [isPlaying, setIsPlaying] = useState(false);
+
+ const { ref: inViewRef, inView } = useInView({ threshold: 0.3 });
+ // Effect: Pauses video when it scrolls out of view
+ // This prevents videos from playing audio/consuming resources when not visible
+ // Only triggers when video is currently playing to avoid unnecessary operations
useEffect(() => {
- const videoElement = videoRef.current;
- if (!videoElement) return;
+ if (!inView && isPlaying) {
+ videoRef.current?.pause();
+ setIsPlaying(false);
+ }
+ }, [inView, isPlaying]);
- let playPromise: Promise<void> | undefined;
+ // Effect: Ensures only one video plays at a time across the page
+ // When any video starts playing, it dispatches a "video-play" event with its unique ID.
+ // This effect listens for those events and pauses this video if a different video started playing.
+ useEffect(() => {
+ function handler(e: Event) {
+ // Check if the event came from this video instance
+ // If so, ignore it (don't pause ourselves)
+ if ((e as CustomEvent<{ id: string }>).detail.id === videoId) return;
- if (inView) {
- playPromise = videoElement.play();
- // Handle the play promise to catch any errors
- if (playPromise !== undefined) {
- playPromise.catch(() => {
- // Ignore play errors - they are expected when the video is removed
- });
- }
- } else {
- videoElement.pause();
+ // Another video started playing, so pause this one
+ videoRef.current?.pause();
+ setIsPlaying(false);
}
- // Cleanup function
- return () => {
- if (playPromise !== undefined) {
- playPromise
- .then(() => {
- videoElement.pause();
- })
- .catch(() => {
- // Ignore cleanup errors
- });
- }
- };
- }, [inView]);
+ // Listen for video-play events from any video on the page
+ window.addEventListener("video-play", handler);
+
+ // Cleanup: remove listener when component unmounts
+ return () => window.removeEventListener("video-play", handler);
+ }, [videoId]);
+
+ // Handler: Called when user clicks the play button
+ function handlePlay() {
+ // Broadcast that this video is starting to play
+ // This will trigger the useEffect in other ManualPlayVideo instances to pause themselves
+ window.dispatchEvent(
+ new CustomEvent("video-play", { detail: { id: videoId } }),
+ );
+
+ // Start playing this video
+ void videoRef.current?.play();
+ setIsPlaying(true);
+ }
return (
- <video
- className="absolute left-0 top-0 h-full w-full cursor-pointer"
- autoPlay
- muted
- loop
- playsInline
- preload="auto"
- ref={setRefs}
- poster={fallbackImg}
- aria-label="This video contains an interactive demo for sighted users. It's a demonstration of EasyInvoicePDF's interface showing the invoice creation process with live preview functionality. The demo showcases how users can create professional invoices in real-time."
- data-testid={testId}
+ <div
+ ref={inViewRef}
+ className={cn("absolute left-0 top-0 h-full w-full", className)}
+ {...props}
>
- {/* #t=0.001 is needed to show thumbnail on ios devices */}
- <source src={`${src}#t=0.001`} type="video/mp4" />
- <p> Sorry, your browser doesn&apos;t support embedded videos.</p>
- </video>
+ {prefersReducedMotion &&
+ typeof renderReducedMotionFallback === "function" ? (
+ renderReducedMotionFallback()
+ ) : (
+ <>
+ {description ? (
+ <p id={descriptionID} className="sr-only">
+ {description}
+ </p>
+ ) : null}
+ <video
+ ref={videoRef}
+ aria-describedby={description ? descriptionID : undefined}
+ className="h-full w-full"
+ playsInline
+ preload="none"
+ loop={loop}
+ muted
+ controls={isPlaying}
+ poster={posterImg}
+ data-testid={testId}
+ >
+ <source src={src} type="video/mp4" />
+ </video>
+ {/*
+ Play button overlay - only shown when video is not playing
+ */}
+ {!isPlaying ? (
+ <button
+ type="button"
+ aria-label={description ? description : "Play video"}
+ className="absolute inset-0 flex items-center justify-center backdrop-blur-[2px]"
+ onClick={handlePlay}
+ >
+ <span className="flex size-14 items-center justify-center rounded-full bg-slate-800/90 shadow-lg transition-transform duration-150 hover:scale-110 active:scale-95">
+ <Play className="ml-1 h-6 w-6 fill-white text-white" />
+ </span>
+ </button>
+ ) : null}
+ </>
+ )}
+ </div>
);
-};
+}
diff --git a/src/config.ts b/src/config.ts
index 8a76e5a..b72247f 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -40,41 +40,43 @@ export const MARKETING_FEATURES_CARDS = [
translationKey: "livePreview",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/live-preview-v1.mp4`,
videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/live-preview-fallback-v1.png`,
+ videoDescription: "Live preview of the invoice as you make changes",
},
{
translationKey: "instantDownload",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/instand-download-v1.mp4`,
- videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/instant-download-fallback-v1.png`,
+ videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/instant-download-fallback-04-03-2026.png`,
+ videoDescription: "Instant download of the invoice as a PDF file",
},
{
translationKey: "shareableLinks",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/share-invoice-v1.mp4`,
videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/share-invoice-fallback-v1.png`,
+ videoDescription: "Shareable links to your invoice",
},
{
translationKey: "taxSupport",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/tax-custom-v1.mp4`,
videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/tax-custom-fallback-v1.png`,
+ videoDescription: "Customizable tax system support",
},
{
translationKey: "multiLanguage",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/multi-lang-v1.mp4`,
videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/multi-lang-fallback-v1.png`,
+ videoDescription: "Multiple languages and currencies support",
},
{
translationKey: "openSource",
videoSrc: `${STATIC_ASSETS_URL}/demo-videos/open-source-v1.mp4`,
videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/open-source-fallback-v1.png`,
- },
- {
- translationKey: "qrCodeMultiPDFpageSupport",
- videoSrc: `${STATIC_ASSETS_URL}/demo-videos/qr-code-and-multi-page-pdf-v1.mp4`,
- videoFallbackImg: `${STATIC_ASSETS_URL}/demo-videos/qr-code-fallback-img-v1.png`,
+ videoDescription: "Open source invoice generator",
},
] as const satisfies {
translationKey: string;
videoSrc: string;
videoFallbackImg: string;
+ videoDescription: string;
}[];
/**