mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
B116 — Início mobile: gap busca÷2 + header título → home
- CampaignMobileTopBar: bloco Jorge Solla / Campanha·Bahia vira Link para /campanha - CampaignContentScroll: pb-2 no Início mobile (metade do p-4) quando sem quick-actions peek - Testes unitários para link e padding compacto Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
dde938bbb1
commit
4f459b9a57
6 changed files with 55 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
'use client'
|
||||
|
||||
import { usePathname } from 'next/navigation'
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import { CampaignGlobalSearchProvider } from '@/components/campaign/dashboard/CampaignGlobalSearchMount'
|
||||
|
|
@ -9,6 +10,7 @@ import {
|
|||
useQuickActionsChromeActive,
|
||||
} from '@/components/campaign/shell/CampaignQuickActionsHost'
|
||||
import { CampaignQuickActionsSnapProvider } from '@/components/campaign/shell/CampaignQuickActionsSnapContext'
|
||||
import { isCampaignHomePath } from '@/lib/campaignQuickActionMount'
|
||||
import type { CampaignRole } from '@/lib/campaignRoles'
|
||||
|
||||
export const CampaignAppScrollChrome = ({
|
||||
|
|
@ -18,10 +20,19 @@ export const CampaignAppScrollChrome = ({
|
|||
role: CampaignRole
|
||||
children: ReactNode
|
||||
}) => {
|
||||
const pathname = usePathname()
|
||||
const quickActionsActive = useQuickActionsChromeActive(role)
|
||||
const compactHomeBottomPadding = isCampaignHomePath(pathname)
|
||||
|
||||
if (!quickActionsActive) {
|
||||
return <CampaignContentScroll quickActionsPeek={false}>{children}</CampaignContentScroll>
|
||||
return (
|
||||
<CampaignContentScroll
|
||||
quickActionsPeek={false}
|
||||
compactHomeBottomPadding={compactHomeBottomPadding}
|
||||
>
|
||||
{children}
|
||||
</CampaignContentScroll>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { ArrowLeft, X } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import { useCampaignListTransition } from '@/components/campaign/shared/CampaignListPending'
|
||||
|
|
@ -11,7 +12,9 @@ import { Button } from '@/components/ui/button'
|
|||
import { SidebarTrigger } from '@/components/ui/Sidebar'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { HOME_SEARCH_COLLAPSE_ARIA_LABEL } from '@/lib/campaignHomeSearchContract'
|
||||
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
||||
import {
|
||||
CAMPAIGN_HOME_TOP_BAR_LINK_ARIA_LABEL,
|
||||
WIZARD_APP_TOP_BAR_ARIA_LABEL,
|
||||
WIZARD_DISMISS_ARIA_LABEL,
|
||||
wizardFlowChromeAriaLabel,
|
||||
|
|
@ -156,8 +159,16 @@ export const CampaignMobileTopBar = ({
|
|||
<SidebarTrigger className="text-primary-foreground" />
|
||||
)}
|
||||
<div className="min-w-0 flex-1 leading-tight">
|
||||
<span className="block truncate text-sm font-semibold">Jorge Solla</span>
|
||||
<span className="block truncate text-xs text-primary-foreground/80">Campanha · Bahia</span>
|
||||
<Link
|
||||
href={CAMPAIGN_HOME}
|
||||
aria-label={CAMPAIGN_HOME_TOP_BAR_LINK_ARIA_LABEL}
|
||||
className="block rounded-md outline-none focus-visible:ring-2 focus-visible:ring-primary-foreground/60"
|
||||
>
|
||||
<span className="block truncate text-sm font-semibold">Jorge Solla</span>
|
||||
<span className="block truncate text-xs text-primary-foreground/80">
|
||||
Campanha · Bahia
|
||||
</span>
|
||||
</Link>
|
||||
{opsSyncStatus ? (
|
||||
<div className="mt-0.5 text-primary-foreground/70 [&_[role=status]]:text-inherit">
|
||||
{opsSyncStatus}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,22 @@ const CampaignContentScrollWithPeek = ({ children }: { children: ReactNode }) =>
|
|||
export const CampaignContentScroll = ({
|
||||
children,
|
||||
quickActionsPeek,
|
||||
compactHomeBottomPadding = false,
|
||||
}: {
|
||||
children: ReactNode
|
||||
quickActionsPeek: boolean
|
||||
/** B116 — Início mobile: half the default scrollport padding below the search dock. */
|
||||
compactHomeBottomPadding?: boolean
|
||||
}) => {
|
||||
if (!quickActionsPeek) {
|
||||
return (
|
||||
<div
|
||||
data-slot="campaign-content-scroll"
|
||||
className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-6 print:h-auto print:overflow-visible print:p-0"
|
||||
data-home-compact-bottom-padding={compactHomeBottomPadding || undefined}
|
||||
className={cn(
|
||||
'min-h-0 flex-1 overflow-y-auto overscroll-contain md:p-6 print:h-auto print:overflow-visible print:p-0',
|
||||
compactHomeBottomPadding ? 'px-4 pt-4 pb-2' : 'p-4',
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ export const WIZARD_STEP_PENDING_MESSAGE = 'Carregando passo…' as const
|
|||
|
||||
export const WIZARD_APP_TOP_BAR_ARIA_LABEL = 'Campanha Jorge Solla' as const
|
||||
|
||||
export const CAMPAIGN_HOME_TOP_BAR_LINK_ARIA_LABEL = 'Ir para o início' as const
|
||||
|
||||
export const wizardMunicipalityChromeAriaLabel = (municipalityLabel: string): string =>
|
||||
`Município em atualização: ${municipalityLabel}`
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
type CampaignWizardChromeState,
|
||||
} from '@/components/campaign/shell/CampaignWizardChromeContext'
|
||||
import { SidebarProvider } from '@/components/ui/Sidebar'
|
||||
import { CAMPAIGN_HOME_TOP_BAR_LINK_ARIA_LABEL } from '@/lib/campaignWizardCopy'
|
||||
import { stubMatchMedia } from '../helpers/matchMedia'
|
||||
|
||||
const WizardChromeProbe = ({ chrome }: { chrome: CampaignWizardChromeState | null }) => {
|
||||
|
|
@ -64,6 +65,11 @@ describe('CampaignMobileTopBar', () => {
|
|||
const topBar = container.querySelector('[data-slot="campaign-mobile-top-bar"]')
|
||||
expect(topBar?.getAttribute('data-mode')).toBe('app')
|
||||
expect(screen.getByText('Jorge Solla')).toBeTruthy()
|
||||
expect(
|
||||
screen
|
||||
.getByRole('link', { name: CAMPAIGN_HOME_TOP_BAR_LINK_ARIA_LABEL })
|
||||
.getAttribute('href'),
|
||||
).toBe('/campanha')
|
||||
expect(screen.queryByRole('link', { name: /Voltar/ })).toBeNull()
|
||||
expect(screen.queryByRole('button', { name: 'Fechar busca' })).toBeNull()
|
||||
expect(screen.queryByRole('link', { name: 'Sair da ação' })).toBeNull()
|
||||
|
|
|
|||
|
|
@ -430,6 +430,20 @@ describe('CampaignQuickActionsDrawer (B105)', () => {
|
|||
})
|
||||
|
||||
describe('CampaignContentScroll quick-actions direction (B105)', () => {
|
||||
it('uses compact bottom padding on Início when quick-actions peek is off (B116)', () => {
|
||||
render(
|
||||
<CampaignContentScroll quickActionsPeek={false} compactHomeBottomPadding>
|
||||
<div />
|
||||
</CampaignContentScroll>,
|
||||
)
|
||||
|
||||
const scrollport = document.querySelector('[data-slot="campaign-content-scroll"]')
|
||||
expect(scrollport?.getAttribute('data-home-compact-bottom-padding')).toBe('true')
|
||||
expect(scrollport?.className).toContain('pb-2')
|
||||
expect(scrollport?.className).toContain('px-4')
|
||||
expect(scrollport?.className).not.toContain(' p-4')
|
||||
})
|
||||
|
||||
it('collapses on scroll down and re-docks on scroll up', () => {
|
||||
renderQuickActionsChrome(
|
||||
<>
|
||||
|
|
|
|||
Loading…
Reference in a new issue