Skip to content

Commit 2f07703

Browse files
committed
componentizes holoverlay
1 parent b317f03 commit 2f07703

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { cn } from '@/lib/utils'
2+
3+
import styles from '@/components/PlayerCard/holo.module.css'
4+
5+
export type HoloEffect = 'dice' | 'lines' | 'wavy'
6+
export default function Holoverlay({
7+
effect,
8+
className,
9+
}: {
10+
effect: HoloEffect
11+
className?: string
12+
}) {
13+
return (
14+
<div
15+
id="holo"
16+
className={`${cn('z-4', styles.shine, styles[effect], 'absolute inset-0 z-3 size-full opacity-[.3] transition-opacity duration-300 hover:opacity-100', className)}`}
17+
/>
18+
)
19+
}

components/PlayerCard/PlayerCard.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { FaDiscord } from 'react-icons/fa'
44

5+
import Holoverlay, { HoloEffect } from './Holoverlay'
56
import { GlobeIcon } from 'lucide-react'
67
import Image from 'next/image'
78

89
import { Card } from '@/components/Card'
9-
import styles from '@/components/PlayerCard/holo.module.css'
1010

1111
import { usePublicProfile } from '@/hooks/useProfiles'
1212
import {
@@ -65,6 +65,8 @@ export default function PlayerCard({
6565
showStatBoxes = false,
6666
asCelestialCard = false,
6767
overrideCelestialCard = null,
68+
holoEffect = 'dice',
69+
pictureEffect = null,
6870
}: {
6971
userId: string | null
7072
tiltFactor?: number
@@ -74,6 +76,8 @@ export default function PlayerCard({
7476
showStatBoxes?: boolean
7577
asCelestialCard?: boolean
7678
overrideCelestialCard?: DbCelestialCard | null
79+
holoEffect?: HoloEffect | null
80+
pictureEffect?: HoloEffect | null
7781
}) {
7882
const scale = width / CARD_WIDTH
7983
const isTiny = tiny || width < 200
@@ -177,10 +181,7 @@ export default function PlayerCard({
177181
aspectRatio: CARD_WIDTH / CARD_HEIGHT,
178182
}}
179183
>
180-
<div
181-
id="holo"
182-
className={`z-4 ${styles.shine} ${styles.dice} absolute inset-0 z-3 size-full opacity-[.3] transition-opacity duration-300 hover:opacity-100`}
183-
/>
184+
{holoEffect && <Holoverlay effect={holoEffect} />}
184185
{/* Background card image */}
185186
<Image
186187
src={washImageSrcs[profile.team || 'unassigned']}
@@ -374,14 +375,22 @@ export default function PlayerCard({
374375
)}
375376
<div className="relative size-full">
376377
{profile.profile_pictures_url && (
377-
<Image
378-
id="player-picture"
379-
src={profile.profile_pictures_url}
380-
alt="Profile picture"
381-
fill
382-
style={{ borderRadius: 12 * scale }}
383-
className="z-2 object-cover"
384-
/>
378+
<>
379+
<Image
380+
id="player-picture"
381+
src={profile.profile_pictures_url}
382+
alt="Profile picture"
383+
fill
384+
style={{ borderRadius: 12 * scale }}
385+
className="z-2 object-cover"
386+
/>
387+
{pictureEffect && (
388+
<Holoverlay
389+
effect={pictureEffect}
390+
className="opacity-10 hover:opacity-10"
391+
/>
392+
)}
393+
</>
385394
)}
386395
{asCelestialCard && (
387396
<div

0 commit comments

Comments
 (0)