Skip to content

Commit

Permalink
EZP-31968: Added spinner to UDW (#1642)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti authored Oct 29, 2020
1 parent 0eceb7f commit db1a5b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@
top: 0;
right: 0;
}

&__loading-spinner {
display: flex;
align-items: center;
justify-content: center;
margin-top: calculateRem(50px);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ const FinderBranch = ({ locationData, itemsPerPage }) => {
return (
<Fragment>
<div className="c-finder-branch__items-wrapper" onScroll={loadMore} style={{ width }}>
{renderLoadingSpinner()}

{subitems.map(({ location }) => (
<FinderLeaf key={location.id} location={location} />
))}
Expand All @@ -119,18 +121,27 @@ const FinderBranch = ({ locationData, itemsPerPage }) => {
</Fragment>
);
};

useEffect(() => {
if (isLoading || !loadedLocations.subitems) {
const renderLoadingSpinner = () => {
if (!isLoading) {
return;
}

const data = { ...locationData, ...loadedLocations, subitems: [...locationData.subitems, ...loadedLocations.subitems] };
return (
<div className="c-finder-branch__loading-spinner">
<Icon name="spinner" extraClasses="ez-icon--medium ez-spin" />
</div>
);
}

useEffect(() => {
if (loadedLocations.subitems) {
const data = { ...locationData, ...loadedLocations, subitems: [...locationData.subitems, ...loadedLocations.subitems] };

dispatchLoadedLocationsAction({ type: 'UPDATE_LOCATIONS', data });
dispatchLoadedLocationsAction({ type: 'UPDATE_LOCATIONS', data });
}
}, [loadedLocations, dispatchLoadedLocationsAction, isLoading]);

if (!subitems.length && !collapsed) {
if (!subitems.length && !collapsed && !isLoading) {
return null;
}

Expand Down

0 comments on commit db1a5b6

Please sign in to comment.