Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
2.0 KB
Raw Blame
'use client'

import React from 'react'
import { CreateFlowPanel } from '@components/CreateFlowPanel'
import { CreatePageHeader } from '@components/CreatePageHeader'
import { DashboardLayout } from '@components/DashboardLayout'
import { TabBar } from '@components/TabBar'
import { cn } from '@lib/cn'
import type { DetailPageShellProps } from './types'

export function DetailPageShell<T extends string>({
  actions,
  activeTab,
  backDisabled,
  backLabel,
  children,
  className,
  contentClassName,
  contentMode = 'card',
  error,
  eyebrow,
  icon,
  notice,
  onBack,
  overlays,
  onTabChange,
  subtitle,
  tabAriaLabel,
  tabClassName,
  tabs,
  title,
  titleActions,
}: DetailPageShellProps<T>) {
  return (
    <DashboardLayout isDetailPage>
      <CreateFlowPanel
        className={cn('cu-detail-flow-panel', className)}
        header={
          <CreatePageHeader
            actions={actions}
            backDisabled={backDisabled}
            backLabel={backLabel}
            eyebrow={eyebrow}
            icon={icon}
            onBack={onBack}
            subtitle={subtitle}
            title={title}
            titleActions={titleActions}
          />
        }
      >
        {tabs && activeTab !== undefined && onTabChange && tabAriaLabel ? (
          <TabBar<T>
            ariaLabel={tabAriaLabel ?? 'Detail sections'}
            activeValue={activeTab as T}
            className={tabClassName}
            onChange={onTabChange as (value: T) => void}
            options={tabs}
          />
        ) : null}
      </CreateFlowPanel>

      {notice}
      {error ? (
        <div className="cu-banner cu-banner--error" role="alert">
          {error}
        </div>
      ) : null}

      {contentMode === 'plain' ? (
        <div className={cn('cu-detail-content-stack', contentClassName)}>{children}</div>
      ) : (
        <div className={cn('cu-card', contentClassName)}>
          <div className="cu-card__body">{children}</div>
        </div>
      )}
      {overlays}
    </DashboardLayout>
  )
}