Skip to content

Commit 21b50f5

Browse files
committed
fix: weather icon in pokemon background popup
1 parent 3717c2e commit 21b50f5

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/features/pokemon/PokemonPopup.jsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export function PokemonPopup({ pokemon, iconUrl, isTutorial = false }) {
286286
metaData={metaData}
287287
perms={pokePerms}
288288
timeOfDay={timeOfDay}
289+
backgroundVisuals={backgroundVisuals}
289290
/>
290291
<ShinyOdds shinyStats={shinyStats} />
291292
<Footer
@@ -569,12 +570,17 @@ const TappableOrigin = ({ tappable, loading }) => {
569570
)
570571
}
571572

572-
const Info = ({ pokemon, metaData, perms, timeOfDay }) => {
573+
const Info = ({ pokemon, metaData, perms, timeOfDay, backgroundVisuals }) => {
573574
const Icons = useMemory((s) => s.Icons)
574575
const { t } = useTranslation()
575576
const { gender, size, weather, form } = pokemon
576577
const formTypes = metaData?.forms?.[form]?.types || metaData?.types || []
577578
const darkMode = useStorage((s) => s.darkMode)
579+
const iconStyles = backgroundVisuals?.styles?.icon
580+
const hasBackground = Boolean(backgroundVisuals?.hasBackground)
581+
const weatherIconTimeOfDay = hasBackground ? 'night' : timeOfDay
582+
const weatherIconUrl =
583+
Icons?.getWeather?.(weather, weatherIconTimeOfDay) || ''
578584
return (
579585
<Grid
580586
xs={perms.iv ? 3 : 11}
@@ -585,13 +591,39 @@ const Info = ({ pokemon, metaData, perms, timeOfDay }) => {
585591
>
586592
{weather != 0 && perms.iv && (
587593
<Grid
588-
className={`grid-item ${darkMode ? '' : 'darken-image'}`}
589594
style={{
590595
height: 24,
591596
width: 24,
592-
backgroundImage: `url(${Icons.getWeather(weather, timeOfDay)})`,
597+
...(iconStyles || {}),
593598
}}
594-
/>
599+
>
600+
<div
601+
className={
602+
hasBackground
603+
? 'grid-item'
604+
: `grid-item ${darkMode ? '' : 'darken-image'}`
605+
}
606+
style={{
607+
height: '100%',
608+
width: '100%',
609+
...(hasBackground
610+
? {
611+
WebkitMaskImage: `url(${weatherIconUrl})`,
612+
maskImage: `url(${weatherIconUrl})`,
613+
WebkitMaskRepeat: 'no-repeat',
614+
maskRepeat: 'no-repeat',
615+
WebkitMaskPosition: 'center',
616+
maskPosition: 'center',
617+
WebkitMaskSize: 'contain',
618+
maskSize: 'contain',
619+
backgroundColor: '#fff',
620+
}
621+
: {
622+
backgroundImage: `url(${weatherIconUrl})`,
623+
}),
624+
}}
625+
/>
626+
</Grid>
595627
)}
596628
{!!gender && (
597629
<Grid textAlign="center">

0 commit comments

Comments
 (0)