mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
B113 — Wizard mobile thumb-zone, títulos e cores nos ícones
- Thumb-zone grid (RTL mobile fill from bottom-right) shared via wizardThumbGrid - Signal/trend tiles: semantic icon colors only; neutral tile borders - Remove redundant step titles (flow name stays in Mandate Red header) - Trend choice: current-status card with Atual chip (2 columns) - Signal body: Salvar disabled until body is non-empty - Leadership grid: list-none + thumb-zone alignment Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
b96b962d73
commit
a72874df20
13 changed files with 199 additions and 45 deletions
|
|
@ -45,7 +45,6 @@ import {
|
||||||
WIZARD_LEADERSHIP_EMPTY_NOTES,
|
WIZARD_LEADERSHIP_EMPTY_NOTES,
|
||||||
WIZARD_LEADERSHIP_FORM_CREATE_TITLE,
|
WIZARD_LEADERSHIP_FORM_CREATE_TITLE,
|
||||||
WIZARD_LEADERSHIP_FORM_EDIT_TITLE,
|
WIZARD_LEADERSHIP_FORM_EDIT_TITLE,
|
||||||
WIZARD_LEADERSHIP_GRID_TITLE,
|
|
||||||
WIZARD_LEADERSHIP_SAVED_TOAST,
|
WIZARD_LEADERSHIP_SAVED_TOAST,
|
||||||
WIZARD_LEADERSHIP_STATUS_DRAWER_TITLE,
|
WIZARD_LEADERSHIP_STATUS_DRAWER_TITLE,
|
||||||
WIZARD_LEADERSHIP_STATUS_PENDING,
|
WIZARD_LEADERSHIP_STATUS_PENDING,
|
||||||
|
|
@ -62,6 +61,10 @@ import {
|
||||||
type SupportStatus,
|
type SupportStatus,
|
||||||
} from '@/lib/schemas/leadership'
|
} from '@/lib/schemas/leadership'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
import {
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
} from '@/lib/wizardThumbGrid'
|
||||||
import {
|
import {
|
||||||
resolveWizardChainEntry,
|
resolveWizardChainEntry,
|
||||||
wizardChainContinueHref,
|
wizardChainContinueHref,
|
||||||
|
|
@ -143,11 +146,11 @@ export const WizardLeadershipStep = ({
|
||||||
)
|
)
|
||||||
|
|
||||||
const stepTitle =
|
const stepTitle =
|
||||||
mode.kind === 'grid'
|
mode.kind === 'form'
|
||||||
? WIZARD_LEADERSHIP_GRID_TITLE
|
? mode.leadership
|
||||||
: mode.leadership
|
|
||||||
? WIZARD_LEADERSHIP_FORM_EDIT_TITLE
|
? WIZARD_LEADERSHIP_FORM_EDIT_TITLE
|
||||||
: WIZARD_LEADERSHIP_FORM_CREATE_TITLE
|
: WIZARD_LEADERSHIP_FORM_CREATE_TITLE
|
||||||
|
: null
|
||||||
|
|
||||||
const trailingAction = skipConfig ? (
|
const trailingAction = skipConfig ? (
|
||||||
<Button variant="ghost" size="sm" className="min-h-11 px-2 text-sm" asChild>
|
<Button variant="ghost" size="sm" className="min-h-11 px-2 text-sm" asChild>
|
||||||
|
|
@ -213,7 +216,8 @@ export const WizardLeadershipStep = ({
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skipConfig}
|
skip={skipConfig}
|
||||||
trailingAction={trailingAction}
|
trailingAction={trailingAction}
|
||||||
contentFocus={mode.kind === 'form' ? 'none' : 'title'}
|
contentAlign={mode.kind === 'grid' ? 'end' : 'start'}
|
||||||
|
contentFocus={mode.kind === 'form' ? 'none' : undefined}
|
||||||
clientLayer={mode.kind === 'form' ? WIZARD_LEADERSHIP_FORM_LAYER : undefined}
|
clientLayer={mode.kind === 'form' ? WIZARD_LEADERSHIP_FORM_LAYER : undefined}
|
||||||
onPopClientLayer={handlePopFormLayer}
|
onPopClientLayer={handlePopFormLayer}
|
||||||
>
|
>
|
||||||
|
|
@ -231,9 +235,20 @@ export const WizardLeadershipStep = ({
|
||||||
{tiles.length === 0 ? (
|
{tiles.length === 0 ? (
|
||||||
<p className="text-sm text-muted-foreground">{WIZARD_LEADERSHIP_EMPTY_GRID}</p>
|
<p className="text-sm text-muted-foreground">{WIZARD_LEADERSHIP_EMPTY_GRID}</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
<<<<<<< HEAD
|
||||||
<ul className="grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4">
|
<ul className="grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4">
|
||||||
{tiles.map((tile) => (
|
{tiles.map((tile) => (
|
||||||
<li key={tile.id}>
|
<li key={tile.id}>
|
||||||
|
=======
|
||||||
|
<ul
|
||||||
|
className={cn(
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
'md:grid-cols-3 lg:grid-cols-4',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{initialTiles.map((tile) => (
|
||||||
|
<li key={tile.id} className={WIZARD_THUMB_TILE_ITEM_CLASS}>
|
||||||
|
>>>>>>> 30522269 (B113 — Wizard mobile thumb-zone, títulos e cores nos ícones)
|
||||||
<LeadershipTileButton
|
<LeadershipTileButton
|
||||||
tile={tile}
|
tile={tile}
|
||||||
onOpen={() => setMode({ kind: 'form', leadership: tile })}
|
onOpen={() => setMode({ kind: 'form', leadership: tile })}
|
||||||
|
|
@ -243,7 +258,7 @@ export const WizardLeadershipStep = ({
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li>
|
<li className={WIZARD_THUMB_TILE_ITEM_CLASS}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex aspect-square w-full flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border bg-transparent p-3 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
className="flex aspect-square w-full flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border bg-transparent p-3 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { useActionState } from 'react'
|
import { useActionState, useState } from 'react'
|
||||||
|
|
||||||
import { createMunicipalityListSignalFormAction } from '@/app/(campaign)/campanha/(app)/municipios/municipalityStaffFormActions'
|
import { createMunicipalityListSignalFormAction } from '@/app/(campaign)/campanha/(app)/municipios/municipalityStaffFormActions'
|
||||||
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
||||||
|
|
@ -15,18 +15,13 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
||||||
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { municipalitySignalTypeLabels } from '@/lib/schemas/municipalityUpdate'
|
|
||||||
import {
|
import {
|
||||||
resolveWizardChainEntry,
|
resolveWizardChainEntry,
|
||||||
wizardChainContinueHref,
|
wizardChainContinueHref,
|
||||||
wizardChainEndHref,
|
wizardChainEndHref,
|
||||||
} from '@/lib/wizardActionChain'
|
} from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
import {
|
import { resolveWizardSignalSkip, WIZARD_SIGNAL_SAVE_LABEL } from '@/lib/wizardSignalUi'
|
||||||
resolveWizardSignalSkip,
|
|
||||||
WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX,
|
|
||||||
WIZARD_SIGNAL_SAVE_LABEL,
|
|
||||||
} from '@/lib/wizardSignalUi'
|
|
||||||
|
|
||||||
type WizardSignalBodyStepProps = {
|
type WizardSignalBodyStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -48,12 +43,13 @@ export const WizardSignalBodyStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
}: WizardSignalBodyStepProps) => {
|
}: WizardSignalBodyStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const [body, setBody] = useState('')
|
||||||
const [state, submitAction, isPending] = useActionState(
|
const [state, submitAction, isPending] = useActionState(
|
||||||
createMunicipalityListSignalFormAction,
|
createMunicipalityListSignalFormAction,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const stepTitle = `${WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX}: ${municipalitySignalTypeLabels[signalType]}`
|
const canSave = body.trim().length > 0 && !isPending
|
||||||
|
|
||||||
useCampaignFormSuccessToast(state, () => {
|
useCampaignFormSuccessToast(state, () => {
|
||||||
recordLastActedMunicipality(municipalitySlug)
|
recordLastActedMunicipality(municipalitySlug)
|
||||||
|
|
@ -67,7 +63,7 @@ export const WizardSignalBodyStep = ({
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={stepTitle}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'signal-body',
|
step: 'signal-body',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -98,6 +94,8 @@ export const WizardSignalBodyStep = ({
|
||||||
<Textarea
|
<Textarea
|
||||||
id="wizard-signal-body"
|
id="wizard-signal-body"
|
||||||
name="body"
|
name="body"
|
||||||
|
value={body}
|
||||||
|
onChange={(event) => setBody(event.target.value)}
|
||||||
rows={5}
|
rows={5}
|
||||||
maxLength={5000}
|
maxLength={5000}
|
||||||
required
|
required
|
||||||
|
|
@ -111,7 +109,11 @@ export const WizardSignalBodyStep = ({
|
||||||
{state.status !== 'success' ? <CampaignFormActionMessage state={state} /> : null}
|
{state.status !== 'success' ? <CampaignFormActionMessage state={state} /> : null}
|
||||||
|
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<Button type="submit" disabled={isPending} className="min-h-11 min-w-[7rem]">
|
<Button
|
||||||
|
type="submit"
|
||||||
|
disabled={!canSave}
|
||||||
|
className="min-h-11 min-w-[7rem]"
|
||||||
|
>
|
||||||
{isPending ? (
|
{isPending ? (
|
||||||
<>
|
<>
|
||||||
<Spinner data-icon="inline-start" aria-hidden="true" />
|
<Spinner data-icon="inline-start" aria-hidden="true" />
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { Info } from 'lucide-react'
|
import { Info } from 'lucide-react'
|
||||||
import { useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
|
|
||||||
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
import { WizardSignalSkipTrailing } from '@/components/campaign/municipality/WizardSignalSkipTrailing'
|
||||||
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
||||||
|
|
@ -20,14 +20,19 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardSignalHref } from '@/lib/campaignActionRoutes'
|
import { wizardSignalHref } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
||||||
import {
|
import {
|
||||||
municipalitySignalTypeMeta,
|
|
||||||
municipalitySignalTypeMetaByType,
|
municipalitySignalTypeMetaByType,
|
||||||
|
type MunicipalitySignalTypeMetaEntry,
|
||||||
} from '@/lib/municipalitySignalTypeMeta'
|
} from '@/lib/municipalitySignalTypeMeta'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi'
|
import { resolveWizardSignalSkip } from '@/lib/wizardSignalUi'
|
||||||
|
import {
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
wizardSignalTypesThumbOrder,
|
||||||
|
} from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
type WizardSignalTypeStepProps = {
|
type WizardSignalTypeStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -48,12 +53,20 @@ export const WizardSignalTypeStep = ({
|
||||||
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
|
|
||||||
|
const thumbOrderedEntries = useMemo(
|
||||||
|
() =>
|
||||||
|
wizardSignalTypesThumbOrder.map(
|
||||||
|
(type) => municipalitySignalTypeMetaByType[type],
|
||||||
|
) satisfies MunicipalitySignalTypeMetaEntry[],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={WIZARD_SIGNAL_TYPE_STEP_TITLE}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'signal-type',
|
step: 'signal-type',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -65,11 +78,11 @@ export const WizardSignalTypeStep = ({
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
||||||
>
|
>
|
||||||
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
<ul className={WIZARD_THUMB_TILE_GRID_CLASS}>
|
||||||
{municipalitySignalTypeMeta.map((entry) => {
|
{thumbOrderedEntries.map((entry) => {
|
||||||
const Icon = entry.icon
|
const Icon = entry.icon
|
||||||
return (
|
return (
|
||||||
<li key={entry.type} className="relative">
|
<li key={entry.type} className={cn('relative', WIZARD_THUMB_TILE_ITEM_CLASS)}>
|
||||||
<CampaignWizardNavLink
|
<CampaignWizardNavLink
|
||||||
href={wizardSignalHref(
|
href={wizardSignalHref(
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -79,13 +92,13 @@ export const WizardSignalTypeStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-transparent p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-background p-3 pr-10 text-left text-foreground',
|
||||||
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon className="size-5 shrink-0 text-foreground" aria-hidden />
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-sm font-medium text-foreground">{entry.label}</span>
|
<span className="text-sm font-medium">{entry.label}</span>
|
||||||
<span className="line-clamp-2 text-xs text-muted-foreground">
|
<span className="line-clamp-2 text-xs text-muted-foreground">
|
||||||
{entry.shortDescription}
|
{entry.shortDescription}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { useState } from 'react'
|
||||||
import { WizardTrendSkipTrailing } from '@/components/campaign/municipality/WizardTrendSkipTrailing'
|
import { WizardTrendSkipTrailing } from '@/components/campaign/municipality/WizardTrendSkipTrailing'
|
||||||
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
import { CampaignWizardNavLink } from '@/components/campaign/shared/CampaignWizardNavLink'
|
||||||
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
||||||
|
import { Badge } from '@/components/ui/Badge'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import {
|
import {
|
||||||
Drawer,
|
Drawer,
|
||||||
|
|
@ -26,12 +27,16 @@ import {
|
||||||
import {
|
import {
|
||||||
resolveWizardTrendSkip,
|
resolveWizardTrendSkip,
|
||||||
selectablePoliticalTrendStatuses,
|
selectablePoliticalTrendStatuses,
|
||||||
wizardTrendChoiceStepTitle,
|
WIZARD_CURRENT_TREND_CHIP_LABEL,
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
import { wizardStepPreviousHref } from '@/lib/wizardBack'
|
||||||
|
import {
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
} from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
type WizardTrendChoiceStepProps = {
|
type WizardTrendChoiceStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -43,6 +48,30 @@ type WizardTrendChoiceStepProps = {
|
||||||
returnPath?: string
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CurrentTrendCard = ({ entry }: { entry: PoliticalTrendWizardMetaEntry }) => {
|
||||||
|
const Icon = entry.icon
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'col-span-2 flex items-center justify-between gap-3 rounded-lg border border-border bg-background p-3',
|
||||||
|
WIZARD_THUMB_TILE_ITEM_CLASS,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="truncate text-sm font-medium">{entry.label}</p>
|
||||||
|
<p className="line-clamp-2 text-xs text-muted-foreground">{entry.changeDescription}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Badge variant="secondary" className="shrink-0">
|
||||||
|
{WIZARD_CURRENT_TREND_CHIP_LABEL}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const WizardTrendChoiceStep = ({
|
export const WizardTrendChoiceStep = ({
|
||||||
actionSlug,
|
actionSlug,
|
||||||
municipalityName,
|
municipalityName,
|
||||||
|
|
@ -55,13 +84,14 @@ export const WizardTrendChoiceStep = ({
|
||||||
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
||||||
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const options = selectablePoliticalTrendStatuses(currentStatus)
|
const options = selectablePoliticalTrendStatuses(currentStatus)
|
||||||
|
const currentEntry = currentStatus ? politicalTrendWizardMetaByStatus[currentStatus] : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={wizardTrendChoiceStepTitle(currentStatus)}
|
stepTitle={null}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'trend-choice',
|
step: 'trend-choice',
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -71,13 +101,15 @@ export const WizardTrendChoiceStep = ({
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
|
contentAlign="end"
|
||||||
>
|
>
|
||||||
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
<ul className={WIZARD_THUMB_TILE_GRID_CLASS}>
|
||||||
|
{currentEntry ? <CurrentTrendCard entry={currentEntry} /> : null}
|
||||||
{options.map((status) => {
|
{options.map((status) => {
|
||||||
const entry = politicalTrendWizardMetaByStatus[status]
|
const entry = politicalTrendWizardMetaByStatus[status]
|
||||||
const Icon = entry.icon
|
const Icon = entry.icon
|
||||||
return (
|
return (
|
||||||
<li key={status} className="relative">
|
<li key={status} className={cn('relative', WIZARD_THUMB_TILE_ITEM_CLASS)}>
|
||||||
<CampaignWizardNavLink
|
<CampaignWizardNavLink
|
||||||
href={wizardTrendHref(
|
href={wizardTrendHref(
|
||||||
actionSlug,
|
actionSlug,
|
||||||
|
|
@ -88,15 +120,14 @@ export const WizardTrendChoiceStep = ({
|
||||||
returnPath,
|
returnPath,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border bg-background p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-background p-3 pr-10 text-left text-foreground',
|
||||||
entry.tileClassName,
|
|
||||||
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon className="size-5 shrink-0" aria-hidden />
|
<Icon className={cn('size-5 shrink-0', entry.iconClassName)} aria-hidden />
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-sm font-medium">{entry.label}</span>
|
<span className="text-sm font-medium">{entry.label}</span>
|
||||||
<span className="line-clamp-2 text-xs opacity-80">
|
<span className="line-clamp-2 text-xs text-muted-foreground">
|
||||||
{entry.changeDescription}
|
{entry.changeDescription}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import {
|
||||||
WIZARD_VOTES_FINAL_CTA_LABEL,
|
WIZARD_VOTES_FINAL_CTA_LABEL,
|
||||||
WIZARD_VOTES_SAVED_MESSAGE,
|
WIZARD_VOTES_SAVED_MESSAGE,
|
||||||
wizardFlowTitleForSlug,
|
wizardFlowTitleForSlug,
|
||||||
wizardNextStepTitle,
|
|
||||||
} from '@/lib/campaignWizardCopy'
|
} from '@/lib/campaignWizardCopy'
|
||||||
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
||||||
import {
|
import {
|
||||||
|
|
@ -136,7 +135,7 @@ export const WizardExpectedVotesStep = ({
|
||||||
return (
|
return (
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
stepTitle={wizardNextStepTitle(actionSlug)}
|
stepTitle={null}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
previousHref={wizardStepPreviousHref({
|
previousHref={wizardStepPreviousHref({
|
||||||
step: 'expected-votes',
|
step: 'expected-votes',
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export type MunicipalitySignalTypeMetaEntry = {
|
||||||
shortDescription: string
|
shortDescription: string
|
||||||
infoContent: string
|
infoContent: string
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
|
iconClassName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
||||||
|
|
@ -30,6 +31,14 @@ const signalTypeIcons: Record<MunicipalitySignalType, LucideIcon> = {
|
||||||
outro: CircleHelp,
|
outro: CircleHelp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const signalTypeIconClassNames: Record<MunicipalitySignalType, string> = {
|
||||||
|
invasao: 'text-destructive',
|
||||||
|
esfriamento: 'text-sky-600',
|
||||||
|
visita_adversario: 'text-amber-600',
|
||||||
|
proposta_broker: 'text-teal-600',
|
||||||
|
outro: 'text-muted-foreground',
|
||||||
|
}
|
||||||
|
|
||||||
const signalTypeInfoContent: Record<MunicipalitySignalType, string> = {
|
const signalTypeInfoContent: Record<MunicipalitySignalType, string> = {
|
||||||
invasao:
|
invasao:
|
||||||
'O adversário está ocupando espaço que era nosso: reunião, base, narrativa ou presença no território. Consequência: a rede pode esfriar ou a leitura do município muda. Use quando a equipe perceber invasão real, não só boatos.',
|
'O adversário está ocupando espaço que era nosso: reunião, base, narrativa ou presença no território. Consequência: a rede pode esfriar ou a leitura do município muda. Use quando a equipe perceber invasão real, não só boatos.',
|
||||||
|
|
@ -50,6 +59,7 @@ export const municipalitySignalTypeMeta: MunicipalitySignalTypeMetaEntry[] =
|
||||||
shortDescription: municipalitySignalTypeDescriptions[type],
|
shortDescription: municipalitySignalTypeDescriptions[type],
|
||||||
infoContent: signalTypeInfoContent[type],
|
infoContent: signalTypeInfoContent[type],
|
||||||
icon: signalTypeIcons[type],
|
icon: signalTypeIcons[type],
|
||||||
|
iconClassName: signalTypeIconClassNames[type],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
export const municipalitySignalTypeMetaByType = Object.fromEntries(
|
export const municipalitySignalTypeMetaByType = Object.fromEntries(
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export type PoliticalTrendWizardMetaEntry = {
|
||||||
changeDescription: string
|
changeDescription: string
|
||||||
infoContent: string
|
infoContent: string
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
tileClassName: string
|
iconClassName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
||||||
|
|
@ -23,10 +23,10 @@ const trendIcons: Record<PoliticalTrendStatusValue, LucideIcon> = {
|
||||||
desfavoravel: ThumbsDown,
|
desfavoravel: ThumbsDown,
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendTileClassNames: Record<PoliticalTrendStatusValue, string> = {
|
const trendIconClassNames: Record<PoliticalTrendStatusValue, string> = {
|
||||||
favoravel: 'border-estimate-confirmed-foreground text-estimate-confirmed-foreground',
|
favoravel: 'text-estimate-confirmed-foreground',
|
||||||
neutra: 'border-border text-foreground',
|
neutra: 'text-muted-foreground',
|
||||||
desfavoravel: 'border-destructive text-destructive',
|
desfavoravel: 'text-destructive',
|
||||||
}
|
}
|
||||||
|
|
||||||
const trendInfoContent: Record<PoliticalTrendStatusValue, string> = {
|
const trendInfoContent: Record<PoliticalTrendStatusValue, string> = {
|
||||||
|
|
@ -45,7 +45,7 @@ export const politicalTrendWizardMeta: PoliticalTrendWizardMetaEntry[] = politic
|
||||||
changeDescription: `Mudar tendência para ${politicalTrendDisplayLabels[status]}`,
|
changeDescription: `Mudar tendência para ${politicalTrendDisplayLabels[status]}`,
|
||||||
infoContent: trendInfoContent[status],
|
infoContent: trendInfoContent[status],
|
||||||
icon: trendIcons[status],
|
icon: trendIcons[status],
|
||||||
tileClassName: trendTileClassNames[status],
|
iconClassName: trendIconClassNames[status],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ export const WIZARD_TREND_SAVED_MESSAGE = 'Tendência política registrada.' as
|
||||||
|
|
||||||
export const WIZARD_TREND_UNREGISTERED_TITLE = 'Tendência não registrada' as const
|
export const WIZARD_TREND_UNREGISTERED_TITLE = 'Tendência não registrada' as const
|
||||||
|
|
||||||
|
export const WIZARD_CURRENT_TREND_CHIP_LABEL = 'Atual' as const
|
||||||
|
|
||||||
export type WizardTrendSkipAction = {
|
export type WizardTrendSkipAction = {
|
||||||
label: string
|
label: string
|
||||||
href: string
|
href: string
|
||||||
|
|
|
||||||
17
src/lib/wizardThumbGrid.ts
Normal file
17
src/lib/wizardThumbGrid.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
|
|
||||||
|
/** Thumb-zone grid: mobile fills from bottom-right; desktop is a normal LTR grid. */
|
||||||
|
export const WIZARD_THUMB_TILE_GRID_CLASS =
|
||||||
|
'grid list-none grid-cols-2 gap-3 place-content-end [direction:rtl] md:grid-cols-3 md:place-content-start md:[direction:ltr]'
|
||||||
|
|
||||||
|
/** Reset text direction inside an RTL thumb grid cell. */
|
||||||
|
export const WIZARD_THUMB_TILE_ITEM_CLASS = '[direction:ltr]'
|
||||||
|
|
||||||
|
/** Signal types ordered for thumb reach — urgency types render last in DOM (= bottom-right on mobile). */
|
||||||
|
export const wizardSignalTypesThumbOrder: MunicipalitySignalType[] = [
|
||||||
|
'invasao',
|
||||||
|
'esfriamento',
|
||||||
|
'visita_adversario',
|
||||||
|
'proposta_broker',
|
||||||
|
'outro',
|
||||||
|
]
|
||||||
|
|
@ -112,7 +112,7 @@ describe('politicalTrendWizardMeta', () => {
|
||||||
expect(entry.changeDescription).toContain(entry.label)
|
expect(entry.changeDescription).toContain(entry.label)
|
||||||
expect(entry.infoContent.length).toBeGreaterThan(20)
|
expect(entry.infoContent.length).toBeGreaterThan(20)
|
||||||
expect(entry.icon).toBeTruthy()
|
expect(entry.icon).toBeTruthy()
|
||||||
expect(entry.tileClassName.length).toBeGreaterThan(0)
|
expect(entry.iconClassName.length).toBeGreaterThan(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ describe('WizardExpectedVotesStep', () => {
|
||||||
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
||||||
|
|
||||||
const step = screen.getByRole('main', { name: /Ajustar votos estimados/i })
|
const step = screen.getByRole('main', { name: /Ação: Ajustar votos/i })
|
||||||
expect(within(step).getByRole('alert').textContent).toMatch(/Pessimista/i)
|
expect(within(step).getByRole('alert').textContent).toMatch(/Pessimista/i)
|
||||||
expect(screen.getByLabelText('Pessimista').getAttribute('aria-invalid')).toBe('true')
|
expect(screen.getByLabelText('Pessimista').getAttribute('aria-invalid')).toBe('true')
|
||||||
expect(screen.getByLabelText('Média').getAttribute('aria-invalid')).toBe('true')
|
expect(screen.getByLabelText('Média').getAttribute('aria-invalid')).toBe('true')
|
||||||
|
|
@ -88,7 +88,7 @@ describe('WizardExpectedVotesStep', () => {
|
||||||
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
fireEvent.change(screen.getByLabelText('Pessimista'), { target: { value: '900' } })
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Salvar estimativas →' }))
|
||||||
|
|
||||||
const step = screen.getByRole('main', { name: /Ajustar votos estimados/i })
|
const step = screen.getByRole('main', { name: /Ação: Ajustar votos/i })
|
||||||
expect(within(step).getByRole('alert')).toBeTruthy()
|
expect(within(step).getByRole('alert')).toBeTruthy()
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText('Média'), { target: { value: '950' } })
|
fireEvent.change(screen.getByLabelText('Média'), { target: { value: '950' } })
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ describe('municipalitySignalTypeMeta', () => {
|
||||||
expect(entry?.shortDescription.length).toBeGreaterThan(0)
|
expect(entry?.shortDescription.length).toBeGreaterThan(0)
|
||||||
expect(entry?.infoContent.length).toBeGreaterThan(20)
|
expect(entry?.infoContent.length).toBeGreaterThan(20)
|
||||||
expect(entry?.icon).toBeTruthy()
|
expect(entry?.icon).toBeTruthy()
|
||||||
|
expect(entry?.iconClassName.length).toBeGreaterThan(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
64
tests/unit/wizardThumbGrid.unit.spec.ts
Normal file
64
tests/unit/wizardThumbGrid.unit.spec.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
|
||||||
|
import {
|
||||||
|
municipalitySignalTypeMetaByType,
|
||||||
|
} from '@/lib/municipalitySignalTypeMeta'
|
||||||
|
import {
|
||||||
|
politicalTrendWizardMeta,
|
||||||
|
politicalTrendWizardMetaByStatus,
|
||||||
|
} from '@/lib/politicalTrendWizardMeta'
|
||||||
|
import { politicalTrendStatuses } from '@/lib/schemas/municipality'
|
||||||
|
import { municipalitySignalTypes } from '@/lib/schemas/municipalityUpdate'
|
||||||
|
import {
|
||||||
|
WIZARD_THUMB_TILE_GRID_CLASS,
|
||||||
|
wizardSignalTypesThumbOrder,
|
||||||
|
} from '@/lib/wizardThumbGrid'
|
||||||
|
|
||||||
|
describe('wizardThumbGrid', () => {
|
||||||
|
it('pins thumb-zone grid classes for mobile RTL fill and desktop LTR grid', () => {
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('list-none')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('[direction:rtl]')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('place-content-end')
|
||||||
|
expect(WIZARD_THUMB_TILE_GRID_CLASS).toContain('md:[direction:ltr]')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('orders signal types with urgency types first in DOM for thumb reach', () => {
|
||||||
|
expect(wizardSignalTypesThumbOrder[0]).toBe('invasao')
|
||||||
|
expect(wizardSignalTypesThumbOrder[1]).toBe('esfriamento')
|
||||||
|
expect(wizardSignalTypesThumbOrder).toHaveLength(municipalitySignalTypes.length)
|
||||||
|
expect(new Set(wizardSignalTypesThumbOrder)).toEqual(new Set(municipalitySignalTypes))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('municipalitySignalTypeMeta icon colors', () => {
|
||||||
|
it('covers every signal type with a semantic icon class', () => {
|
||||||
|
for (const type of municipalitySignalTypes) {
|
||||||
|
const entry = municipalitySignalTypeMetaByType[type]
|
||||||
|
expect(entry?.iconClassName.length).toBeGreaterThan(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(municipalitySignalTypeMetaByType.invasao.iconClassName).toContain('destructive')
|
||||||
|
expect(municipalitySignalTypeMetaByType.esfriamento.iconClassName).toContain('sky')
|
||||||
|
expect(municipalitySignalTypeMetaByType.visita_adversario.iconClassName).toContain('amber')
|
||||||
|
expect(municipalitySignalTypeMetaByType.proposta_broker.iconClassName).toContain('teal')
|
||||||
|
expect(municipalitySignalTypeMetaByType.outro.iconClassName).toContain('muted-foreground')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('politicalTrendWizardMeta icon colors', () => {
|
||||||
|
it('covers every trend with icon-only semantic classes', () => {
|
||||||
|
expect(politicalTrendWizardMeta).toHaveLength(politicalTrendStatuses.length)
|
||||||
|
|
||||||
|
for (const status of politicalTrendStatuses) {
|
||||||
|
const entry = politicalTrendWizardMetaByStatus[status]
|
||||||
|
expect(entry.iconClassName.length).toBeGreaterThan(0)
|
||||||
|
expect(entry.icon).toBeTruthy()
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(politicalTrendWizardMetaByStatus.favoravel.iconClassName).toContain(
|
||||||
|
'estimate-confirmed',
|
||||||
|
)
|
||||||
|
expect(politicalTrendWizardMetaByStatus.desfavoravel.iconClassName).toContain('destructive')
|
||||||
|
expect(politicalTrendWizardMetaByStatus.neutra.iconClassName).toContain('muted-foreground')
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue