Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types/structured list #13632

Merged
merged 11 commits into from
Sep 27, 2023
23 changes: 0 additions & 23 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7324,9 +7324,6 @@ Map {
"render": [Function],
},
"StructuredListBody" => Object {
"defaultProps": Object {
"onKeyDown": [Function],
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand All @@ -7343,10 +7340,6 @@ Map {
},
},
"StructuredListCell" => Object {
"defaultProps": Object {
"head": false,
"noWrap": false,
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand All @@ -7373,9 +7366,6 @@ Map {
},
},
"StructuredListInput" => Object {
"defaultProps": Object {
"title": "title",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand All @@ -7397,10 +7387,6 @@ Map {
},
},
"StructuredListRow" => Object {
"defaultProps": Object {
"head": false,
"onKeyDown": [Function],
},
"propTypes": Object {
"children": Object {
"type": "node",
Expand All @@ -7421,9 +7407,6 @@ Map {
},
},
"StructuredListSkeleton" => Object {
"defaultProps": Object {
"rowCount": 5,
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand All @@ -7434,12 +7417,6 @@ Map {
},
},
"StructuredListWrapper" => Object {
"defaultProps": Object {
"aria-label": "Structured list section",
"isCondensed": false,
"isFlush": false,
"selection": false,
},
"propTypes": Object {
"aria-label": Object {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,40 @@ import React from 'react';
import cx from 'classnames';
import { usePrefix } from '../../internal/usePrefix';

const StructuredListSkeleton = ({ rowCount, className, ...rest }) => {
export interface StructuredListSkeletonProps {
/**
* Specify an optional className to add.
*/
className?: string;

/**
* number of table rows
*/
rowCount?: number;
}

export default function StructuredListSkeleton({
rowCount = 5,
className,
...rest
}: StructuredListSkeletonProps) {
const prefix = usePrefix();
const StructuredListSkeletonClasses = cx(className, {
[`${prefix}--skeleton`]: true,
[`${prefix}--structured-list`]: true,
});
const classNames = cx(
`${prefix}--skeleton`,
`${prefix}--structured-list`,
className
);

const rows = [];
for (var i = 0; i < rowCount; i++) {
rows.push(
<div className={`${prefix}--structured-list-row`} key={i}>
<div className={`${prefix}--structured-list-td`} />
<div className={`${prefix}--structured-list-td`} />
<div className={`${prefix}--structured-list-td`} />
</div>
);
}
const rows = new Array(rowCount).fill(null).map((_, i) => (
<div className={`${prefix}--structured-list-row`} key={i}>
<div className={`${prefix}--structured-list-td`} />
<div className={`${prefix}--structured-list-td`} />
<div className={`${prefix}--structured-list-td`} />
</div>
));

return (
<div className={StructuredListSkeletonClasses} {...rest}>
<div className={classNames} {...rest}>
<div className={`${prefix}--structured-list-thead`}>
<div
className={`${prefix}--structured-list-row ${prefix}--structured-list-row--header-row`}>
Expand All @@ -47,7 +61,7 @@ const StructuredListSkeleton = ({ rowCount, className, ...rest }) => {
<div className={`${prefix}--structured-list-tbody`}>{rows}</div>
</div>
);
};
}

StructuredListSkeleton.propTypes = {
/**
Expand All @@ -60,9 +74,3 @@ StructuredListSkeleton.propTypes = {
*/
rowCount: PropTypes.number,
};

StructuredListSkeleton.defaultProps = {
rowCount: 5,
};

export default StructuredListSkeleton;
Loading