Skip to content

Commit

Permalink
chore: Merge branch 'master' of https://github.com/layer5io/sistent i…
Browse files Browse the repository at this point in the history
…nto 368-themeprovider

Signed-off-by: Antonette Caldwell <[email protected]>
  • Loading branch information
nebula-aac committed Jan 8, 2024
2 parents e4b1723 + 44df8e0 commit c8c2adf
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/components/src/custom/ResponsiveDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const ResponsiveDataTable = ({

React.useEffect(() => {
columns?.forEach((col) => {
console.log('Current Column:', col);
if (typeof col === 'object' && col !== null) {
if (!col.options) {
col.options = {};
Expand Down
63 changes: 61 additions & 2 deletions packages/components/src/custom/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Responsive Data Table Component
# Custom Components

## Responsive Data Table Component

This custom React component, `ResponsiveDataTable`, is a wrapper around the Material-UI (MUI) DataTables library (`mui-datatables`). It provides a responsive and customizable table with additional features tailored for specific use cases. Below is an explanation of each component and its functionalities.

Expand Down Expand Up @@ -31,7 +33,7 @@ This custom React component, `ResponsiveDataTable`, is a wrapper around the Mate
| `theme` | `object` | (Optional) Theme object for styling the table. |
| `colViews` | `Record<string, boolean> \| undefined` | (Optional) Object representing the visibility status of each column. This is similar to `columnVisibility`. |

## Customization
### Customization

### Column Visibility

Expand All @@ -44,3 +46,60 @@ Custom rendering for specific columns can be achieved using the `options.customB
### Date formatting

The component includes a formatDate function to format date values consistently. You can customize the date formatting by modifying the formatDate function.

<hr>

## Custom Search Component

## Overview

The `SearchBar` component is a reusable search bar. This component provides a user-friendly interface for searching within your application. It features a text input field with the ability to expand and collapse, a search icon, and a clear icon for removing the entered search text.

## Props

| Property | Type | Description |
| ------------- | -------- | ------------------------------------------------------------------------------------- |
| `onSearch` | `func` | Callback function to handle the search logic. |
| `onClear` | `func` | Callback function to handle the clear logic. |
| `placeholder` | `string` | (Optional) Placeholder text to be displayed in the search bar. |
| `expanded` | `bool` | (Optional) Set to `true` if the search bar should be expanded initially. |
| `setExpanded` | `func` | (Optional) Callback function to update the expanded state of the search bar. |
| `iconFill` | `string` | (Optional) Color of the search icon. If not provided, the default color will be used. |

## Usage

```javascript
import React, { useState } from 'react';
import SearchBar from '@layer5/sistent/components';

function App() {
const [searchText, setSearchText] = useState('');

// this handles the search logic only will be needed if the api doesn't have search param
const handleSearch = (text) => {
// Handle the search logic here
setSearchText(text);
};

const handleClear = () => {
// Handle the clear logic here
setSearchText('');
};

return (
<div>
<SearchBar
onSearch={handleSearch}
onClear={handleClear}
placeholder="Search..."
expanded={searchText !== ''}
setExpanded={(isExpanded) => setSearchText(isExpanded)}
iconFill="#000" // Optional: customize the icon color
/>
{/* Your application content here */}
</div>
);
}

export default App;
```

0 comments on commit c8c2adf

Please sign in to comment.