Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.4 KB
Raw Blame
import { useActions } from 'kea'
import type { ReactNode } from 'react'

import { TodayFigureCard } from './TodayFigureCard'
import { TodayFigureCardContent } from './todayFigureSources'
import { TodayHoverMark } from './TodayHoverMark'
import { TodayPenMark } from './TodayPenMark'
import { circlePath } from './todayPenPaths'
import { type TodayMarkKind, todayReportLogic } from './todayReportLogic'

const PEN_DELAY_MS = 250
const PEN_STAGGER_MS = 160

export function TodayFigureMark({
    children,
    figure,
    content,
    reportId,
    order,
    kind,
}: {
    children: ReactNode
    figure: string
    content: TodayFigureCardContent
    reportId: string
    order: number
    kind: TodayMarkKind
}): JSX.Element {
    const { markOpened } = useActions(todayReportLogic({ reportId }))
    return (
        <TodayHoverMark
            className="TodayFigureMark"
            dataAttr="today-report-figure"
            onOpen={() => markOpened(kind)}
            card={<TodayFigureCard content={content} figure={figure} reportId={reportId} />}
        >
            <TodayPenMark seed={figure} delayMs={PEN_DELAY_MS + order * PEN_STAGGER_MS}>
                {children}
            </TodayPenMark>
            <svg className="TodayFigureMark__circle" viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden>
                <path d={circlePath(figure)} pathLength={1} />
            </svg>
        </TodayHoverMark>
    )
}