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
13 changes: 13 additions & 0 deletions web/e2e/qr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ test.describe('QR sheet', () => {
}
});

test('closes from its corner on a portrait tablet, over the lanyard (#170)', async ({
page,
}) => {
await page.setViewportSize({ width: 820, height: 1180 });
await page.goto('/lanyard');
await page.getByRole('link', { name: 'Share' }).click();
const sheet = page.getByRole('dialog', { name: 'Dr Ada Example' });
await expect(sheet).toBeVisible();
// A real click: it fails if the strap is over the button.
await sheet.getByRole('button', { name: 'Close' }).click({ timeout: 2000 });
await expect(sheet).toBeHidden();
});

test('stays black on white in dark mode', async ({ page }) => {
await page.emulateMedia({ colorScheme: 'dark' });
await page.goto('/lanyard');
Expand Down
7 changes: 4 additions & 3 deletions web/scripts/styleRules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ const CHROME = [
const LANYARD_ONLY = [
'src/components/RichText/',
'src/features/qr/components/QrSheet/',
// Show QR as a page (#150): the badge's ground while it loads.
// Share as a page (#150): the badge's ground while it loads.
'src/features/qr/components/SharePage/',
'src/features/qr/components/LanyardStraps/',
// The Share badge's printed lanyard (#169).
// The printed lanyard every badge hangs from (#169, #170).
'src/features/qr/components/LanyardRibbon/',
// The clear sleeve a badge hangs in (#170).
'src/features/qr/components/BadgeSleeve/',
];

/**
Expand Down
29 changes: 17 additions & 12 deletions web/src/features/home/components/HomeBadge/HomeBadge.styles.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
// Lanyards' own billboard badge (#145), hung from its straps on brand
// blue as on the Share screen (spec §8), and built as a person's is
// (spec §7). The badge's tokens are the same in light and dark.
// Lanyards' own billboard badge (#145), in a clear sleeve on a lanyard
// printed with the site's address, on brand blue, as on the Share screen
// (#170), and built as a person's is (spec §7). The badge's tokens are the
// same in light and dark.

/** Edge to edge: the ground the badge hangs on. */
/** Edge to edge: the ground the badge hangs on. Crops the straps' tops. */
export const stage =
'flex w-full flex-col items-center overflow-hidden bg-qr-ground px-4 pb-14 md:px-8 md:pb-20';

export const hang = 'flex w-full max-w-[58rem] flex-col items-center';

export const straps = 'h-28 w-[11.75rem] md:h-40 md:w-[16.75rem]';
// The clasp's hook ends in the sleeve's slot, a little below its top edge.
export const ribbon =
'relative z-10 h-32 w-auto shrink-0 translate-y-[1.125rem] md:h-52 md:translate-y-7';

// Tilted on its clasp from md up, after one swing as it arrives. A mouse
// sways it on the same clasp (#151), with a transform added to the tilt.
export const sleeve =
'origin-top md:-rotate-[1.5deg] md:p-4 md:pt-12 md:motion-safe:animate-swing';

/** A bigger slot for the bigger sleeve. */
export const slot = 'md:top-4 md:h-4 md:w-24';

// Tilted on its clip from md up, after one swing as it arrives. A mouse
// sways it on the same clip (#151), with a transform added to the tilt.
export const badge =
'@container flex w-full origin-top 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)] md:-rotate-[1.5deg] md:motion-safe:animate-swing';
'@container flex w-full flex-col overflow-hidden rounded-sm bg-accent text-on-accent';

export const cover = 'relative h-30 @min-[40rem]:h-52';

/** Where the clip goes through the badge: the ground shows through. */
export const slot =
'absolute left-1/2 top-3.5 h-3 w-16 -translate-x-1/2 rounded-sm bg-qr-ground shadow-[inset_0_2px_3px_rgb(6_1_30/0.4)] @min-[40rem]:top-[1.125rem] @min-[40rem]:h-3.5 @min-[40rem]:w-24';

export const field =
'flex flex-col gap-4 px-5 pb-8 @min-[40rem]:px-12 @min-[40rem]:pb-12';

Expand Down
18 changes: 18 additions & 0 deletions web/src/features/home/components/HomeBadge/HomeBadge.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ afterEach(() => {
});

describe('HomeBadge (#151)', () => {
it('hangs in a clear sleeve from a lanyard printed lanyards.app (#170)', () => {
pointer(false);
const { container } = renderWithProviders(
<HomeBadge headingId="welcome" />
);
const heading = screen.getByRole('heading', { level: 1 });
expect(heading.closest('[data-sleeve]')).not.toBeNull();
const straps = container.querySelectorAll('textPath');
expect(straps).toHaveLength(2);
for (const strap of straps) {
expect(strap.textContent).toContain('lanyards.app');
}
// The old plain straps are gone: one lanyard, not two.
expect(container.querySelectorAll('polygon')).toHaveLength(0);
});

it('sways on its clip as a mouse moves across the lanyard', () => {
pointer(true);
vi.useFakeTimers({
Expand All @@ -50,6 +66,8 @@ describe('HomeBadge (#151)', () => {
sweep(heading);
const badge = turned(heading);
expect(badge).not.toBeNull();
// The badge turns in its sleeve, together, on the clasp (#170).
expect(badge).toHaveAttribute('data-sleeve');
expect(badge?.style.transform).toMatch(/^rotate\(-[\d.]+deg\)$/);
// It turns about its clip, at the top, as the arrival swing does.
expect(badge?.className).toMatch(/(^|\s)origin-top(\s|$)/);
Expand Down
69 changes: 39 additions & 30 deletions web/src/features/home/components/HomeBadge/HomeBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { useRef } from 'react';

import { CoverPattern } from '@/components/CoverPattern/CoverPattern';
import { Logo } from '@/components/Logo/Logo';
import { LanyardStraps } from '@/features/qr/components/LanyardStraps/LanyardStraps';
import { BadgeSleeve } from '@/features/qr/components/BadgeSleeve/BadgeSleeve';
import { LanyardRibbon } from '@/features/qr/components/LanyardRibbon/LanyardRibbon';
import { BRAND_PRINT } from '@/features/qr/components/LanyardRibbon/LanyardRibbon.constants';
import { cn } from '@/lib/utils';

import { usePointerSway } from '../../usePointerSway';
Expand All @@ -12,44 +14,51 @@ import * as styles from './HomeBadge.styles';
import type { HomeBadgeProps } from './HomeBadge.types';

/**
* Lanyards' own billboard badge, hanging from its straps at the top of the
* homepage (#145): the old homepage's welcome, in the new design language.
* A mouse moving across the lanyard sways it on its clip (#151).
* Lanyards' own billboard badge, hanging at the top of the homepage
* (#145): the old homepage's welcome, in the new design language. It
* hangs in a clear sleeve from a lanyard printed with the site's address,
* as a person's does on the Share screen (#170). A mouse moving across the
* lanyard sways the sleeve on its clasp (#151).
*/
export function HomeBadge({ headingId, className }: HomeBadgeProps) {
const { t, i18n } = useLingui();
const lanyard = useRef<HTMLDivElement>(null);
const badge = useRef<HTMLDivElement>(null);
usePointerSway(lanyard, badge);
const sleeve = useRef<HTMLDivElement>(null);
usePointerSway(lanyard, sleeve);
return (
<div data-accent={ACCENT} className={cn(styles.stage, className)}>
<div ref={lanyard} className={styles.hang}>
<LanyardStraps className={styles.straps} />
<div ref={badge} className={styles.badge}>
<div className={styles.cover}>
<CoverPattern pattern={COVER} initials="L" />
<span aria-hidden="true" className={styles.slot} />
</div>
<div className={styles.field}>
<div className={styles.logoBox}>
<Logo fixed="blue" className={styles.logo} />
<LanyardRibbon text={BRAND_PRINT} className={styles.ribbon} />
<BadgeSleeve
ref={sleeve}
className={styles.sleeve}
slotClassName={styles.slot}
>
<div className={styles.badge}>
<div className={styles.cover}>
<CoverPattern pattern={COVER} initials="L" />
</div>
<h1 id={headingId} className={styles.name}>
{t`Welcome to Lanyards`}
</h1>
<p className={styles.statement}>
{t`The curated link for academic researchers that collects your complete scholarly presence—publications, talks, affiliations, and social profiles.`}
</p>
</div>
<dl className={styles.board}>
{BOARD.map((cell) => (
<div key={cell.label.id} className={styles.cell}>
<dt className={styles.label}>{i18n._(cell.label)}</dt>
<dd className={styles.value}>{i18n._(cell.value)}</dd>
<div className={styles.field}>
<div className={styles.logoBox}>
<Logo fixed="blue" className={styles.logo} />
</div>
))}
</dl>
</div>
<h1 id={headingId} className={styles.name}>
{t`Welcome to Lanyards`}
</h1>
<p className={styles.statement}>
{t`The curated link for academic researchers that collects your complete scholarly presence—publications, talks, affiliations, and social profiles.`}
</p>
</div>
<dl className={styles.board}>
{BOARD.map((cell) => (
<div key={cell.label.id} className={styles.cell}>
<dt className={styles.label}>{i18n._(cell.label)}</dt>
<dd className={styles.value}>{i18n._(cell.value)}</dd>
</div>
))}
</dl>
</div>
</BadgeSleeve>
</div>
</div>
);
Expand Down
30 changes: 16 additions & 14 deletions web/src/features/home/components/SignInPage/SignInPage.styles.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// 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 sign-in page (#157): the form on a badge in a clear sleeve, hanging
// from a lanyard on the brand blue as the homepage's does (#170), 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';

/** Crops the straps' tops, so they never run up behind the header. */
export const main =
'flex flex-1 flex-col items-center px-4 pb-14 md:px-8 md:pb-20';
'flex flex-1 flex-col items-center overflow-hidden 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]';
// The clasp's hook ends in the sleeve's slot, a little below its top edge.
export const ribbon =
'relative z-10 h-28 w-auto shrink-0 translate-y-[1.125rem] md:h-36';

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)]';
'@container flex w-full flex-col overflow-hidden rounded-sm bg-accent text-on-accent';

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';

Expand All @@ -36,9 +36,11 @@ export const heading =

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)]';
// The form keeps the app's own palette: a card on the badge, full width,
// over the sleeve's glare so its text keeps its full contrast.
export const form =
'relative z-20 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';
'relative z-20 rounded-sm border border-ui-border bg-ui-surface p-6 text-[15px] leading-[22px] text-ui-text-muted';
19 changes: 19 additions & 0 deletions web/src/features/home/components/SignInPage/SignInPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ describe('SignInPage (#157)', () => {
await expectNoAxeViolations(container);
});

it('hangs in a clear sleeve from a lanyard printed lanyards.app (#170)', async () => {
const { container } = page();
const heading = await screen.findByRole('heading', {
level: 1,
name: 'Sign in',
});
const sleeve = heading.closest('[data-sleeve]');
expect(sleeve).not.toBeNull();
expect(sleeve).toContainElement(
screen.getByRole('combobox', { name: 'Your handle' })
);
const straps = container.querySelectorAll('textPath');
expect(straps).toHaveLength(2);
for (const strap of straps) {
expect(strap.textContent).toContain('lanyards.app');
}
expect(container.querySelectorAll('polygon')).toHaveLength(0);
});

it('has the homepage’s header, without a Sign in link to itself', async () => {
page();
const banner = await screen.findByRole('banner');
Expand Down
56 changes: 30 additions & 26 deletions web/src/features/home/components/SignInPage/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ 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 { BadgeSleeve } from '@/features/qr/components/BadgeSleeve/BadgeSleeve';
import { LanyardRibbon } from '@/features/qr/components/LanyardRibbon/LanyardRibbon';
import { BRAND_PRINT } from '@/features/qr/components/LanyardRibbon/LanyardRibbon.constants';
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import { safeReturnTo } from '@/lib/atproto/oauthConfig';

Expand All @@ -18,8 +20,9 @@ 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.
* badge in a clear sleeve, hanging from a lanyard on the brand blue as the
* homepage's does (#170). Signed in already, it sends people on to where
* they were going.
*/
export function SignInPage({ returnTo }: SignInPageProps) {
const { t } = useLingui();
Expand All @@ -42,31 +45,32 @@ export function SignInPage({ returnTo }: SignInPageProps) {
<HomeHeader signIn={false} />
<main className={styles.main}>
<div data-accent={BADGE_ACCENT} className={styles.hang}>
<LanyardStraps className={styles.straps} />
<section aria-labelledby={headingId} className={styles.badge}>
<div className={styles.cover}>
<CoverPattern pattern={COVER} initials="L" />
<span aria-hidden="true" className={styles.slot} />
</div>
<div className={styles.field}>
<div className={styles.logoBox}>
<Logo fixed="blue" className={styles.logo} />
<LanyardRibbon text={BRAND_PRINT} className={styles.ribbon} />
<BadgeSleeve>
<section aria-labelledby={headingId} className={styles.badge}>
<div className={styles.cover}>
<CoverPattern pattern={COVER} initials="L" />
</div>
<h1 id={headingId} className={styles.heading}>
{t`Sign in`}
</h1>
<p className={styles.lede}>
{t`Use your handle from Bluesky or any other AT Protocol app. New here? Create an account, and it’s yours to take anywhere.`}
</p>
{session.status === 'signedOut' ? (
<SignInForm returnTo={destination} className={styles.form} />
) : (
<p role="status" className={styles.loading}>
{t`Loading…`}
<div className={styles.field}>
<div className={styles.logoBox}>
<Logo fixed="blue" className={styles.logo} />
</div>
<h1 id={headingId} className={styles.heading}>
{t`Sign in`}
</h1>
<p className={styles.lede}>
{t`Use your handle from Bluesky or any other AT Protocol app. New here? Create an account, and it’s yours to take anywhere.`}
</p>
)}
</div>
</section>
{session.status === 'signedOut' ? (
<SignInForm returnTo={destination} className={styles.form} />
) : (
<p role="status" className={styles.loading}>
{t`Loading…`}
</p>
)}
</div>
</section>
</BadgeSleeve>
</div>
</main>
</div>
Expand Down
15 changes: 15 additions & 0 deletions web/src/features/qr/components/BadgeSleeve/BadgeSleeve.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// A clear plastic badge sleeve (#169, #170), on any lanyard ground: the
// plastic is white, a little opaque, and its lip has a slot where the
// clasp goes through, so the ground shows through the slot. Callers size
// it with their own classes, which win over these.

export const sleeve =
'relative isolate w-full rounded-sm border border-white/60 bg-white/15 p-2.5 pt-8 shadow-[inset_0_0_0_1px_rgb(255_255_255/0.15),0_30px_60px_rgb(6_1_30/0.3)]';

export const slot =
'absolute left-1/2 top-2.5 h-3 w-16 -translate-x-1/2 rounded-sm bg-qr-ground shadow-[inset_0_2px_3px_rgb(6_1_30/0.45)] ring-1 ring-white/60';

// Light on the plastic, over the badge. Anything that must keep its full
// contrast (a code to scan, a form) sits above it, at z-20.
export const glare =
'pointer-events-none absolute inset-0 z-10 rounded-sm bg-[linear-gradient(115deg,transparent_30%,rgb(255_255_255/0.22)_38%,transparent_47%,transparent_62%,rgb(255_255_255/0.12)_66%,transparent_72%)]';
Loading
Loading