feat(a11y): add live region feedback for auth and billing flows
This commit is contained in:
@@ -175,7 +175,14 @@ export default function SignInPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<p className="text-sm text-red-500">{error}</p>
|
<p
|
||||||
|
className="text-sm text-red-500"
|
||||||
|
role="alert"
|
||||||
|
aria-live="assertive"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -194,7 +201,14 @@ export default function SignInPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{socialMessage && (
|
{socialMessage && (
|
||||||
<p className="text-sm text-amber-600">{socialMessage}</p>
|
<p
|
||||||
|
className="text-sm text-amber-600"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{socialMessage}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@@ -214,7 +228,14 @@ export default function SignInPage() {
|
|||||||
{magicLinkLoading ? "Wird gesendet…" : "Magic Link senden"}
|
{magicLinkLoading ? "Wird gesendet…" : "Magic Link senden"}
|
||||||
</button>
|
</button>
|
||||||
{magicLinkMessage && (
|
{magicLinkMessage && (
|
||||||
<p className="text-sm text-emerald-600">{magicLinkMessage}</p>
|
<p
|
||||||
|
className="text-sm text-emerald-600"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{magicLinkMessage}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ export default function SignUpPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen items-center justify-center bg-background">
|
<div className="flex min-h-screen items-center justify-center bg-background">
|
||||||
<div className="w-full max-w-sm space-y-4 rounded-xl border bg-card p-8 shadow-sm">
|
<div className="w-full max-w-sm space-y-4 rounded-xl border bg-card p-8 shadow-sm">
|
||||||
<div className="text-center">
|
<div className="text-center" role="status" aria-live="polite" aria-atomic="true">
|
||||||
<div className="text-4xl mb-3">📧</div>
|
<div className="text-4xl mb-3">📧</div>
|
||||||
<h1 className="text-xl font-semibold">E-Mail bestätigen</h1>
|
<h1 className="text-xl font-semibold">E-Mail bestätigen</h1>
|
||||||
<p className="mt-2 text-sm text-muted-foreground">
|
<p className="mt-2 text-sm text-muted-foreground">
|
||||||
@@ -291,7 +291,14 @@ export default function SignUpPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<p className="text-sm text-red-500">{error}</p>
|
<p
|
||||||
|
className="text-sm text-red-500"
|
||||||
|
role="alert"
|
||||||
|
aria-live="assertive"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -310,7 +317,14 @@ export default function SignUpPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{socialMessage && (
|
{socialMessage && (
|
||||||
<p className="text-sm text-amber-600">{socialMessage}</p>
|
<p
|
||||||
|
className="text-sm text-amber-600"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{socialMessage}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useAuthQuery } from "@/hooks/use-auth-query";
|
import { useAuthQuery } from "@/hooks/use-auth-query";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { ExternalLink } from "lucide-react";
|
import { ExternalLink } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -20,11 +21,15 @@ const TIER_LABELS: Record<keyof typeof TIER_MONTHLY_CREDITS, string> = {
|
|||||||
|
|
||||||
export function ManageSubscription() {
|
export function ManageSubscription() {
|
||||||
const t = useTranslations('toasts');
|
const t = useTranslations('toasts');
|
||||||
|
const [liveMessage, setLiveMessage] = useState("");
|
||||||
const subscription = useAuthQuery(api.credits.getSubscription);
|
const subscription = useAuthQuery(api.credits.getSubscription);
|
||||||
const tier = normalizeTier(subscription?.tier);
|
const tier = normalizeTier(subscription?.tier);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between rounded-xl border bg-card p-6">
|
<div className="flex items-center justify-between rounded-xl border bg-card p-6">
|
||||||
|
<p className="sr-only" role="status" aria-live="polite" aria-atomic="true">
|
||||||
|
{liveMessage}
|
||||||
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-muted-foreground">Current plan</p>
|
<p className="text-sm text-muted-foreground">Current plan</p>
|
||||||
<div className="mt-1 flex items-center gap-2">
|
<div className="mt-1 flex items-center gap-2">
|
||||||
@@ -45,6 +50,7 @@ export function ManageSubscription() {
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setLiveMessage(t('billing.openingPortalTitle'));
|
||||||
toast.info(
|
toast.info(
|
||||||
t('billing.openingPortalTitle'),
|
t('billing.openingPortalTitle'),
|
||||||
t('billing.openingPortalDesc'),
|
t('billing.openingPortalDesc'),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useAuthQuery } from "@/hooks/use-auth-query";
|
import { useAuthQuery } from "@/hooks/use-auth-query";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Check } from "lucide-react";
|
import { Check } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -19,10 +20,12 @@ const TIER_ORDER = ["free", "starter", "pro", "max"] as const;
|
|||||||
|
|
||||||
export function PricingCards() {
|
export function PricingCards() {
|
||||||
const t = useTranslations('toasts');
|
const t = useTranslations('toasts');
|
||||||
|
const [liveMessage, setLiveMessage] = useState("");
|
||||||
const subscription = useAuthQuery(api.credits.getSubscription);
|
const subscription = useAuthQuery(api.credits.getSubscription);
|
||||||
const currentTier = normalizeTier(subscription?.tier);
|
const currentTier = normalizeTier(subscription?.tier);
|
||||||
|
|
||||||
async function handleCheckout(polarProductId: string) {
|
async function handleCheckout(polarProductId: string) {
|
||||||
|
setLiveMessage(t('billing.redirectingToCheckoutTitle'));
|
||||||
toast.info(
|
toast.info(
|
||||||
t('billing.redirectingToCheckoutTitle'),
|
t('billing.redirectingToCheckoutTitle'),
|
||||||
t('billing.redirectingToCheckoutDesc'),
|
t('billing.redirectingToCheckoutDesc'),
|
||||||
@@ -32,6 +35,9 @@ export function PricingCards() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
|
<p className="sr-only" role="status" aria-live="polite" aria-atomic="true">
|
||||||
|
{liveMessage}
|
||||||
|
</p>
|
||||||
<div className="flex flex-col gap-4 rounded-xl border bg-card p-6">
|
<div className="flex flex-col gap-4 rounded-xl border bg-card p-6">
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-1 flex items-center justify-between">
|
<div className="mb-1 flex items-center justify-between">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
import { TOPUP_PRODUCTS } from "@/lib/polar-products";
|
import { TOPUP_PRODUCTS } from "@/lib/polar-products";
|
||||||
@@ -8,8 +9,10 @@ import { toast } from "@/lib/toast";
|
|||||||
|
|
||||||
export function TopupPanel() {
|
export function TopupPanel() {
|
||||||
const t = useTranslations('toasts');
|
const t = useTranslations('toasts');
|
||||||
|
const [liveMessage, setLiveMessage] = useState("");
|
||||||
|
|
||||||
async function handleTopup(polarProductId: string) {
|
async function handleTopup(polarProductId: string) {
|
||||||
|
setLiveMessage(t('billing.redirectingToCheckoutTitle'));
|
||||||
toast.info(
|
toast.info(
|
||||||
t('billing.redirectingToCheckoutTitle'),
|
t('billing.redirectingToCheckoutTitle'),
|
||||||
t('billing.redirectingToCheckoutDesc'),
|
t('billing.redirectingToCheckoutDesc'),
|
||||||
@@ -41,6 +44,9 @@ export function TopupPanel() {
|
|||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
Angezeigt werden nur kaufbare Top-up Pakete aus der serverseitigen Polar-Produktkonfiguration.
|
Angezeigt werden nur kaufbare Top-up Pakete aus der serverseitigen Polar-Produktkonfiguration.
|
||||||
</p>
|
</p>
|
||||||
|
<p className="sr-only" role="status" aria-live="polite" aria-atomic="true">
|
||||||
|
{liveMessage}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user