Component Library
This document describes the reusable component conventions in the Rhesis frontend. There is no generic design-system wrapper library (no custom Button/TextField/Select/Card) — components either use MUI directly or wrap it under a Base* prefix for shared behavior (pagination, loading states, action buttons).
Component Organization
Layout
AppShell
Root two-column layout (src/components/layout/AppShell.tsx) — a CSS grid of sidebar + content, with collapse state shared via SidebarCollapseContext so children don’t need prop-drilling:
Sidebar
src/components/navigation/Sidebar.tsx reads navigation items from useNavigationItems(), collapse state from useSidebarCollapse() (exported by AppShell), and theme mode from ColorModeContext — it takes no isOpen/onToggle props.
Common Components (src/components/common/)
The directory is flat (no form//data-display/ subfolders). Notable Base* components:
| Component | Purpose |
|---|---|
BaseDataGrid | Wraps MUI X DataGrid — columns, rows, actionButtons, toolbar, density, row click |
BaseTable | Simpler tabular display — columns, data, actionButtons, row highlighting |
BaseDrawer | Side-panel form/detail drawer — open, onClose, onSave, onDelete, loading/error state |
BaseLineChart / BasePieChart / BaseScatterChart | Recharts wrappers with theme-aware color palettes |
BaseChartsGrid | Layout grid for arranging multiple chart components |
BaseTag, BaseFreesoloAutocomplete, BaseWorkflowSection | Smaller shared UI primitives |
ActionBar | Toolbar of action buttons above lists/grids |
Can | Affordance primitives — can(), useCan(), <Can> (see apps/frontend/AGENTS.md) |
EntityCard and other entity-specific cards | Feature-specific display cards (no generic Card wrapper exists) |
There is no LineChart/BarChart/FlowChart generic component — React Flow (reactflow) is used directly in one place, SpanGraphView under the traces feature, not as a reusable common component.
BaseDataGrid props (abridged)
BaseDrawer props
Using Components
Component Best Practices
- Use TypeScript props interfaces for every component
- Prefer composing MUI directly over introducing new generic wrappers — reach for a
Base*component only when the same cross-cutting behavior (pagination, loading, action buttons) repeats across features - Gate on affordances, not ad-hoc ownership checks — use
can/useCan/<Can>(seeapps/frontend/AGENTS.md) - Accessibility: components should meet WCAG standards
- Responsive design: components should work across screen sizes
Creating New Components
- Place them in the appropriate directory based on purpose (
common/for cross-feature reuse, otherwise the relevant feature directory) - Define a clear TypeScript props interface
- Add test cases alongside the component (see Testing)
- Consider reusability, but don’t generalize a one-off into a
Base*component prematurely