Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/[locale]/employers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export default async function EmployersPage({
return (
<div className="page empPage">
<EmployersNav />
<EmployersContent />
<main id="main" tabIndex={-1}>
<EmployersContent />
</main>
<Footer />
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { notFound } from 'next/navigation';
import { SmoothScroll } from '@/components/SmoothScroll';
import { LocaleProvider } from '@/i18n/LocaleProvider';
import { LOCALES, isLocale } from '@/i18n/types';
import { messages } from '@/i18n/messages';
import OrganizationSchema from '../organization-schema';
import '../../styles/globals.css';
import '../../styles/ui.css';
Expand Down Expand Up @@ -36,6 +37,8 @@ export default async function RootLayout({
return (
<html lang={locale}>
<body>
{/* First stop for keyboard users: jump past the navigation (WCAG 2.4.1) */}
<a className="skipLink" href="#main">{messages[locale].nav.skipToContent}</a>
<OrganizationSchema />
<LocaleProvider locale={locale}>
<SmoothScroll />
Expand Down
16 changes: 9 additions & 7 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export default async function Home({
return (
<div className="page homePage">
<Nav ctaHref="#signup" />
<HomeRoad />
<HomeHero />
<HomeProblem />
<HomeImpact />
<HomeBackers />
<HomeHow />
<SignupForm />
<main id="main" tabIndex={-1}>
<HomeRoad />
<HomeHero />
<HomeProblem />
<HomeImpact />
<HomeBackers />
<HomeHow />
<SignupForm />
</main>
<Footer showSupport={false} />
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/PrivacyContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function PrivacyContent() {
const p = t.privacy;

return (
<main className="legalDoc">
<main className="legalDoc" id="main" tabIndex={-1}>
<article className="legalInner">
<h1>{p.title}</h1>
<p className="legalMeta">{p.updated}</p>
Expand Down
123 changes: 97 additions & 26 deletions src/components/SignupForm.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
'use client';

import { useState, useRef, useEffect, useCallback } from 'react';
import { useState, useRef, useEffect, useCallback, useId } from 'react';
import { useLocale } from '@/i18n/LocaleProvider';
import { localePath } from '@/i18n/metadata';
import { CALENDLY_URL } from '@/lib/constants';

type Branch = 'individual' | 'employer';
type FormStatus = 'idle' | 'submitting' | 'success' | 'error';
type FieldName = 'name' | 'email' | 'company' | 'consent';

export function SignupForm() {
const { t, locale } = useLocale();
const [branch, setBranch] = useState<Branch>('individual');
const [status, setStatus] = useState<FormStatus>('idle');
const [errorMsg, setErrorMsg] = useState('');
const [consent, setConsent] = useState(false);
const [invalid, setInvalid] = useState<FieldName[]>([]);
const uid = useId();
const ids = {
who: `${uid}-who`,
name: `${uid}-name`,
email: `${uid}-email`,
company: `${uid}-company`,
error: `${uid}-error`,
};
const stageRef = useRef<HTMLDivElement>(null);
const formRef = useRef<HTMLFormElement>(null);

Expand Down Expand Up @@ -63,24 +73,38 @@ export function SignupForm() {
sizeStage();
}, [status, sizeStage]);

// The submit button disappears on success, so move focus to the message
// that replaces it; otherwise keyboard and screen reader users are lost (WCAG 4.1.3).
const successRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (status === 'success') successRef.current?.focus();
}, [status]);

const handleBranchChange = (b: Branch) => {
setBranch(b);
setStatus('idle');
setErrorMsg('');
setInvalid([]);
};

// Mark the fields in error and move focus to the first one, so the error is
// identified in text, announced, and reachable (WCAG 3.3.1).
const flagInvalid = (fields: FieldName[], msg: string) => {
setInvalid(fields);
setErrorMsg(msg);
setStatus('error');
const first = fields[0];
const form = formRef.current;
if (!first || !form) return;
const el = first === 'consent'
? (form.querySelector('input[type="checkbox"]') as HTMLInputElement | null)
: (form.querySelector(`input[name="${first}"]`) as HTMLInputElement | null);
el?.focus();
};

const handleSubmit = async () => {
if (status === 'submitting') return;

if (!consent) {
setErrorMsg(t.signup.errors.consent);
setStatus('error');
return;
}

setStatus('submitting');
setErrorMsg('');

const form = formRef.current;
if (!form) return;

Expand All @@ -91,12 +115,23 @@ export function SignupForm() {
const email = (form.querySelector('input[name="email"]') as HTMLInputElement)?.value ?? '';
const company = (form.querySelector('input[name="company"]') as HTMLInputElement)?.value ?? '';

if (!name || !email || !company) {
setErrorMsg(t.signup.errors.required);
setStatus('error');
const empty = (['name', 'email', 'company'] as const).filter(
(f) => !{ name, email, company }[f].trim(),
);
if (empty.length) {
flagInvalid(empty, t.signup.errors.required);
return;
}

if (!consent) {
flagInvalid(['consent'], t.signup.errors.consent);
return;
}

setStatus('submitting');
setErrorMsg('');
setInvalid([]);

const payload = { role: 'individual', name, email, company, consent: true, website: honeypot };

try {
Expand Down Expand Up @@ -140,8 +175,8 @@ export function SignupForm() {

{status !== 'success' && (
<>
<div className="radioLabel">{t.signup.signingUpAs}</div>
<div className="radioOpts">
<div className="radioLabel" id={ids.who}>{t.signup.signingUpAs}</div>
<div className="radioOpts" role="radiogroup" aria-labelledby={ids.who}>
<RadioOption
value="individual"
title={t.signup.branches.individual.title}
Expand All @@ -162,9 +197,9 @@ export function SignupForm() {

<div className={`formStage${status === 'success' ? ' formStageSuccess' : ''}`} ref={stageRef}>
{/* Individual */}
<div className={`branch ${branch === 'individual' ? 'active' : ''}`}>
<div className={`branch ${branch === 'individual' ? 'active' : ''}`} inert={branch !== 'individual'}>
{status === 'success' && branch === 'individual' ? (
<div className="formSuccess">
<div className="formSuccess" ref={successRef} role="status" tabIndex={-1}>
<p>{t.signup.success}</p>
<button className="formCta formCtaBack" type="button" onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}>
{t.signup.backToTop} <span className="arr">↑</span>
Expand All @@ -173,23 +208,59 @@ export function SignupForm() {
) : (
<>
<div className="field">
<label>{t.signup.fields.name}</label>
<input type="text" name="name" placeholder="Jānis Bērziņš" />
<label htmlFor={ids.name}>{t.signup.fields.name}</label>
<input
id={ids.name}
type="text"
name="name"
autoComplete="name"
required
aria-invalid={invalid.includes('name') || undefined}
aria-describedby={invalid.includes('name') ? ids.error : undefined}
placeholder="Jānis Bērziņš"
onChange={() => { if (invalid.includes('name')) setInvalid((v) => v.filter((x) => x !== 'name')); }}
/>
</div>
<div className="field">
<label>{t.signup.fields.email}</label>
<input type="email" name="email" placeholder="janis@example.lv" />
<label htmlFor={ids.email}>{t.signup.fields.email}</label>
<input
id={ids.email}
type="email"
name="email"
autoComplete="email"
required
aria-invalid={invalid.includes('email') || undefined}
aria-describedby={invalid.includes('email') ? ids.error : undefined}
placeholder="janis@example.lv"
onChange={() => { if (invalid.includes('email')) setInvalid((v) => v.filter((x) => x !== 'email')); }}
/>
</div>
<div className="field">
<label>{t.signup.fields.company}</label>
<input type="text" name="company" placeholder={t.signup.fields.companyPlaceholder} />
<label htmlFor={ids.company}>{t.signup.fields.company}</label>
<input
id={ids.company}
type="text"
name="company"
autoComplete="organization"
required
aria-invalid={invalid.includes('company') || undefined}
aria-describedby={invalid.includes('company') ? ids.error : undefined}
placeholder={t.signup.fields.companyPlaceholder}
onChange={() => { if (invalid.includes('company')) setInvalid((v) => v.filter((x) => x !== 'company')); }}
/>
</div>

<label className="consentRow">
<input
type="checkbox"
checked={consent}
onChange={(e) => { setConsent(e.target.checked); if (status === 'error') setErrorMsg(''); }}
aria-invalid={invalid.includes('consent') || undefined}
aria-describedby={invalid.includes('consent') ? ids.error : undefined}
onChange={(e) => {
setConsent(e.target.checked);
if (invalid.includes('consent')) setInvalid((v) => v.filter((x) => x !== 'consent'));
if (status === 'error' && invalid.every((x) => x === 'consent')) setErrorMsg('');
}}
/>
<span className="consentText">
{t.signup.consentBefore}{' '}
Expand All @@ -199,7 +270,7 @@ export function SignupForm() {
</label>

{status === 'error' && errorMsg && (
<div className="formError">{errorMsg}</div>
<div className="formError" id={ids.error} role="alert">{errorMsg}</div>
)}

<button
Expand All @@ -217,7 +288,7 @@ export function SignupForm() {
</div>

{/* Employer */}
<div className={`branch ${branch === 'employer' ? 'active' : ''}`}>
<div className={`branch ${branch === 'employer' ? 'active' : ''}`} inert={branch !== 'employer'}>
<p className="branchMsg">{t.signup.employerMsg}</p>
<button className="formCta" type="button" onClick={handleBookCall}>
{t.signup.bookCall} <span className="arr">→</span>
Expand Down
8 changes: 8 additions & 0 deletions src/components/SmoothScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export function SmoothScroll() {
target.scrollIntoView({ behavior: reduced.matches ? 'instant' : 'smooth' });
}
history.pushState(null, '', href);

// preventDefault() above also stops the browser from moving focus, so
// keyboard and screen reader users would stay at the link. Move focus
// to the target without a second scroll (WCAG 2.4.1, 2.4.3).
if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {
target.setAttribute('tabindex', '-1');
}
target.focus({ preventScroll: true });
};

document.addEventListener('click', onAnchorClick);
Expand Down
5 changes: 2 additions & 3 deletions src/components/employers/AdminTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ export function AdminTimeline() {
type="button"
role="tab"
aria-selected={active}
aria-label={label}
className={`emStop${i <= stage ? ' passed' : ''}${active ? ' on' : ''}`}
onClick={() => go(i)}
>
<span className="emStopDot" aria-hidden="true" />
<span className="emStopLabel emStopLong" aria-hidden="true">{label}</span>
<span className="emStopLabel emStopShort" aria-hidden="true">{tl.stagesShort[i]}</span>
<span className="emStopLabel emStopLong">{label}</span>
<span className="emStopLabel emStopShort">{tl.stagesShort[i]}</span>
</button>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions src/components/home/HeroDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export function HeroDemo() {
})}
</div>

<div className="hdMap" role="img" aria-label={d.mapAria}>
<div className="hdMap" role="group" aria-label={d.mapAria}>
<svg aria-hidden="true" viewBox={`0 0 ${MAP_W} ${MAP_H}`} className="hdMapSvg">
{STREETS.map((s) => (
<path key={s} d={s} stroke="#EEEEEE" strokeWidth="14" strokeLinecap="round" fill="none" />
Expand Down Expand Up @@ -400,7 +400,7 @@ export function HeroDemo() {
{match && !on && <span aria-hidden="true" className="hdPing" />}
<button
type="button"
aria-label={fmt(on ? d.removeAria : d.addAria, { name: p.first })}
aria-label={`${p.ini}, ${fmt(on ? d.removeAria : d.addAria, { name: p.first })}`}
aria-pressed={on}
disabled={!match}
onClick={() => toggle(p.id)}
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const en = {
'Join verified communities going on the same routes as you. Drive together and split the cost of your commute.',
},
nav: {
skipToContent: 'Skip to content',
homeAria: 'Coride home',
home: 'Home',
joinWaitlist: 'Join the waitlist',
Expand Down Expand Up @@ -355,6 +356,7 @@ const lv = {
'Pievienojies kolēģiem, kas brauc pa tiem pašiem maršrutiem. Brauc kopā un dali ceļa izmaksas.',
},
nav: {
skipToContent: 'Pāriet uz saturu',
homeAria: 'Coride sākums',
home: 'Sākums',
joinWaitlist: 'Piesakies agrīnai piekļuvei',
Expand Down
6 changes: 3 additions & 3 deletions src/styles/emp.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
/* report demo */
.emReportGrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: stretch; }
.emRides { display: flex; flex-direction: column; gap: 8px; }
.emRide { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; background: #F7F7F7; transition: opacity 0.4s ease, transform 0.4s ease; }
.emRide.counted { opacity: 0.45; transform: translateX(6px); }
.emRide { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; background: #F7F7F7; transition: opacity 0.4s ease, transform 0.4s ease; }
.emRide.counted { opacity: 0.65; transform: translateX(6px); }
.emRoute { display: flex; align-items: center; flex: none; width: 56px; }
.emRoute span:nth-child(1) { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--rc); }
.emRoute span:nth-child(2) { display: block; flex: 1; height: 3px; background: var(--rc); }
.emRoute span:nth-child(3) { display: block; width: 8px; height: 8px; box-sizing: border-box; border: 2px solid var(--rc); border-radius: 50%; background: #FFFFFF; }
.emRideLabel { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emRideLabel { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.emCheck { display: flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: #DBDBDB; color: #FFFFFF; font-size: 12px; font-weight: 700; transition: background 0.3s ease; }
.emRide.counted .emCheck { background: var(--green); }
.emSheet { display: flex; flex-direction: column; gap: 16px; padding: 20px; border: 1px solid #E8E8E8; border-radius: 14px; background: #FFFFFF; }
Expand Down
6 changes: 3 additions & 3 deletions src/styles/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.footLegal { display: flex; flex-direction: column; align-items: flex-end; gap: 13px; }
.footColLabel {
font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.5px;
text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 3px; white-space: nowrap;
text-transform: uppercase; color: var(--text-secondary); margin-bottom: 3px; white-space: nowrap;
}
.footLegal a {
font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.1px;
Expand All @@ -40,7 +40,7 @@
}
.footCopy {
font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2px;
color: var(--text-tertiary); white-space: nowrap;
color: var(--text-secondary); white-space: nowrap;
}
.footBarRight { display: flex; align-items: center; gap: 18px; }

Expand All @@ -59,7 +59,7 @@
.footSupport { display: flex; align-items: center; gap: 12px; margin-top: 92px; }
.footSupportLabel {
font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.4px;
color: var(--ink-400); white-space: nowrap;
color: var(--text-secondary); white-space: nowrap;
}
.footRtu {
display: block; width: auto; height: 44px;
Expand Down
10 changes: 10 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ body {
text-rendering: optimizeLegibility;
}

/* ── Skip link: hidden until focused (WCAG 2.4.1) ────── */
.skipLink {
position: absolute; left: 16px; top: -100px; z-index: 1000;
padding: 10px 16px; border-radius: var(--radius-md);
background: var(--ink-950); color: var(--text-inverse);
font-family: var(--font-body); font-size: 15px; font-weight: 600; text-decoration: none;
}
.skipLink:focus { top: 16px; }
[tabindex="-1"]:focus { outline: none; }

/* ── Page shell ──────────────────────────────────────── */
.page {
position: relative;
Expand Down
Loading