diff --git a/client/src/components/BackToTop.css b/client/src/components/BackToTop.css index 015f556..6b04977 100644 --- a/client/src/components/BackToTop.css +++ b/client/src/components/BackToTop.css @@ -1,16 +1,16 @@ .back-to-top { position: fixed; - right: max(0.75rem, env(safe-area-inset-right)); - top: max(1rem, env(safe-area-inset-top)); + right: max(1rem, env(safe-area-inset-right)); + bottom: max(1.25rem, env(safe-area-inset-bottom)); z-index: 2; - display: flex; + display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; width: fit-content; max-width: calc(100% - 1.5rem); min-height: 2.75rem; - padding: 0.5rem; + padding: 0.5rem 0.875rem; border: 1px solid var(--accent); border-radius: 100px; background: var(--surface); @@ -20,8 +20,9 @@ font-weight: 700; } -.back-to-top span { +.back-to-top__icon { font-size: 1.25rem; + line-height: 1; } .back-to-top:hover { @@ -31,8 +32,15 @@ @media (max-width: 700px) { .back-to-top { - /* Keep narrow-screen controls clear, including with enlarged text. */ - position: static; - margin: 1.5rem 0 0 auto; + right: max(0.75rem, env(safe-area-inset-right)); + bottom: max(1rem, env(safe-area-inset-bottom)); + width: 2.75rem; + height: 2.75rem; + padding: 0; + border-radius: 50%; + } + + .back-to-top__label { + display: none; } } diff --git a/client/src/components/BackToTop.test.tsx b/client/src/components/BackToTop.test.tsx index f639c8a..434ade6 100644 --- a/client/src/components/BackToTop.test.tsx +++ b/client/src/components/BackToTop.test.tsx @@ -1,6 +1,7 @@ import { afterEach, expect, it, vi } from 'vitest'; import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import axe from 'axe-core'; import BackToTop from './BackToTop.js'; @@ -16,7 +17,13 @@ it('appears after 600px, hides near the top and removes its listener on unmount' expect(screen.queryByRole('button', { name: 'Back to top' })).not.toBeInTheDocument(); vi.stubGlobal('scrollY', 601); fireEvent.scroll(window); - expect(screen.getByRole('button', { name: 'Back to top' })).toHaveTextContent('Top'); + const button = screen.getByRole('button', { name: 'Back to top' }); + expect(button).toHaveTextContent('Top'); + expect(button.querySelector('.back-to-top__icon')).toHaveAttribute( + 'aria-hidden', + 'true', + ); + expect(button.querySelector('.back-to-top__label')).toHaveTextContent('Top'); vi.stubGlobal('scrollY', 600); fireEvent.scroll(window); expect(screen.queryByRole('button', { name: 'Back to top' })).not.toBeInTheDocument(); @@ -24,6 +31,17 @@ it('appears after 600px, hides near the top and removes its listener on unmount' expect(removeListener).toHaveBeenCalledWith('scroll', expect.any(Function)); }); +it('keeps an accessible label and passes axe when visible', async () => { + vi.stubGlobal('scrollY', 650); + const { container } = render(); + const button = screen.getByRole('button', { name: 'Back to top' }); + expect(button).toHaveAttribute('aria-label', 'Back to top'); + const results = await axe.run(container, { + rules: { 'color-contrast': { enabled: false } }, + }); + expect(results.violations).toEqual([]); +}); + it.each([ ['click', false, 'smooth'], ['{Enter}', false, 'smooth'], diff --git a/client/src/components/BackToTop.tsx b/client/src/components/BackToTop.tsx index c379e3c..8b8dc65 100644 --- a/client/src/components/BackToTop.tsx +++ b/client/src/components/BackToTop.tsx @@ -30,8 +30,10 @@ export default function BackToTop() { }); }} > - - Top + + Top ); } diff --git a/client/src/components/ResultsLayout.css b/client/src/components/ResultsLayout.css index 29aea01..824939a 100644 --- a/client/src/components/ResultsLayout.css +++ b/client/src/components/ResultsLayout.css @@ -1,6 +1,12 @@ .results { padding-bottom: 2.5rem; } +@media (max-width: 700px) { + /* Leave clearance above the floating bottom-right Back to top button. */ + .results { + padding-bottom: 4.5rem; + } +} .results-header { margin-bottom: 1rem; } diff --git a/docs/AI-USAGE.md b/docs/AI-USAGE.md index 2bc56e0..f272ce0 100644 --- a/docs/AI-USAGE.md +++ b/docs/AI-USAGE.md @@ -105,6 +105,7 @@ the part that matters most. | 2026-11-17 | erikhfj | Antigravity | #91, E2E search helper fix: updated `e2e/tests/search.spec.ts` to match the `Search` and `Filters` buttons with `exact: true` so `Clear recent searches` does not trigger a strict-mode violation, and cleared `E2E_USER_ID`'s recorded search history during cleanup. Verified locally with two consecutive full `pnpm test:e2e` runs against a throwaway seeded PostgreSQL stack. | | 2026-11-20 | erikhfj | Antigravity | #100, review author privacy: removed `User.id` from `schema.graphql` and the `AlbumDetail` query, replaced `Listener ` with deterministic SHA-256 music pseudonyms in `server/src/userIdentity.ts` (including read-time sanitization of legacy labels in `Review.user`), added `User` cache merge policy, and updated schema/unit/client tests and `docs/architecture.md`. Verified with `pnpm codegen`, `pnpm format:check`, `pnpm lint`, `pnpm typecheck`, `pnpm test`, and `pnpm build`. | | 2026-11-20 | erikhfj | Antigravity | #103, search history error visibility and focus: moved the search history error message and Retry button inside the open `RecentSearches` dropdown so closed-state errors cannot overlap page content, returned retry success from `useSearchHistory`, restored focus to the search input after a successful retry in `SearchForm`, and added unit/integration tests. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build`. | +| 2026-11-20 | erikhfj | Antigravity | #102, floating mobile Back to Top button: positioned `BackToTop` fixed at bottom-right across viewports with a compact 44px circular icon-only layout on mobile (`<= 700px`), preserved the `Back to top` accessible name, added bottom clearance on `.results` so controls such as `Load more` stay unobstructed, and expanded `BackToTop.test.tsx`. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build`. | | 2026-11-20 | erikhfj | Antigravity | #95, loading skeleton cards: rendered 8 `aria-hidden="true"` placeholder cards inside `.album-grid--loading` while `ResultsLayout` is loading so the layout does not collapse, styled with plain CSS and `prefers-reduced-motion` support, kept `role="status"` and `aria-busy` unchanged, and added a loading-state test in `App.test.tsx`. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build`. | | 2026-11-20 | robertky | Codex (ChatGPT) | #105: assisted with expanding the MusicBrainz snapshot to 2,000 albums, selecting familiar album targets, paginating source searches, batching artist-country lookups and updating catalog checks and documentation. Robert requested the expansion following instructor feedback; validation results are recorded in the PR. | | 2026-11-22 | evenkkl | Claude | #96, skip count and facet queries on Load more: Claude made the search aggregates lazy `AlbumConnection` field resolvers, added a `SearchAlbumsPage` query for Load more, kept page one's count and facets in the Apollo merge, and added server and client tests. Verified with lint, typecheck, the test suites and the PostgreSQL tests on PGlite. |