Skip to content

Commit

Permalink
fix(build): bundler failing
Browse files Browse the repository at this point in the history
  • Loading branch information
MFarabi619 committed Aug 18, 2024
1 parent 0a0c719 commit 8531898
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 135 deletions.
6 changes: 6 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const withMDX = createMDX({
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
// TODO: Eliminate this workaround
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
}

export default withMDX(config)
2 changes: 1 addition & 1 deletion src/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSearchAPI } from 'fumadocs-core/search/server'
import { getPages } from '@/app/source'
import { getPages } from '@/app/docs/source'

export const { GET } = createSearchAPI('advanced', {
indexes: getPages().map(page => ({
Expand Down
14 changes: 12 additions & 2 deletions src/components/sections/home/hero/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Image from 'next/image'

import logo from '@root/public/assets/spac_logo_year_stars.svg'
import { SponsorshipPackage } from '@/components/sections/home/hero/sponsorship-package'
// import { SponsorshipPackage } from '@/components/sections/home/hero/sponsorship-package'
import { ShinyButton } from '@/components/twilight/shiny-button/shiny-button'
import { BorderBeam } from '@/components/twilight/border-beam/border-beam'

Check failure on line 6 in src/components/sections/home/hero/hero.tsx

View workflow job for this annotation

GitHub Actions / release (20)

'BorderBeam' is defined but never used
import SparklesText from '@/components/twilight/sparkles-text/sparkles-text'
import ShineBorder from '@/components/twilight/shine-pulse/shine-pulse'
Expand Down Expand Up @@ -64,7 +65,16 @@ export function Hero() {
</div>
)}
/>
<SponsorshipPackage />
{/* <SponsorshipPackage /> */}
<a
href="https://drive.google.com/file/d/1wfvpv5T8Xg-cmt5kmps9Gzlddq9_Cdc0/view?usp=sharing"
target="_blank"
rel="noopener noreferrer"
>
<ShinyButton
text="Become a Patron"
/>
</a>
</main>
</ShineBorder>
</div>
Expand Down
255 changes: 128 additions & 127 deletions src/components/sections/home/hero/sponsorship-package.tsx
Original file line number Diff line number Diff line change
@@ -1,127 +1,128 @@
'use client'

import 'react-pdf/dist/Page/TextLayer.css'
import 'react-pdf/dist/Page/AnnotationLayer.css'

import { useCallback, useEffect, useMemo, useState } from 'react'
import { Document, Page, pdfjs } from 'react-pdf'
import ShinyButton from '@/components/twilight/shiny-button/shiny-button'

pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url,
).toString()

export function SponsorshipPackage() {
const numPages = 11
const [pageIndex, setPageIndex] = useState<number>(0)

const calculateScale = useCallback(() => {
const MIN_SCALE = 0.2
const MAX_SCALE = 0.38

const MIN_WIDTH = 320
const MAX_WIDTH = 768
const MIN_HEIGHT = 500

const calculateWidthScale = () => {
if (window.innerWidth < MIN_WIDTH) {
return MIN_SCALE
}
if (window.innerWidth > MAX_WIDTH) {
return MAX_SCALE
}
return (
MIN_SCALE
+ (MAX_SCALE - MIN_SCALE)
* ((window.innerWidth - MIN_WIDTH) / (MAX_WIDTH - MIN_WIDTH))
)
}

const calculateHeightScale = () => {
return window.innerHeight < MIN_HEIGHT ? MIN_SCALE : MAX_SCALE
}

const widthScale = calculateWidthScale()
const heightScale = calculateHeightScale()

// Return the minimum scale to ensure it fits within both width and height constraints
return Math.min(widthScale, heightScale)
}, [])

const [scale, setScale] = useState<number>(calculateScale())

useEffect(() => {
const handleResize = () => {
setScale(calculateScale())
}

window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize)
}, [calculateScale])

const file = useMemo(() => 'spac-patronage-package-2024.pdf', [])

return (
<>
<ShinyButton
text="Become a Patron"
// eslint-disable-next-line no-console
onClick={() => console.log('clicked')}
/>

<dialog id="sponsorship-package-modal" className="modal">
<div className="modal-box relative h-3/4 space-y-2 scroll-smooth px-0">
<Document file={file}>
{Array.from({ length: numPages }).map((_, index) => (
<Page
key={`page_${index}`}
canvasBackground="transparent"
className="flex justify-center"
scale={scale}
inputRef={(ref) => {
if (ref && pageIndex === index) {
ref.scrollIntoView()
}
}}
pageIndex={index}
/>
))}
</Document>
{/* Buttons and page number */}
<div className="left-0 top-0 z-10 w-full space-y-2">
<div className="flex justify-center space-x-2">
<button
type="button"
className="btn btn-outline btn-accent"
onClick={() =>
setPageIndex((pageIndex - 1 + numPages) % numPages)}
>
Previous
</button>
<button
type="button"
className="btn btn-outline btn-accent"
onClick={() => setPageIndex((pageIndex + 1) % numPages)}
>
Next
</button>
</div>
<p className="flex justify-center">
Page
{' '}
{pageIndex + 1}
{' '}
of
{' '}
{numPages}
</p>
</div>
</div>
<form method="dialog" className="modal-backdrop">
<button type="button">close</button>
</form>
</dialog>
</>
)
}
// TODO: Re - enable SponsorshipPackage component. Diabled due to failing build.
// 'use client'
//
// import 'react-pdf/dist/Page/TextLayer.css'
// import 'react-pdf/dist/Page/AnnotationLayer.css'
//
// import { useCallback, useEffect, useMemo, useState } from 'react'
// import { Document, Page, pdfjs } from 'react-pdf'
// import { ShinyButton } from '@/components/twilight/shiny-button/shiny-button'
//
// pdfjs.GlobalWorkerOptions.workerSrc = new URL(
// 'pdfjs-dist/build/pdf.worker.min.mjs',
// import.meta.url,
// ).toString()
//
// export function SponsorshipPackage() {
// const numPages = 11
// const [pageIndex, setPageIndex] = useState<number>(0)
//
// const calculateScale = useCallback(() => {
// const MIN_SCALE = 0.2
// const MAX_SCALE = 0.38
//
// const MIN_WIDTH = 320
// const MAX_WIDTH = 768
// const MIN_HEIGHT = 500
//
// const calculateWidthScale = () => {
// if (window.innerWidth < MIN_WIDTH) {
// return MIN_SCALE
// }
// if (window.innerWidth > MAX_WIDTH) {
// return MAX_SCALE
// }
// return (
// MIN_SCALE
// + (MAX_SCALE - MIN_SCALE)
// * ((window.innerWidth - MIN_WIDTH) / (MAX_WIDTH - MIN_WIDTH))
// )
// }
//
// const calculateHeightScale = () => {
// return window.innerHeight < MIN_HEIGHT ? MIN_SCALE : MAX_SCALE
// }
//
// const widthScale = calculateWidthScale()
// const heightScale = calculateHeightScale()
//
// // Return the minimum scale to ensure it fits within both width and height constraints
// return Math.min(widthScale, heightScale)
// }, [])
//
// const [scale, setScale] = useState<number>(calculateScale())
//
// useEffect(() => {
// const handleResize = () => {
// setScale(calculateScale())
// }
//
// window.addEventListener('resize', handleResize)
// return () => window.removeEventListener('resize', handleResize)
// }, [calculateScale])
//
// const file = useMemo(() => 'spac-patronage-package-2024.pdf', [])
//
// return (
// <>
// <ShinyButton
// text="Become a Patron"
// // eslint-disable-next-line no-console
// onClick={() => console.log('clicked')}
// />
//
// <dialog id="sponsorship-package-modal" className="modal">
// <div className="modal-box relative h-3/4 space-y-2 scroll-smooth px-0">
// <Document file={file}>
// {Array.from({ length: numPages }).map((_, index) => (
// <Page
// key={`page_${index}`}
// canvasBackground="transparent"
// className="flex justify-center"
// scale={scale}
// inputRef={(ref) => {
// if (ref && pageIndex === index) {
// ref.scrollIntoView()
// }
// }}
// pageIndex={index}
// />
// ))}
// </Document>
// {/* Buttons and page number */}
// <div className="left-0 top-0 z-10 w-full space-y-2">
// <div className="flex justify-center space-x-2">
// <button
// type="button"
// className="btn btn-outline btn-accent"
// onClick={() =>
// setPageIndex((pageIndex - 1 + numPages) % numPages)}
// >
// Previous
// </button>
// <button
// type="button"
// className="btn btn-outline btn-accent"
// onClick={() => setPageIndex((pageIndex + 1) % numPages)}
// >
// Next
// </button>
// </div>
// <p className="flex justify-center">
// Page
// {' '}
// {pageIndex + 1}
// {' '}
// of
// {' '}
// {numPages}
// </p>
// </div>
// </div>
// <form method="dialog" className="modal-backdrop">
// <button type="button">close</button>
// </form>
// </dialog>
// </>
// )
// }
14 changes: 12 additions & 2 deletions src/components/sections/home/past-patrons/past-patrons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import public_service_commission_of_canada_logo from '@root/public/assets/public
import ross_video_logo from '@root/public/assets/ross_video_logo.svg'
import uber_logo from '@root/public/assets/uber_logo.svg'
import { Spotlight } from '@/components/twilight/spotlight/spotlight'
import { SponsorshipPackage } from '@/components/sections/home/hero/sponsorship-package'
// import { SponsorshipPackage } from '@/components/sections/home/hero/sponsorship-package'
import { ShinyButton } from '@/components/twilight/shiny-button/shiny-button'

// Logo and Tier types
interface Logo {
Expand Down Expand Up @@ -154,7 +155,16 @@ export function PastPatrons() {
gradientClass="from-primary via-secondary to-black"
/>
<span className="inline-flex w-full justify-center">
<SponsorshipPackage />
{/* <SponsorshipPackage /> */}
<a
href="https://drive.google.com/file/d/1wfvpv5T8Xg-cmt5kmps9Gzlddq9_Cdc0/view?usp=sharing"
target="_blank"
rel="noopener noreferrer"
>
<ShinyButton
text="Become a Patron"
/>
</a>
</span>
</div>
)
Expand Down
9 changes: 6 additions & 3 deletions src/components/twilight/shiny-button/shiny-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const animationProps = {
},
} as AnimationProps

function ShinyButton({ text = 'shiny-button', onClick }) {
export function ShinyButton(
{
text = 'shiny-button',
onClick,
}: { text?: string, onClick?: () => void },
) {
return (
<motion.button
{...animationProps}
Expand All @@ -50,5 +55,3 @@ function ShinyButton({ text = 'shiny-button', onClick }) {
</motion.button>
)
}

export default ShinyButton

0 comments on commit 8531898

Please sign in to comment.