-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zones): Migrate zones list to generic table MAASENG-4306 (#5588)
- Loading branch information
1 parent
78b4551
commit e953942
Showing
14 changed files
with
276 additions
and
218 deletions.
There are no files selected for viewing
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
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
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
32 changes: 32 additions & 0 deletions
32
src/app/base/components/GenericTable/TableHeader/TableHeader.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Button } from "@canonical/react-components"; | ||
import type { Header } from "@tanstack/react-table"; | ||
import { flexRender } from "@tanstack/react-table"; | ||
import classNames from "classnames"; | ||
|
||
import SortingIndicator from "@/app/base/components/GenericTable/SortingIndicator"; | ||
|
||
type TableHeaderProps<T> = { | ||
header: Header<T, unknown>; | ||
}; | ||
|
||
const TableHeader = <T,>({ header }: TableHeaderProps<T>) => { | ||
return ( | ||
<th className={classNames(`${header.column.id}`)} key={header.id}> | ||
{header.column.getCanSort() ? ( | ||
<Button | ||
appearance="link" | ||
className="p-button--table-header" | ||
onClick={header.column.getToggleSortingHandler()} | ||
type="button" | ||
> | ||
{flexRender(header.column.columnDef.header, header.getContext())} | ||
<SortingIndicator header={header} /> | ||
</Button> | ||
) : ( | ||
flexRender(header.column.columnDef.header, header.getContext()) | ||
)} | ||
</th> | ||
); | ||
}; | ||
|
||
export default TableHeader; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./TableHeader"; |
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,11 +1,10 @@ | ||
.generic-table { | ||
table-layout: auto; | ||
th:not(th:nth-of-type(1), th:nth-of-type(2), th:last-of-type) { | ||
padding-left: 1.5rem; | ||
.p-generic-table { | ||
thead, tbody { | ||
display: table-row-group; | ||
width: 100%; | ||
} | ||
|
||
.individual-row { | ||
width: calc(100% - 1rem); | ||
margin-left: 1rem; | ||
.group-select, .select { | ||
width: 2rem; | ||
} | ||
} | ||
} |
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
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,4 +1,4 @@ | ||
.generic-table { | ||
.p-generic-table { | ||
.status { | ||
width: 15rem; | ||
} | ||
|
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
Oops, something went wrong.