.. _frontend-components:
==========
Components
==========
This page documents the reusable React components in ``frontend/src/components/``.
----
Layout Components
=================
:Location: ``src/components/layout/``
Components that define the overall page structure.
Layout.tsx
----------
Main layout wrapper that provides the header, sidebar, and content area.
.. code-block:: text
import { Layout } from '@/components/layout/Layout'
// Used in App.tsx as the root route element
}>
} />
{/* Child routes render in the Outlet */}
Structure:
.. code-block:: text
┌─────────────────────────────────────────────────┐
│ Header │
├──────────┬──────────────────────────────────────┤
│ │ │
│ Sidebar │ Content │
│ │ (Outlet) │
│ │ │
└──────────┴──────────────────────────────────────┘
Header.tsx
----------
Top navigation bar with logo, title, and global actions.
.. code-block:: text
FUSION
{/* Theme toggle, user menu, etc. */}
Sidebar.tsx
-----------
Navigation sidebar with links to all pages.
.. code-block:: text
const navItems = [
{ path: '/', label: 'Runs', icon: PlayIcon },
{ path: '/topology', label: 'Topology', icon: NetworkIcon },
{ path: '/config', label: 'Config', icon: FileIcon },
{ path: '/codebase', label: 'Codebase', icon: CodeIcon },
{ path: '/settings', label: 'Settings', icon: SettingsIcon },
]
----
Run Components
==============
:Location: ``src/components/runs/``
Components for displaying and managing simulation runs.
RunCard.tsx
-----------
Card component displaying a single run in the list view.
.. code-block:: text
interface RunCardProps {
run: Run
onClick?: () => void
}
function RunCard({ run, onClick }: RunCardProps) {
return (
{run.name || run.id}
Created: {formatDate(run.created_at)}
)
}
RunStatusBadge.tsx
------------------
Status indicator badge with appropriate colors.
.. code-block:: text
interface RunStatusBadgeProps {
status: RunStatus
}
const statusColors = {
PENDING: 'bg-yellow-100 text-yellow-800',
RUNNING: 'bg-blue-100 text-blue-800',
COMPLETED: 'bg-green-100 text-green-800',
FAILED: 'bg-red-100 text-red-800',
CANCELLED: 'bg-gray-100 text-gray-800',
}
function RunStatusBadge({ status }: RunStatusBadgeProps) {
return (
{status}
)
}
ProgressChart.tsx
-----------------
Visual progress indicator for running simulations.
.. code-block:: text
interface ProgressChartProps {
progress: RunProgress | null
}
function ProgressChart({ progress }: ProgressChartProps) {
if (!progress) return null
const percent = progress.percent_complete ?? 0
return (