-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
144f354
commit b53a578
Showing
4 changed files
with
76 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import classnames from 'classnames'; | ||
import type { JSX } from 'preact'; | ||
|
||
import type { PresentationalProps } from '../../types'; | ||
import { downcastRef } from '../../util/typing'; | ||
|
||
import TableSectionContext from './TableSectionContext'; | ||
import type { TableSection } from './TableSectionContext'; | ||
|
||
type HTMLAttributes = JSX.HTMLAttributes<HTMLTableSectionElement>; | ||
|
||
export type TableFootProps = PresentationalProps & HTMLAttributes; | ||
|
||
/** | ||
* Render a table footer section | ||
*/ | ||
const TableFootNext = function TableFoot({ | ||
children, | ||
classes, | ||
elementRef, | ||
|
||
...htmlAttributes | ||
}: TableFootProps) { | ||
const sectionContext: TableSection = { | ||
section: 'foot', | ||
}; | ||
|
||
return ( | ||
<TableSectionContext.Provider value={sectionContext}> | ||
<tfoot | ||
{...htmlAttributes} | ||
data-component="TableFoot" | ||
ref={downcastRef(elementRef)} | ||
className={classnames( | ||
// This tfoot element will take up available extra vertical space when | ||
// a Table has sparse data. This prevents <TableRow>s from stretching | ||
// vertically to fill extra space. | ||
'h-full', | ||
classes | ||
)} | ||
> | ||
{children} | ||
</tfoot> | ||
</TableSectionContext.Provider> | ||
); | ||
}; | ||
|
||
export default TableFootNext; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { mount } from 'enzyme'; | ||
|
||
import { testPresentationalComponent } from '../../test/common-tests'; | ||
|
||
import TableFoot from '../TableFoot'; | ||
|
||
describe('TableFoot', () => { | ||
// Content function for shared presentational test does not wrap with context | ||
// This is to ensure the component functions as expected without context | ||
const contentFn = (Component, props = {}) => { | ||
return mount( | ||
<table> | ||
<Component {...props}> | ||
<tr> | ||
<td>Cell content</td> | ||
</tr> | ||
</Component> | ||
</table> | ||
); | ||
}; | ||
|
||
testPresentationalComponent(TableFoot, { | ||
createContent: contentFn, | ||
elementSelector: '[data-component="TableFoot"]', | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ export { | |
Table, | ||
TableBody, | ||
TableCell, | ||
TableFoot, | ||
TableHead, | ||
TableRow, | ||
Thumbnail, | ||
|