-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapting the *WithBatteries components
Signed-off-by: Mike Turley <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
50 deletions.
There are no files selected for viewing
64 changes: 42 additions & 22 deletions
64
...module/src/tackle2-ui-legacy/components/TableControls/TableHeaderContentWithBatteries.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
import React from 'react'; | ||
import { Th } from '@patternfly/react-table'; | ||
import { TableBatteries } from '../../../types'; | ||
|
||
export interface TableHeaderContentWithBatteriesProps { | ||
numColumnsBeforeData: number; | ||
numColumnsAfterData: number; | ||
export interface TableHeaderContentWithBatteriesProps< | ||
TItem, | ||
TColumnKey extends string, | ||
TSortableColumnKey extends TColumnKey, | ||
TFilterCategoryKey extends string = string, | ||
TPersistenceKeyPrefix extends string = string | ||
> extends TableBatteries<TItem, TColumnKey, TSortableColumnKey, TFilterCategoryKey, TPersistenceKeyPrefix> { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const TableHeaderContentWithBatteries: React.FC<TableHeaderContentWithBatteriesProps> = ({ | ||
numColumnsBeforeData, | ||
numColumnsAfterData, | ||
children | ||
}) => ( | ||
<> | ||
{Array(numColumnsBeforeData) | ||
.fill(null) | ||
.map((_, i) => ( | ||
<Th key={i} /> | ||
))} | ||
{children} | ||
{Array(numColumnsAfterData) | ||
.fill(null) | ||
.map((_, i) => ( | ||
<Th key={i} /> | ||
))} | ||
</> | ||
); | ||
export const TableHeaderContentWithBatteries = < | ||
TItem, | ||
TColumnKey extends string, | ||
TSortableColumnKey extends TColumnKey, | ||
TFilterCategoryKey extends string = string, | ||
TPersistenceKeyPrefix extends string = string | ||
>( | ||
props: React.PropsWithChildren< | ||
TableHeaderContentWithBatteriesProps< | ||
TItem, | ||
TColumnKey, | ||
TSortableColumnKey, | ||
TFilterCategoryKey, | ||
TPersistenceKeyPrefix | ||
> | ||
> | ||
) => { | ||
const { numColumnsBeforeData, numColumnsAfterData, children } = props; | ||
return ( | ||
<> | ||
{Array(numColumnsBeforeData) | ||
.fill(null) | ||
.map((_, i) => ( | ||
<Th key={i} /> | ||
))} | ||
{children} | ||
{Array(numColumnsAfterData) | ||
.fill(null) | ||
.map((_, i) => ( | ||
<Th key={i} /> | ||
))} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters