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
6 changes: 3 additions & 3 deletions web/e2e/landing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
6 changes: 3 additions & 3 deletions web/src/app/lanyard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 () => {
Expand Down
8 changes: 2 additions & 6 deletions web/src/components/AppHeader/AppHeader.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
21 changes: 7 additions & 14 deletions web/src/components/AppHeader/AppHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<typeof import('@/lib/atproto/session')>()),
startSignUp: vi.fn(() => Promise.resolve()),
}));

describe('AppHeader', () => {
it('links the logo home and shows no account link when signed out', async () => {
Expand Down Expand Up @@ -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(),
Expand All @@ -154,16 +148,15 @@ describe('AppHeader', () => {
<AppHeader signedOutActions />,
'/@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);
});

Expand Down
30 changes: 10 additions & 20 deletions web/src/components/AppHeader/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -42,22 +41,13 @@ export function AppHeader({
);
} else if (signedOutActions && session.status === 'signedOut') {
end = (
<div className={styles.nav}>
<Link
to="/sign-in"
search={{ returnTo: path }}
className={styles.navLink}
>
{t`Sign in`}
</Link>
<Button
size="md"
className={styles.signUp}
onClick={() => makeLanyard(path)}
>
{t`Make your lanyard`}
</Button>
</div>
<Link
to="/sign-in"
search={{ returnTo: path }}
className={buttonClassName({ className: styles.signIn })}
>
{t`Sign in`}
</Link>
);
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/AppHeader/AppHeader.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
7 changes: 3 additions & 4 deletions web/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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 && <span className={spinner} aria-hidden="true" />}
Expand Down
30 changes: 30 additions & 0 deletions web/src/components/Button/buttonClassName.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vitest';

import { buttonClassName } from './buttonClassName';

// A link that looks like a button (#162) gets the button's classes, merged
// as the button merges them, so a size's padding wins over the base's.
describe('buttonClassName', () => {
it('is the ui primary button at the default size', () => {
const classes = buttonClassName().split(' ');
expect(classes).toContain('bg-ui-primary');
expect(classes).toContain('min-h-11');
});

it('keeps one value per property, the most specific winning', () => {
const classes = buttonClassName({
tone: 'badge',
size: 'lg',
className: 'px-3 text-sm leading-5',
}).split(' ');
expect(classes).toContain('bg-badge-button');
expect(classes).toContain('px-3');
expect(classes).not.toContain('px-4');
expect(classes).not.toContain('px-6');
expect(classes).toContain('text-sm');
expect(classes).not.toContain('text-lg');
// The badge tone's weight, not the base's.
expect(classes).toContain('font-semibold');
expect(classes).not.toContain('font-medium');
});
});
24 changes: 24 additions & 0 deletions web/src/components/Button/buttonClassName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { cn } from '@/lib/utils';

import { base, sizes, tones } from './Button.styles';
import type { ButtonSize, ButtonTone, ButtonVariant } from './Button.types';

type ButtonLook = {
tone?: ButtonTone;
variant?: ButtonVariant;
size?: ButtonSize;
className?: string;
};

/**
* A button's classes, merged as Button merges them, for a link that looks
* like one (#162): Sign in, and calls to action that go to another page.
*/
export function buttonClassName({
tone = 'ui',
variant = 'primary',
size = 'md',
className,
}: ButtonLook = {}): string {
return cn(base, tones[tone][variant], sizes[size], className);
}
21 changes: 0 additions & 21 deletions web/src/features/auth/useMakeLanyard.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The brand pages' top bar (#151): no bar at all. The logo and Sign in sit
// on the brand blue, over the top of the badge's straps; text and focus
// rings are the accent field's, which read on it in light and dark.
// on the brand blue, over the top of the badge's straps; the focus rings
// are the accent field's, which read on it in light and dark.
// 56px tall, as the app header is; installed on iPhone, it also clears
// the status bar / notch.
export const header =
Expand All @@ -9,5 +9,5 @@ export const header =
export const homeLink =
'inline-flex min-h-11 min-w-11 items-center rounded-sm focus-visible:outline-(--focus-ring-on-accent)';

export const signIn =
'inline-flex min-h-11 items-center rounded-sm px-3 text-sm font-semibold leading-5 text-on-accent hover:bg-on-accent/10 focus-visible:outline-(--focus-ring-on-accent)';
/** Sign in: the badge's main button, white on the blue (#162). */
export const signIn = 'px-3 text-sm leading-5';
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ describe('HomeHeader (#151)', () => {
'/logo-dark.svg'
);
// Sign in has its own page; account creation is there too.
expect(
within(banner).getByRole('link', { name: 'Sign in' })
).toHaveAttribute('href', '/sign-in');
const signIn = within(banner).getByRole('link', { name: 'Sign in' });
expect(signIn).toHaveAttribute('href', '/sign-in');
// A primary button: the badge's main button, white on the blue (#162).
expect(signIn.className).toContain('bg-badge-button');
expect(within(banner).queryByRole('button')).toBeNull();
// No bar: it sits over the badge's ground.
expect(banner.className).not.toMatch(/\bbg-|\bborder-b\b/);
Expand Down
9 changes: 8 additions & 1 deletion web/src/features/home/components/HomeHeader/HomeHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useLingui } from '@lingui/react/macro';
import { Link } from '@tanstack/react-router';

import { buttonClassName } from '@/components/Button/buttonClassName';
import { Logo } from '@/components/Logo/Logo';
import { useSession } from '@/features/auth/session/useSession';
import { cn } from '@/lib/utils';
Expand All @@ -24,7 +25,13 @@ export function HomeHeader({ signIn = true, className }: HomeHeaderProps) {
<Logo fixed="lime" />
</Link>
{signIn && session.status === 'signedOut' && (
<Link to="/sign-in" className={styles.signIn}>
<Link
to="/sign-in"
className={buttonClassName({
tone: 'badge',
className: styles.signIn,
})}
>
{t`Sign in`}
</Link>
)}
Expand Down
11 changes: 1 addition & 10 deletions web/src/features/home/components/HomePage/HomePage.styles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
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.
Expand All @@ -21,7 +15,7 @@ export const column = 'flex w-full max-w-[70rem] flex-col gap-20 md:gap-28';
/** 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 startLink = `${buttonBase} ${buttonTones.accent.primary} ${buttonSizes.lg} font-semibold`;
export const startLink = 'font-semibold';

export const startMore = 'text-base font-medium leading-6 underline-offset-4';

Expand All @@ -44,9 +38,6 @@ 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)';
Expand Down
15 changes: 13 additions & 2 deletions web/src/features/home/components/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useLingui } from '@lingui/react/macro';
import { Link } from '@tanstack/react-router';
import { useId } from 'react';

import { buttonClassName } from '@/components/Button/buttonClassName';
import { CoverPattern } from '@/components/CoverPattern/CoverPattern';
import { ExternalLink } from '@/components/ExternalLink/ExternalLink';
import { cn } from '@/lib/utils';
Expand Down Expand Up @@ -43,7 +44,14 @@ export function HomePage({ className }: HomePageProps) {
intro={t`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.`}
>
<div className={styles.start}>
<Link to="/sign-in" className={styles.startLink}>
<Link
to="/sign-in"
className={buttonClassName({
tone: 'accent',
size: 'lg',
className: styles.startLink,
})}
>
{t`Sign in to get started`}
</Link>
<ExternalLink
Expand Down Expand Up @@ -114,7 +122,10 @@ export function HomePage({ className }: HomePageProps) {
{t`Join researchers building their professional identity on open infrastructure.`}
</p>
<div className={styles.actions}>
<Link to="/sign-in" className={styles.bannerLink}>
<Link
to="/sign-in"
className={buttonClassName({ tone: 'badge', size: 'lg' })}
>
{t`Create your lanyard`}
</Link>
<ExternalLink
Expand Down
Loading
Loading