Add icon property to table.
This commit is contained in:
@ -7,14 +7,16 @@ import {
|
|||||||
useReactTable,
|
useReactTable,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import TableHeader from './TableHeader';
|
import TableHeader from './TableHeader';
|
||||||
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
data: Array<any>;
|
data: Array<any>;
|
||||||
columns: Array<ColumnDef<any, any>>;
|
columns: Array<ColumnDef<any, any>>;
|
||||||
viewName: string;
|
viewName: string;
|
||||||
|
viewIcon?: IconProp;
|
||||||
};
|
};
|
||||||
|
|
||||||
function Table({ data, columns, viewName }: OwnProps) {
|
function Table({ data, columns, viewName, viewIcon }: OwnProps) {
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
@ -23,7 +25,7 @@ function Table({ data, columns, viewName }: OwnProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<TableHeader viewName={viewName} />
|
<TableHeader viewName={viewName} viewIcon={viewIcon} />
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
|
|||||||
@ -1,15 +1,27 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
viewName: string;
|
viewName: string;
|
||||||
|
viewIcon?: IconProp;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledTitle = styled.div`
|
const StyledTitle = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
color: ${(props) => props.theme.text60};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function TableHeader({ viewName }: OwnProps) {
|
function TableHeader({ viewName, viewIcon }: OwnProps) {
|
||||||
return <StyledTitle>{viewName}</StyledTitle>;
|
return (
|
||||||
|
<StyledTitle>
|
||||||
|
{viewIcon && <FontAwesomeIcon icon={viewIcon} />}
|
||||||
|
{viewName}
|
||||||
|
</StyledTitle>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TableHeader;
|
export default TableHeader;
|
||||||
|
|||||||
Reference in New Issue
Block a user