feat: adding flame animation

This commit is contained in:
Chubby Granny Chaser 2024-09-17 16:25:19 +01:00
parent ff91284a91
commit aa4ca25653
No known key found for this signature in database
5 changed files with 61 additions and 10 deletions

View File

@ -6,7 +6,7 @@
"home": { "home": {
"featured": "Destaques", "featured": "Destaques",
"trending": "Populares", "trending": "Populares",
"hot": "🔥 Populares agora", "hot": "Populares agora",
"weekly": "📅 Mais baixados da semana", "weekly": "📅 Mais baixados da semana",
"surprise_me": "Surpreenda-me", "surprise_me": "Surpreenda-me",
"no_results": "Nenhum resultado encontrado", "no_results": "Nenhum resultado encontrado",

View File

@ -1,4 +1,3 @@
import { useRef } from "react";
import Lottie from "lottie-react"; import Lottie from "lottie-react";
import downloadingAnimation from "@renderer/assets/lottie/downloading.json"; import downloadingAnimation from "@renderer/assets/lottie/downloading.json";
@ -8,11 +7,8 @@ export interface DownloadIconProps {
} }
export function DownloadIcon({ isDownloading }: DownloadIconProps) { export function DownloadIcon({ isDownloading }: DownloadIconProps) {
const lottieRef = useRef(null);
return ( return (
<Lottie <Lottie
lottieRef={lottieRef}
animationData={downloadingAnimation} animationData={downloadingAnimation}
loop={isDownloading} loop={isDownloading}
autoplay={isDownloading} autoplay={isDownloading}

View File

@ -105,7 +105,7 @@ export function GameDetailsContextProvider({
setShopDetails(appDetailsResult.value); setShopDetails(appDetailsResult.value);
if ( if (
appDetailsResult.value!.content_descriptors.ids.includes( appDetailsResult.value?.content_descriptors.ids.includes(
SteamContentDescriptor.AdultOnlySexualContent SteamContentDescriptor.AdultOnlySexualContent
) )
) { ) {

View File

@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@ -8,10 +8,11 @@ import { Button, GameCard, Hero } from "@renderer/components";
import type { Steam250Game, CatalogueEntry } from "@types"; import type { Steam250Game, CatalogueEntry } from "@types";
import starsAnimation from "@renderer/assets/lottie/stars.json"; import starsAnimation from "@renderer/assets/lottie/stars.json";
import flameAnimation from "@renderer/assets/lottie/flame.json";
import * as styles from "./home.css"; import * as styles from "./home.css";
import { vars } from "@renderer/theme.css"; import { SPACING_UNIT, vars } from "@renderer/theme.css";
import Lottie from "lottie-react"; import Lottie, { type LottieRefCurrentProps } from "lottie-react";
import { buildGameDetailsPath } from "@renderer/helpers"; import { buildGameDetailsPath } from "@renderer/helpers";
import { CatalogueCategory } from "@shared"; import { CatalogueCategory } from "@shared";
@ -19,6 +20,8 @@ export function Home() {
const { t } = useTranslation("home"); const { t } = useTranslation("home");
const navigate = useNavigate(); const navigate = useNavigate();
const flameAnimationRef = useRef<LottieRefCurrentProps>(null);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [randomGame, setRandomGame] = useState<Steam250Game | null>(null); const [randomGame, setRandomGame] = useState<Steam250Game | null>(null);
@ -82,6 +85,18 @@ export function Home() {
const categories = Object.values(CatalogueCategory); const categories = Object.values(CatalogueCategory);
const handleMouseEnterCategory = (category: CatalogueCategory) => {
if (category === CatalogueCategory.Hot) {
flameAnimationRef?.current?.play();
}
};
const handleMouseLeaveCategory = (category: CatalogueCategory) => {
if (category === CatalogueCategory.Hot) {
flameAnimationRef?.current?.stop();
}
};
return ( return (
<SkeletonTheme baseColor={vars.color.background} highlightColor="#444"> <SkeletonTheme baseColor={vars.color.background} highlightColor="#444">
<section className={styles.content}> <section className={styles.content}>
@ -100,7 +115,28 @@ export function Home() {
: "outline" : "outline"
} }
onClick={() => handleCategoryClick(category)} onClick={() => handleCategoryClick(category)}
onMouseEnter={() => handleMouseEnterCategory(category)}
onMouseLeave={() => handleMouseLeaveCategory(category)}
> >
{category === CatalogueCategory.Hot && (
<div
style={{ width: 16, height: 16, position: "relative" }}
>
<Lottie
lottieRef={flameAnimationRef}
animationData={flameAnimation}
loop
autoplay={false}
style={{
width: 30,
top: -10,
left: -5,
position: "absolute",
}}
/>
</div>
)}
{t(category)} {t(category)}
</Button> </Button>
</li> </li>
@ -123,7 +159,25 @@ export function Home() {
</Button> </Button>
</section> </section>
<h2>{t(currentCatalogueCategory)}</h2> <h2 style={{ display: "flex", gap: SPACING_UNIT }}>
{currentCatalogueCategory === CatalogueCategory.Hot && (
<div style={{ width: 24, height: 24, position: "relative" }}>
<Lottie
animationData={flameAnimation}
loop
autoplay
style={{
width: 40,
top: -10,
left: -5,
position: "absolute",
}}
/>
</div>
)}
{t(currentCatalogueCategory)}
</h2>
<section className={styles.cards}> <section className={styles.cards}>
{isLoading {isLoading

View File

@ -155,6 +155,7 @@ export const listItemImage = style({
width: "32px", width: "32px",
height: "32px", height: "32px",
borderRadius: "4px", borderRadius: "4px",
objectFit: "cover",
}); });
export const listItemDetails = style({ export const listItemDetails = style({