Skip to content

SinRas/animals-clicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐾 Animals Clicker

A React-based clicker game where users can click on animal icons and track their progress. The app stores click data in local storage and syncs with a server every 13 seconds.

✨ Features

  • Interactive Animal Icons: Click on 6 different animal emojis (πŸ±πŸΆπŸ°πŸ¦πŸ πŸ¦‹)
  • Local Storage: All click data is automatically saved to browser's local storage
  • Auto Sync: Automatically syncs with server every 13 seconds
  • Manual Sync: Option to manually trigger sync
  • Responsive Design: Works on desktop and mobile devices
  • Modern UI: Beautiful gradient background with glassmorphism effects

πŸš€ Getting Started

Prerequisites

  • Node.js (version 14 or higher)
  • npm or yarn

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd animals-clicker
  1. Install dependencies:
npm install
  1. Start the development server:
npm start
  1. Open http://localhost:3000 to view it in the browser.

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ AnimalIcon.js          # Individual animal clickable component
β”‚   β”œβ”€β”€ AnimalIcon.css
β”‚   β”œβ”€β”€ ClickCounter.js        # Displays total click count
β”‚   β”œβ”€β”€ ClickCounter.css
β”‚   β”œβ”€β”€ SyncStatus.js          # Shows sync status and controls
β”‚   └── SyncStatus.css
β”œβ”€β”€ hooks/
β”‚   └── useLocalStorage.js     # Custom hook for localStorage
β”œβ”€β”€ services/
β”‚   └── syncService.js         # Server sync logic
β”œβ”€β”€ App.js                     # Main application component
β”œβ”€β”€ App.css                    # Main application styles
β”œβ”€β”€ index.js                   # React entry point
└── index.css                  # Global styles

πŸ”§ Configuration

Environment Variables

Create a .env file in the root directory to configure the API endpoint:

REACT_APP_API_URL=http://localhost:3000/api

πŸ”„ Next.js Backend Integration

The project is designed to be easily integrated with a Next.js backend. The sync service (src/services/syncService.js) contains commented code showing how to implement the actual API calls.

Backend API Endpoint

When you add the Next.js backend, create an API endpoint at /api/sync-clicks that accepts:

{
  "clicks": {
    "cat": 5,
    "dog": 3,
    "rabbit": 1
  },
  "timestamp": "2024-01-01T12:00:00.000Z",
  "userId": "anonymous"
}

🎨 Customization

Adding New Animals

Edit the ANIMALS array in src/App.js:

const ANIMALS = [
  { id: 'cat', name: 'Cat', emoji: '🐱' },
  { id: 'dog', name: 'Dog', emoji: '🐢' },
  // Add your new animal here
  { id: 'unicorn', name: 'Unicorn', emoji: 'πŸ¦„' }
];

Styling

  • Global styles: src/index.css
  • App layout: src/App.css
  • Component styles: src/components/*.css

πŸ“± Available Scripts

  • npm start - Runs the app in development mode
  • npm build - Builds the app for production
  • npm test - Launches the test runner
  • npm eject - Ejects from Create React App (one-way operation)

πŸ› οΈ Technologies Used

  • React 18 - Frontend framework
  • CSS3 - Styling with modern features (backdrop-filter, gradients)
  • Local Storage API - Data persistence
  • Create React App - Build tooling

πŸ“„ License

This project is licensed under the MIT License.

About

🐰 Which animal is more popular in the world?

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •