diff --git a/web/e2e/landing.spec.ts b/web/e2e/landing.spec.ts index 191a8f0..7e4e3c7 100644 --- a/web/e2e/landing.spec.ts +++ b/web/e2e/landing.spec.ts @@ -162,10 +162,10 @@ test.describe('the homepage’s hero (#151)', () => { await expect .poll(() => swayOf(page), { timeout: 2000 }) .toMatch(/^rotate\(-?[\d.]+deg\)$/); - // A few degrees at most, and still again within about three seconds. + // A few degrees at most, and still again after about six seconds. const angle = Number(/-?[\d.]+/.exec((await swayOf(page)) ?? '')?.[0]); - expect(Math.abs(angle)).toBeLessThan(4); - await expect.poll(() => swayOf(page), { timeout: 4000 }).toBe(''); + expect(Math.abs(angle)).toBeLessThan(5); + await expect.poll(() => swayOf(page), { timeout: 9000 }).toBe(''); }); test('keeps the badge still with reduced motion', async ({ page }) => { diff --git a/web/src/app/lanyard.test.tsx b/web/src/app/lanyard.test.tsx index 65bab4b..3c8da7e 100644 --- a/web/src/app/lanyard.test.tsx +++ b/web/src/app/lanyard.test.tsx @@ -353,7 +353,7 @@ describe('lanyard blocks', () => { }); describe('visitor actions on the page', () => { - it('offers signed-out visitors Bluesky, with sign-in and sign-up in the header', async () => { + it('offers signed-out visitors Bluesky, and only Sign in in the header', async () => { servePerson(); renderRoute('/alice.test'); expect( @@ -369,8 +369,8 @@ describe('visitor actions on the page', () => { `/sign-in?returnTo=${encodeURIComponent('/alice.test')}` ); expect( - within(header).getByRole('button', { name: 'Make your lanyard' }) - ).toBeInTheDocument(); + within(header).queryByRole('button', { name: 'Make your lanyard' }) + ).toBeNull(); }); it('gives owners edit links by DID when their handle doesn’t verify', async () => { diff --git a/web/src/components/AppHeader/AppHeader.styles.ts b/web/src/components/AppHeader/AppHeader.styles.ts index 443d241..1744927 100644 --- a/web/src/components/AppHeader/AppHeader.styles.ts +++ b/web/src/components/AppHeader/AppHeader.styles.ts @@ -19,9 +19,5 @@ export const end = 'flex min-w-0 items-center gap-2 md:gap-3'; /** Show QR and Account, from md up; on phones they're in the bottom bar. */ export const own = 'hidden items-center gap-1 md:flex'; -export const nav = 'flex items-center gap-1'; - -export const signUp = 'px-3 text-sm font-semibold leading-5'; - -export const navLink = - 'inline-flex min-h-11 items-center rounded-sm px-3 text-sm font-medium leading-5 text-ui-text hover:bg-ui-surface-muted'; +/** Sign in, signed out: a primary button, sized for the bar (#162). */ +export const signIn = 'px-3 text-sm font-semibold leading-5'; diff --git a/web/src/components/AppHeader/AppHeader.test.tsx b/web/src/components/AppHeader/AppHeader.test.tsx index b95a221..f13c61c 100644 --- a/web/src/components/AppHeader/AppHeader.test.tsx +++ b/web/src/components/AppHeader/AppHeader.test.tsx @@ -1,9 +1,7 @@ import { screen, within } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import { describe, expect, it, vi } from 'vitest'; import { useSession } from '@/features/auth/session/useSession'; -import { startSignUp } from '@/lib/atproto/session'; import { useProfile } from '@/lib/atproto/useProfile'; import { expectNoAxeViolations } from '@/test/axe'; import { ALICE } from '@/test/fixtures'; @@ -13,10 +11,6 @@ import { AppHeader } from './AppHeader'; vi.mock('@/features/auth/session/useSession', () => ({ useSession: vi.fn() })); vi.mock('@/lib/atproto/useProfile', () => ({ useProfile: vi.fn() })); -vi.mock('@/lib/atproto/session', async (importOriginal) => ({ - ...(await importOriginal()), - startSignUp: vi.fn(() => Promise.resolve()), -})); describe('AppHeader', () => { it('links the logo home and shows no account link when signed out', async () => { @@ -143,7 +137,7 @@ describe('AppHeader', () => { await expectNoAxeViolations(container); }); - it('offers sign-in and sign-up to signed-out visitors where asked', async () => { + it('offers signed-out visitors only Sign in, as a primary button (#162)', async () => { vi.mocked(useSession).mockReturnValue({ status: 'signedOut', signOut: vi.fn(), @@ -154,16 +148,15 @@ describe('AppHeader', () => { , '/@alice.test' ); - expect( - await screen.findByRole('link', { name: 'Sign in' }) - ).toHaveAttribute( + const signIn = await screen.findByRole('link', { name: 'Sign in' }); + expect(signIn).toHaveAttribute( 'href', `/sign-in?returnTo=${encodeURIComponent('/@alice.test')}` ); - await userEvent.click( - screen.getByRole('button', { name: 'Make your lanyard' }) - ); - expect(startSignUp).toHaveBeenCalledWith('/@alice.test'); + // The app's primary button, as a link. + expect(signIn.className).toContain('bg-ui-primary'); + // Account creation is on the sign-in page. + expect(within(screen.getByRole('banner')).queryByRole('button')).toBeNull(); await expectNoAxeViolations(container); }); diff --git a/web/src/components/AppHeader/AppHeader.tsx b/web/src/components/AppHeader/AppHeader.tsx index 6755741..14ff979 100644 --- a/web/src/components/AppHeader/AppHeader.tsx +++ b/web/src/components/AppHeader/AppHeader.tsx @@ -3,10 +3,9 @@ import { Link, useLocation } from '@tanstack/react-router'; import { IdCard, SlidersHorizontal } from 'lucide-react'; import { AccountLink } from '@/components/AccountLink/AccountLink'; -import { Button } from '@/components/Button/Button'; +import { buttonClassName } from '@/components/Button/buttonClassName'; import { Logo } from '@/components/Logo/Logo'; import { useSession } from '@/features/auth/session/useSession'; -import { useMakeLanyard } from '@/features/auth/useMakeLanyard'; import { ShowQrButton } from '@/features/qr/components/ShowQrButton/ShowQrButton'; import { useOwnPaths } from '@/hooks/useOwnPaths'; import { OWN_PAGE_ACTIVE } from '@/lib/person/ownPaths'; @@ -19,7 +18,8 @@ import type { AppHeaderProps } from './AppHeader.types'; * The top bar. Signed in (#150): the logo (your customiser), Customise and * View on the left; a page's own actions, Show QR and Account on the * right. On phones, the bottom bar carries the rest. Signed out, where - * asked: Sign in and Make your lanyard. (The homepage has its own.) + * asked: Sign in, as a primary button (#162); account creation is on the + * sign-in page. (The homepage has its own header.) */ export function AppHeader({ actions, @@ -30,7 +30,6 @@ export function AppHeader({ const session = useSession(); const path = useLocation({ select: (location) => location.pathname }); const own = useOwnPaths(); - const makeLanyard = useMakeLanyard(); let end = null; if (own) { @@ -42,22 +41,13 @@ export function AppHeader({ ); } else if (signedOutActions && session.status === 'signedOut') { end = ( -
- - {t`Sign in`} - - -
+ + {t`Sign in`} + ); } diff --git a/web/src/components/AppHeader/AppHeader.types.ts b/web/src/components/AppHeader/AppHeader.types.ts index 5eb3cec..1520d33 100644 --- a/web/src/components/AppHeader/AppHeader.types.ts +++ b/web/src/components/AppHeader/AppHeader.types.ts @@ -6,7 +6,7 @@ export type AppHeaderProps = { * Show QR and Account, and the only ones in the top bar on phones. */ actions?: ReactNode; - /** Offer Sign in and Make your lanyard when signed out (#129). */ + /** Offer Sign in when signed out (#129, #162). */ signedOutActions?: boolean; className?: string; }; diff --git a/web/src/components/Button/Button.tsx b/web/src/components/Button/Button.tsx index 7f42a09..a49264e 100644 --- a/web/src/components/Button/Button.tsx +++ b/web/src/components/Button/Button.tsx @@ -1,7 +1,6 @@ -import { cn } from '@/lib/utils'; - -import { base, sizes, spinner, tones } from './Button.styles'; +import { spinner } from './Button.styles'; import type { ButtonProps } from './Button.types'; +import { buttonClassName } from './buttonClassName'; export function Button({ variant = 'primary', @@ -32,7 +31,7 @@ export function Button({ } onClick?.(event); }} - className={cn(base, tones[tone][variant], sizes[size], className)} + className={buttonClassName({ tone, variant, size, className })} {...rest} > {loading &&