: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { useValues } from 'kea'
import { productTourLogic } from '../productTourLogic'
import { isBannerAnnouncement } from '../productToursLogic'
import { hasElementTarget } from '../stepUtils'
import { PostHogLogo } from './icons'
export function FooterPreview({ tourId }: { tourId: string }): JSX.Element | null {
const { productTour, productTourForm, selectedStep, selectedStepIndex } = useValues(
productTourLogic({ id: tourId })
)
const steps = productTourForm.content?.steps ?? []
const appearance = productTourForm.content?.appearance
if (productTour && isBannerAnnouncement(productTour)) {
return null
}
if (!selectedStep) {
return null
}
const totalSteps = steps.length
const isFirstStep = selectedStepIndex === 0
const hasCustomButtons = !!selectedStep.buttons
const needsDefaultButtons = selectedStep.progressionTrigger === 'button' || !hasElementTarget(selectedStep)
const showButtons = hasCustomButtons || needsDefaultButtons
const showProgress = totalSteps > 1
const showBranding = isFirstStep && !appearance?.whiteLabel
if (!showButtons && !showProgress && !showBranding) {
return null
}
const isLastStep = selectedStepIndex >= totalSteps - 1
const primaryText = selectedStep.buttons?.primary?.text ?? (isLastStep ? 'Done' : 'Next')
const secondaryText = selectedStep.buttons?.secondary?.text ?? 'Back'
const showSecondary = hasCustomButtons ? !!selectedStep.buttons?.secondary : !isFirstStep
return (
<>
{(showButtons || showProgress) && (
<div className="StepContentEditor__footer">
{showProgress && (
<span className="StepContentEditor__progress">
{selectedStepIndex + 1} of {totalSteps}
</span>
)}
{showButtons && (
<div className="StepContentEditor__buttons">
{showSecondary && (
<button
type="button"
className="StepContentEditor__button StepContentEditor__button--secondary"
>
{secondaryText}
</button>
)}
<button
type="button"
className="StepContentEditor__button StepContentEditor__button--primary"
>
{primaryText}
</button>
</div>
)}
</div>
)}
{showBranding && (
<div className="StepContentEditor__branding">
Tour by <PostHogLogo />
</div>
)}
</>
)
}