import React from 'react'; import {useSpring, animated} from '@react-spring/web'; import LoginForm from './LoginForm'; import ScoreCounter from './ScoreCounter'; import Icon from './Icon'; import { useJSONLocalStorage, useLocalStorage } from './hooks/useLocalStorage'; import {toot, starman, flush, getCheer} from './sound'; import './App.css'; const COLUMNS = [1,2,3,4,5,6,7,8,9,10]; interface Stats { attempts: number; scheduledPoops: number; selfPoops: number; cleanUndies: number; streaks: number[]; currentStreakSince: number; }; const initialStats:Stats = { attempts: 1, scheduledPoops: 1, selfPoops: 1, cleanUndies: 1, streaks: [0,0,0,0], currentStreakSince: Date.now() }; function App() { const [stats, setStats] = useJSONLocalStorage("stats", initialStats); const [name] = useLocalStorage("name", {}); const [password] = useLocalStorage("password", {}); const { attempts, scheduledPoops, selfPoops, cleanUndies, streaks, currentStreakSince } = stats; return !name || !password ? :(
Hello Pax!
Points:
{ setStats({...stats, attempts: attempts + 1 }); flush.play(); setTimeout(() => getCheer().play(), 1800) }}> {COLUMNS.map(i => i <= attempts ? :
)}
{ e.stopPropagation(); setStats({...stats, attempts: Math.max(0, attempts - 1)}); console.log("BLARG"); }} > 🚫
{ setStats({...stats, scheduledPoops: scheduledPoops + 1 }); toot.play(); setTimeout(() => getCheer().play(), 1800) }}> {COLUMNS.map(i => i <= scheduledPoops ? :
)}
{ e.stopPropagation(); setStats({...stats, scheduledPoops: Math.max(0, scheduledPoops - 1)}); }} > 🚫
{ setStats({...stats, selfPoops: selfPoops + 1 }); toot.play(); setTimeout(() => getCheer().play(), 1800) }}> {COLUMNS.map(i => i <= selfPoops ? :
)}
{ e.stopPropagation(); setStats({...stats, selfPoops: Math.max(0, selfPoops - 1)}); }} > 🚫
{ setStats({...stats, cleanUndies: cleanUndies + 1 }) starman.play(); setTimeout(() => getCheer().play(), 1800) }}> {COLUMNS.map(i => i <= cleanUndies ? :
)}
{ e.stopPropagation(); setStats({...stats, cleanUndies: Math.max(0, cleanUndies - 1)}); }} > 🚫
); } export default App;