Skip to content

Latest commit

 

History

History
112 lines (74 loc) · 2.43 KB

File metadata and controls

112 lines (74 loc) · 2.43 KB

🔢 Counter + Theme Toggle

A simple and interactive counter application with light/dark theme switching built using HTML, CSS, and Vanilla JavaScript.


📌 Project Overview

This project demonstrates fundamental frontend concepts including:

  • State management
  • DOM manipulation
  • Event handling
  • Conditional logic
  • Theme switching using CSS variables

It focuses on clean structure and modular logic rather than visual complexity.


🚀 Features

Feature Description
➕ Increment Increase counter value
➖ Decrement Decrease counter value (no negative values)
🔄 Reset Reset counter to zero
🌗 Theme Toggle Switch between light and dark mode
🎨 CSS Variables Theme handled using custom properties
📱 Responsive Layout Centered layout across devices

🛠 Tech Stack

Technology Usage
HTML5 Structure
CSS3 Styling & theme variables
JavaScript Logic & state management

📸 Screenshots

☀️ Light Mode

Light Mode


🌙 Dark Mode

Dark Mode


🧠 Key Concepts Demonstrated

  • Managing application state using a JavaScript variable
  • Updating UI using a dedicated render function
  • Preventing invalid state (no negative counter)
  • Toggling CSS classes for theme switching
  • Using CSS variables for scalable theming

counter-theme-toggle/ │ ├── index.html ├── style.css ├── script.js └── output/ ├── light-mode.png └── dark-mode.png


🎤 Interview Talking Points

How is state managed?

The counter value is stored in a count variable and updated through event listeners.

How did you prevent invalid submissions?

The decrement function checks if the counter is greater than zero before decreasing.

How does theme switching work?

A dark class is toggled on the <body> element, and CSS variables update colors dynamically.

Why use CSS variables?

They allow centralized theme control and scalable design adjustments.


🔮 Possible Improvements

  • Store theme preference in localStorage
  • Add animated counter transitions
  • Add input-based counter mode
  • Convert into reusable component (React)

👨‍💻 Author

Rajeev Ranjan Singh
Frontend Developer


⭐ If you found this project useful, consider giving it a star.

🏗 Project Structure