From 586ac7d218de98637a3a853f2f379c0ac774d8ba Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 2 Aug 2026 00:54:55 +0000 Subject: [PATCH] =?UTF-8?q?B118=20=E2=80=94=20hide=20list=20page=20title,?= =?UTF-8?q?=20subtitle=20and=20scope=20chip=20on=20mobile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract CampaignListPageHeader with sr-only/md:not-sr-only h1 and hidden subtitle/scope below md. Apply to all 8 list index routes. Unit + e2e pins. Co-authored-by: Francisco Solla --- .../campanha/(app)/apoiadores/page.tsx | 45 ++++++++-------- .../campanha/(app)/assessores/page.tsx | 12 ++--- .../campanha/(app)/atividades/page.tsx | 51 +++++++++---------- .../campanha/(app)/demandas/page.tsx | 30 +++++------ .../campanha/(app)/dobradinhas/page.tsx | 28 +++++----- .../campanha/(app)/liderancas/page.tsx | 27 +++++----- .../campanha/(app)/municipios/page.tsx | 14 +++-- .../campanha/(app)/territorios/page.tsx | 17 +++---- .../shared/CampaignListPageHeader.tsx | 47 +++++++++++++++++ tests/e2e/campaignMunicipalities.e2e.spec.ts | 17 +++++++ .../unit/campaignListPageHeader.unit.spec.ts | 27 ++++++++++ 11 files changed, 199 insertions(+), 116 deletions(-) create mode 100644 src/components/campaign/shared/CampaignListPageHeader.tsx create mode 100644 tests/unit/campaignListPageHeader.unit.spec.ts diff --git a/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx b/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx index 620cf3a3..39a87285 100644 --- a/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx +++ b/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx @@ -6,6 +6,7 @@ import { getPayload } from 'payload' import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignListPendingBoundary, CampaignListResults, @@ -109,35 +110,35 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro return ( -
-
-

Apoiadores

-

- Base nominal de apoio com intenção de voto e vínculo opcional a municípios. -

+ {isCampaignUnrestricted(user) ? `${campaignRoleLabels[user.role]} · todos os apoiadores` : getSupporterScopeLabel(result.totalDocs)} -
-
- {isCampaignCoordinator(user) ? ( - + ) : null} + - ) : null} - -
-
+ + } + /> {main}
diff --git a/src/app/(campaign)/campanha/(app)/assessores/page.tsx b/src/app/(campaign)/campanha/(app)/assessores/page.tsx index 68e5c9ca..7f6f4a0f 100644 --- a/src/app/(campaign)/campanha/(app)/assessores/page.tsx +++ b/src/app/(campaign)/campanha/(app)/assessores/page.tsx @@ -5,6 +5,7 @@ import type { ReactNode } from 'react' import { AdvisorsTable } from '@/components/campaign/advisor/AdvisorsTable' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignListPendingBoundary, CampaignListResults, @@ -105,13 +106,10 @@ export default async function AdvisorsPage({ searchParams }: AdvisorsPageProps) return ( -
-

Assessores

-

- Consulte na tabela; ative Editar para alterar campos e carteira. Nome abre a ficha; - e-mail/celular copiam; município abre o município. -

-
+ {main}
diff --git a/src/app/(campaign)/campanha/(app)/atividades/page.tsx b/src/app/(campaign)/campanha/(app)/atividades/page.tsx index 5b1ae1ea..4c8ed5d2 100644 --- a/src/app/(campaign)/campanha/(app)/atividades/page.tsx +++ b/src/app/(campaign)/campanha/(app)/atividades/page.tsx @@ -12,6 +12,7 @@ import { ActivityFilters } from '@/components/campaign/activity/ActivityFilters' import { ActivityList } from '@/components/campaign/activity/ActivityList' import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell' import { Button } from '@/components/ui/button' import type { Activity } from '@/payload-types' @@ -53,32 +54,30 @@ export default async function ActivityListPage({ searchParams }: ActivityListPag return ( -
-
-

Atividades

-

- Organize caminhadas, comícios, panfletagens e demais ações de campanha. -

-
- {canCreate ? ( -
- {/* E13: the planner generates several drafts at once, so it sits next - to "Nova atividade" rather than replacing it. */} - - -
- ) : null} -
+ + {/* E13: the planner generates several drafts at once, so it sits next + to "Nova atividade" rather than replacing it. */} + + + + ) : null + } + /> -
-
-

Demandas

-

- Necessidades da campanha abertas pelas lideranças, revisadas pela assessoria e — quando - preciso — decididas pelo Coordenador Geral. -

+ {openCount} {openCount === 1 ? 'demanda em aberto' : 'demandas em aberto'} -
- -
+ } + actions={ + + } + /> {main}
diff --git a/src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx b/src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx index c072d910..12698722 100644 --- a/src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx +++ b/src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx @@ -5,6 +5,7 @@ import { redirect } from 'next/navigation' import { getPayload } from 'payload' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignListPendingBoundary, CampaignListResults, @@ -282,21 +283,18 @@ export default async function StateDeputiesPage({ searchParams }: StateDeputiesP return ( -
-
-

Dobradinhas

-

- Deputados estaduais com quem a campanha dobra — vincule lideranças e municípios direto - na lista. -

-
- -
+ + +
diff --git a/src/app/(campaign)/campanha/(app)/liderancas/page.tsx b/src/app/(campaign)/campanha/(app)/liderancas/page.tsx index 97e396af..1d85134f 100644 --- a/src/app/(campaign)/campanha/(app)/liderancas/page.tsx +++ b/src/app/(campaign)/campanha/(app)/liderancas/page.tsx @@ -13,6 +13,7 @@ import { } from '@/components/campaign/leadership/LeadershipSortableHead' import { CampaignCopyableCell } from '@/components/campaign/shared/CampaignCopyableCell' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignListPendingBoundary, CampaignListResults, @@ -436,20 +437,18 @@ export default async function LeadershipsPage({ searchParams }: LeadershipsPageP return ( -
-
-

Lideranças

-

- Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações. -

-
- -
+ + +
diff --git a/src/app/(campaign)/campanha/(app)/municipios/page.tsx b/src/app/(campaign)/campanha/(app)/municipios/page.tsx index 078ec158..6300e16c 100644 --- a/src/app/(campaign)/campanha/(app)/municipios/page.tsx +++ b/src/app/(campaign)/campanha/(app)/municipios/page.tsx @@ -13,6 +13,7 @@ import { MunicipalityFilters } from '@/components/campaign/municipality/Municipa import { MunicipalityList } from '@/components/campaign/municipality/MunicipalityList' import { MunicipalityListOverview } from '@/components/campaign/municipality/MunicipalityListOverview' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge' import { OpsListPage } from '@/components/campaign/shared/OpsListPage' import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell' @@ -185,14 +186,11 @@ export default async function MunicipalitiesPage({ searchParams }: Municipalitie return ( -
-

Municípios

-

- Os 435 municípios da campanha: um por município da Bahia — em Salvador, uma zona eleitoral - cada. -

- {getCampaignScopeLabel(user.role, scopeTotal)} -
+ {getCampaignScopeLabel(user.role, scopeTotal)}} + /> {main} {listVisitLabel ? ( diff --git a/src/app/(campaign)/campanha/(app)/territorios/page.tsx b/src/app/(campaign)/campanha/(app)/territorios/page.tsx index 26d3eb5b..d35b934b 100644 --- a/src/app/(campaign)/campanha/(app)/territorios/page.tsx +++ b/src/app/(campaign)/campanha/(app)/territorios/page.tsx @@ -5,6 +5,7 @@ import { getPayload } from 'payload' import { TerritoryFilters } from '@/components/campaign/municipality/TerritoryFilters' import { TerritoryList } from '@/components/campaign/municipality/TerritoryList' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' import { CampaignListPendingBoundary, CampaignListResults, @@ -81,15 +82,13 @@ export default async function TerritoriesPage({ searchParams }: TerritoriesPageP return ( -
-

- Territórios de Identidade -

-

- Compare a concentração histórica e a cobertura de assessoria das regiões da Bahia. Abra um - território para ver seus municípios. -

-
+ {main}
) diff --git a/src/components/campaign/shared/CampaignListPageHeader.tsx b/src/components/campaign/shared/CampaignListPageHeader.tsx new file mode 100644 index 00000000..b82b046b --- /dev/null +++ b/src/components/campaign/shared/CampaignListPageHeader.tsx @@ -0,0 +1,47 @@ +import type { ReactNode } from 'react' + +import { cn } from '@/lib/utils' + +type CampaignListPageHeaderProps = { + title: string + description: string + scope?: ReactNode + actions?: ReactNode + className?: string + titleClassName?: string + descriptionClassName?: string +} + +export const CampaignListPageHeader = ({ + title, + description, + scope, + actions, + className, + titleClassName, + descriptionClassName, +}: CampaignListPageHeaderProps) => ( +
+
+

+ {title} +

+

+ {description} +

+ {scope ?
{scope}
: null} +
+ {actions} +
+) diff --git a/tests/e2e/campaignMunicipalities.e2e.spec.ts b/tests/e2e/campaignMunicipalities.e2e.spec.ts index 3df22418..9c99c0ed 100644 --- a/tests/e2e/campaignMunicipalities.e2e.spec.ts +++ b/tests/e2e/campaignMunicipalities.e2e.spec.ts @@ -39,6 +39,23 @@ test.describe('Municípios — shell (OH8)', () => { }) }) +test.describe('Municípios — list header mobile (B118)', () => { + test.use({ viewport: { width: 390, height: 844 } }) + + test('hides page title chrome on mobile but keeps list tools', async ({ campaign, page }) => { + const { fixtures } = campaign + const coordinator = await fixtures.createCampaignUser('coordinator', { + name: fixtures.value('Coordenador Mobile Header'), + }) + + await campaign.login(page, coordinator.email!, coordinator.password) + await page.goto(`${campaign.baseURL}/campanha/municipios`) + await expect(page.getByRole('heading', { name: 'Municípios', exact: true })).toBeHidden() + await expect(page.getByLabel('Buscar município')).toBeVisible() + await expect(page.getByText(/\d+ municípios encontrados/)).toBeVisible() + }) +}) + test.describe('Municípios — jornadas por papel', () => { test('coordinator opens the municipalities list, edits strategy and assigns an advisor', async ({ campaign, diff --git a/tests/unit/campaignListPageHeader.unit.spec.ts b/tests/unit/campaignListPageHeader.unit.spec.ts new file mode 100644 index 00000000..2f6780f9 --- /dev/null +++ b/tests/unit/campaignListPageHeader.unit.spec.ts @@ -0,0 +1,27 @@ +import { createElement } from 'react' +import { renderToStaticMarkup } from 'react-dom/server' +import { describe, expect, it } from 'vitest' + +import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader' +import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge' + +describe('CampaignListPageHeader (B118)', () => { + it('keeps h1 in the DOM with sr-only on mobile and hides subtitle and scope chip below md', () => { + const html = renderToStaticMarkup( + createElement(CampaignListPageHeader, { + title: 'Municípios', + description: 'Os 435 municípios da campanha.', + scope: createElement(CampaignScopeBadge, null, '435 municípios'), + }), + ) + + expect(html).toContain('