Skip to main content

Views

DataTable

Description

The DataTable component is a versatile and customizable table component designed for displaying tabular data. It supports features such as pagination, search functionality, and row click handling, making it suitable for a wide range of applications where data needs to be presented in a tabular format.

Use Case

This component is ideal for:

  • Displaying lists of items in a tabular format.
  • Providing search functionality to filter data.
  • Enabling pagination to navigate through large datasets.
  • Handling row clicks for interactive data tables.

Props Table

Prop NameTypeDescriptionDefault ValueRequired
datasetT[]The array of data items to be displayed in the table. Each item should be an object with key-value pairs representing columns and their values.N/AYes
headerLabelsstring[]An array of strings representing the labels for the table headers.undefinedNo
paginationbooleanA boolean indicating whether pagination is enabled.trueNo
paginationType"infinite-loading" | "default"The type of pagination to be used ("infinite-loading" or "default")."default"No
onClickRow(label: string, index: number) => voidCallback function to handle row clicks. Receives the label and index of the clicked row as parameters.undefinedNo
numberOfRowsnumberThe number of rows to display per page.10No
rowStyleTypes"transparent" | "outline" | "alternative-fill"The style type for rows."transparent"No
searchBarPosition"start" | "center" | "end"The position of the search bar."end"No

Example

import React from "react";
import DataTable from "./DataTable";
import { DataTableItemType } from "./datatable.types";

const dataset: DataTableItemType[] = [
{ name: "John Doe", age: 30, email: "john@example.com" },
{ name: "Jane Smith", age: 25, email: "jane@example.com" },
// ...more data items
];

const headerLabels = ["Name", "Age", "Email"];

const App: React.FC = () => {
const handleRowClick = (label: string, index: number) => {
console.log(`Clicked row with label ${label} at index ${index}`);
};

return (
<DataTable
dataset={dataset}
headerLabels={headerLabels}
onClickRow={handleRowClick}
/>
);
};

export default App;

Flex

Description

The Flex component is a versatile layout component that utilizes CSS flexbox to arrange its children. It supports various flex properties such as direction, wrapping, and flexible weights for child elements.

Use Case

This component is ideal for:

  • Creating flexible and responsive layouts.
  • Aligning and distributing space among items in a container.
  • Building complex grid systems using flex properties.

Props Table

Prop NameTypeDescriptionDefault ValueRequired
direction"row" | "column" | "row-reverse" | "column-reverse"Defines the direction of the flex container's main axis."row"No
weightnumber[]An array of numbers defining the flex-grow values for each child element. The number of elements in the array must match the number of children.undefinedNo
wrapbooleanDetermines whether the flex container's children should wrap onto multiple lines.falseNo
maxRownumberThe maximum number of rows. (Not used in the current implementation but included for extensibility.)undefinedNo

Example

import React from "react";
import { Flex } from "./Flex";

const App: React.FC = () => {
return (
<Flex direction="row" weight={[1, 2, 1]} wrap={true} className="customClass">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</Flex>
);
};

export default App;

Image

Description

The Image component is a flexible and customizable image container that supports various properties such as overlay, aspect ratio, border radius, and object fit. It also allows for additional functionalities like update options and icons.

Use Case

This component is ideal for:

  • Displaying images with specific styles and properties.
  • Adding overlays and icons to images.
  • Handling image updates with custom update UI options.

Props Table

Prop NameTypeDescriptionDefault ValueRequired
titlestringThe title of the image, used for accessibility."Image Component"No
numberOfLinesForTitlenumberNumber of lines for the title text.undefinedNo
descriptionstringThe description of the image.undefinedNo
numberOfLinesForDescriptionnumberNumber of lines for the description text.undefinedNo
overlaybooleanWhether to display an overlay over the image.undefinedNo
overlayOpacitynumberThe opacity of the overlay.undefinedNo
sourcestringThe source URL of the image.undefinedYes
iconReact.FC<AssetProps>An optional icon to be displayed over the image.undefinedNo
aspectRationumberThe aspect ratio of the image.undefinedNo
canUpdatebooleanWhether the image can be updated.undefinedNo
updateUI"overlay" | "pen"The UI option for updating the image.undefinedNo
onUpdate(url: string, file: Blob) => voidCallback function to handle image updates.undefinedNo
acceptedstringThe accepted file types for image updates.undefinedNo
fit"contain" | "cover" | "fill" | "scale-down" | "none"How the image should fit within its container."cover"No
borderRadiusnumberThe border radius of the image container.spacing.borderRadius.r2No

Example

import React from "react";
import { Image } from "./Image";

const App: React.FC = () => {
return (
<Image
source="https://example.com/image.jpg"
title="Sample Image"
description="This is a sample image."
overlay={true}
overlayOpacity={0.5}
borderRadius={10}
fit="cover"
/>
);
};

export default App;

ListView

Description

The ListView component is a flexible container for rendering lists of items. It supports horizontal and vertical orientations, and allows for custom headers and footers. The component utilizes a render prop pattern for rendering each item in the list, providing maximum flexibility.

Use Case

This component is ideal for:

  • Rendering lists of data with custom item components.
  • Displaying lists in either horizontal or vertical orientation.
  • Adding custom headers and footers to lists.

Props Table

Prop NameTypeDescriptionDefault ValueRequired
datasetT[]The array of data items to be displayed in the list.N/AYes
renderItem(item: T, index: number) => React.JSX.ElementA function that returns the JSX element for each item in the list.undefinedNo
headerReact.JSX.ElementA custom header element to be displayed at the top of the list.undefinedNo
footerReact.JSX.ElementA custom footer element to be displayed at the bottom of the list.undefinedNo
horizontalbooleanIf true, the list is displayed horizontally.falseNo
ListHeaderComponentStyleCSSPropertiesCustom styles for the header component.undefinedNo
ListFooterComponentStyleCSSPropertiesCustom styles for the footer component.undefinedNo

Example

import React from "react";
import ListView from "./ListView";

const dataset = [
{ id: 1, name: "Item 1" },
{ id: 2, name: "Item 2" },
{ id: 3, name: "Item 3" },
];

const renderItem = (item: { id: number; name: string }, index: number) => (
<div key={item.id}>
{item.name}
</div>
);

const App: React.FC = () => {
return (
<ListView
dataset={dataset}
renderItem={renderItem}
header={<div>Header</div>}
footer={<div>Footer</div>}
horizontal={true}
/>
);
};

export default App;

Row

Description

The Row component is a flexible row layout component that extends the Flex component to include additional styling options. It supports different style types for various use cases such as outlined borders and alternating row fills.

Use Case

This component is ideal for:

  • Rendering rows within a table or list with specific styling needs.
  • Applying alternating background colors or borders to rows.
  • Creating structured row layouts with flexible weights for child elements.

Props Table

Prop NameTypeDescriptionDefault ValueRequired
styleType"transparent" | "outline" | "alternative-fill"Defines the style type for the row."transparent"No
weightnumber[]An array of numbers defining the flex-grow values for each child.undefinedNo
indexnumberThe index of the row, used for applying styles based on row position.undefinedNo

Example

import React from "react";
import { Row } from "./Row";

const dataset = [
{ id: 1, name: "Item 1" },
{ id: 2, name: "Item 2" },
{ id: 3, name: "Item 3" },
];

const App: React.FC = () => {
return (
<div>
{dataset.map((item, index) => (
<Row key={item.id} styleType="alternative-fill" index={index}>
<div>{item.name}</div>
</Row>
))}
</div>
);
};

export default App;

SplitPane