Skip to main content

Shared Components

The src/shared/components/ directory provides reusable UI components built on Chakra UI.

Component Categories

shared/components/
├── forms/          # Form inputs and wrappers
├── tables/         # Data table components
├── layout/         # Page and section layouts
├── inputs/         # Input components
├── feedback/       # Alerts, toasts, loading
└── display/        # Cards, badges, labels

Layout Components

Page

import { Page, PageHeader, PageContent } from "@/shared/components";

function MyPage() {
  return (
    <Page>
      <PageHeader
        title="Fund Families"
        description="Manage your fund families"
        actions={<Button>Create</Button>}
      />
      <PageContent>
        {/* Page content */}
      </PageContent>
    </Page>
  );
}

Section

import { Section } from "@/shared/components";

<Section
  title="Details"
  description="Fund family information"
  actions={<EditButton />}
>
  <DetailsContent />
</Section>

Form Components

Form Wrapper

import { Form, FormField, FormInput } from "@/shared/components";

function MyForm() {
  const methods = useForm<FormData>();
  
  return (
    <Form methods={methods} onSubmit={handleSubmit}>
      <FormField name="name" label="Name" required>
        <FormInput name="name" />
      </FormField>
      
      <FormField name="description" label="Description">
        <FormTextarea name="description" />
      </FormField>
      
      <SubmitButton>Save</SubmitButton>
    </Form>
  );
}

Input Types

// Text input
<FormInput name="name" placeholder="Enter name" />

// Number input
<FormNumberInput name="amount" prefix="$" />

// Select
<FormSelect name="status" options={statusOptions} />

// Date picker
<FormDatePicker name="effectiveDate" />

// Money input
<FormMoneyInput name="commitment" currency="USD" />

Table Components

Data Table

import { DataTable } from "@/shared/components";

function MyTable() {
  const columns = [
    { field: "name", headerName: "Name" },
    { field: "status", headerName: "Status" },
    { field: "amount", headerName: "Amount", type: "money" },
  ];
  
  return (
    <DataTable
      columns={columns}
      data={data}
      onRowClick={handleRowClick}
    />
  );
}

AG-Grid Integration

import { AGGridTable } from "@/shared/components";

<AGGridTable
  columnDefs={columnDefs}
  rowData={rowData}
  pagination={true}
  paginationPageSize={25}
  enableRangeSelection={true}
/>

Input Components

Money Input

<MoneyInput
  value={amount}
  onChange={setAmount}
  currency="USD"
  allowNegative={false}
/>

Date Picker

<DatePicker
  value={date}
  onChange={setDate}
  minDate={minDate}
  maxDate={maxDate}
/>

Entity Select

<EntitySelect
  entityType="investor"
  value={selectedId}
  onChange={setSelectedId}
  filter={{ status: "active" }}
/>

Feedback Components

Loading

import { PageLoader, Spinner, Skeleton } from "@/shared/components";

// Full page loader
<PageLoader />

// Inline spinner
<Spinner size="sm" />

// Content skeleton
<Skeleton height="20px" />

Alerts

import { Alert, ErrorAlert } from "@/shared/components";

<Alert status="warning" title="Pending Changes">
  You have unsaved changes.
</Alert>

<ErrorAlert error={error} onRetry={refetch} />

Toast

import { useToast } from "@/shared/hooks";

const toast = useToast();

toast.success("Saved successfully");
toast.error("Failed to save");
toast.warning("Check your input");
import { Modal, Drawer } from "@/shared/components";

<Modal
  isOpen={isOpen}
  onClose={onClose}
  title="Edit Fund Family"
>
  <ModalBody>
    <EditForm />
  </ModalBody>
  <ModalFooter>
    <Button onClick={onClose}>Cancel</Button>
    <Button colorScheme="blue">Save</Button>
  </ModalFooter>
</Modal>

<Drawer
  isOpen={isOpen}
  onClose={onClose}
  title="Details"
  size="md"
>
  <DrawerBody>
    <DetailPanel />
  </DrawerBody>
</Drawer>

Using Components

Import from the shared barrel:
import {
  Page,
  PageHeader,
  Form,
  FormInput,
  DataTable,
  Alert,
} from "@/shared/components";