Skip to content

Commit

Permalink
fix: use react memo and lazy importing
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasti810 committed Jan 28, 2025
1 parent d9f5a31 commit 0a6bf83
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"react-icons": "^5.3.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4",
"prism-wasm-lightclient": "github:deltadevsde/prism#prism-wasm:crates/node_types/wasm-lightclient"
"zod": "^3.22.4"
},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
Expand Down
Binary file added public/images/Verif_New3.mp4
Binary file not shown.
Binary file removed public/images/Verifiable.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion src/app/components/ContentSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ContentSection = () => {
</div>
<div className='w-full md:w-[40%]'>
<video
src='/images/Verifiable.mp4'
src='/images/Verif_new3.mp4'
autoPlay
loop
muted
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/InfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ interface InfoCardProps {
const InfoCard = ({ title, description, imageSrc }: InfoCardProps) => {
return (
<div className='flex flex-col border-2 border-[#FFF1EE] bg-[#131111] p-8'>
<div className='mx-auto mb-8 flex h-60 w-60 items-center'>
<div className='mx-auto mb-8 flex h-60 w-60 items-center lg:h-80 lg:w-80'>
{imageSrc && (
<div className='relative mx-auto h-60 w-60'>
<div className='relative mx-auto h-60 w-60 lg:h-80 lg:w-80'>
<Image
src={imageSrc}
alt={`${title} icon`}
className='object-contain'
sizes='10vw'
sizes='20vw'
fill
loading='lazy'
/>
Expand Down
17 changes: 12 additions & 5 deletions src/app/components/LightNodeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Spline from '@splinetool/react-spline';
import { X } from 'lucide-react';
import React, { useEffect, useRef, useState } from 'react';

const Spline = React.lazy(() => import('@splinetool/react-spline'));

import { LogEntry, useLightClient } from '@/lib/use-light-client';

interface ModalProps {
Expand Down Expand Up @@ -61,6 +62,15 @@ const LogContainer = ({ logs }: { logs: LogEntry[] }) => {
);
};

const SplineContainer = React.memo(() => (
<React.Suspense fallback={<div>Loading...</div>}>
<Spline
style={{ height: 1000, width: 1000 }}
scene='https://prod.spline.design/V30jxm7Rt3T1ZpnJ/scene.splinecode'
/>
</React.Suspense>
));

const LightNodeModal = ({ isOpen, onClose }: ModalProps) => {
const [modalPosition, setModalPosition] = useState(0);

Expand Down Expand Up @@ -167,10 +177,7 @@ const LightNodeModal = ({ isOpen, onClose }: ModalProps) => {
<div className='relative order-1 h-48 md:order-2 md:h-96'>
<div className='absolute inset-0 flex items-center justify-center'>
<div className='origin-center scale-[0.2] md:scale-[0.35]'>
<Spline
style={{ height: 1000, width: 1000 }}
scene='https://prod.spline.design/V30jxm7Rt3T1ZpnJ/scene.splinecode'
/>
{isOpen && <SplineContainer />}
</div>
</div>
</div>
Expand Down
Empty file.

0 comments on commit 0a6bf83

Please sign in to comment.