Skip to content

Commit f118c64

Browse files
committed
cleanup code
1 parent 2b104c4 commit f118c64

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/pages/index.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,29 @@ import merge from "@/public/images/upgrades/merge.png"
7070
import robotfixed from "@/public/images/wallet-cropped.png"
7171
import ethereum from "@/public/images/what-is-ethereum.png"
7272

73+
// lazy loaded components
74+
const Codeblock = lazy(() =>
75+
Promise.all([
76+
import("@/components/Codeblock"),
77+
// Add a delay to prevent the skeleton from flashing
78+
new Promise((resolve) => setTimeout(resolve, 1000)),
79+
]).then(([module]) => module)
80+
)
7381
const StatsBoxGrid = lazy(() => import("@/components/StatsBoxGrid"))
7482

83+
const Skeleton = () => (
84+
<Stack px={6} pt="2.75rem" h="50vh">
85+
<SkeletonText
86+
mt="4"
87+
noOfLines={6}
88+
spacing={4}
89+
skeletonHeight="1.4rem"
90+
startColor="body.medium"
91+
opacity={0.2}
92+
/>
93+
</Stack>
94+
)
95+
7596
const SectionHeading = (props: HeadingProps) => (
7697
<Heading
7798
lineHeight={1.4}
@@ -227,27 +248,6 @@ export const getStaticProps = (async ({ locale }) => {
227248
}
228249
}) satisfies GetStaticProps<Props>
229250

230-
const CodeblockSkeleton = () => (
231-
<Stack px={6} pt="2.75rem" h="50vh">
232-
<SkeletonText
233-
mt="4"
234-
noOfLines={6}
235-
spacing={4}
236-
skeletonHeight="1.4rem"
237-
startColor="body.medium"
238-
opacity={0.2}
239-
/>
240-
</Stack>
241-
)
242-
243-
const Codeblock = lazy(() =>
244-
Promise.all([
245-
import("@/components/Codeblock"),
246-
// Add a delay to prevent the skeleton from flashing
247-
new Promise((resolve) => setTimeout(resolve, 1000)),
248-
]).then(([module]) => module)
249-
)
250-
251251
const HomePage = ({
252252
communityEvents,
253253
metricResults,
@@ -563,7 +563,7 @@ const HomePage = ({
563563
setIsOpen={setModalOpen}
564564
title={codeExamples[activeCode].title}
565565
>
566-
<Suspense fallback={<CodeblockSkeleton />}>
566+
<Suspense fallback={<Skeleton />}>
567567
<Codeblock
568568
codeLanguage={codeExamples[activeCode].codeLanguage}
569569
allowCollapse={false}
@@ -589,7 +589,7 @@ const HomePage = ({
589589

590590
<LazyLoadComponent
591591
component={StatsBoxGrid}
592-
fallback={<CodeblockSkeleton />}
592+
fallback={<Skeleton />}
593593
componentProps={{ data: metricResults }}
594594
intersectionOptions={{
595595
root: null,

0 commit comments

Comments
 (0)