Skip to content

Commit

Permalink
perf(website)!: slow load times from spline components
Browse files Browse the repository at this point in the history
  • Loading branch information
HasithDeAlwis committed Dec 2, 2024
1 parent 1a5600d commit a668227
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 69 deletions.
28 changes: 14 additions & 14 deletions libs/website/feature/events/ui/event.section.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { SplineComponent } from '@website/shared/ui/spline/spline-component'
import { EVENT_CONSTANTS } from '../constants/event.constants.ts'
import { EventPresenter } from './event-presenter/event-presenter'
/* import { SplineComponent } from '@website/shared/ui/spline/spline-component'; */
import { EVENT_CONSTANTS } from '../constants/event.constants.ts';
import { EventPresenter } from './event-presenter/event-presenter';

export function EventSection() {
return (
<section id="events" className="relative flex justify-center w-full">
<div className="w-full max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<div className="w-full">
<EventPresenter events={EVENT_CONSTANTS.EVENTS} />
</div>
</div>
<SplineComponent
return (
<section id="events" className="relative flex justify-center w-full">
<div className="w-full max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<div className="w-full">
<EventPresenter events={EVENT_CONSTANTS.EVENTS} />
</div>
</div>
{/* <SplineComponent
link="https://prod.spline.design/ApEljaMrr9NQtUwP/scene.splinecode"
className="absolute -bottom-[15vh] lg:-bottom-[5vh] left-0 scale-1 md:scale-[1.2] z-[-1]"
/>
</section>
)
/> */}
</section>
);
}
28 changes: 17 additions & 11 deletions libs/website/shared/ui/spline/spline-component.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { cn } from '@cuhacking/shared/utils/cn'
import { ErrorBoundary } from '@cuhacking/shared/utils/ErrorBoundary'
import { lazy, Suspense } from 'react'
import { cn } from '@cuhacking/shared/utils/cn';
/* import { ErrorBoundary } from '@cuhacking/shared/utils/ErrorBoundary' */
import { lazy, Suspense } from 'react';

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

export function SplineComponent({ link, className }: { link: string, className: string }) {
export function SplineComponent({
link,
className,
}: {
link: string;
className: string;
}) {
return (
<div className="overflow-x-hidden">
<ErrorBoundary>
<Suspense fallback={<div>Loading...</div>}>
<Spline className={cn(className)} scene={link} />
</Suspense>
</ErrorBoundary>
{/* <ErrorBoundary> */}
<Suspense fallback={<div>Loading...</div>}>
<Spline className={cn(className)} scene={link} />
</Suspense>
{/* </ErrorBoundary> */}
</div>
)
);
}
28 changes: 14 additions & 14 deletions libs/website/ui/introduction/constants/welcome.constants.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import discord_green from '@cuhacking/shared/assets/icons/socials/discord-green-1.svg'
import docs_green from '@cuhacking/shared/assets/icons/socials/docs-green-1.svg'
import email_green from '@cuhacking/shared/assets/icons/socials/email-green-1.svg'
import figma_green from '@cuhacking/shared/assets/icons/socials/figma-green-1.svg'
import github_green from '@cuhacking/shared/assets/icons/socials/github-green-1.svg'
import instagram_green from '@cuhacking/shared/assets/icons/socials/instagram-green-1.svg'
import linkedin_green from '@cuhacking/shared/assets/icons/socials/linkedin-green-1.svg'
import linktree_green from '@cuhacking/shared/assets/icons/socials/linktree-green-1.svg'
import discord_green from '@cuhacking/shared/assets/icons/socials/discord-green-1.svg';
import docs_green from '@cuhacking/shared/assets/icons/socials/docs-green-1.svg';
import email_green from '@cuhacking/shared/assets/icons/socials/email-green-1.svg';
import figma_green from '@cuhacking/shared/assets/icons/socials/figma-green-1.svg';
import github_green from '@cuhacking/shared/assets/icons/socials/github-green-1.svg';
import instagram_green from '@cuhacking/shared/assets/icons/socials/instagram-green-1.svg';
import linkedin_green from '@cuhacking/shared/assets/icons/socials/linkedin-green-1.svg';
import linktree_green from '@cuhacking/shared/assets/icons/socials/linktree-green-1.svg';

interface Media {
src: string
alt: string
src: string;
alt: string;
}

const socials: { link: string, media: Media }[] = [
const socials: { link: string; media: Media }[] = [
{
link: 'https://www.instagram.com/cuhacking/',
media: { src: instagram_green, alt: 'Instagram' },
Expand Down Expand Up @@ -45,7 +45,7 @@ const socials: { link: string, media: Media }[] = [
link: 'https://linktr.ee/cuhacking_?fbclid=PAZXh0bgNhZW0CMTEAAaZcB9hM3ZkwE4vR0NjpoFmPrg3gfXxlm5NdhqMy-eKHv-VXw8ekbvCznlM_aem_wSxlDGzbFI7sVeAAUVTAoQ',
media: { src: linktree_green, alt: 'Linktree' },
},
]
export const WELCOME_CONSTATNTS = {
];
export const WELCOME_CONSTANTS = {
SOCIALS: socials,
}
};
34 changes: 17 additions & 17 deletions libs/website/ui/introduction/mission/mission.section.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { SplineComponent } from '@website/shared/ui/spline/spline-component'
import { MISSION_CONSTANTS } from '../constants/mission.constants'
import { Mission } from './mission'
/* import { SplineComponent } from '@website/shared/ui/spline/spline-component'; */
import { MISSION_CONSTANTS } from '../constants/mission.constants';
import { Mission } from './mission';

export function MissionSection() {
return (
<section id="#about" className="relative flex justify-center w-full">
<SplineComponent
return (
<section id="#about" className="relative flex justify-center w-full">
{/* <SplineComponent
className="absolute -bottom-[15vh] lg:-bottom-[5vh] left-0 scale-1 md:scale-[1.2]"
link="https://prod.spline.design/TGlqj05806lq8PRV/scene.splinecode"
/>
<main className="max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<div
id="about"
className="relative min-h-[160vh] lg:min-h-screen w-full"
>
<Mission logo={MISSION_CONSTANTS.LOGO} />
</div>
</main>
</section>
)
/> */}
<main className="max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<div
id="about"
className="relative min-h-[160vh] lg:min-h-screen w-full"
>
<Mission logo={MISSION_CONSTANTS.LOGO} />
</div>
</main>
</section>
);
}
26 changes: 13 additions & 13 deletions libs/website/ui/introduction/welcome/welcome.section.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { SplineComponent } from '@website/shared/ui/spline/spline-component'
import { WELCOME_CONSTATNTS } from '../constants/welcome.constants'
import { Welcome } from './welcome'
/* import { SplineComponent } from '@website/shared/ui/spline/spline-component'; */
import { WELCOME_CONSTANTS } from '../constants/welcome.constants';
import { Welcome } from './welcome';

export function WelcomeSection() {
return (
<section className="relative flex justify-center w-full mx-auto lg:mx-0">
<SplineComponent
return (
<section className="relative flex justify-center w-full mx-auto lg:mx-0">
{/* <SplineComponent
className="absolute -bottom-16 lg:left-0 lg:top-0 lg:scale-[1.2]"
link="https://prod.spline.design/nnjZJFW1wThAacUS/scene.splinecode"
/>
<div className="w-full h-screen max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<section className="w-full lg:w-3/5">
<Welcome socials={WELCOME_CONSTATNTS.SOCIALS} />
/> */}
<div className="w-full h-screen max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14">
<section className="w-full lg:w-3/5">
<Welcome socials={WELCOME_CONSTANTS.SOCIALS} />
</section>
</div>
</section>
</div>
</section>
)
);
}

0 comments on commit a668227

Please sign in to comment.