mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
- Empty blur → collapsed; blur with text stays FULL (drawer whenEmpty policy). - Handle tap and snap→collapsed clear search so uiFocused cannot reopen FULL. - Keep all snap points while focused so swipe ↓ can dismiss. - Pathname change (in-chrome) clears + collapses; initial load stays dock. - Compact dock/search stack gap (~⅓) without cutting safe-area. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
createContext,
|
|
useContext,
|
|
useMemo,
|
|
useState,
|
|
type Dispatch,
|
|
type ReactNode,
|
|
type SetStateAction,
|
|
} from 'react'
|
|
|
|
import {
|
|
QUICK_ACTIONS_SNAP_DOCK,
|
|
quickActionsSnapIsDock,
|
|
quickActionsSnapIsFull,
|
|
type QuickActionsSnapPoint,
|
|
} from '@/lib/campaignQuickActionSnap'
|
|
|
|
type CampaignQuickActionsSnapContextValue = {
|
|
snapPoint: QuickActionsSnapPoint | null
|
|
setSnapPoint: Dispatch<SetStateAction<QuickActionsSnapPoint | null>>
|
|
isDock: boolean
|
|
isFull: boolean
|
|
}
|
|
|
|
const CampaignQuickActionsSnapContext = createContext<CampaignQuickActionsSnapContextValue | null>(
|
|
null,
|
|
)
|
|
|
|
export const CampaignQuickActionsSnapProvider = ({ children }: { children: ReactNode }) => {
|
|
// B112 — load = dock; pathname collapse lives in the drawer (needs `clear`).
|
|
const [snapPoint, setSnapPoint] = useState<QuickActionsSnapPoint | null>(QUICK_ACTIONS_SNAP_DOCK)
|
|
|
|
const value = useMemo(
|
|
(): CampaignQuickActionsSnapContextValue => ({
|
|
snapPoint,
|
|
setSnapPoint,
|
|
isDock: quickActionsSnapIsDock(snapPoint),
|
|
isFull: quickActionsSnapIsFull(snapPoint),
|
|
}),
|
|
[snapPoint],
|
|
)
|
|
|
|
return (
|
|
<CampaignQuickActionsSnapContext.Provider value={value}>
|
|
{children}
|
|
</CampaignQuickActionsSnapContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useCampaignQuickActionsSnap = (): CampaignQuickActionsSnapContextValue => {
|
|
const value = useContext(CampaignQuickActionsSnapContext)
|
|
if (!value) {
|
|
throw new Error('CampaignQuickActionsSnapProvider is required')
|
|
}
|
|
return value
|
|
}
|