feat: enhance signup form with new styling and noindex functionality

Added new CSS styles for the signup form, including a grid layout and improved note visibility. Updated the application logic to include a noindex option for specific pages, ensuring search engines do not index sensitive content. Modified tests to verify the presence of new elements and the correct application of noindex headers.
This commit is contained in:
blake committed 2026-11-02 11:46:46 -06:00
1 parent 019f61bc4a
commit ffec79cbec
5 files changed
+52 -5

No files matched your search

+21
View File
@@ -1794,6 +1794,27 @@ article.shift-card {
font-size: 1.6rem;
}
.signup-lead {
display: grid;
gap: 0.4rem;
}
.signup-lead p {
margin: 0;
line-height: 1.5;
}
.signup-note {
font-size: 0.92rem;
line-height: 1.45;
color: var(--hope-ink-2);
}
.signup-form .hint {
font-size: 0.92rem;
line-height: 1.45;
}
.name-pair {
display: grid;
grid-template-columns: 1fr 1fr;
+7 -1
View File
@@ -71,6 +71,8 @@ export function createApp(
at,
`${only.title} · Hope Volunteer`,
<EventPage config={config} event={only} now={at} month={c.req.query('month')} view={c.req.query('view')} path="/" />,
200,
{ noindex: true },
);
}
return page(
@@ -99,6 +101,8 @@ export function createApp(
at,
`${event.title} · Hope Volunteer`,
<EventPage config={config} event={event} now={at} month={c.req.query('month')} view={c.req.query('view')} />,
200,
{ noindex: true },
);
});
@@ -142,11 +146,13 @@ function page(
title: string,
body: Child,
status: 200 | 404 | 500 = 200,
options?: { noindex?: boolean },
) {
c.header('Cache-Control', 'no-store');
if (options?.noindex) c.header('X-Robots-Tag', 'noindex');
const account = readSession(db, c.req.header('cookie'), now);
return c.html(
<Layout config={config} title={title} path={c.req.path} account={account ? { csrf: account.csrf } : null}>
<Layout config={config} title={title} path={c.req.path} noindex={options?.noindex} account={account ? { csrf: account.csrf } : null}>
{body}
</Layout>,
status,
+7 -2
View File
@@ -26,6 +26,7 @@ export function Layout(props: {
title: string;
path?: string;
turnstile?: boolean;
noindex?: boolean;
account?: { csrf: string } | null;
children?: Child;
}) {
@@ -44,6 +45,7 @@ export function Layout(props: {
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
{props.noindex ? <meta name="robots" content="noindex" /> : null}
<title>{props.title}</title>
<link rel="icon" href={asset(props.config, '/img/favicons/favicon.png')} />
<link rel="apple-touch-icon" href={asset(props.config, '/img/favicons/favicon-apple.png')} />
@@ -1041,7 +1043,10 @@ function SignupForm(props: { config: AppConfig; shiftId: number; remaining: numb
return (
<form class="signup-form" method="post" action={appPath(props.config, `/s/${props.shiftId}`)}>
<h2>Sign up</h2>
<p>Choose how many people are coming, including you. This signup holds that many spots under your name. Another person can use the same email address.</p>
<div class="signup-lead">
<p>Choose how many people are coming, including you. This signup holds that many spots under your name. Another person can use the same email address.</p>
<p class="signup-note">Your full name is listed on the public sign-up page. Email, phone, and notes stay off that page.</p>
</div>
<noscript>
<p class="error">Signing up needs JavaScript for the abuse check. The pantry has not published a contact method for help with signup.</p>
</noscript>
@@ -1110,7 +1115,7 @@ function SignupForm(props: { config: AppConfig; shiftId: number; remaining: numb
) : null}
</label>
<div class="cf-turnstile" data-sitekey={form.siteKey} data-action="signup" />
<p id="signup-turnstile-hint">This check confirms the signup came from a browser.</p>
<p class="signup-note" id="signup-turnstile-hint">This check confirms the signup came from a browser.</p>
<button type="submit">Sign up</button>
</form>
);
+16 -2
View File
@@ -36,6 +36,8 @@ describe('public pages', () => {
expect(html).toContain('Wednesday Sorting');
expect(html).toContain('Wednesday Greeting');
expect(html).toContain('Lane Wednesday');
expect(html).toContain('<meta name="robots" content="noindex"');
expect(home.headers.get('x-robots-tag')).toBe('noindex');
expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v=');
expect(html).toContain('Live Greeting');
expect(html).toContain('0/2 spots filled');
@@ -116,6 +118,8 @@ describe('public pages', () => {
expect(eventHtml).toContain('Sioux Center, Iowa');
expect(eventHtml).toContain('Wednesday Sorting');
expect(eventHtml).toContain('Lane Wednesday');
expect(eventHtml).toContain('<meta name="robots" content="noindex"');
expect(event.headers.get('x-robots-tag')).toBe('noindex');
expect(eventHtml).toContain('Sign up');
expect(eventHtml).not.toContain('shift-calendar');
expect(eventHtml).not.toContain('November 2026');
@@ -164,6 +168,9 @@ describe('public pages', () => {
expect(shiftHtml).toContain('name="last_name"');
expect(shiftHtml).toContain('First name');
expect(shiftHtml).toContain('Last name');
expect(shiftHtml).toContain('class="signup-note">Your full name is listed on the public sign-up page. Email, phone, and notes stay off that page.');
expect(shiftHtml).not.toContain('name="robots"');
expect(shift.headers.get('x-robots-tag')).toBeNull();
expect(shiftHtml).toContain('https://challenges.cloudflare.com/turnstile/v0/api.js');
expect(shiftHtml).not.toContain('data-under-18');
expect(shiftHtml).not.toContain('data-guardian');
@@ -506,6 +513,7 @@ describe('public pages', () => {
expect(html).toContain('<title>Volunteer shifts · Hope Volunteer</title>');
expect(html).toContain('<h1>Volunteer shifts</h1>');
expect(html).toContain('No events are posted.');
expect(html).not.toContain('name="robots"');
expect(html).not.toContain('Weekly pantry');
});
@@ -557,7 +565,10 @@ describe('public pages', () => {
published: 1,
});
const html = await (await app.request('/')).text();
const home = await app.request('/');
const html = await home.text();
expect(home.headers.get('x-robots-tag')).toBeNull();
expect(html).not.toContain('name="robots"');
expect(html).toContain('<h1>Volunteer shifts</h1>');
expect(html).toContain('aria-label="Published events"');
expect(html).toContain('View shifts');
@@ -574,7 +585,10 @@ describe('public pages', () => {
expect(html).not.toContain('Bagging');
expect(html).not.toContain('class="day-card"');
const event = await (await app.request('/e/volunteer-shifts')).text();
const eventResponse = await app.request('/e/volunteer-shifts');
const event = await eventResponse.text();
expect(eventResponse.headers.get('x-robots-tag')).toBe('noindex');
expect(event).toContain('<meta name="robots" content="noindex"');
expect(event).toContain('Bagging');
expect(event).toContain('Bring a box.');
});
+1
View File
@@ -293,6 +293,7 @@ describe('capacity-safe signup', () => {
const formHtml = await form.text();
expect(formHtml).toContain('How many people?');
expect(formHtml).toContain('This signup holds that many spots.');
expect(formHtml).toContain('Your full name is listed on the public sign-up page.');
expect(formHtml).toContain('value="4"');
const saved = await postSignup(