-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(details): Improve performance (#2650)
* refactor(performance): Improve details Closes #2639 * refactor(details): Improve performance for details Closes #2639 * fix double query * fix some condition on panel * fix condition, rename file * Typos --------- Co-authored-by: jolevesq <[email protected]>
- Loading branch information
Showing
14 changed files
with
448 additions
and
353 deletions.
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
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
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
23 changes: 17 additions & 6 deletions
23
packages/geoview-core/src/core/components/details/details-skeleton.tsx
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 |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import { memo } from 'react'; | ||
import { Box, Skeleton } from '@/ui'; | ||
|
||
// Constants outside component to prevent recreating every render | ||
const sizes = ['15%', '10%', '15%', '25%', '10%', '20%', '10%']; | ||
|
||
const SKELETON_STYLES = { | ||
box: { padding: '10px' }, | ||
title: { mb: 1 }, | ||
text: { pt: 4, pb: 4 }, | ||
} as const; | ||
|
||
/** | ||
* Custom details skeleton build with mui skeleton component. | ||
* @returns {JSX.Element} | ||
*/ | ||
export default function DetailsSkeleton(): JSX.Element { | ||
const sizes = ['15%', '10%', '15%', '25%', '10%', '20%', '10%']; | ||
// Memoizes entire component, preventing re-renders if props haven't changed | ||
export const DetailsSkeleton = memo(function DetailsSkeleton(): JSX.Element { | ||
return ( | ||
<Box padding={8}> | ||
<Box pb={8}> | ||
<Box sx={SKELETON_STYLES.box}> | ||
<Skeleton variant="text" width="60%" height={32} sx={SKELETON_STYLES.title} /> | ||
<Box sx={SKELETON_STYLES.box}> | ||
{sizes.map((size, index) => ( | ||
<Box display="flex" justifyContent="space-between" pt={4} pb={4} key={`${index.toString()}-${size}}`}> | ||
<Box display="flex" justifyContent="space-between" sx={SKELETON_STYLES.text} key={`${index.toString()}-${size}}`}> | ||
<Skeleton variant="text" width={size} height="25px" /> | ||
<Skeleton variant="text" width={size} height="25px" /> | ||
</Box> | ||
))} | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
}); |
Oops, something went wrong.