supporters full integrated exept sponsors item

This commit is contained in:
MathieuG-P
2022-09-09 02:11:15 +02:00
parent 2600785a10
commit bbff1c6934
16 changed files with 283 additions and 42 deletions
@@ -0,0 +1,19 @@
import { CSSProperties } from "react";
import { Supporter } from "shared/models/supporters";
import { motion } from "framer-motion";
import txtBg from "../../../../../assets/images/gifs/txt-bg.gif"
interface Props { supporter: Supporter, delay?: number }
export function SupporterItem({supporter, delay}: Props) {
const additionnalStyles: CSSProperties = (() => {
if(supporter.type === "gold"){ return {color: "#ffe270", textShadow: "0px 0px 10px #ffdd59", backgroundImage: `url(${txtBg})`, backgroundSize: "70% 15px", backgroundRepeat: "no-repeat", backgroundPosition: "center"}; }
if(supporter.type === "diamond"){ return {color: "#e574fc", textShadow: "0px 0px 15px #e056fd", backgroundImage: `url(${txtBg})`, backgroundSize: "70% 19px", backgroundRepeat: "no-repeat", backgroundPosition: "center"}; }
return {};
})()
return (
<motion.span className="text-2xl font-bold px-3 pb-1" style={additionnalStyles} initial={{y: "100%", opacity: 0}} animate={{y: 0, opacity: 1}} transition={{delay: delay}}>{supporter.username}</motion.span>
)
}
@@ -0,0 +1,22 @@
import { Supporter } from "shared/models/supporters";
import { SupporterItem } from "./supporter-item.component";
interface Props {className?: string, title: string, supporters: Supporter[]}
export function SupportersBlock({className, title, supporters}: Props) {
const someDelay = () => {
const [min, max] = [0, .55]
const baseDelay = .15;
return baseDelay + Math.random() * (max - min) + min;
}
return (
<div className={`mb-10 flex flex-col items-center ${className}`}>
<h2 className="uppercase text-3xl font-bold">{title}</h2>
<div className="flex justify-center flex-wrap py-5 px-20">
{supporters.map(s => <SupporterItem supporter={s} delay={someDelay()}/>)}
</div>
</div>
)
}
@@ -0,0 +1,49 @@
import { motion, AnimatePresence } from "framer-motion"
import { useEffect, useState } from "react";
import { BsmButton } from "renderer/components/shared/bsm-button.component"
import { Supporter } from "shared/models/supporters";
import { SupportersService } from "renderer/services/supporters.service";
import { SupportersBlock } from "./supporters-block.component";
import ManheraChanGif from "../../../../../assets/images/gifs/menhera-chan.gif"
import ManheraSadGif from "../../../../../assets/images/gifs/menhera-sad.gif"
interface Props {isVisible: boolean, setVisible: (b: boolean) => void}
export function SupportersView({isVisible, setVisible}: Props) {
const supportersService = SupportersService.getInstance();
const [supporters, setSupporters] = useState([] as Supporter[]);
const [sponsors, setSponsors] = useState([] as Supporter[]);
useEffect(() => {
if(isVisible){
supportersService.getSupporters().then(supporters => {
setSponsors(supporters.filter(s => s.type === "sponsor"));
setSupporters(supporters.filter(s => !s.type || s.type !== "sponsor"));
});
}
}, [isVisible])
return (
<AnimatePresence>
({isVisible &&
<motion.div className="fixed top-0 left-0 w-full h-full bg-black bg-opacity-90 z-40 text-gray-200" transition={{duration: .3}} initial={{opacity: 0, y: "-100%"}} animate={{opacity: 1, y: "0%"}} exit={{opacity: 0, y: "-100%"}}>
<BsmButton className="absolute right-10 top-10 !bg-transparent w-7 h-7" icon="cross" withBar={false} onClick={() => setVisible(false)}></BsmButton>
{(!!sponsors.length || !!supporters.length) && <img className="absolute bottom-5 right-5 rotate-45 w-32 h-32" src={ManheraChanGif}/>}
<div className="w-full h-full overflow-y-scroll">
{!!sponsors.length && <SupportersBlock className="mt-12" title="sponsors" supporters={sponsors}/>}
{!!supporters.length && <SupportersBlock className="mt-12" title="supporters" supporters={supporters}/>}
{(!sponsors.length && !supporters.length) && (
<>
<h2 className="w-full text-center text-3xl font-bold mt-10 mb-24">No supporter yet</h2>
<img className="m-auto" src={ManheraSadGif} />
</>
)}
</div>
</motion.div>
})
</AnimatePresence>
)
}