mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-24 00:53:05 +00:00
Merge pull request #252 from fsolla/cursor/pool-i249-19771f24-3b0c
B122 — Início mobile — ações em grade 2×3 (sem scroll)
This commit is contained in:
commit
9ebe55fadb
10 changed files with 279 additions and 43 deletions
65
docs/plans/inicio-acoes-grid-2x3-mobile-impl.md
Normal file
65
docs/plans/inicio-acoes-grid-2x3-mobile-impl.md
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
# Impl: Início mobile — ações em grade 2×3 (sem scroll)
|
||||||
|
|
||||||
|
Status: aprovado
|
||||||
|
Atualizado em: 2026-08-02
|
||||||
|
Issue: #249
|
||||||
|
Intenção: docs/plans/inicio-acoes-grid-2x3-mobile.md
|
||||||
|
Appetite restante: ~0,5d (layout + tests)
|
||||||
|
|
||||||
|
## Leitura da intenção
|
||||||
|
|
||||||
|
- **Outcome:** No Início mobile, as 6 ações staff aparecem numa grade 2×3 sem scroll horizontal; desktop mantém strip.
|
||||||
|
- **O que NÃO negociar:** drawer de outras rotas continua strip; catálogo/lockdown leader; long-press/tooltip.
|
||||||
|
- **O que reavaliar:** bleed `-mx-4` do B99 — removido no mobile porque a grade cabe no gutter.
|
||||||
|
|
||||||
|
## Abordagem recomendada
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
Strip["CampaignHomeActionStrip"]
|
||||||
|
Strip -->|variant=responsive| R["grid lt-md / flex md+"]
|
||||||
|
Strip -->|variant=strip| S["flex + overflow-x"]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Opções consideradas:** A) CSS só no strip (`grid md:flex`) | B) componente `CampaignHomeActionGrid` | C) duplicar markup no `CampaignHomeActions`
|
||||||
|
**Recomendação:** **A** — edita o dono; `variant` explícito para o drawer.
|
||||||
|
**Rejeitadas:** B (twin); C (duplica map de ações).
|
||||||
|
|
||||||
|
### Componentes / mudanças
|
||||||
|
|
||||||
|
- **`CampaignHomeActionStrip`** (`src/components/campaign/dashboard/CampaignHomeActionStrip.tsx`): prop `variant?: 'strip' | 'responsive'` (default `'responsive'`). Responsive: `grid grid-cols-2 gap-3` + sem overflow no mobile; `md:flex md:overflow-x-auto` + pan handlers. Strip: comportamento atual.
|
||||||
|
- **`CampaignHomeActionButton`** (`CampaignHomeActionButton.tsx`): `actionControlClassName` ganha `w-full md:w-[5.5rem]` quando pai é responsive (via prop `layout` ou classe compartilhada exportada).
|
||||||
|
- **`CampaignHomeActions`**: passa `variant="responsive"` (explícito).
|
||||||
|
- **`CampaignQuickActionsDrawer`**: passa `variant="strip"`.
|
||||||
|
- **`CampaignHomeLayout`**: `home-actions` perde `-mx-4 w-[calc(100%+2rem)]` no mobile; bleed só se strip voltar (não neste slice).
|
||||||
|
- **Migration:** sem migration.
|
||||||
|
- **UI:** Impeccable B — craft; sem novo token.
|
||||||
|
|
||||||
|
### Dados → forma
|
||||||
|
|
||||||
|
N/A — launcher estático.
|
||||||
|
|
||||||
|
## Fases verificáveis
|
||||||
|
|
||||||
|
1. **Strip + button** — `variant` + classes grid/strip; drawer `variant="strip"`.
|
||||||
|
2. **Layout + tests** — remover bleed mobile; unit layout/strip; e2e 6 ações visíveis em 390px.
|
||||||
|
3. **Gates** — `pnpm gate:fast`; `pnpm push`.
|
||||||
|
|
||||||
|
## Rabbit holes / Não escopo (engenharia)
|
||||||
|
|
||||||
|
- Extrair tile genérico wizard/home.
|
||||||
|
- Grid no drawer.
|
||||||
|
- Mudar tamanho do círculo sem pedido de produto.
|
||||||
|
|
||||||
|
## Riscos e mitigação
|
||||||
|
|
||||||
|
- **Pan handlers em grid mobile:** inofensivos (sem overflow); não montar scroller ref em grid se simplificar.
|
||||||
|
- **Teste bleed antigo:** atualizar spec `campaignHomeLayout` para refletir gutter no mobile.
|
||||||
|
|
||||||
|
## Aceite de engenharia
|
||||||
|
|
||||||
|
- [x] Aceite de produto da intenção ainda coberto
|
||||||
|
- [x] Invariantes AGENTS/engineering-standards
|
||||||
|
- [x] Testes de domínio previstos (unit/int) onde access/write paths mudam
|
||||||
|
|
||||||
|
Self-score decision-quality: 5/5
|
||||||
123
docs/plans/inicio-acoes-grid-2x3-mobile.md
Normal file
123
docs/plans/inicio-acoes-grid-2x3-mobile.md
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
# Início mobile — ações em grade 2×3 (sem scroll)
|
||||||
|
|
||||||
|
Status: registrado
|
||||||
|
Atualizado em: 2026-08-02
|
||||||
|
Issue: #249
|
||||||
|
Priority: P1
|
||||||
|
Model: composer-2.5
|
||||||
|
Impeccable: B — `CampaignHomeActionStrip` / `CampaignHomeLayout` (Início staff/leader)
|
||||||
|
Appetite: ~0,5d eng; layout responsivo; sem migration
|
||||||
|
Responsável: —
|
||||||
|
|
||||||
|
## Design (Impeccable)
|
||||||
|
|
||||||
|
Âncoras: `PRODUCT.md` (Clarity under pressure; Feel the action) / `DESIGN.md` · B44/B45 strip · B63 grid 2×3 wizard · tema `campaign`.
|
||||||
|
|
||||||
|
Na implementação: craft compacto → critique → polish (iPhone 390px; 6 ações staff).
|
||||||
|
|
||||||
|
Brief:
|
||||||
|
|
||||||
|
- **Persona / contexto:** CG/assessor no celular — polegar na thumb zone; hoje precisa pan horizontal para ver as 6 ações.
|
||||||
|
- **Job principal:** ver **todas** as ações staff (6) de uma vez, sem scroll horizontal, em grade 2 colunas × 3 linhas.
|
||||||
|
- **Estratégia de cor:** herda B44 (círculo `bg-muted` + label).
|
||||||
|
- **Edit where you see:** não — launchers.
|
||||||
|
- **Anti-goals:** card com borda envolvendo a grade; scroll horizontal no mobile do Início; mudar o drawer de outras rotas (continua strip).
|
||||||
|
|
||||||
|
### Wireframe (texto)
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌─ /campanha mobile (< md) ──────────────────────┐
|
||||||
|
│ │
|
||||||
|
│ ┌──────────┐ ┌──────────┐ │
|
||||||
|
│ │ Ajustar │ │Registrar │ │
|
||||||
|
│ │ votos │ │ sinal │ │
|
||||||
|
│ └──────────┘ └──────────┘ │
|
||||||
|
│ ┌──────────┐ ┌──────────┐ │
|
||||||
|
│ │ Mudar │ │Atualizar │ │
|
||||||
|
│ │tendência │ │liderança │ │
|
||||||
|
│ └──────────┘ └──────────┘ │
|
||||||
|
│ ┌──────────┐ ┌──────────┐ │
|
||||||
|
│ │Registrar │ │ Ver │ │
|
||||||
|
│ │ pedido │ │esquecidos│ │
|
||||||
|
│ └──────────┘ └──────────┘ │
|
||||||
|
│ │
|
||||||
|
│ ┌ Buscar na campanha ────────────────────────┐│
|
||||||
|
└────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
md+: strip horizontal atual (B44/B67) — inalterada.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dados → decisão → apresentação
|
||||||
|
|
||||||
|
Dados: N/A — chrome de launcher; catálogo B45 inalterado.
|
||||||
|
|
||||||
|
## Contexto
|
||||||
|
|
||||||
|
**B44–B74 / B99** iteraram na strip horizontal (gap, bleed, pan). Com 6 ações staff, o mobile ainda exige pan — produto pede **grade 2×3 sem scroll** no Início. Precedente visual: `WizardSignalTypeStep` (`grid-cols-2 gap-3`). O **drawer** de ações rápidas (B105) permanece strip horizontal no peek.
|
||||||
|
|
||||||
|
## Objetivos
|
||||||
|
|
||||||
|
- **< `md` (Início):** `CampaignHomeActions` renderiza grade `grid-cols-2 gap-3`; 6 ações staff visíveis sem `overflow-x`; liderança (2 ações) em 1 linha.
|
||||||
|
- **`md+`:** strip horizontal atual (scroll, pan fine, tooltip).
|
||||||
|
- `CampaignQuickActionsDrawer`: continua `variant="strip"` (sem grade).
|
||||||
|
- Remover bleed `-mx-4` do slot `home-actions` no mobile (grade respeita gutter `p-4`).
|
||||||
|
- Long-press Drawer / Tooltip fine inalterados.
|
||||||
|
- Unit + e2e smoke: grade no mobile; strip no drawer; ações staff todas visíveis em viewport 390.
|
||||||
|
- Sem migration / collection / server action.
|
||||||
|
|
||||||
|
## Decisões travadas
|
||||||
|
|
||||||
|
- **Grade só no Início mobile; strip no drawer e no `md+`.** **Rejeitado:** grade global (drawer peek não cabe 3 linhas); manter strip no mobile “com gap menor” (B99/B74 esgotaram).
|
||||||
|
- **`variant` no dono `CampaignHomeActionStrip`.** `responsive` (default no Início) vs `strip` (drawer). **Rejeitado:** componente paralelo `CampaignHomeActionGrid`.
|
||||||
|
- **Botão com classes responsivas** (`w-full md:w-[5.5rem]`). **Rejeitado:** segundo primitivo de botão.
|
||||||
|
- **i18n:** ids/classes em inglês; copy B58 intacta.
|
||||||
|
|
||||||
|
## Questões em aberto
|
||||||
|
|
||||||
|
- **Círculo menor na grade?** **Opções:** A) manter `size-14` | B) `size-12` na grade. **Recomendação:** **A** — célula larga o suficiente; critique mede. _(assumido)_
|
||||||
|
|
||||||
|
## Abordagem proposta
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TB
|
||||||
|
Home["CampaignHomeActions"] --> Strip["CampaignHomeActionStrip variant=responsive"]
|
||||||
|
Drawer["CampaignQuickActionsDrawer"] --> Strip2["CampaignHomeActionStrip variant=strip"]
|
||||||
|
Strip --> Grid["lt md: grid 2×3"]
|
||||||
|
Strip --> HStrip["md+: horizontal strip"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Componentes:
|
||||||
|
|
||||||
|
- **`CampaignHomeActionStrip.tsx`:** prop `variant`; lista `grid grid-cols-2 gap-3` vs `flex` + overflow.
|
||||||
|
- **`CampaignHomeActionButton.tsx`:** `w-full` na grade / largura fixa na strip.
|
||||||
|
- **`CampaignHomeLayout.tsx`:** remover bleed mobile do slot `home-actions`.
|
||||||
|
- **Testes:** unit strip/grid classes; e2e 6 ações visíveis em 390px.
|
||||||
|
|
||||||
|
## Dependências
|
||||||
|
|
||||||
|
- Dura: B45 ✓ (catálogo), B44 ✓ (primitivo). Soft: B99 bleed (revertido no mobile para grade).
|
||||||
|
|
||||||
|
## Não escopo
|
||||||
|
|
||||||
|
- Catálogo / labels / wizards.
|
||||||
|
- Grade no drawer B105.
|
||||||
|
- Mudar ordem thumb-zone (B46).
|
||||||
|
|
||||||
|
## Rabbit holes
|
||||||
|
|
||||||
|
- **Unificar grade wizard + home num tile genérico.** Mitigação: classes Tailwind compartilhadas só; sem extrair até 3º call site.
|
||||||
|
- **CSS container queries.** Mitigação: breakpoint `md` como o resto do Início.
|
||||||
|
|
||||||
|
## Adiado com gatilho
|
||||||
|
|
||||||
|
- **Grade no drawer** se peek crescer. Revisitar com redesign B105.
|
||||||
|
- **3 colunas em tablet portrait.** Revisitar se `md` grid pedido.
|
||||||
|
|
||||||
|
## Referências
|
||||||
|
|
||||||
|
- Issue #249 · `WizardSignalTypeStep.tsx` (grid 2×3)
|
||||||
|
- `CampaignHomeActionStrip.tsx` · `CampaignHomeLayout.tsx` · `CampaignQuickActionsDrawer.tsx`
|
||||||
|
- [botao-acao-inicio-strip.md](botao-acao-inicio-strip.md) · [strip-acoes-edge-gap-inicio.md](strip-acoes-edge-gap-inicio.md)
|
||||||
|
- `PRODUCT.md` / `DESIGN.md`
|
||||||
|
|
||||||
|
Qualidade de decisão: 5/5
|
||||||
|
|
@ -25,10 +25,18 @@ export type CampaignHomeActionButtonProps = {
|
||||||
href?: string
|
href?: string
|
||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
layout?: 'strip' | 'responsive'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actionControlClassName =
|
const actionControlBaseClassName =
|
||||||
'group box-content flex min-h-11 w-[5.5rem] shrink-0 snap-start flex-col items-center gap-2 rounded-md text-center outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90 disabled:pointer-events-none disabled:opacity-50'
|
'group box-content flex min-h-11 flex-col items-center gap-2 rounded-md text-center outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90 disabled:pointer-events-none disabled:opacity-50'
|
||||||
|
|
||||||
|
const actionStripControlClassName = cn(actionControlBaseClassName, 'w-[5.5rem] shrink-0 snap-start')
|
||||||
|
|
||||||
|
const actionResponsiveControlClassName = cn(
|
||||||
|
actionControlBaseClassName,
|
||||||
|
'w-full md:w-[5.5rem] md:shrink-0 md:snap-start',
|
||||||
|
)
|
||||||
|
|
||||||
const circleClassName =
|
const circleClassName =
|
||||||
'flex size-14 items-center justify-center rounded-full bg-muted text-foreground transition-[transform,colors] duration-150 ease-out motion-reduce:transition-none pointer-fine:group-hover:scale-[1.05] pointer-coarse:group-data-[pressing=true]:scale-[1.05] motion-reduce:scale-100 group-hover:bg-muted/80 group-focus-visible:bg-muted/80'
|
'flex size-14 items-center justify-center rounded-full bg-muted text-foreground transition-[transform,colors] duration-150 ease-out motion-reduce:transition-none pointer-fine:group-hover:scale-[1.05] pointer-coarse:group-data-[pressing=true]:scale-[1.05] motion-reduce:scale-100 group-hover:bg-muted/80 group-focus-visible:bg-muted/80'
|
||||||
|
|
@ -51,6 +59,7 @@ export const CampaignHomeActionButton = ({
|
||||||
href,
|
href,
|
||||||
onClick,
|
onClick,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
layout = 'strip',
|
||||||
}: CampaignHomeActionButtonProps) => {
|
}: CampaignHomeActionButtonProps) => {
|
||||||
const isCoarsePointer = useCoarsePointer()
|
const isCoarsePointer = useCoarsePointer()
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false)
|
const [drawerOpen, setDrawerOpen] = useState(false)
|
||||||
|
|
@ -74,7 +83,10 @@ export const CampaignHomeActionButton = ({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const className = cn(actionControlClassName, isInert && 'cursor-default')
|
const className = cn(
|
||||||
|
layout === 'responsive' ? actionResponsiveControlClassName : actionStripControlClassName,
|
||||||
|
isInert && 'cursor-default',
|
||||||
|
)
|
||||||
const aria = {
|
const aria = {
|
||||||
'aria-label': label,
|
'aria-label': label,
|
||||||
'aria-describedby': drawerOpen && longPressEnabled ? descriptionId : undefined,
|
'aria-describedby': drawerOpen && longPressEnabled ? descriptionId : undefined,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import { cn } from '@/lib/utils'
|
||||||
/** Horizontal pan threshold (px) — below this, child link/button clicks still fire. */
|
/** Horizontal pan threshold (px) — below this, child link/button clicks still fire. */
|
||||||
export const HOME_ACTION_STRIP_DRAG_THRESHOLD_PX = 8
|
export const HOME_ACTION_STRIP_DRAG_THRESHOLD_PX = 8
|
||||||
|
|
||||||
|
export type CampaignHomeActionStripVariant = 'strip' | 'responsive'
|
||||||
|
|
||||||
type DragSession = {
|
type DragSession = {
|
||||||
pointerId: number
|
pointerId: number
|
||||||
startX: number
|
startX: number
|
||||||
|
|
@ -33,15 +35,19 @@ export const CampaignHomeActionStrip = ({
|
||||||
actions,
|
actions,
|
||||||
ariaLabel = 'Ações rápidas',
|
ariaLabel = 'Ações rápidas',
|
||||||
className,
|
className,
|
||||||
|
variant = 'responsive',
|
||||||
}: {
|
}: {
|
||||||
actions?: readonly (CampaignHomeActionButtonProps & { id?: string })[]
|
actions?: readonly (CampaignHomeActionButtonProps & { id?: string })[]
|
||||||
ariaLabel?: string
|
ariaLabel?: string
|
||||||
className?: string
|
className?: string
|
||||||
|
/** `responsive`: 2×3 grid on mobile, horizontal strip on md+. `strip`: always horizontal. */
|
||||||
|
variant?: CampaignHomeActionStripVariant
|
||||||
}) => {
|
}) => {
|
||||||
const isCoarsePointer = useCoarsePointer()
|
const isCoarsePointer = useCoarsePointer()
|
||||||
const scrollerRef = useRef<HTMLDivElement>(null)
|
const scrollerRef = useRef<HTMLDivElement>(null)
|
||||||
const dragRef = useRef<DragSession | null>(null)
|
const dragRef = useRef<DragSession | null>(null)
|
||||||
const suppressClickRef = useRef(false)
|
const suppressClickRef = useRef(false)
|
||||||
|
const isStripLayout = variant === 'strip'
|
||||||
|
|
||||||
const endDragSession = useCallback((pointerId: number) => {
|
const endDragSession = useCallback((pointerId: number) => {
|
||||||
const session = dragRef.current
|
const session = dragRef.current
|
||||||
|
|
@ -126,25 +132,36 @@ export const CampaignHomeActionStrip = ({
|
||||||
onClickCapture,
|
onClickCapture,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const listClassName = cn(
|
||||||
|
'm-0 list-none p-0',
|
||||||
|
isStripLayout
|
||||||
|
? 'flex min-w-max snap-x snap-proximity gap-0 px-4 pb-1 md:px-0'
|
||||||
|
: 'grid grid-cols-2 gap-3 md:flex md:min-w-max md:snap-x md:snap-proximity md:gap-0 md:px-0 md:pb-1',
|
||||||
|
)
|
||||||
|
|
||||||
|
const scrollerClassName = cn(
|
||||||
|
'min-w-0',
|
||||||
|
isStripLayout
|
||||||
|
? 'overflow-x-auto overflow-y-hidden overscroll-x-contain [touch-action:pan-x] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden pointer-fine:cursor-grab pointer-fine:data-[dragging=true]:cursor-grabbing pointer-fine:data-[dragging=true]:select-none'
|
||||||
|
: 'md:overflow-x-auto md:overflow-y-hidden md:overscroll-x-contain md:[touch-action:pan-x] md:[scrollbar-width:none] md:[&::-webkit-scrollbar]:hidden md:pointer-fine:cursor-grab md:pointer-fine:data-[dragging=true]:cursor-grabbing md:pointer-fine:data-[dragging=true]:select-none',
|
||||||
|
className,
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider delayDuration={300}>
|
<TooltipProvider delayDuration={300}>
|
||||||
<div
|
<div
|
||||||
ref={scrollerRef}
|
ref={scrollerRef}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
className={cn(
|
className={scrollerClassName}
|
||||||
'min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain [touch-action:pan-x] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
|
|
||||||
'pointer-fine:cursor-grab pointer-fine:data-[dragging=true]:cursor-grabbing pointer-fine:data-[dragging=true]:select-none',
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...finePointerPanProps}
|
{...finePointerPanProps}
|
||||||
>
|
>
|
||||||
<ul
|
<ul role="list" className={listClassName}>
|
||||||
role="list"
|
|
||||||
className="m-0 flex min-w-max list-none snap-x snap-proximity gap-0 px-4 pb-1 md:px-0"
|
|
||||||
>
|
|
||||||
{actions?.map(({ id, ...button }) => (
|
{actions?.map(({ id, ...button }) => (
|
||||||
<li key={id ?? button.href ?? button.label} className="m-0 list-none p-0">
|
<li key={id ?? button.href ?? button.label} className="m-0 list-none p-0">
|
||||||
<CampaignHomeActionButton {...button} />
|
<CampaignHomeActionButton
|
||||||
|
{...button}
|
||||||
|
layout={isStripLayout ? 'strip' : 'responsive'}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,5 @@ export const CampaignHomeActions = ({
|
||||||
|
|
||||||
if (actions.length === 0) return null
|
if (actions.length === 0) return null
|
||||||
|
|
||||||
return <CampaignHomeActionStrip actions={actions} className="w-full" />
|
return <CampaignHomeActionStrip actions={actions} className="w-full" variant="responsive" />
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,11 @@ const HomeChromeRetractionShell = ({
|
||||||
slot,
|
slot,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
allowHorizontalBleed = false,
|
|
||||||
}: {
|
}: {
|
||||||
retracted: boolean
|
retracted: boolean
|
||||||
slot?: string
|
slot?: string
|
||||||
className?: string
|
className?: string
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
/** B111 — keep Y clip for grid-rows retraction without clipping -mx bleed on X. */
|
|
||||||
allowHorizontalBleed?: boolean
|
|
||||||
}) => (
|
}) => (
|
||||||
<div
|
<div
|
||||||
data-slot={slot}
|
data-slot={slot}
|
||||||
|
|
@ -30,12 +27,7 @@ const HomeChromeRetractionShell = ({
|
||||||
className={cn(homeChromeRetractionClass(retracted), className)}
|
className={cn(homeChromeRetractionClass(retracted), className)}
|
||||||
aria-hidden={retracted || undefined}
|
aria-hidden={retracted || undefined}
|
||||||
>
|
>
|
||||||
<div
|
<div className="min-h-0 overflow-hidden">{children}</div>
|
||||||
className={cn('min-h-0', allowHorizontalBleed ? 'overflow-y-hidden' : 'overflow-hidden')}
|
|
||||||
data-allow-horizontal-bleed={allowHorizontalBleed || undefined}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -71,12 +63,8 @@ export const CampaignHomeLayout = ({
|
||||||
retracted={focused}
|
retracted={focused}
|
||||||
slot="home-actions-chrome"
|
slot="home-actions-chrome"
|
||||||
className="order-1 md:order-2"
|
className="order-1 md:order-2"
|
||||||
allowHorizontalBleed
|
|
||||||
>
|
>
|
||||||
<div
|
<div data-slot="home-actions" className="min-w-0 md:mx-0 md:w-auto">
|
||||||
data-slot="home-actions"
|
|
||||||
className="min-w-0 -mx-4 w-[calc(100%+2rem)] md:mx-0 md:w-auto"
|
|
||||||
>
|
|
||||||
{actions}
|
{actions}
|
||||||
</div>
|
</div>
|
||||||
</HomeChromeRetractionShell>
|
</HomeChromeRetractionShell>
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ export const CampaignQuickActionsDrawer = ({
|
||||||
{showActions ? (
|
{showActions ? (
|
||||||
<div className="-mx-4 w-[calc(100%+2rem)]">
|
<div className="-mx-4 w-[calc(100%+2rem)]">
|
||||||
<CampaignHomeActionStrip
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
actions={actions.map((action) => ({
|
actions={actions.map((action) => ({
|
||||||
id: action.id,
|
id: action.id,
|
||||||
label: action.label,
|
label: action.label,
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,8 @@ test.describe('Início — busca global (B47)', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test.describe('Início — catálogo de ações (B45)', () => {
|
test.describe('Início — catálogo de ações (B45)', () => {
|
||||||
|
test.use({ viewport: { width: 390, height: 844 } })
|
||||||
|
|
||||||
test('staff sees six home actions and can open municipalities without coverage', async ({
|
test('staff sees six home actions and can open municipalities without coverage', async ({
|
||||||
campaign,
|
campaign,
|
||||||
page,
|
page,
|
||||||
|
|
@ -112,7 +114,8 @@ test.describe('Início — catálogo de ações (B45)', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await expect(page.getByLabel('Ações rápidas')).toBeVisible()
|
const actionsRegion = page.getByLabel('Ações rápidas')
|
||||||
|
await expect(actionsRegion).toBeVisible()
|
||||||
|
|
||||||
for (const label of staffActionLabels) {
|
for (const label of staffActionLabels) {
|
||||||
const link = page.getByRole('link', { name: label, exact: true })
|
const link = page.getByRole('link', { name: label, exact: true })
|
||||||
|
|
@ -120,6 +123,10 @@ test.describe('Início — catálogo de ações (B45)', () => {
|
||||||
await expect(link.or(button)).toBeVisible()
|
await expect(link.or(button)).toBeVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const overflowX = await actionsRegion.evaluate((el) => getComputedStyle(el).overflowX)
|
||||||
|
expect(overflowX).not.toBe('auto')
|
||||||
|
expect(overflowX).not.toBe('scroll')
|
||||||
|
|
||||||
await page.getByRole('link', { name: 'Ajustar votos', exact: true }).click()
|
await page.getByRole('link', { name: 'Ajustar votos', exact: true }).click()
|
||||||
await page.waitForURL(/\/campanha\/acoes\/atualizar-votos/)
|
await page.waitForURL(/\/campanha\/acoes\/atualizar-votos/)
|
||||||
await expect(page.getByLabel('Buscar município')).toBeVisible()
|
await expect(page.getByLabel('Buscar município')).toBeVisible()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CampaignHomeActionButton,
|
CampaignHomeActionButton,
|
||||||
actionControlClassName,
|
|
||||||
type CampaignHomeActionButtonProps,
|
type CampaignHomeActionButtonProps,
|
||||||
} from '@/components/campaign/dashboard/CampaignHomeActionButton'
|
} from '@/components/campaign/dashboard/CampaignHomeActionButton'
|
||||||
import {
|
import {
|
||||||
|
|
@ -95,7 +94,8 @@ describe('CampaignHomeActionButton', () => {
|
||||||
const onClick = vi.fn()
|
const onClick = vi.fn()
|
||||||
renderActionButton({ label: 'Registrar', icon: BarChart3, onClick })
|
renderActionButton({ label: 'Registrar', icon: BarChart3, onClick })
|
||||||
const control = screen.getByRole('button', { name: 'Registrar' })
|
const control = screen.getByRole('button', { name: 'Registrar' })
|
||||||
expect(control.className).toBe(actionControlClassName)
|
expect(control.className).toContain('min-h-11')
|
||||||
|
expect(control.className).toContain('w-[5.5rem]')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens the description drawer on long-press when the pointer is coarse', () => {
|
it('opens the description drawer on long-press when the pointer is coarse', () => {
|
||||||
|
|
@ -178,6 +178,7 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
it('renders a horizontal scroller with list semantics', () => {
|
it('renders a horizontal scroller with list semantics', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<CampaignHomeActionStrip
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
actions={[
|
actions={[
|
||||||
{ label: 'Um', icon: BarChart3 },
|
{ label: 'Um', icon: BarChart3 },
|
||||||
{ label: 'Dois', icon: BarChart3 },
|
{ label: 'Dois', icon: BarChart3 },
|
||||||
|
|
@ -189,10 +190,33 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
expect(scroller).toBeTruthy()
|
expect(scroller).toBeTruthy()
|
||||||
const list = scroller?.querySelector('ul[role="list"]')
|
const list = scroller?.querySelector('ul[role="list"]')
|
||||||
expect(list).toBeTruthy()
|
expect(list).toBeTruthy()
|
||||||
|
expect(list?.className).toMatch(/flex/)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders a 2-column grid on mobile when variant is responsive', () => {
|
||||||
|
const { container } = render(
|
||||||
|
<CampaignHomeActionStrip
|
||||||
|
variant="responsive"
|
||||||
|
actions={[
|
||||||
|
{ label: 'Um', icon: BarChart3 },
|
||||||
|
{ label: 'Dois', icon: BarChart3 },
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
|
||||||
|
const region = container.querySelector('[aria-label="Ações rápidas"]')
|
||||||
|
expect(region).toBeTruthy()
|
||||||
|
const list = region?.querySelector('ul[role="list"]')
|
||||||
|
expect(list).toBeTruthy()
|
||||||
|
expect(list?.className).toMatch(/grid-cols-2/)
|
||||||
|
expect(list?.className).toMatch(/md:flex/)
|
||||||
|
const regionClasses = region?.className.split(/\s+/) ?? []
|
||||||
|
expect(regionClasses).not.toContain('overflow-x-auto')
|
||||||
|
expect(regionClasses.some((token) => token.includes('md:overflow-x-auto'))).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('scrolls horizontally on pointer-fine drag past the threshold', () => {
|
it('scrolls horizontally on pointer-fine drag past the threshold', () => {
|
||||||
const { container } = render(<CampaignHomeActionStrip actions={manyActions} />)
|
const { container } = render(<CampaignHomeActionStrip variant="strip" actions={manyActions} />)
|
||||||
const scroller = getScroller(container)
|
const scroller = getScroller(container)
|
||||||
mockScrollerOverflow(scroller)
|
mockScrollerOverflow(scroller)
|
||||||
|
|
||||||
|
|
@ -227,6 +251,7 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
const onClick = vi.fn()
|
const onClick = vi.fn()
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<CampaignHomeActionStrip
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
actions={[{ label: 'Registrar', icon: BarChart3, onClick }, ...manyActions]}
|
actions={[{ label: 'Registrar', icon: BarChart3, onClick }, ...manyActions]}
|
||||||
/>,
|
/>,
|
||||||
)
|
)
|
||||||
|
|
@ -246,6 +271,7 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
const onClick = vi.fn()
|
const onClick = vi.fn()
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<CampaignHomeActionStrip
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
actions={[{ label: 'Registrar', icon: BarChart3, onClick }, ...manyActions.slice(0, 3)]}
|
actions={[{ label: 'Registrar', icon: BarChart3, onClick }, ...manyActions.slice(0, 3)]}
|
||||||
/>,
|
/>,
|
||||||
)
|
)
|
||||||
|
|
@ -263,7 +289,10 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
it('allows child click when movement stays below the drag threshold', () => {
|
it('allows child click when movement stays below the drag threshold', () => {
|
||||||
const onClick = vi.fn()
|
const onClick = vi.fn()
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<CampaignHomeActionStrip actions={[{ label: 'Registrar', icon: BarChart3, onClick }]} />,
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
|
actions={[{ label: 'Registrar', icon: BarChart3, onClick }]}
|
||||||
|
/>,
|
||||||
)
|
)
|
||||||
const scroller = getScroller(container)
|
const scroller = getScroller(container)
|
||||||
mockScrollerOverflow(scroller)
|
mockScrollerOverflow(scroller)
|
||||||
|
|
@ -285,6 +314,7 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
const onLinkClick = vi.fn()
|
const onLinkClick = vi.fn()
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<CampaignHomeActionStrip
|
<CampaignHomeActionStrip
|
||||||
|
variant="strip"
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
label: 'Ajustar votos',
|
label: 'Ajustar votos',
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,13 @@ describe('CampaignHomeLayout', () => {
|
||||||
expect(actions?.closest('[data-slot="home-dock"]')).not.toBeNull()
|
expect(actions?.closest('[data-slot="home-dock"]')).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('bleeds home-actions edge-to-edge on mobile (compensates scroll p-4)', () => {
|
it('does not bleed home-actions on mobile (B122 grid uses page gutter)', () => {
|
||||||
const { container } = render(<CampaignHomeLayout actions={<p>Actions block</p>} />)
|
const { container } = render(<CampaignHomeLayout actions={<p>Actions block</p>} />)
|
||||||
|
|
||||||
const actions = container.querySelector('[data-slot="home-actions"]')
|
const actions = container.querySelector('[data-slot="home-actions"]')
|
||||||
expect(actions).not.toBeNull()
|
expect(actions).not.toBeNull()
|
||||||
expect(actions?.closest('[data-slot="home-actions-chrome"]')).not.toBeNull()
|
expect(actions?.className).not.toMatch(/-mx-4/)
|
||||||
})
|
expect(actions?.className).not.toMatch(/calc\(100%\+2rem\)/)
|
||||||
|
|
||||||
it('does not clip horizontal bleed on the actions retraction shell', () => {
|
|
||||||
const { container } = render(<CampaignHomeLayout actions={<p>Actions block</p>} />)
|
|
||||||
|
|
||||||
const actionsChrome = container.querySelector('[data-slot="home-actions-chrome"]')
|
|
||||||
const bleedWrapper = actionsChrome?.querySelector('[data-allow-horizontal-bleed="true"]')
|
|
||||||
expect(bleedWrapper).not.toBeNull()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders search slot inside home-dock when provided', () => {
|
it('renders search slot inside home-dock when provided', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue