Skip to content

Commit

Permalink
refactor: Refactor table footer (#237)
Browse files Browse the repository at this point in the history
* refactor: refactor table footer

Signed-off-by: yazhou <[email protected]>

* chore: update version

Signed-off-by: yazhou <[email protected]>

---------

Signed-off-by: yazhou <[email protected]>
  • Loading branch information
yazhouio authored Jun 13, 2024
1 parent b8b2550 commit d32ed55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-yaks-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kubed/components': patch
---

refactor: Refactor table footer
8 changes: 2 additions & 6 deletions packages/components/src/Table/DataTable/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface PaginationProps<T> {
table: Table<T>;
}

const TableFooter = styled.div`
export const TableFooter = styled.div`
position: relative;
padding: 10px 20px;
background-color: ${({ theme }) => theme.palette.accents_0};
Expand Down Expand Up @@ -41,9 +41,5 @@ export const Pagination = <T extends {}>({ table }: PaginationProps<T>) => {
};
}, [table, props.total]);

return (
<TableFooter>
<BaseTable.BasePagination instance={instance} {...props} />
</TableFooter>
);
return <BaseTable.BasePagination instance={instance} {...props} />;
};
8 changes: 6 additions & 2 deletions packages/components/src/Table/DataTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cx from 'classnames';
import * as React from 'react';
import * as BaseTable from '../BaseTable';
import { BaseDataTable } from './BaseTable';
import { Pagination } from './Pagination';
import { Pagination, TableFooter } from './Pagination';
import { Toolbar } from './Toolbar';
import {
DataTableRootProps,
Expand Down Expand Up @@ -91,7 +91,11 @@ export function DataTable<T>({ className, table }: DataTableRootProps<T>) {
<div className={cx('table-container', className)}>
{!!toolbar && <Toolbar table={table} />}
<BaseDataTable table={table} />
{!!pagination && <Pagination table={table} />}
{!!pagination && (
<TableFooter>
<Pagination table={table} />
</TableFooter>
)}
</div>
);
}

0 comments on commit d32ed55

Please sign in to comment.