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.

2.2 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { IconSearch } from '@posthog/icons'
import { cn } from '@posthog/quill'

import { commandLogic } from 'lib/components/Command/commandLogic'

import { TODAY_PANES } from './todayRailItems'
import { TODAY_RAIL_PANES, todayShellLogic } from './todayShellLogic'

const TAB_CLASS =
    'flex min-w-0 flex-1 cursor-pointer flex-col items-center justify-center gap-0.5 rounded-md text-xxs font-medium outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-inset [&_svg]:size-5'

export function TodayTabBar(): JSX.Element {
    const { activePane } = useValues(todayShellLogic)
    const { clickRailPane } = useActions(todayShellLogic)
    const { toggleCommand } = useActions(commandLogic)

    return (
        <div className="TodayTabBar" data-quill>
            <nav aria-label="Main" className="flex h-14 min-w-0 flex-1 gap-1">
                {TODAY_RAIL_PANES.map((pane) => {
                    const { label, icon } = TODAY_PANES[pane]
                    const active = activePane === pane
                    return (
                        <button
                            key={pane}
                            type="button"
                            aria-current={active ? 'page' : undefined}
                            data-attr={`today-rail-${pane}`}
                            onClick={() => clickRailPane(pane)}
                            className={cn(
                                TAB_CLASS,
                                active ? 'bg-fill-selected text-foreground' : 'text-muted-foreground'
                            )}
                        >
                            {icon}
                            <span className="max-w-full truncate">{label}</span>
                        </button>
                    )
                })}
                <button
                    type="button"
                    data-attr="today-rail-search"
                    onClick={() => toggleCommand('nav-search-button')}
                    className={cn(TAB_CLASS, 'text-muted-foreground')}
                >
                    <IconSearch />
                    <span className="max-w-full truncate">Search</span>
                </button>
            </nav>
        </div>
    )
}