-
Notifications
You must be signed in to change notification settings - Fork 148
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
e4eeba9
commit 6705f3d
Showing
15 changed files
with
329 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import Table from '../src/Table' | ||
|
||
describe('Table', () => { | ||
it('should render without crashing', () => { | ||
mount(<Table />) | ||
}) | ||
|
||
it('should contain a table', () => { | ||
const wrapper = mount(<Table />) | ||
|
||
expect(wrapper.find('table')).toBeTruthy() | ||
}) | ||
}) |
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,24 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import TableBody from '../src/TableBody' | ||
|
||
describe('TableBody', () => { | ||
it('should render without crashing', () => { | ||
mount( | ||
<table> | ||
<TableBody /> | ||
</table> | ||
) | ||
}) | ||
|
||
it('should render with base styles', () => { | ||
const expected = 'bg-white divide-y dark:divide-gray-700 dark:bg-gray-800' | ||
const wrapper = mount( | ||
<table> | ||
<TableBody /> | ||
</table> | ||
) | ||
|
||
expect(wrapper.find('tbody').getDOMNode().getAttribute('class')).toContain(expected) | ||
}) | ||
}) |
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 React from 'react' | ||
import { mount } from 'enzyme' | ||
import TableCell from '../src/TableCell' | ||
|
||
describe('TableCell', () => { | ||
it('should render without crashing', () => { | ||
mount( | ||
<table> | ||
<tbody> | ||
<tr> | ||
<TableCell /> | ||
</tr> | ||
</tbody> | ||
</table> | ||
) | ||
}) | ||
|
||
it('should render with base styles', () => { | ||
const expected = 'px-4 py-3' | ||
const wrapper = mount( | ||
<table> | ||
<tbody> | ||
<tr> | ||
<TableCell /> | ||
</tr> | ||
</tbody> | ||
</table> | ||
) | ||
|
||
expect(wrapper.find('td').getDOMNode().getAttribute('class')).toContain(expected) | ||
}) | ||
}) |
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,16 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import TableContainer from '../src/TableContainer' | ||
|
||
describe('TableContainer', () => { | ||
it('should render without crashing', () => { | ||
mount(<TableContainer />) | ||
}) | ||
|
||
it('should render with base styles', () => { | ||
const expected = 'w-full overflow-hidden rounded-lg shadow-xs' | ||
const wrapper = mount(<TableContainer />) | ||
|
||
expect(wrapper.find(TableContainer).getDOMNode().getAttribute('class')).toContain(expected) | ||
}) | ||
}) |
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,25 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import TableHeader from '../src/TableHeader' | ||
|
||
describe('TableHeader', () => { | ||
it('should render without crashing', () => { | ||
mount( | ||
<table> | ||
<TableHeader /> | ||
</table> | ||
) | ||
}) | ||
|
||
it('should render with base styles', () => { | ||
const expected = | ||
'text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800' | ||
const wrapper = mount( | ||
<table> | ||
<TableHeader /> | ||
</table> | ||
) | ||
|
||
expect(wrapper.find('thead').getDOMNode().getAttribute('class')).toContain(expected) | ||
}) | ||
}) |
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,28 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import TableRow from '../src/TableRow' | ||
|
||
describe('TableRow', () => { | ||
it('should render without crashing', () => { | ||
mount( | ||
<table> | ||
<tbody> | ||
<TableRow /> | ||
</tbody> | ||
</table> | ||
) | ||
}) | ||
|
||
it('should render with base styles', () => { | ||
const expected = 'text-gray-700 dark:text-gray-400' | ||
const wrapper = mount( | ||
<table> | ||
<tbody> | ||
<TableRow /> | ||
</tbody> | ||
</table> | ||
) | ||
|
||
expect(wrapper.find('tr').getDOMNode().getAttribute('class')).toContain(expected) | ||
}) | ||
}) |
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,16 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
function Table({ children }) { | ||
return ( | ||
<div className="w-full overflow-x-auto"> | ||
<table className="w-full whitespace-no-wrap">{children}</table> | ||
</div> | ||
) | ||
} | ||
|
||
Table.propTypes = { | ||
children: PropTypes.node, | ||
} | ||
|
||
export default Table |
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,28 @@ | ||
import React, { useContext } from 'react' | ||
import classNames from 'classnames' | ||
import PropTypes from 'prop-types' | ||
import { ThemeContext } from './context/ThemeContext' | ||
import defaultTheme from './themes/default' | ||
|
||
function TableBody(props) { | ||
const { className, children, ...other } = props | ||
|
||
const { tableBody } = useContext(ThemeContext) || defaultTheme | ||
|
||
const baseStyle = tableBody.base | ||
|
||
const cls = classNames(baseStyle, className) | ||
|
||
return ( | ||
<tbody className={cls} {...other}> | ||
{children} | ||
</tbody> | ||
) | ||
} | ||
|
||
TableBody.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
} | ||
|
||
export default TableBody |
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,28 @@ | ||
import React, { useContext } from 'react' | ||
import classNames from 'classnames' | ||
import PropTypes from 'prop-types' | ||
import { ThemeContext } from './context/ThemeContext' | ||
import defaultTheme from './themes/default' | ||
|
||
function TableCell(props) { | ||
const { className, children, ...other } = props | ||
|
||
const { tableCell } = useContext(ThemeContext) || defaultTheme | ||
|
||
const baseStyle = tableCell.base | ||
|
||
const cls = classNames(baseStyle, className) | ||
|
||
return ( | ||
<td className={cls} {...other}> | ||
{children} | ||
</td> | ||
) | ||
} | ||
|
||
TableCell.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
} | ||
|
||
export default TableCell |
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,28 @@ | ||
import React, { useContext } from 'react' | ||
import classNames from 'classnames' | ||
import PropTypes from 'prop-types' | ||
import { ThemeContext } from './context/ThemeContext' | ||
import defaultTheme from './themes/default' | ||
|
||
function TableContainer(props) { | ||
const { className, children, ...other } = props | ||
|
||
const { tableContainer } = useContext(ThemeContext) || defaultTheme | ||
|
||
const baseStyle = tableContainer.base | ||
|
||
const cls = classNames(baseStyle, className) | ||
|
||
return ( | ||
<div className={cls} {...other}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
TableContainer.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
} | ||
|
||
export default TableContainer |
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,28 @@ | ||
import React, { useContext } from 'react' | ||
import classNames from 'classnames' | ||
import PropTypes from 'prop-types' | ||
import { ThemeContext } from './context/ThemeContext' | ||
import defaultTheme from './themes/default' | ||
|
||
function TableHeader(props) { | ||
const { className, children, ...other } = props | ||
|
||
const { tableHeader } = useContext(ThemeContext) || defaultTheme | ||
|
||
const baseStyle = tableHeader.base | ||
|
||
const cls = classNames(baseStyle, className) | ||
|
||
return ( | ||
<thead className={cls} {...other}> | ||
{children} | ||
</thead> | ||
) | ||
} | ||
|
||
TableHeader.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
} | ||
|
||
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,28 @@ | ||
import React, { useContext } from 'react' | ||
import classNames from 'classnames' | ||
import PropTypes from 'prop-types' | ||
import { ThemeContext } from './context/ThemeContext' | ||
import defaultTheme from './themes/default' | ||
|
||
function TableRow(props) { | ||
const { className, children, ...other } = props | ||
|
||
const { tableRow } = useContext(ThemeContext) || defaultTheme | ||
|
||
const baseStyle = tableRow.base | ||
|
||
const cls = classNames(baseStyle, className) | ||
|
||
return ( | ||
<tr className={cls} {...other}> | ||
{children} | ||
</tr> | ||
) | ||
} | ||
|
||
TableRow.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
} | ||
|
||
export default TableRow |
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