Skip to content

Commit d5164eb

Browse files
authored
Merge pull request #469 from performant-software/RB-record-detail-loading
Adds loading prop to `RecordDetailPanel`
2 parents 1c64c56 + ecf869d commit d5164eb

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

packages/core-data/src/components/RecordDetailPanel.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import AccordionItemsList from './AccordionItemsList';
77
import RecordDetailHeader from './RecordDetailHeader';
88
import type { RelatedRecordsList } from '../types/RelatedRecordsList';
99
import RecordDetailBreadcrumbs from './RecordDetailBreadcrumbs';
10+
import LoadAnimation from './LoadAnimation';
1011

1112
type Props = {
1213
/**
@@ -45,6 +46,11 @@ type Props = {
4546
*/
4647
icon?: string,
4748

49+
/**
50+
* If true, displays a loading icon in place of the related records list
51+
*/
52+
loading?: Boolean,
53+
4854
/**
4955
* A function called when the `close` icon is clicked
5056
*/
@@ -113,11 +119,15 @@ const RecordDetailPanel = (props: Props) => (
113119
{ props.children }
114120
</RecordDetailHeader>
115121
</div>
116-
<AccordionItemsList
117-
className={clsx(props.classNames?.relatedRecords)}
118-
items={props.relations}
119-
count={props.count}
120-
/>
122+
{ props.loading
123+
? <div className='py-4 px-8'><LoadAnimation /></div>
124+
: (
125+
<AccordionItemsList
126+
className={clsx(props.classNames?.relatedRecords)}
127+
items={props.relations}
128+
count={props.count}
129+
/>
130+
) }
121131
</div>
122132
);
123133

packages/storybook/src/core-data/RecordDetailPanel.stories.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,40 @@ export const NoRelatedRecords = () => (
322322
</p>
323323
</RecordDetailPanel>
324324
);
325+
326+
export const WithLoadingDelay = () => {
327+
const [loading, setLoading] = useState(true);
328+
329+
useEffect(() => {
330+
setTimeout(() => {
331+
setLoading(false);
332+
}, 3000);
333+
}, []);
334+
335+
return (
336+
<RecordDetailPanel
337+
loading={loading}
338+
relations={sampleData}
339+
title='West Tokyo Qualifiers Quarterfinal'
340+
detailItems={[
341+
{
342+
text: 'July 27',
343+
icon: 'date'
344+
},
345+
{
346+
text: 'Meiji Jinju Stadium',
347+
icon: 'location'
348+
}
349+
]}
350+
>
351+
<p>
352+
Arcu imperdiet sit sit viverra id volutpat commodo.
353+
{' '}
354+
<span className='font-bold'>Tempor sem malesuada porttitor congue.</span>
355+
{' '}
356+
Nibh aenean vitae blandit vitae sapien ac varius mattis.
357+
Aliquam vitae purus arcu eros enim tempus parturient orci fames.
358+
</p>
359+
</RecordDetailPanel>
360+
);
361+
};

0 commit comments

Comments
 (0)