fix snowfall
This commit is contained in:
parent
7d798e9511
commit
11150400ab
2 changed files with 56 additions and 35 deletions
|
@ -1,14 +1,12 @@
|
||||||
'use client'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment } from 'react'
|
||||||
import { affiliations, nationalities, authors } from '../../db/data'
|
import { affiliations, nationalities, authors } from '../../db/data'
|
||||||
import { Zilla_Slab } from 'next/font/google'
|
import { Zilla_Slab } from 'next/font/google'
|
||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
import DocumentCard from '@/app/components/DocumentCard'
|
import DocumentCard from '@/app/components/DocumentCard'
|
||||||
import findDocumentsByAuthor from './findDocumentsByAuthor'
|
import findDocumentsByAuthor from './findDocumentsByAuthor'
|
||||||
import cardEffects from '@/app/styles/cardEffects.module.css'
|
import cardEffects from '@/app/styles/cardEffects.module.css'
|
||||||
import Konami from 'react-konami-code'
|
import KonamiSnowfall from './KonamiSnowfall'
|
||||||
import Snowfall from 'react-snowfall'
|
|
||||||
|
|
||||||
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
||||||
|
|
||||||
|
@ -20,13 +18,9 @@ export default function AuthorDisplay({
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const [snowfallActivated, setSnowfallActivated] = useState<boolean>(false)
|
|
||||||
const { name, affiliation, image, nationality, formerAffiliations } = data
|
const { name, affiliation, image, nationality, formerAffiliations } = data
|
||||||
|
|
||||||
const authorsDocuments = findDocumentsByAuthor(author)
|
const authorsDocuments = findDocumentsByAuthor(author)
|
||||||
const handleKonami = () => {
|
|
||||||
setSnowfallActivated(!snowfallActivated)
|
|
||||||
}
|
|
||||||
|
|
||||||
const MainPosition = () => {
|
const MainPosition = () => {
|
||||||
const mainAffiliationShort = affiliation[0].split('@')[1]
|
const mainAffiliationShort = affiliation[0].split('@')[1]
|
||||||
|
@ -34,33 +28,8 @@ export default function AuthorDisplay({
|
||||||
const mainAffiliation = affiliations[mainAffiliationShort]
|
const mainAffiliation = affiliations[mainAffiliationShort]
|
||||||
const { website } = data
|
const { website } = data
|
||||||
|
|
||||||
const images: HTMLImageElement[] = []
|
|
||||||
nationality.forEach((n) => {
|
|
||||||
const { flag } = nationalities[n]
|
|
||||||
const image = new Image()
|
|
||||||
image.src = flag
|
|
||||||
images.push(image)
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Konami action={handleKonami} />
|
|
||||||
{snowfallActivated && (
|
|
||||||
<Snowfall
|
|
||||||
snowflakeCount={500}
|
|
||||||
color='white'
|
|
||||||
images={images}
|
|
||||||
radius={[20, 60]}
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
zIndex: -1,
|
|
||||||
pointerEvents: 'none',
|
|
||||||
height: `${document.documentElement.scrollHeight}px`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<span>{mainPosition} at </span>
|
<span>{mainPosition} at </span>
|
||||||
<Link href={`/affiliation/${mainAffiliationShort}`}>
|
<Link href={`/affiliation/${mainAffiliationShort}`}>
|
||||||
{mainAffiliation.name}
|
{mainAffiliation.name}
|
||||||
|
@ -173,7 +142,8 @@ export default function AuthorDisplay({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
|
<KonamiSnowfall nationalityList={nationality} />
|
||||||
<div className='grid grid-cols-1 md:grid-cols-2 items-center max-w-3xl mx-auto'>
|
<div className='grid grid-cols-1 md:grid-cols-2 items-center max-w-3xl mx-auto'>
|
||||||
<div className='aspect-square w-[60vw] md:w-[30vw] lg:w-[20vw] 2xl:w-[15vw] overflow-hidden mx-auto mb-4'>
|
<div className='aspect-square w-[60vw] md:w-[30vw] lg:w-[20vw] 2xl:w-[15vw] overflow-hidden mx-auto mb-4'>
|
||||||
<img
|
<img
|
||||||
|
@ -225,6 +195,6 @@ export default function AuthorDisplay({
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
51
src/app/author/[author]/KonamiSnowfall.tsx
Normal file
51
src/app/author/[author]/KonamiSnowfall.tsx
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
'use client'
|
||||||
|
import Konami from 'react-konami-code'
|
||||||
|
import { Snowfall } from 'react-snowfall'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { nationalities } from '@/app/db/data'
|
||||||
|
|
||||||
|
export default function KonamiSnowfall({
|
||||||
|
nationalityList,
|
||||||
|
}: Readonly<{
|
||||||
|
nationalityList: string[]
|
||||||
|
}>) {
|
||||||
|
const [snowfallActivated, setSnowfallActivated] = useState<boolean>(false)
|
||||||
|
const [images, setImages] = useState<HTMLImageElement[]>([])
|
||||||
|
|
||||||
|
const handleKonami = () => {
|
||||||
|
setSnowfallActivated(!snowfallActivated)
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const imagesTemp: HTMLImageElement[] = []
|
||||||
|
nationalityList.forEach((n) => {
|
||||||
|
const { flag } = nationalities[n]
|
||||||
|
const image = new Image()
|
||||||
|
image.src = flag
|
||||||
|
imagesTemp.push(image)
|
||||||
|
})
|
||||||
|
setImages(imagesTemp)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Konami action={handleKonami} />
|
||||||
|
{snowfallActivated && (
|
||||||
|
<Snowfall
|
||||||
|
snowflakeCount={500}
|
||||||
|
color='white'
|
||||||
|
images={images}
|
||||||
|
radius={[20, 60]}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
zIndex: -1,
|
||||||
|
pointerEvents: 'none',
|
||||||
|
height: `${document.documentElement.scrollHeight}px`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue