diff --git a/web/README.md b/web/README.md index 9400d5e..80f1dae 100644 --- a/web/README.md +++ b/web/README.md @@ -124,10 +124,9 @@ keep falling back to broad permissions for a few minutes after publishing. ## Deploying (`lanyards.app`) The app deploys from the Vercel project **`lanyards`** (team `renderghost`, -Git repo `renderghost/lanyards`), with Root Directory `web`. Until the swap -(#154), that project served the legacy Next.js app from the repository root, -and the beta ran on a second project, `lanyards-next`, at -`next.lanyards.app`. +Git repo `renderghost/lanyards`), with Root Directory `web`. It was the +beta's project, `lanyards-next`, renamed at the swap (#154), when the legacy +Next.js project was deleted and `lanyards.app` moved to it. ### 1. Project settings diff --git a/web/e2e/callback.spec.ts b/web/e2e/callback.spec.ts index af159d8..b00a831 100644 --- a/web/e2e/callback.spec.ts +++ b/web/e2e/callback.spec.ts @@ -6,7 +6,7 @@ test('explains a cancelled sign-in and scrubs the URL', async ({ page }) => { expect(page.url()).not.toContain('#'); await expect(page.getByRole('link', { name: 'Try again' })).toHaveAttribute( 'href', - '/' + '/sign-in' ); }); diff --git a/web/e2e/fixtures.ts b/web/e2e/fixtures.ts index 11829ba..4312122 100644 --- a/web/e2e/fixtures.ts +++ b/web/e2e/fixtures.ts @@ -2,9 +2,6 @@ import { test as base, expect } from '@playwright/test'; export const HEADING = 'Welcome to Lanyards'; -/** The homepage's live sample lanyard (#145), framed at `md` and up. */ -export const SAMPLE_PATH = '/renderg.host'; - const APP_ORIGIN = 'http://127.0.0.1:4173'; /** @@ -24,16 +21,6 @@ export const test = base.extend({ await page.route('https://public.api.bsky.app/**', (route) => route.fulfill({ json: { actors: [] } }) ); - // The homepage frames a real person's lanyard: stand in a page, so its - // reads of that person never leave the run. - await page.route( - (url) => url.origin === APP_ORIGIN && url.pathname === SAMPLE_PATH, - (route) => - route.fulfill({ - contentType: 'text/html', - body: 'Sample lanyard

Sample

', - }) - ); await use(page); expect(unexpected, 'unexpected third-party requests').toEqual([]); }, diff --git a/web/e2e/landing.spec.ts b/web/e2e/landing.spec.ts index 00b3061..191a8f0 100644 --- a/web/e2e/landing.spec.ts +++ b/web/e2e/landing.spec.ts @@ -1,12 +1,15 @@ import AxeBuilder from '@axe-core/playwright'; -import { expect, HEADING, SAMPLE_PATH, test } from './fixtures'; +import { expect, HEADING, test } from './fixtures'; const WCAG = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']; +/** The sign-in page's heading (#157). */ +const SIGN_IN = { level: 1, name: 'Sign in' } as const; + test('asks for a handle when submitted empty', async ({ page }) => { - await page.goto('/'); - await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); + await page.goto('/sign-in'); + await expect(page.getByRole('heading', SIGN_IN)).toBeVisible(); await page.getByRole('button', { name: 'Sign in' }).click(); await expect(page.getByText('Enter your handle')).toBeVisible(); }); @@ -16,6 +19,11 @@ for (const colorScheme of ['light', 'dark'] as const) { await page.emulateMedia({ colorScheme }); await page.goto('/'); await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); + const home = await new AxeBuilder({ page }).withTags(WCAG).analyze(); + expect(home.violations).toEqual([]); + + await page.goto('/sign-in'); + await expect(page.getByRole('heading', SIGN_IN)).toBeVisible(); const clean = await new AxeBuilder({ page }).withTags(WCAG).analyze(); expect(clean.violations).toEqual([]); @@ -26,70 +34,62 @@ for (const colorScheme of ['light', 'dark'] as const) { }); } -test('fits a 320px-wide screen without sideways scrolling', async ({ - page, -}) => { - await page.setViewportSize({ width: 320, height: 640 }); - await page.goto('/'); - await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); - const scrollWidth = await page.evaluate( - () => document.documentElement.scrollWidth - ); - expect(scrollWidth).toBeLessThanOrEqual(320); -}); +for (const path of ['/', '/sign-in']) { + test(`fits a 320px-wide screen without sideways scrolling (${path})`, async ({ + page, + }) => { + await page.setViewportSize({ width: 320, height: 640 }); + await page.goto(path); + await expect(page.getByRole('heading', { level: 1 })).toBeVisible(); + const scrollWidth = await page.evaluate( + () => document.documentElement.scrollWidth + ); + expect(scrollWidth).toBeLessThanOrEqual(320); + }); +} test.describe('the homepage (#145)', () => { - test('frames a sample lanyard on desktop, and links to it', async ({ + test('takes Sign in at the top to the sign-in page (#157)', async ({ page, }) => { - await page.setViewportSize({ width: 1280, height: 900 }); await page.goto('/'); - await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); - const frame = page.getByTitle('Sample lanyard'); - await expect(frame).toBeVisible(); - await expect(frame).toHaveAttribute('src', SAMPLE_PATH); + const banner = page.getByRole('banner'); await expect( - page.frameLocator('iframe[title="Sample lanyard"]').getByRole('heading') - ).toHaveText('Sample'); + banner.getByRole('button', { name: 'Make your lanyard' }) + ).toHaveCount(0); + await banner.getByRole('link', { name: 'Sign in' }).click(); + await expect(page).toHaveURL('/sign-in'); + await expect(page.getByRole('heading', SIGN_IN)).toBeVisible(); await expect( - page.getByRole('link', { name: /View sample profile/ }) - ).toHaveAttribute('href', SAMPLE_PATH); + page.getByRole('combobox', { name: 'Your handle' }) + ).toBeVisible(); }); - test('links to the sample, without the frame, on phones', async ({ + test('leads with a call to action to the sign-in page (#157)', async ({ page, }) => { - await page.setViewportSize({ width: 320, height: 640 }); await page.goto('/'); - await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); - await expect(page.getByTitle('Sample lanyard')).toBeHidden(); - await expect( - page.getByRole('link', { name: /View sample profile/ }) - ).toBeVisible(); + await expect(page.getByRole('combobox')).toHaveCount(0); + await expect(page.getByTitle('Sample lanyard')).toHaveCount(0); + const start = page.getByRole('region', { + name: 'Everything you work on, in one link', + }); + await start.getByRole('link', { name: 'Sign in to get started' }).click(); + await expect(page).toHaveURL('/sign-in'); }); - test('takes “Create your lanyard” to the sign-in form', async ({ page }) => { + test('takes “Create your lanyard” to the sign-in page', async ({ page }) => { await page.goto('/'); - await page.getByRole('button', { name: 'Create your lanyard' }).click(); - const handle = page.getByRole('combobox', { name: 'Your handle' }); - await expect(handle).toBeFocused(); - await expect(handle).toBeInViewport(); + await page.getByRole('link', { name: 'Create your lanyard' }).click(); + await expect(page).toHaveURL('/sign-in'); + await expect(page.getByRole('heading', SIGN_IN)).toBeVisible(); }); - test('offers Sign in at the top, taking people to the form (#148)', async ({ - page, - }) => { - await page.setViewportSize({ width: 1920, height: 1080 }); - await page.goto('/'); - const signIn = page - .getByRole('banner') - .getByRole('link', { name: 'Sign in' }); - await expect(signIn).toBeInViewport(); - const handle = page.getByRole('combobox', { name: 'Your handle' }); - await expect(handle).not.toBeInViewport(); - await signIn.click(); - await expect(handle).toBeFocused(); - await expect(handle).toBeInViewport(); + // Old links to the homepage's sign-in (#157). + test('sends /?returnTo= on to the sign-in page', async ({ page }) => { + await page.goto('/?returnTo=%2Fsettings'); + await expect(page).toHaveURL('/sign-in?returnTo=%2Fsettings'); + await expect(page.getByRole('heading', SIGN_IN)).toBeVisible(); }); }); diff --git a/web/e2e/settings.spec.ts b/web/e2e/settings.spec.ts index 4079ebf..dc02a01 100644 --- a/web/e2e/settings.spec.ts +++ b/web/e2e/settings.spec.ts @@ -1,8 +1,10 @@ -import { expect, HEADING, test } from './fixtures'; +import { expect, test } from './fixtures'; test('sends signed-out visitors to sign in first', async ({ page }) => { await page.goto('/settings'); - await expect(page).toHaveURL('/?returnTo=%2Fsettings'); - await expect(page.getByRole('heading', { name: HEADING })).toBeVisible(); + await expect(page).toHaveURL('/sign-in?returnTo=%2Fsettings'); + await expect( + page.getByRole('heading', { level: 1, name: 'Sign in' }) + ).toBeVisible(); await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible(); }); diff --git a/web/src/app/callback.test.tsx b/web/src/app/callback.test.tsx index cc155a4..27322b1 100644 --- a/web/src/app/callback.test.tsx +++ b/web/src/app/callback.test.tsx @@ -43,7 +43,10 @@ describe('OAuth callback, trying again', () => { ); renderRoute('/oauth/callback#error=access_denied'); await screen.findByText('Sign-in was cancelled.'); - expect(tryAgain()).toHaveAttribute('href', '/?returnTo=%2F%40alice.test'); + expect(tryAgain()).toHaveAttribute( + 'href', + '/sign-in?returnTo=%2F%40alice.test' + ); sessionStorage.clear(); }); @@ -54,7 +57,7 @@ describe('OAuth callback, trying again', () => { ); renderRoute('/oauth/callback#error=access_denied'); await screen.findByText('Sign-in was cancelled.'); - expect(tryAgain()).toHaveAttribute('href', '/'); + expect(tryAgain()).toHaveAttribute('href', '/sign-in'); sessionStorage.clear(); }); }); @@ -68,7 +71,7 @@ describe('OAuth callback', () => { expect( await screen.findByText('Sign-in was cancelled.') ).toBeInTheDocument(); - expect(tryAgain()).toHaveAttribute('href', '/'); + expect(tryAgain()).toHaveAttribute('href', '/sign-in'); expect(completeSignIn).toHaveBeenCalledTimes(1); expect(completeSignIn).toHaveBeenCalledWith('#error=access_denied'); expect(router.state.location.hash).toBe(''); @@ -83,13 +86,16 @@ describe('OAuth callback', () => { vi.mocked(completeSignIn).mockRejectedValue( new OAuthCallbackError('denied') ); - renderRoute('/oauth/callback#error=access_denied'); + const { router } = renderRoute('/oauth/callback#error=access_denied'); await userEvent.click( await screen.findByRole('link', { name: 'Try again' }) ); + // Trying again goes to the sign-in page (#157), whose heading is also + // "Sign in": wait for it to replace the callback page's. + await waitForRoute(router, '/sign-in'); const heading = await screen.findByRole('heading', { level: 1, - name: 'Welcome to Lanyards', + name: 'Sign in', }); await waitFor(() => expect(heading).toHaveFocus()); }); @@ -104,7 +110,7 @@ describe('OAuth callback', () => { 'This sign-in link has expired or was already used.' ) ).toBeInTheDocument(); - expect(tryAgain()).toHaveAttribute('href', '/'); + expect(tryAgain()).toHaveAttribute('href', '/sign-in'); }); it('explains a failed exchange and reports it', async () => { diff --git a/web/src/app/customise.test.tsx b/web/src/app/customise.test.tsx index 79bb663..ac7c84b 100644 --- a/web/src/app/customise.test.tsx +++ b/web/src/app/customise.test.tsx @@ -132,7 +132,7 @@ describe('//edit', { timeout: 20_000 }, () => { it('sends signed-out visitors to sign in, then back here', async () => { vi.mocked(useSession).mockReturnValue(signedOutSession()); const { router } = renderRoute(EDIT); - await waitForRoute(router, `/?returnTo=${encodeURIComponent(EDIT)}`, 5000); + await waitForRoute(router, `/sign-in?returnTo=${encodeURIComponent(EDIT)}`, 5000); }); it('forwards /lanyard to your own //edit (#150)', async () => { diff --git a/web/src/app/landing.test.tsx b/web/src/app/landing.test.tsx index fd77dba..d8b9a36 100644 --- a/web/src/app/landing.test.tsx +++ b/web/src/app/landing.test.tsx @@ -33,12 +33,12 @@ describe('landing page', () => { refresh: vi.fn(), }); renderRoute('/'); - await screen.findByRole('button', { name: 'Sign in' }); + await screen.findByRole('heading', { name: 'Welcome to Lanyards' }); expect(screen.queryByRole('button', { name: 'Send feedback' })).toBeNull(); expect(screen.queryByRole('button', { name: 'Give feedback' })).toBeNull(); }); - it('shows the sign-in form to signed-out visitors', async () => { + it('shows signed-out visitors the homepage, with no form on it (#157)', async () => { vi.mocked(useSession).mockReturnValue({ status: 'signedOut', signOut: vi.fn(), @@ -48,13 +48,14 @@ describe('landing page', () => { expect( await screen.findByRole('heading', { name: 'Welcome to Lanyards' }) ).toBeInTheDocument(); - expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument(); + expect(screen.queryByRole('combobox')).toBeNull(); + expect(screen.queryByRole('button', { name: 'Sign in' })).toBeNull(); expect(document.title).toBe( 'Researcher profiles on the AT Protocol · Lanyards' ); }); - it('offers Sign in and Make your lanyard in the header (#148)', async () => { + it('offers Sign in in the header, to its own page (#157)', async () => { vi.mocked(useSession).mockReturnValue({ status: 'signedOut', signOut: vi.fn(), @@ -64,21 +65,41 @@ describe('landing page', () => { const banner = await screen.findByRole('banner'); expect( await within(banner).findByRole('link', { name: 'Sign in' }) + ).toHaveAttribute('href', '/sign-in'); + expect( + within(banner).queryByRole('button', { name: 'Make your lanyard' }) + ).toBeNull(); + }); + + it('signs in on /sign-in, with the typeahead (#157)', async () => { + vi.mocked(useSession).mockReturnValue({ + status: 'signedOut', + signOut: vi.fn(), + refresh: vi.fn(), + }); + renderRoute('/sign-in?returnTo=%2Fsettings'); + expect( + await screen.findByRole('heading', { level: 1, name: 'Sign in' }) ).toBeInTheDocument(); expect( - within(banner).getByRole('button', { name: 'Make your lanyard' }) + screen.getByRole('combobox', { name: 'Your handle' }) ).toBeInTheDocument(); + expect(screen.getAllByRole('banner')).toHaveLength(1); + expect(document.title).toBe('Sign in · Lanyards'); }); - it('is titled for signing in when sent here to sign in (#145)', async () => { + // Links from before the sign-in page had its own address (#157). + it('sends /?returnTo= on to /sign-in, keeping where to return', async () => { vi.mocked(useSession).mockReturnValue({ status: 'signedOut', signOut: vi.fn(), refresh: vi.fn(), }); - renderRoute('/?returnTo=%2Fsettings'); - await screen.findByRole('heading', { name: 'Welcome to Lanyards' }); - expect(document.title).toBe('Sign in · Lanyards'); + const { router } = renderRoute('/?returnTo=%2Fsettings'); + await waitForRoute(router, '/sign-in?returnTo=%2Fsettings'); + expect( + await screen.findByRole('heading', { level: 1, name: 'Sign in' }) + ).toBeInTheDocument(); }); it('sends a signed-in visitor to their own customiser (#150)', async () => { diff --git a/web/src/app/lanyard.test.tsx b/web/src/app/lanyard.test.tsx index f003768..65bab4b 100644 --- a/web/src/app/lanyard.test.tsx +++ b/web/src/app/lanyard.test.tsx @@ -201,7 +201,7 @@ describe('lanyard page states', () => { ).toBeInTheDocument(); expect( within(screen.getByRole('main')).getByRole('link', { name: 'Sign in' }) - ).toHaveAttribute('href', '/?returnTo=%2Falice.test'); + ).toHaveAttribute('href', '/sign-in?returnTo=%2Falice.test'); expect(screen.queryByText('Dr Ada Example')).not.toBeInTheDocument(); // The name must not leak through the tab title either. await waitFor(() => @@ -366,7 +366,7 @@ describe('visitor actions on the page', () => { within(header).getByRole('link', { name: 'Sign in' }) ).toHaveAttribute( 'href', - `/?returnTo=${encodeURIComponent('/alice.test')}` + `/sign-in?returnTo=${encodeURIComponent('/alice.test')}` ); expect( within(header).getByRole('button', { name: 'Make your lanyard' }) diff --git a/web/src/app/settings.test.tsx b/web/src/app/settings.test.tsx index 31c673b..a86e7ff 100644 --- a/web/src/app/settings.test.tsx +++ b/web/src/app/settings.test.tsx @@ -27,7 +27,7 @@ describe('/settings', () => { refresh: vi.fn(), }); const { router } = renderRoute('/settings'); - await waitForRoute(router, '/?returnTo=%2Fsettings'); + await waitForRoute(router, '/sign-in?returnTo=%2Fsettings'); }); it('shows the account to signed-in visitors', async () => { diff --git a/web/src/components/AppHeader/AppHeader.test.tsx b/web/src/components/AppHeader/AppHeader.test.tsx index 26f9b3e..b95a221 100644 --- a/web/src/components/AppHeader/AppHeader.test.tsx +++ b/web/src/components/AppHeader/AppHeader.test.tsx @@ -158,7 +158,7 @@ describe('AppHeader', () => { await screen.findByRole('link', { name: 'Sign in' }) ).toHaveAttribute( 'href', - `/?returnTo=${encodeURIComponent('/@alice.test')}` + `/sign-in?returnTo=${encodeURIComponent('/@alice.test')}` ); await userEvent.click( screen.getByRole('button', { name: 'Make your lanyard' }) diff --git a/web/src/components/AppHeader/AppHeader.tsx b/web/src/components/AppHeader/AppHeader.tsx index b0ed5a2..6755741 100644 --- a/web/src/components/AppHeader/AppHeader.tsx +++ b/web/src/components/AppHeader/AppHeader.tsx @@ -43,7 +43,11 @@ export function AppHeader({ } else if (signedOutActions && session.status === 'signedOut') { end = (
- + {t`Sign in`} -
+ {signIn && session.status === 'signedOut' && ( + + {t`Sign in`} + )} ); diff --git a/web/src/features/home/components/HomeHeader/HomeHeader.types.ts b/web/src/features/home/components/HomeHeader/HomeHeader.types.ts index 5d9123b..9287868 100644 --- a/web/src/features/home/components/HomeHeader/HomeHeader.types.ts +++ b/web/src/features/home/components/HomeHeader/HomeHeader.types.ts @@ -1,3 +1,5 @@ export type HomeHeaderProps = { + /** Offer Sign in; off on the sign-in page itself. */ + signIn?: boolean; className?: string; }; diff --git a/web/src/features/home/components/HomePage/HomePage.constants.ts b/web/src/features/home/components/HomePage/HomePage.constants.ts index a40cce6..e5b1efc 100644 --- a/web/src/features/home/components/HomePage/HomePage.constants.ts +++ b/web/src/features/home/components/HomePage/HomePage.constants.ts @@ -19,9 +19,6 @@ import { type Message = ReturnType; type Point = { title: Message; text: Message }; -/** The lanyard shown as a sample, live (#145). */ -export const SAMPLE_HANDLE = 'renderg.host'; - export const LINKS = { docs: DOCS_URL, github: 'https://github.com/renderghost/lanyards', diff --git a/web/src/features/home/components/HomePage/HomePage.styles.ts b/web/src/features/home/components/HomePage/HomePage.styles.ts index 12659ae..2d410d5 100644 --- a/web/src/features/home/components/HomePage/HomePage.styles.ts +++ b/web/src/features/home/components/HomePage/HomePage.styles.ts @@ -1,3 +1,9 @@ +import { + base as buttonBase, + sizes as buttonSizes, + tones as buttonTones, +} from '@/components/Button/Button.styles'; + // The brand's own page (#145), in the lanyard's palette pinned to brand // blue: the hanging badge edge to edge, then sections in billboard type, // then a billboard to close. Bold like the badge; quiet where it reads. @@ -12,13 +18,12 @@ export const body = /** As wide as a person's hero (spec §7). */ export const column = 'flex w-full max-w-[70rem] flex-col gap-20 md:gap-28'; -export const start = - 'grid items-start gap-10 md:grid-cols-[minmax(0,1fr)_375px] md:gap-16'; +/** The call to action's way in: sign in, or read more first (#157). */ +export const start = 'flex flex-wrap items-center gap-x-6 gap-y-4'; -export const signIn = 'flex flex-col gap-4'; +export const startLink = `${buttonBase} ${buttonTones.accent.primary} ${buttonSizes.lg} font-semibold`; -export const learnMore = - 'self-start text-base font-medium leading-6 underline-offset-4'; +export const startMore = 'text-base font-medium leading-6 underline-offset-4'; export const threeColumns = 'grid gap-5 md:grid-cols-3 md:gap-6'; @@ -39,6 +44,9 @@ export const ctaIntro = export const actions = 'flex flex-wrap gap-3'; +/** Create your lanyard: the badge's main button, as a link. */ +export const bannerLink = `${buttonBase} ${buttonTones.badge.primary} ${buttonSizes.lg}`; + /** Follow on Bluesky: the badge's secondary button, as a link. */ export const secondaryLink = 'inline-flex min-h-11 items-center justify-center rounded-sm border-2 border-on-accent px-4 text-base font-semibold leading-6 text-on-accent no-underline hover:bg-on-accent/10 hover:no-underline focus-visible:outline-(--focus-ring-on-accent)'; diff --git a/web/src/features/home/components/HomePage/HomePage.test.tsx b/web/src/features/home/components/HomePage/HomePage.test.tsx index 2416315..5c5ab9f 100644 --- a/web/src/features/home/components/HomePage/HomePage.test.tsx +++ b/web/src/features/home/components/HomePage/HomePage.test.tsx @@ -1,5 +1,4 @@ import { screen, within } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { useSession } from '@/features/auth/session/useSession'; @@ -12,17 +11,9 @@ vi.mock('@/features/auth/session/useSession', () => ({ useSession: vi.fn() })); const WIKI = 'https://github.com/renderghost/lanyards/wiki/'; -/** Stands in for the sign-in form, which the landing route provides. */ -const signIn = ( - -); - /** The homepage, once its router has loaded. */ async function home() { - const view = renderInRouter(, '/'); + const view = renderInRouter(, '/'); await screen.findByRole('heading', { level: 1 }); return view; } @@ -36,7 +27,7 @@ beforeEach(() => { }); describe('HomePage (#145)', () => { - it('welcomes visitors, with sign-in where Get started was', async () => { + it('welcomes visitors', async () => { const { container } = await home(); expect( screen.getByRole('heading', { level: 1, name: 'Welcome to Lanyards' }) @@ -49,14 +40,31 @@ describe('HomePage (#145)', () => { expect( screen.getByText(/collects your complete scholarly presence/) ).toBeInTheDocument(); + await expectNoAxeViolations(container); + }); + + // Sign-in has its own page: the homepage makes its case and points there. + it('leads with what Lanyards does, then a way in (#157)', async () => { + await home(); + const start = screen.getByRole('region', { + name: 'Everything you work on, in one link', + }); expect( - screen.getByRole('textbox', { name: 'Your handle' }) + within(start).getByText(/gathers your publications, talks/) ).toBeInTheDocument(); - expect(screen.getByRole('link', { name: /Learn more/ })).toHaveAttribute( - 'href', - WIKI - ); - await expectNoAxeViolations(container); + expect( + within(start).getByRole('link', { name: 'Sign in to get started' }) + ).toHaveAttribute('href', '/sign-in'); + expect( + within(start).getByRole('link', { name: /Learn more/ }) + ).toHaveAttribute('href', WIKI); + }); + + it('has no sign-in form and no live sample lanyard (#157)', async () => { + await home(); + expect(screen.queryByRole('combobox')).toBeNull(); + expect(screen.queryByRole('textbox')).toBeNull(); + expect(screen.queryByTitle('Sample lanyard')).toBeNull(); }); it('puts its own header on the blue, over the hanging badge (#151)', async () => { @@ -83,8 +91,8 @@ describe('HomePage (#145)', () => { expect( screen.getAllByRole('heading', { level: 2 }).map((h) => h.textContent) ).toEqual([ - // Sign-in, under the old "Get started" call to action. - 'Get started', + // The call to action, where the sign-in widget was (#157). + 'Everything you work on, in one link', 'The visibility paradox', 'One link, everything visible', 'Built for researchers', @@ -134,23 +142,11 @@ describe('HomePage (#145)', () => { expect(screen.getByText(/Decentralised, open, yours/)).toBeInTheDocument(); }); - it('shows a sample lanyard, live in a phone frame, and links to it', async () => { + it('takes “Create your lanyard” to the sign-in page (#157)', async () => { await home(); - const frame = screen.getByTitle('Sample lanyard'); - expect(frame.tagName).toBe('IFRAME'); - expect(frame).toHaveAttribute('src', '/renderg.host'); - expect(frame).toHaveAttribute('loading', 'lazy'); expect( - screen.getByRole('link', { name: /View sample profile/ }) - ).toHaveAttribute('href', '/renderg.host'); - }); - - it('takes “Create your lanyard” to the sign-in form', async () => { - await home(); - await userEvent.click( - screen.getByRole('button', { name: 'Create your lanyard' }) - ); - expect(screen.getByRole('textbox', { name: 'Your handle' })).toHaveFocus(); + screen.getByRole('link', { name: 'Create your lanyard' }) + ).toHaveAttribute('href', '/sign-in'); expect( screen.getByRole('link', { name: /Follow on Bluesky/ }) ).toHaveAttribute('href', 'https://bsky.app/profile/lanyards.app'); diff --git a/web/src/features/home/components/HomePage/HomePage.tsx b/web/src/features/home/components/HomePage/HomePage.tsx index bafa61a..e29ca1a 100644 --- a/web/src/features/home/components/HomePage/HomePage.tsx +++ b/web/src/features/home/components/HomePage/HomePage.tsx @@ -1,10 +1,9 @@ import { useLingui } from '@lingui/react/macro'; +import { Link } from '@tanstack/react-router'; import { useId } from 'react'; -import { Button } from '@/components/Button/Button'; import { CoverPattern } from '@/components/CoverPattern/CoverPattern'; import { ExternalLink } from '@/components/ExternalLink/ExternalLink'; -import { FIELD_ID } from '@/features/auth/components/SignInForm/SignInForm.constants'; import { cn } from '@/lib/utils'; import { BenefitList } from '../BenefitList/BenefitList'; @@ -13,31 +12,21 @@ import { HomeBadge } from '../HomeBadge/HomeBadge'; import { HomeBoard } from '../HomeBoard/HomeBoard'; import { HomeHeader } from '../HomeHeader/HomeHeader'; import { HomeSection } from '../HomeSection/HomeSection'; -import { SampleLanyard } from '../SampleLanyard/SampleLanyard'; -import { - BENEFITS, - FEATURES, - LINKS, - PARADOX, - SAMPLE_HANDLE, -} from './HomePage.constants'; +import { BENEFITS, FEATURES, LINKS, PARADOX } from './HomePage.constants'; import * as styles from './HomePage.styles'; import type { HomePageProps } from './HomePage.types'; /** * The homepage for people who aren't signed in: the old site's homepage - * (#145) in the new design language, with sign-in where its "Get started" - * button was. It wears brand blue whatever lanyard was last open, and - * draws its own header on that blue (#151). + * (#145) in the new design language. It makes its case and points to the + * sign-in page (#157). It wears brand blue whatever lanyard was last open, + * and draws its own header on that blue (#151). */ -export function HomePage({ signIn, className }: HomePageProps) { +export function HomePage({ className }: HomePageProps) { const { t, i18n } = useLingui(); const headingId = useId(); const ctaId = useId(); - // Focusing the handle field scrolls the sign-in form into view. - const toSignIn = () => document.getElementById(FIELD_ID)?.focus(); - return (
@@ -49,21 +38,21 @@ export function HomePage({ signIn, className }: HomePageProps) {
-
- {signIn} - - {t`Learn more`} - -
- + + {t`Sign in to get started`} + + + {t`Learn more`} +
@@ -125,9 +114,9 @@ export function HomePage({ signIn, className }: HomePageProps) { {t`Join researchers building their professional identity on open infrastructure.`}

- + { + it('shows a lanyard live in a phone frame, and links to it', () => { + renderWithProviders(); + const frame = screen.getByTitle('Sample lanyard'); + expect(frame.tagName).toBe('IFRAME'); + expect(frame).toHaveAttribute('src', '/renderg.host'); + expect(frame).toHaveAttribute('loading', 'lazy'); + expect( + screen.getByRole('link', { name: /View sample profile/ }) + ).toHaveAttribute('href', '/renderg.host'); + }); +}); diff --git a/web/src/features/home/components/SignInPage/SignInPage.constants.ts b/web/src/features/home/components/SignInPage/SignInPage.constants.ts new file mode 100644 index 0000000..346ccd2 --- /dev/null +++ b/web/src/features/home/components/SignInPage/SignInPage.constants.ts @@ -0,0 +1,7 @@ +import type { Accent } from '@/design/accents'; +import type { CoverPattern } from '@/design/covers'; + +/** Lanyards' own badge, as on the homepage: lime on brand blue. */ +export const BADGE_ACCENT: Accent = 'lime'; + +export const COVER: CoverPattern = 'arrows'; diff --git a/web/src/features/home/components/SignInPage/SignInPage.styles.ts b/web/src/features/home/components/SignInPage/SignInPage.styles.ts new file mode 100644 index 0000000..a255d0a --- /dev/null +++ b/web/src/features/home/components/SignInPage/SignInPage.styles.ts @@ -0,0 +1,44 @@ +// The sign-in page (#157): the form on a badge, hanging on the brand blue +// as the homepage's does, but straight and still so the form is easy to +// use. The badge's tokens are the same in light and dark; the form keeps +// the app's own palette in a panel on the badge. + +/** The page's ground: brand blue (the blue palette's accent). */ +export const page = 'relative flex min-h-dvh flex-col bg-accent'; + +export const main = + 'flex flex-1 flex-col items-center px-4 pb-14 md:px-8 md:pb-20'; + +export const hang = 'flex w-full max-w-[34rem] flex-col items-center'; + +export const straps = 'h-24 w-[10rem] md:h-32 md:w-[12.5rem]'; + +export const badge = + '@container flex w-full flex-col overflow-hidden rounded-sm bg-accent text-on-accent shadow-[0_2px_4px_rgb(6_1_30/0.2),0_12px_24px_rgb(6_1_30/0.2),0_32px_64px_rgb(6_1_30/0.3)]'; + +export const cover = 'relative h-24 @min-[30rem]:h-28'; + +/** Where the clip goes through the badge: the ground shows through. */ +export const slot = + 'absolute left-1/2 top-3 h-3 w-14 -translate-x-1/2 rounded-sm bg-qr-ground shadow-[inset_0_2px_3px_rgb(6_1_30/0.4)]'; + +export const field = + 'flex flex-col gap-4 px-5 pb-6 @min-[30rem]:px-8 @min-[30rem]:pb-8'; + +/** Half the logo's height: the other half overlaps the cover. */ +export const logoBox = 'h-10 @min-[30rem]:h-12'; + +export const logo = + 'size-20 -translate-y-1/2 shadow-[0_0_0_6px_var(--accent)] @min-[30rem]:size-24'; + +export const heading = + 'text-[clamp(2.5rem,12cqi,3.75rem)] font-extrabold leading-[0.9] tracking-[-0.04em]'; + +export const lede = 'max-w-[34ch] text-lg font-medium leading-7'; + +/** The form keeps the app's own palette: a card on the badge, full width. */ +export const form = 'max-w-none shadow-[0_1px_2px_rgb(6_1_30/0.15)]'; + +/** While the session loads: the same card, saying so. */ +export const loading = + 'rounded-sm border border-ui-border bg-ui-surface p-6 text-[15px] leading-[22px] text-ui-text-muted'; diff --git a/web/src/features/home/components/SignInPage/SignInPage.test.tsx b/web/src/features/home/components/SignInPage/SignInPage.test.tsx new file mode 100644 index 0000000..50d5058 --- /dev/null +++ b/web/src/features/home/components/SignInPage/SignInPage.test.tsx @@ -0,0 +1,109 @@ +import { screen, waitFor, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import { useSession } from '@/features/auth/session/useSession'; +import { startSignIn, startSignUp } from '@/lib/atproto/session'; +import { expectNoAxeViolations } from '@/test/axe'; +import { ADA } from '@/test/people'; +import { signedInSession } from '@/test/person'; +import { renderInRouter } from '@/test/router'; + +import { SignInPage } from './SignInPage'; + +vi.mock('@/features/auth/session/useSession', () => ({ useSession: vi.fn() })); +vi.mock('@/lib/atproto/session', async (importOriginal) => ({ + ...(await importOriginal()), + startSignIn: vi.fn(() => Promise.resolve()), + startSignUp: vi.fn(() => Promise.resolve()), +})); + +const signedOut = () => + vi.mocked(useSession).mockReturnValue({ + status: 'signedOut', + signOut: vi.fn(), + refresh: vi.fn(), + }); + +const page = (returnTo = '/settings') => + renderInRouter( + , + `/sign-in?returnTo=${encodeURIComponent(returnTo)}` + ); + +beforeEach(() => { + signedOut(); +}); + +describe('SignInPage (#157)', () => { + it('puts the sign-in form on a badge, with the typeahead', async () => { + const { container } = page(); + expect( + await screen.findByRole('heading', { level: 1, name: 'Sign in' }) + ).toBeInTheDocument(); + expect( + screen.getByRole('combobox', { name: 'Your handle' }) + ).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'Create an account' }) + ).toBeInTheDocument(); + expect(document.title).toBe('Sign in · Lanyards'); + await expectNoAxeViolations(container); + }); + + it('has the homepage’s header, without a Sign in link to itself', async () => { + page(); + const banner = await screen.findByRole('banner'); + expect( + within(banner).getByRole('link', { name: 'Lanyards' }) + ).toHaveAttribute('href', '/'); + expect(within(banner).queryByRole('link', { name: 'Sign in' })).toBeNull(); + expect(screen.getByRole('main')).not.toContainElement(banner); + }); + + it('signs in, coming back to where the person was', async () => { + page(); + await userEvent.type( + await screen.findByRole('combobox', { name: 'Your handle' }), + 'alice.bsky.social' + ); + await userEvent.click(screen.getByRole('button', { name: 'Sign in' })); + expect(startSignIn).toHaveBeenCalledWith('alice.bsky.social', '/settings'); + }); + + it('creates an account, coming back to where the person was', async () => { + page(); + await userEvent.click( + await screen.findByRole('button', { name: 'Create an account' }) + ); + expect(startSignUp).toHaveBeenCalledWith('/settings'); + }); + + it('says it’s loading while the session loads', async () => { + vi.mocked(useSession).mockReturnValue({ + status: 'loading', + signOut: vi.fn(), + refresh: vi.fn(), + }); + page(); + expect(await screen.findByRole('status')).toHaveTextContent('Loading…'); + expect(screen.queryByRole('combobox')).toBeNull(); + }); + + it('sends someone already signed in on to where they were going', async () => { + vi.mocked(useSession).mockReturnValue(signedInSession(ADA.did)); + const { router } = page(); + await waitFor(() => + expect(router.state.location.pathname).toBe('/settings') + ); + }); + + it('sends someone already signed in to their lanyard by default', async () => { + vi.mocked(useSession).mockReturnValue(signedInSession(ADA.did)); + const { router } = page('/'); + await waitFor(() => + expect(router.state.location.pathname).toBe('/lanyard') + ); + }); +}); diff --git a/web/src/features/home/components/SignInPage/SignInPage.tsx b/web/src/features/home/components/SignInPage/SignInPage.tsx new file mode 100644 index 0000000..6126b1a --- /dev/null +++ b/web/src/features/home/components/SignInPage/SignInPage.tsx @@ -0,0 +1,74 @@ +import { useLingui } from '@lingui/react/macro'; +import { useRouter } from '@tanstack/react-router'; +import { useEffect, useId } from 'react'; + +import { CoverPattern } from '@/components/CoverPattern/CoverPattern'; +import { Logo } from '@/components/Logo/Logo'; +import { SIGNED_IN_HOME } from '@/features/auth/components/LandingPage/LandingPage.constants'; +import { SignInForm } from '@/features/auth/components/SignInForm/SignInForm'; +import { useSession } from '@/features/auth/session/useSession'; +import { LanyardStraps } from '@/features/qr/components/LanyardStraps/LanyardStraps'; +import { useDocumentTitle } from '@/hooks/useDocumentTitle'; +import { safeReturnTo } from '@/lib/atproto/oauthConfig'; + +import { HomeHeader } from '../HomeHeader/HomeHeader'; +import { BADGE_ACCENT, COVER } from './SignInPage.constants'; +import * as styles from './SignInPage.styles'; +import type { SignInPageProps } from './SignInPage.types'; + +/** + * `/sign-in` (#157): the sign-in form, with its handle typeahead, on a + * badge hanging on the brand blue. Signed in already, it sends people on + * to where they were going. + */ +export function SignInPage({ returnTo }: SignInPageProps) { + const { t } = useLingui(); + const session = useSession(); + const router = useRouter(); + const headingId = useId(); + useDocumentTitle(t`Sign in`); + const safe = safeReturnTo(returnTo); + const destination = safe === '/' ? SIGNED_IN_HOME : safe; + const signedIn = session.status === 'signedIn'; + + useEffect(() => { + // destination is a validated same-origin path, which may not be a typed + // route, so use the history directly. + if (signedIn) router.history.replace(destination); + }, [signedIn, destination, router]); + + return ( +
+ +
+
+ +
+
+ +
+
+
+ +
+

+ {t`Sign in`} +

+

+ {t`Use your handle from Bluesky or any other AT Protocol app. New here? Create an account, and it’s yours to take anywhere.`} +

+ {session.status === 'signedOut' ? ( + + ) : ( +

+ {t`Loading…`} +

+ )} +
+
+
+
+
+ ); +} diff --git a/web/src/features/home/components/SignInPage/SignInPage.types.ts b/web/src/features/home/components/SignInPage/SignInPage.types.ts new file mode 100644 index 0000000..57f15e4 --- /dev/null +++ b/web/src/features/home/components/SignInPage/SignInPage.types.ts @@ -0,0 +1,4 @@ +export type SignInPageProps = { + /** Where to land after signing in; already a safe, same-origin path. */ + returnTo: string; +}; diff --git a/web/src/features/lanyard/components/LanyardPage/LanyardPage.tsx b/web/src/features/lanyard/components/LanyardPage/LanyardPage.tsx index fe2657a..661eec7 100644 --- a/web/src/features/lanyard/components/LanyardPage/LanyardPage.tsx +++ b/web/src/features/lanyard/components/LanyardPage/LanyardPage.tsx @@ -94,7 +94,7 @@ export function LanyardPage({

{t`This person has chosen to show their lanyard only to people who are signed in.`}

- + {t`Sign in`} diff --git a/web/src/features/lanyard/customise/CustomisePage/CustomisePage.tsx b/web/src/features/lanyard/customise/CustomisePage/CustomisePage.tsx index 147558c..d4d84ae 100644 --- a/web/src/features/lanyard/customise/CustomisePage/CustomisePage.tsx +++ b/web/src/features/lanyard/customise/CustomisePage/CustomisePage.tsx @@ -53,7 +53,7 @@ export function CustomisePage({ // Signed out: sign in, then come back to this page. Once, from where // they are: the page is still here while the sign-in page loads. const signIn = useEffectEvent(() => { - router.history.replace(`/?returnTo=${encodeURIComponent(path)}`); + router.history.replace(`/sign-in?returnTo=${encodeURIComponent(path)}`); }); useEffect(() => { if (signedOut) signIn(); diff --git a/web/src/i18n/locales/en-GB/messages.po b/web/src/i18n/locales/en-GB/messages.po index 9a8c198..d8f3938 100644 --- a/web/src/i18n/locales/en-GB/messages.po +++ b/web/src/i18n/locales/en-GB/messages.po @@ -113,7 +113,7 @@ msgstr "Add this link to the Websites & social links section of your ORCID recor msgid "Add your ORCID iD on Sifa to show verified publications." msgstr "Add your ORCID iD on Sifa to show verified publications." -#: src/features/home/components/HomePage/HomePage.constants.ts:67 +#: src/features/home/components/HomePage/HomePage.constants.ts:64 msgid "Affiliations, qualifications, and skills presented with proper academic aesthetic." msgstr "Affiliations, qualifications, and skills presented with proper academic aesthetic." @@ -138,7 +138,7 @@ msgid "Articles" msgstr "Articles" #: src/features/home/components/HomeBadge/HomeBadge.constants.ts:17 -#: src/features/home/components/HomePage/HomePage.constants.ts:102 +#: src/features/home/components/HomePage/HomePage.constants.ts:99 msgid "AT Protocol" msgstr "AT Protocol" @@ -146,7 +146,7 @@ msgstr "AT Protocol" msgid "Audio" msgstr "Audio" -#: src/features/home/components/HomePage/HomePage.constants.ts:87 +#: src/features/home/components/HomePage/HomePage.constants.ts:84 msgid "Auto-ingestion" msgstr "Auto-ingestion" @@ -195,7 +195,7 @@ msgstr "Bluesky isn't answering right now. Check your connection and try again." msgid "Board positions" msgstr "Board positions" -#: src/features/home/components/HomePage/HomePage.tsx:105 +#: src/features/home/components/HomePage/HomePage.tsx:94 msgid "Built for researchers" msgstr "Built for researchers" @@ -203,11 +203,11 @@ msgstr "Built for researchers" msgid "Built on" msgstr "Built on" -#: src/features/home/components/HomePage/HomePage.constants.ts:122 +#: src/features/home/components/HomePage/HomePage.constants.ts:119 msgid "Built on AT Protocol—transparent, inspectable, and aligned with academic values of openness and reusability." msgstr "Built on AT Protocol—transparent, inspectable, and aligned with academic values of openness and reusability." -#: src/features/home/components/HomePage/HomePage.tsx:144 +#: src/features/home/components/HomePage/HomePage.tsx:133 msgid "Built on the AT Protocol" msgstr "Built on the AT Protocol" @@ -219,11 +219,11 @@ msgstr "Cancel" msgid "Capture this screen" msgstr "Capture this screen" -#: src/features/home/components/HomePage/HomePage.constants.ts:117 +#: src/features/home/components/HomePage/HomePage.constants.ts:114 msgid "Career continuity" msgstr "Career continuity" -#: src/features/home/components/HomePage/HomePage.tsx:73 +#: src/features/home/components/HomePage/HomePage.tsx:62 msgid "Career progression demands comprehensive online presence, but maintaining it is administratively overwhelming." msgstr "Career progression demands comprehensive online presence, but maintaining it is administratively overwhelming." @@ -282,11 +282,11 @@ msgstr "Collections" msgid "Commissions" msgstr "Commissions" -#: src/features/home/components/HomePage/HomePage.constants.ts:113 +#: src/features/home/components/HomePage/HomePage.constants.ts:110 msgid "Complete visibility" msgstr "Complete visibility" -#: src/features/home/components/HomePage/HomePage.constants.ts:81 +#: src/features/home/components/HomePage/HomePage.constants.ts:78 msgid "Connect all your academic and social profiles in one place." msgstr "Connect all your academic and social profiles in one place." @@ -294,15 +294,15 @@ msgstr "Connect all your academic and social profiles in one place." msgid "Connect on Bluesky" msgstr "Connect on Bluesky" -#: src/features/home/components/HomePage/HomePage.constants.ts:88 +#: src/features/home/components/HomePage/HomePage.constants.ts:85 msgid "Connect ORCID, and your publications appear automatically." msgstr "Connect ORCID, and your publications appear automatically." -#: src/features/home/components/HomePage/HomePage.constants.ts:43 +#: src/features/home/components/HomePage/HomePage.constants.ts:40 msgid "Constant maintenance" msgstr "Constant maintenance" -#: src/features/home/components/HomePage/HomePage.tsx:165 +#: src/features/home/components/HomePage/HomePage.tsx:154 msgid "Contact" msgstr "Contact" @@ -369,12 +369,12 @@ msgstr "Couldn't show this block" msgid "Couldn't start account creation. Please try again." msgstr "Couldn't start account creation. Please try again." -#: src/features/auth/components/SignInForm/SignInForm.tsx:80 +#: src/features/auth/components/SignInForm/SignInForm.tsx:81 msgid "Couldn't start creating an account. Please try again." msgstr "Couldn't start creating an account. Please try again." #: src/features/auth/components/PermissionNotice/PermissionNotice.tsx:40 -#: src/features/auth/components/SignInForm/SignInForm.tsx:69 +#: src/features/auth/components/SignInForm/SignInForm.tsx:70 #: src/features/feedback/components/FeedbackDialog/FeedbackDialog.tsx:149 msgid "Couldn't start sign-in. Please try again." msgstr "Couldn't start sign-in. Please try again." @@ -388,15 +388,15 @@ msgstr "Couldn't use that image. Please try another." msgid "Cover" msgstr "Cover" -#: src/features/auth/components/SignInForm/SignInForm.tsx:111 +#: src/features/auth/components/SignInForm/SignInForm.tsx:116 msgid "Create an account" msgstr "Create an account" -#: src/features/home/components/HomePage/HomePage.tsx:129 +#: src/features/home/components/HomePage/HomePage.tsx:118 msgid "Create your lanyard" msgstr "Create your lanyard" -#: src/components/AppHeader/AppHeader.tsx:75 +#: src/components/AppHeader/AppHeader.tsx:79 #: src/components/MobileNav/MobileNav.tsx:42 msgid "Customise" msgstr "Customise" @@ -405,7 +405,7 @@ msgstr "Customise" msgid "Customise your lanyard" msgstr "Customise your lanyard" -#: src/features/home/components/HomePage/HomePage.constants.ts:103 +#: src/features/home/components/HomePage/HomePage.constants.ts:100 msgid "Decentralised, open, yours—no platform lock-in or data silos." msgstr "Decentralised, open, yours—no platform lock-in or data silos." @@ -431,7 +431,7 @@ msgid "Discard your unsaved changes?" msgstr "Discard your unsaved changes?" #: src/features/feedback/components/SupportLinks/SupportLinks.tsx:54 -#: src/features/home/components/HomePage/HomePage.tsx:151 +#: src/features/home/components/HomePage/HomePage.tsx:140 msgid "Documentation" msgstr "Documentation" @@ -479,6 +479,10 @@ msgstr "Enter your handle" msgid "Enter your handle, not your email — for example alice.bsky.social" msgstr "Enter your handle, not your email — for example alice.bsky.social" +#: src/features/home/components/HomePage/HomePage.tsx:42 +msgid "Everything you work on, in one link" +msgstr "Everything you work on, in one link" + #: src/features/lanyard/hooks/useFollow.ts:96 msgid "Failed to follow. Please try again." msgstr "Failed to follow. Please try again." @@ -508,7 +512,7 @@ msgstr "Follow" msgid "Follow @{BLUESKY_HANDLE} on Bluesky" msgstr "Follow @{BLUESKY_HANDLE} on Bluesky" -#: src/features/home/components/HomePage/HomePage.tsx:136 +#: src/features/home/components/HomePage/HomePage.tsx:125 #: src/features/lanyard/components/HeroActions/HeroActions.tsx:60 msgid "Follow on Bluesky" msgstr "Follow on Bluesky" @@ -549,7 +553,7 @@ msgstr "Following" msgid "For" msgstr "For" -#: src/features/auth/components/SignInForm/SignInForm.tsx:89 +#: src/features/auth/components/SignInForm/SignInForm.tsx:94 msgid "For example alice.bsky.social" msgstr "For example alice.bsky.social" @@ -557,11 +561,11 @@ msgstr "For example alice.bsky.social" msgid "Full-time roles" msgstr "Full-time roles" -#: src/features/home/components/HomePage/HomePage.tsx:53 +#: src/features/home/components/HomePage/HomePage.tsx:41 msgid "Get started" msgstr "Get started" -#: src/features/home/components/HomePage/HomePage.tsx:158 +#: src/features/home/components/HomePage/HomePage.tsx:147 msgid "GitHub" msgstr "GitHub" @@ -607,7 +611,7 @@ msgstr "Host" msgid "Include technical details" msgstr "Include technical details" -#: src/features/home/components/HomePage/HomePage.constants.ts:40 +#: src/features/home/components/HomePage/HomePage.constants.ts:37 msgid "Informal work like preprints, datasets, ongoing projects, and social engagement doesn’t fit existing academic infrastructure." msgstr "Informal work like preprints, datasets, ongoing projects, and social engagement doesn’t fit existing academic infrastructure." @@ -619,7 +623,7 @@ msgstr "Interview" msgid "Items to show for {name}" msgstr "Items to show for {name}" -#: src/features/home/components/HomePage/HomePage.tsx:125 +#: src/features/home/components/HomePage/HomePage.tsx:114 msgid "Join researchers building their professional identity on open infrastructure." msgstr "Join researchers building their professional identity on open infrastructure." @@ -683,15 +687,15 @@ msgstr "Lanyards needs your permission" msgid "Lanyards needs your permission to post feedback" msgstr "Lanyards needs your permission to post feedback" -#: src/features/home/components/HomePage/HomePage.tsx:86 +#: src/features/home/components/HomePage/HomePage.tsx:75 msgid "Lanyards pulls together your complete scholarly presence with zero maintenance overhead." msgstr "Lanyards pulls together your complete scholarly presence with zero maintenance overhead." -#: src/features/home/components/HomePage/HomePage.tsx:63 +#: src/features/home/components/HomePage/HomePage.tsx:54 msgid "Learn more" msgstr "Learn more" -#: src/features/home/components/HomePage/HomePage.constants.ts:109 +#: src/features/home/components/HomePage/HomePage.constants.ts:106 msgid "Less admin, more research" msgstr "Less admin, more research" @@ -721,8 +725,8 @@ msgid "Loading your profile…" msgstr "Loading your profile…" #: src/features/account/components/SettingsPage/SettingsPage.tsx:28 -#: src/features/auth/components/LandingPage/LandingPage.tsx:45 #: src/features/feedback/components/FeedbackDialog/FeedbackDialog.tsx:246 +#: src/features/home/components/SignInPage/SignInPage.tsx:65 #: src/features/lanyard/customise/CustomisePage/CustomisePage.tsx:68 #: src/features/qr/components/SharePage/SharePage.tsx:41 msgid "Loading…" @@ -736,8 +740,7 @@ msgstr "Location" msgid "Location and languages" msgstr "Location and languages" -#: src/components/AppHeader/AppHeader.tsx:54 -#: src/features/home/components/HomeHeader/HomeHeader.tsx:54 +#: src/components/AppHeader/AppHeader.tsx:58 msgid "Make your lanyard" msgstr "Make your lanyard" @@ -753,7 +756,7 @@ msgstr "Message us privately on Signal:" msgid "Mint" msgstr "Mint" -#: src/features/home/components/HomePage/HomePage.constants.ts:39 +#: src/features/home/components/HomePage/HomePage.constants.ts:36 msgid "Missing context" msgstr "Missing context" @@ -769,11 +772,11 @@ msgstr "Move {name} down" msgid "Move {name} up" msgstr "Move {name} up" -#: src/features/home/components/HomePage/HomePage.constants.ts:114 +#: src/features/home/components/HomePage/HomePage.constants.ts:111 msgid "New connections see the full scope of your work immediately—from formal publications to informal contributions that drive real connections." msgstr "New connections see the full scope of your work immediately—from formal publications to informal contributions that drive real connections." -#: src/features/home/components/HomePage/HomePage.constants.ts:47 +#: src/features/home/components/HomePage/HomePage.constants.ts:44 msgid "No single truth" msgstr "No single truth" @@ -800,11 +803,11 @@ msgstr "Nothing to show yet" msgid "Now" msgstr "Now" -#: src/features/home/components/HomePage/HomePage.tsx:85 +#: src/features/home/components/HomePage/HomePage.tsx:74 msgid "One link, everything visible" msgstr "One link, everything visible" -#: src/features/home/components/HomePage/HomePage.constants.ts:121 +#: src/features/home/components/HomePage/HomePage.constants.ts:118 msgid "Open infrastructure" msgstr "Open infrastructure" @@ -829,7 +832,7 @@ msgstr "Orb" msgid "ORCID" msgstr "ORCID" -#: src/features/home/components/HomePage/HomePage.constants.ts:36 +#: src/features/home/components/HomePage/HomePage.constants.ts:33 msgid "ORCID for publications, ResearchGate for networking, personal website for informal work, Twitter for visibility, conference sites for talks—each needs manual updates." msgstr "ORCID for publications, ResearchGate for networking, personal website for informal work, Twitter for visibility, conference sites for talks—each needs manual updates." @@ -895,7 +898,7 @@ msgstr "Podcasts and videos" msgid "Post on Bluesky, {date}" msgstr "Post on Bluesky, {date}" -#: src/features/home/components/HomePage/HomePage.tsx:106 +#: src/features/home/components/HomePage/HomePage.tsx:95 msgid "Powerful tools designed for academic needs, not corporate networking." msgstr "Powerful tools designed for academic needs, not corporate networking." @@ -907,7 +910,7 @@ msgstr "Preparing screenshot…" msgid "Preview" msgstr "Preview" -#: src/features/home/components/HomePage/HomePage.constants.ts:66 +#: src/features/home/components/HomePage/HomePage.constants.ts:63 msgid "Professional identity" msgstr "Professional identity" @@ -915,11 +918,11 @@ msgstr "Professional identity" msgid "Publications" msgstr "Publications" -#: src/features/home/components/HomePage/HomePage.constants.ts:74 +#: src/features/home/components/HomePage/HomePage.constants.ts:71 msgid "Publications, talks, and events—both formal and informal contributions." msgstr "Publications, talks, and events—both formal and informal contributions." -#: src/features/home/components/HomePage/HomePage.constants.ts:95 +#: src/features/home/components/HomePage/HomePage.constants.ts:92 msgid "Put your work in the order you want, and hide what’s not relevant." msgstr "Put your work in the order you want, and hide what’s not relevant." @@ -927,7 +930,7 @@ msgstr "Put your work in the order you want, and hide what’s not relevant." msgid "QR code for {value}" msgstr "QR code for {value}" -#: src/features/home/components/HomePage/HomePage.tsx:122 +#: src/features/home/components/HomePage/HomePage.tsx:111 msgid "Ready to simplify your research presence?" msgstr "Ready to simplify your research presence?" @@ -952,11 +955,11 @@ msgstr "Reorder {name}" msgid "Reordering cancelled. {name} stayed where it was." msgstr "Reordering cancelled. {name} stayed where it was." -#: src/features/home/components/HomePage/HomePage.constants.ts:73 +#: src/features/home/components/HomePage/HomePage.constants.ts:70 msgid "Research outputs" msgstr "Research outputs" -#: src/features/auth/components/LandingPage/LandingPage.tsx:26 +#: src/features/auth/components/LandingPage/LandingPage.tsx:20 msgid "Researcher profiles on the AT Protocol" msgstr "Researcher profiles on the AT Protocol" @@ -1001,7 +1004,7 @@ msgstr "Saving…" msgid "Scan to see my lanyard" msgstr "Scan to see my lanyard" -#: src/features/home/components/HomePage/HomePage.constants.ts:35 +#: src/features/home/components/HomePage/HomePage.constants.ts:32 msgid "Scattered presence" msgstr "Scattered presence" @@ -1071,25 +1074,30 @@ msgstr "Show what you’re open to" msgid "Sifa" msgstr "Sifa" -#: src/components/AppHeader/AppHeader.tsx:47 +#: src/components/AppHeader/AppHeader.tsx:51 #: src/features/auth/components/CallbackStatus/CallbackStatus.tsx:22 #: src/features/auth/components/CallbackStatus/CallbackStatus.tsx:32 -#: src/features/auth/components/LandingPage/LandingPage.tsx:26 -#: src/features/auth/components/SignInForm/SignInForm.tsx:104 -#: src/features/home/components/HomeHeader/HomeHeader.tsx:46 +#: src/features/auth/components/SignInForm/SignInForm.tsx:109 +#: src/features/home/components/HomeHeader/HomeHeader.tsx:28 +#: src/features/home/components/SignInPage/SignInPage.tsx:29 +#: src/features/home/components/SignInPage/SignInPage.tsx:56 #: src/features/lanyard/components/LanyardPage/LanyardPage.tsx:98 msgid "Sign in" msgstr "Sign in" -#: src/features/home/components/HomePage/HomePage.tsx:52 -msgid "Sign in or sign up" -msgstr "Sign in or sign up" +#: src/features/home/components/HomePage/HomePage.tsx:47 +msgid "Sign in to get started" +msgstr "Sign in to get started" #: src/features/lanyard/components/LanyardPage/LanyardPage.tsx:60 #: src/features/lanyard/components/LanyardPage/LanyardPage.tsx:93 msgid "Sign in to see this lanyard" msgstr "Sign in to see this lanyard" +#: src/features/home/components/HomePage/HomePage.tsx:43 +msgid "Sign in with your Bluesky handle, or any AT Protocol account, and Lanyards gathers your publications, talks, affiliations and profiles into one lanyard to share anywhere: on a conference badge, in an email signature, on a slide." +msgstr "Sign in with your Bluesky handle, or any AT Protocol account, and Lanyards gathers your publications, talks, affiliations and profiles into one lanyard to share anywhere: on a conference badge, in an email signature, on a slide." + #: src/features/account/components/AccountCard/AccountCard.tsx:43 msgid "Sign out" msgstr "Sign out" @@ -1130,7 +1138,7 @@ msgstr "Skills" msgid "Social posts" msgstr "Social posts" -#: src/features/home/components/HomePage/HomePage.constants.ts:80 +#: src/features/home/components/HomePage/HomePage.constants.ts:77 msgid "Social presence" msgstr "Social presence" @@ -1197,15 +1205,15 @@ msgstr "That doesn't look like a handle — for example alice.bsky.social" msgid "The curated link for academic researchers that collects your complete scholarly presence—publications, talks, affiliations, and social profiles." msgstr "The curated link for academic researchers that collects your complete scholarly presence—publications, talks, affiliations, and social profiles." -#: src/features/home/components/HomePage/HomePage.tsx:71 +#: src/features/home/components/HomePage/HomePage.tsx:60 msgid "The problem" msgstr "The problem" -#: src/features/home/components/HomePage/HomePage.tsx:72 +#: src/features/home/components/HomePage/HomePage.tsx:61 msgid "The visibility paradox" msgstr "The visibility paradox" -#: src/features/home/components/HomePage/HomePage.constants.ts:48 +#: src/features/home/components/HomePage/HomePage.constants.ts:45 msgid "There’s no single place that represents your complete, current scholarly identity when opportunities arise." msgstr "There’s no single place that represents your complete, current scholarly identity when opportunities arise." @@ -1237,7 +1245,7 @@ msgstr "This sign-in link has expired or was already used." msgid "TikTok" msgstr "TikTok" -#: src/features/home/components/HomePage/HomePage.constants.ts:44 +#: src/features/home/components/HomePage/HomePage.constants.ts:41 msgid "Time spent updating multiple platforms is time not spent on research. Each change requires logging into different systems." msgstr "Time spent updating multiple platforms is time not spent on research. Each change requires logging into different systems." @@ -1291,7 +1299,7 @@ msgstr "Up to 4. Choose, paste or drop images." msgid "Update" msgstr "Update" -#: src/features/home/components/HomePage/HomePage.constants.ts:110 +#: src/features/home/components/HomePage/HomePage.constants.ts:107 msgid "Update once, share everywhere. No more Sunday afternoons updating ten different websites or managing multiple link collections." msgstr "Update once, share everywhere. No more Sunday afternoons updating ten different websites or managing multiple link collections." @@ -1299,6 +1307,10 @@ msgstr "Update once, share everywhere. No more Sunday afternoons updating ten di msgid "Updating your podcasts and videos…" msgstr "Updating your podcasts and videos…" +#: src/features/home/components/SignInPage/SignInPage.tsx:59 +msgid "Use your handle from Bluesky or any other AT Protocol app. New here? Create an account, and it’s yours to take anywhere." +msgstr "Use your handle from Bluesky or any other AT Protocol app. New here? Create an account, and it’s yours to take anywhere." + #: src/features/lanyard/components/BlockSection/BlockSection.constants.ts:13 msgid "UserInput" msgstr "UserInput" @@ -1319,8 +1331,8 @@ msgstr "Verify your ORCID iD" msgid "Video" msgstr "Video" -#: src/components/AppHeader/AppHeader.tsx:85 -#: src/components/AppHeader/AppHeader.tsx:95 +#: src/components/AppHeader/AppHeader.tsx:89 +#: src/components/AppHeader/AppHeader.tsx:99 #: src/components/MobileNav/MobileNav.tsx:52 #: src/components/MobileNav/MobileNav.tsx:62 msgid "View" @@ -1387,7 +1399,7 @@ msgstr "What happened, and what did you expect? Steps to repeat it help." msgid "What is this about?" msgstr "What is this about?" -#: src/features/home/components/HomePage/HomePage.tsx:84 +#: src/features/home/components/HomePage/HomePage.tsx:73 msgid "What you get" msgstr "What you get" @@ -1395,7 +1407,7 @@ msgstr "What you get" msgid "What you share" msgstr "What you share" -#: src/features/home/components/HomePage/HomePage.tsx:104 +#: src/features/home/components/HomePage/HomePage.tsx:93 msgid "Why Lanyards" msgstr "Why Lanyards" @@ -1415,7 +1427,7 @@ msgstr "You follow each other" msgid "You have unsaved changes. Leave without saving?" msgstr "You have unsaved changes. Leave without saving?" -#: src/features/auth/components/SignInForm/SignInForm.tsx:100 +#: src/features/auth/components/SignInForm/SignInForm.tsx:105 msgid "You're offline. Connect to sign in." msgstr "You're offline. Connect to sign in." @@ -1434,7 +1446,7 @@ msgstr "You've been signed out. Please sign in again." msgid "Your account" msgstr "Your account" -#: src/features/home/components/HomePage/HomePage.constants.ts:94 +#: src/features/home/components/HomePage/HomePage.constants.ts:91 msgid "Your control" msgstr "Your control" @@ -1450,7 +1462,7 @@ msgstr "Your feedback is on our board, where you can follow what happens to it." msgid "Your feedback is posted from your own account to our board on UserInput. To do that, Lanyards needs permission to post there and upload your screenshots." msgstr "Your feedback is posted from your own account to our board on UserInput. To do that, Lanyards needs permission to post there and upload your screenshots." -#: src/features/auth/components/SignInForm/SignInForm.tsx:88 +#: src/features/auth/components/SignInForm/SignInForm.tsx:93 msgid "Your handle" msgstr "Your handle" @@ -1459,7 +1471,7 @@ msgstr "Your handle" msgid "Your lanyard" msgstr "Your lanyard" -#: src/components/AppHeader/AppHeader.tsx:67 +#: src/components/AppHeader/AppHeader.tsx:71 #: src/components/MobileNav/MobileNav.tsx:30 msgid "Your Lanyards" msgstr "Your Lanyards" @@ -1472,7 +1484,7 @@ msgstr "Your ORCID iD is verified" msgid "Your podcasts and videos were updated to the new format." msgstr "Your podcasts and videos were updated to the new format." -#: src/features/home/components/HomePage/HomePage.constants.ts:118 +#: src/features/home/components/HomePage/HomePage.constants.ts:115 msgid "Your research identity stays with you across institutions. No more losing control when changing positions." msgstr "Your research identity stays with you across institutions. No more losing control when changing positions." diff --git a/web/src/lib/atproto/oauthConfig.ts b/web/src/lib/atproto/oauthConfig.ts index 42f4646..3f8634a 100644 --- a/web/src/lib/atproto/oauthConfig.ts +++ b/web/src/lib/atproto/oauthConfig.ts @@ -30,8 +30,12 @@ export const FALLBACK_SCOPE = 'atproto transition:generic'; /** Everything the client may request, declared in its metadata. */ export const CLIENT_SCOPE = `${GRANULAR_SCOPE} ${FEEDBACK_SCOPE} transition:generic`; -/** Where new accounts are created when someone has no AT Protocol account. */ -export const SIGN_UP_PDS = 'https://bsky.social'; +/** + * Where new accounts are created when someone has no AT Protocol account: + * mu.social, whose accounts live on the Eurosky PDS (#157). Its server, + * eurosky.social, supports OAuth account creation (prompt=create). + */ +export const SIGN_UP_PDS = 'https://pds.mu.social'; export const REDIRECT_PATH = '/oauth/callback'; export const METADATA_PATH = '/oauth-client-metadata.json'; diff --git a/web/src/lib/atproto/session.test.ts b/web/src/lib/atproto/session.test.ts index b22136b..9c1988e 100644 --- a/web/src/lib/atproto/session.test.ts +++ b/web/src/lib/atproto/session.test.ts @@ -180,13 +180,14 @@ describe('isUnknownAccountError', () => { }); describe('startSignUp', () => { - it('opens account creation at bsky.social', async () => { + // mu.social's accounts live on the Eurosky PDS (#157). + it('opens account creation on mu.social', async () => { vi.mocked(createAuthorizationUrl).mockResolvedValue( - new URL('https://bsky.social/oauth/authorize') + new URL('https://eurosky.social/oauth/authorize') ); await startSignUp('/settings'); expect(createAuthorizationUrl).toHaveBeenCalledWith({ - target: { type: 'pds', serviceUrl: 'https://bsky.social' }, + target: { type: 'pds', serviceUrl: 'https://pds.mu.social' }, scope: GRANULAR_SCOPE, prompt: 'create', state: { returnTo: '/settings' }, diff --git a/web/src/routes/index.tsx b/web/src/routes/index.tsx index 982b058..610011c 100644 --- a/web/src/routes/index.tsx +++ b/web/src/routes/index.tsx @@ -1,4 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute, redirect } from '@tanstack/react-router'; import { LandingPage } from '@/features/auth/components/LandingPage/LandingPage'; import { safeReturnTo } from '@/lib/atproto/oauthConfig'; @@ -12,12 +12,21 @@ export const Route = createFileRoute('/')({ const returnTo = safeReturnTo(search.returnTo); return { returnTo: returnTo === '/' ? undefined : returnTo }; }, + // Links from before sign-in had its own page go there (#157). + beforeLoad: ({ search }) => { + if (search.returnTo) { + throw redirect({ + to: '/sign-in', + search: { returnTo: search.returnTo }, + replace: true, + }); + } + }, // The homepage draws its own header, on the brand blue (#151). staticData: { ownHeader: true }, component: Landing, }); function Landing() { - const { returnTo } = Route.useSearch(); - return ; + return ; } diff --git a/web/src/routes/sign-in.tsx b/web/src/routes/sign-in.tsx new file mode 100644 index 0000000..578a813 --- /dev/null +++ b/web/src/routes/sign-in.tsx @@ -0,0 +1,23 @@ +import { createFileRoute } from '@tanstack/react-router'; + +import { SignInPage } from '@/features/home/components/SignInPage/SignInPage'; +import { safeReturnTo } from '@/lib/atproto/oauthConfig'; + +type SignInSearch = { returnTo?: string }; + +export const Route = createFileRoute('/sign-in')({ + // Always return the key: search params merge with the parent route's raw + // params, so omitting it would let an unvalidated value through. + validateSearch: (search: Record): SignInSearch => { + const returnTo = safeReturnTo(search.returnTo); + return { returnTo: returnTo === '/' ? undefined : returnTo }; + }, + // The page draws its own header, on the brand blue (#157). + staticData: { ownHeader: true }, + component: SignIn, +}); + +function SignIn() { + const { returnTo } = Route.useSearch(); + return ; +}