From f000fecba21268aa7648ecd95c5acb9f2bc73486 Mon Sep 17 00:00:00 2001 From: billy Date: Sun, 30 Mar 2025 15:45:58 -0400 Subject: [PATCH] Refactor App and component files to streamline imports and enhance UI consistency. Removed unused imports and simplified event handlers for better performance. Updated BuildingInfo to utilize Chakra UI modal for improved user experience, and adjusted MultiplierShop functionality comments for clarity. --- src/App.tsx | 13 ++----- src/components/BuildingButton.tsx | 1 - src/components/BuildingInfo.tsx | 51 ++++++++------------------ src/components/MultiplierShop.tsx | 7 ++-- src/components/NextBuildingPreview.tsx | 13 +------ src/components/ResourceDisplay.tsx | 2 +- src/components/SoundToggleButton.tsx | 4 +- src/main.tsx | 4 +- src/utils/soundUtils.ts | 9 +---- 9 files changed, 29 insertions(+), 75 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4ad94bd..709f81f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,8 @@ import { ResourceDisplay } from './components/ResourceDisplay' import { BuildingButton } from './components/BuildingButton' import { NextBuildingPreview } from './components/NextBuildingPreview' -import { ResetButton } from './components/ResetButton' import { useGameStore } from './store/gameStore' -import { playClickSound, initAudio } from './utils/soundUtils' -import { formatNumber } from './utils/numberUtils' +import { initAudio } from './utils/soundUtils' import { ChakraProvider, Box, @@ -14,9 +12,6 @@ import { VStack, SimpleGrid, Button, - Flex, - Image, - Center, Modal, ModalOverlay, ModalContent, @@ -28,7 +23,6 @@ import { } from '@chakra-ui/react' import theme from './theme' import { useEffect, useState } from 'react' -import logoImg from './assets/logo.png' type BuildingId = 'mouseFarms' | 'keyboardFactories' | 'monitorDisplays' | 'officeSpace' | 'serverRooms' | 'dataCenters' | 'dataCities' | 'dataCountries' | 'dataContinents' | 'dataWorlds' | 'dataMoons' | @@ -39,7 +33,6 @@ type BuildingLevelKey = `${BuildingId}Level` function App() { const { points, - playerLevel, getAvailableBuildings, tick, click, @@ -47,7 +40,7 @@ function App() { const [agreedToTerms, setAgreedToTerms] = useState(false) const [hasStarted, setHasStarted] = useState(false) - const { isOpen, onClose } = useDisclosure({ defaultIsOpen: true }) + const { onClose } = useDisclosure({ defaultIsOpen: true }) const availableBuildings = getAvailableBuildings() // Set up game tick interval @@ -66,7 +59,7 @@ function App() { // This is now handled globally, but we'll keep a simpler version // for UI feedback only (cursor change, etc) - const handleClick = (e: React.MouseEvent) => { + const handleClick = () => { // Don't call click() here as it's now handled globally // Just for visual feedback if (hasStarted) { diff --git a/src/components/BuildingButton.tsx b/src/components/BuildingButton.tsx index aa52cb8..ee253bc 100644 --- a/src/components/BuildingButton.tsx +++ b/src/components/BuildingButton.tsx @@ -3,7 +3,6 @@ import { Button, VStack, Text, - Badge, Tooltip, HStack, Image, diff --git a/src/components/BuildingInfo.tsx b/src/components/BuildingInfo.tsx index 432a43c..f7bba03 100644 --- a/src/components/BuildingInfo.tsx +++ b/src/components/BuildingInfo.tsx @@ -1,4 +1,4 @@ -import { motion, AnimatePresence } from 'framer-motion' +import { Box, Heading, Text, Modal, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalCloseButton } from '@chakra-ui/react' interface BuildingInfoProps { isOpen: boolean @@ -11,44 +11,23 @@ interface BuildingInfoProps { } export const BuildingInfo = ({ isOpen, onClose, title, description, production }: BuildingInfoProps) => { - if (!isOpen) return null - return ( - - - e.stopPropagation()} - > -
-

{title}

- -
+ + + + {title} + + + {description} -

{description}

- -
-

Production:

+ + Production: {production.points && ( -
+{production.points} points/s
+ +{production.points} points/s )} -
-
-
-
+ + + + ) } \ No newline at end of file diff --git a/src/components/MultiplierShop.tsx b/src/components/MultiplierShop.tsx index 852e9d7..2be946e 100644 --- a/src/components/MultiplierShop.tsx +++ b/src/components/MultiplierShop.tsx @@ -1,4 +1,4 @@ -import { Box, Button, VStack, HStack, Text, SimpleGrid } from '@chakra-ui/react' +import { Box, Button, VStack, Text, SimpleGrid } from '@chakra-ui/react' import { useGameStore } from '../store/gameStore' const MULTIPLIER_PURCHASES = [ @@ -11,7 +11,7 @@ const MULTIPLIER_PURCHASES = [ ] export function MultiplierShop() { - const { points, buyMultiplier } = useGameStore() + const { points } = useGameStore() return ( @@ -26,7 +26,8 @@ export function MultiplierShop() { {MULTIPLIER_PURCHASES.map((purchase) => (