Skip to content

Commit

Permalink
perf(web): lazy load spline and remove unnecessary react imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MFarabi619 committed Dec 2, 2024
1 parent e7f359f commit 678b94d
Show file tree
Hide file tree
Showing 28 changed files with 22 additions and 94 deletions.
1 change: 0 additions & 1 deletion libs/shared/ui/accordion/accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react'
import React from 'react'
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './accordion'

const meta = {
Expand Down
1 change: 0 additions & 1 deletion libs/shared/ui/glassmorphic-card/glassmorphic-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ReactNode } from 'react'
import InfoIcon from '@cuhacking/shared/assets/icons/general/info-1.svg'
import { cn } from '@cuhacking/shared/utils/cn'
import { cva } from 'class-variance-authority'
import React from 'react'

interface GlassmorphicCardProps {
children: ReactNode
Expand Down
1 change: 0 additions & 1 deletion libs/shared/ui/terminal-text/terminal-text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import chevron_down from '@cuhacking/shared/assets/icons/general/chevron-down-1.
import chevron_up from '@cuhacking/shared/assets/icons/general/chevron-up-1.svg'
import link from '@cuhacking/shared/assets/icons/general/link-1.svg'
import phone from '@cuhacking/shared/assets/icons/general/phone-1.svg'
import React from 'react'
import { TerminalText } from './terminal-text'

const meta = {
Expand Down
1 change: 0 additions & 1 deletion libs/shared/ui/terminal-text/terminal-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type Media from '@cuhacking/types/media'
import type { ReactNode } from 'react'
import { cn } from '@cuhacking/shared/utils/cn'
import { cva } from 'class-variance-authority'
import React from 'react'
import { Icon } from '../icon/icon'

interface TerminalTextProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Event } from '../../types/event'
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import React from 'react'
import { EventItem } from '../event-item/event-item'

interface EventContainerProps {
Expand Down
16 changes: 5 additions & 11 deletions libs/website/feature/events/ui/event.section.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { SplineComponent } from '@website/shared/ui/spline/spline.client'
import React from 'react'
import { ClientOnly } from 'remix-utils/client-only'
import { SplineComponent } from '@website/shared/ui/spline/spline-component'
import { EVENT_CONSTANTS } from '../constants/event.constants.ts'
import { EventPresenter } from './event-presenter/event-presenter'

Expand All @@ -12,14 +10,10 @@ export function EventSection() {
<EventPresenter events={EVENT_CONSTANTS.EVENTS} />
</div>
</div>
<ClientOnly>
{() => (
<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]"
/>
)}
</ClientOnly>
<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>
)
}
1 change: 0 additions & 1 deletion libs/website/layouts/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
NAVBAR_CONSTANTS,
NavbarContainer,
} from '@website/shared/ui/navigation'
import React from 'react'
import { ClientOnly } from 'remix-utils/client-only'

export function Layout({ children }) {
Expand Down
1 change: 0 additions & 1 deletion libs/website/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Layout } from '@website/layouts/base'
import { FAQSection } from '@website/ui/faq'
import { MissionSection, WelcomeSection } from '@website/ui/introduction'
import { SponsorshipSection } from '@website/ui/sponsorship'
import React from 'react'

export function Home() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@cuhacking/shared/ui/navigation-menu'
import { VisuallyHidden } from '@radix-ui/react-visually-hidden'
import { Link } from '@remix-run/react'
import React, { useState } from 'react'
import { useState } from 'react'
import { Socials } from '../../../socials'
import { NavItem } from './nav-item'
import { MobileNavItem } from './nav-item-mobile'
Expand Down
1 change: 0 additions & 1 deletion libs/website/shared/ui/socials/socials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Media } from '@cuhacking/shared/types/media'
import { Icon } from '@cuhacking/shared/ui/icon'
import { cn } from '@cuhacking/shared/utils/cn'
import { Link } from '@remix-run/react'
import React from 'react'

interface SocialsProps {
socials: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { cn } from '@cuhacking/shared/utils/cn'
import { ErrorBoundary } from '@cuhacking/shared/utils/ErrorBoundary'
import Spline from '@splinetool/react-spline'
import React, { Suspense } from 'react'
import { lazy, Suspense } from 'react'

interface SplineComponentProps {
link: string
className: string
}
export function SplineComponent({ link, className }: SplineComponentProps) {
const Spline = lazy(() => import('@splinetool/react-spline'))

export function SplineComponent({ link, className }: { link: string, className: string }) {
return (
<div className="overflow-x-hidden">
<ErrorBoundary>
<Suspense>
<Suspense fallback={<div>Loading...</div>}>
<Spline className={cn(className)} scene={link} />
</Suspense>
</ErrorBoundary>
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/faq/faq-item/faq-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
AccordionTrigger,
} from '@cuhacking/shared/ui/accordion'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import React from 'react'

interface FAQItemProps {
question: string
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/faq/faq-presenter/faq.presenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@c
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import { Link } from '@remix-run/react'
import React from 'react'
import { FAQItem } from '../faq-item/faq-item'

interface FAQPresenterProps {
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/faq/faq.section.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { FAQ_CONSTANTS } from './constants/faq.constants'
import { FAQPresenter } from './faq-presenter/faq.presenter'

Expand Down
16 changes: 5 additions & 11 deletions libs/website/ui/introduction/mission/mission.section.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { SplineComponent } from '@website/shared/ui/spline/spline.client'
import React from 'react'
import { ClientOnly } from 'remix-utils/client-only'
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">
<ClientOnly>
{() => (
<SplineComponent
className="absolute -bottom-[15vh] lg:-bottom-[5vh] left-0 scale-1 md:scale-[1.2]"
link="https://prod.spline.design/TGlqj05806lq8PRV/scene.splinecode"
/>
)}
</ClientOnly>
<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"
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/introduction/mission/mission.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import { Separator } from '@cuhacking/shared/ui/separator'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import React from 'react'

interface MissionProps {
logo: string
Expand Down
16 changes: 0 additions & 16 deletions libs/website/ui/introduction/mission/spline-mission.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions libs/website/ui/introduction/welcome/spline-welcome.tsx

This file was deleted.

16 changes: 5 additions & 11 deletions libs/website/ui/introduction/welcome/welcome.section.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { SplineComponent } from '@website/shared/ui/spline/spline.client'
import React from 'react'
import { ClientOnly } from 'remix-utils/client-only'
import { SplineComponent } from '@website/shared/ui/spline/spline-component'
import { WELCOME_CONSTATNTS } 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">
<ClientOnly>
{() => (
<SplineComponent
className="absolute -bottom-16 lg:left-0 lg:top-0 lg:scale-[1.2]"
link="https://prod.spline.design/nnjZJFW1wThAacUS/scene.splinecode"
/>
)}
</ClientOnly>
<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} />
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/introduction/welcome/welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import { Socials } from '@website/shared/ui/socials'
import React from 'react'

interface Media {
src: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Sponsor } from '../types/sponsorship'
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import { cn } from '@cuhacking/shared/utils/cn'
import { cva } from 'class-variance-authority'
import React from 'react'

interface SponsorPresenterProps {
sponsor: Sponsor
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Sponsor } from '../../types/sponsorship'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import React from 'react'
import { SponsorItem } from './sponsor-item'

interface SponsorDisplayProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Button } from '@cuhacking/shared/ui/button'
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import { TerminalText } from '@cuhacking/shared/ui/terminal-text'
import { Link } from '@remix-run/react'
import React from 'react'
import { SponsorPresenter } from '../sponsor-presenter/sponsor.presenter'

interface SponsorshipContainerProps {
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/sponsorship/sponsorship-section.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { SPONSORSHIP_CONSTANTS } from './constants/sponsorship.constants'
import { SponsorshipPresenter } from './sponsorship-presenter/sponsorship.presenter'

Expand Down
4 changes: 1 addition & 3 deletions libs/website/ui/stats/stat-item/stat-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

interface StatsProps {
imgUrl: string
title: string
Expand All @@ -14,7 +12,7 @@ export function StatItem({ imgUrl, title }: StatsProps) {
loading="lazy"
alt={`${title} icon`}
/>
<p className="font-sans text-lg font-medium">{title}</p>
<p className="text-lg font-medium">{title}</p>
</div>
)
}
1 change: 0 additions & 1 deletion libs/website/ui/stats/stats-presenter/stats.presenter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
import React from 'react'
import { StatItem } from '../stat-item/stat-item'

interface StatContainerProps {
Expand Down
1 change: 0 additions & 1 deletion libs/website/ui/stats/stats.section.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { STATS_CONSTANTS } from './constants/stats.constants'
import { StatPresenter } from './stats-presenter/stats.presenter'

Expand Down

0 comments on commit 678b94d

Please sign in to comment.