Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
import React, { type FunctionComponent, TableHTMLAttributes } from 'react';
import cx from 'classnames';
import { usePrefix } from '../../internal/usePrefix';
import { DataTableSize } from '../DataTable/DataTable';

export interface DataTableSkeletonHeader {
/**
Expand Down Expand Up @@ -55,6 +56,9 @@ export interface DataTableSkeletonProps
*/
showToolbar?: boolean;


size?: DataTableSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this code been formatted?

Suggested change
size?: DataTableSize;
/*
* Changes the row height of table.
*/
size?: DataTableSize;


/**
* Optionally specify whether you want the DataTable to be zebra striped
*/
Expand All @@ -74,12 +78,14 @@ const DataTableSkeleton: FunctionComponent<DataTableSkeletonProps> = ({
className,
showHeader = true,
showToolbar = true,
size = 'lg',
...rest
}) => {
const prefix = usePrefix();
const dataTableSkeletonClasses = cx(className, {
[`${prefix}--skeleton`]: true,
[`${prefix}--data-table`]: true,
[`${prefix}--data-table--${size}`]: size,
[`${prefix}--data-table--zebra`]: zebra,
[`${prefix}--data-table--compact`]: compact,
});
Expand Down Expand Up @@ -181,6 +187,9 @@ DataTableSkeleton.propTypes = {
*/
showToolbar: PropTypes.bool,


size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
/*
* Changes the row height of table.
*/
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),


/**
* Optionally specify whether you want the DataTable to be zebra striped
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ describe('DataTableSkeleton', () => {
expect(toolbar).not.toBeInTheDocument();
});

it('should respect the size prop', () => {
render(<DataTableSkeleton size="xs" />);

expect(screen.getByRole('table')).toHaveClass(
`${prefix}--data-table--xs`
);
});
Comment on lines +97 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest also including a check for the prop's default value.


it('should respect the zebra prop', () => {
render(<DataTableSkeleton zebra />);

Expand Down
Loading