Skip to content

Avuii/react-scientific-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ React Scientific Calculator

Modern scientific calculator web app with interactive graphing, memory operations and unit conversion.

Live Demo


๐Ÿ“š Table of Contents


๐Ÿ“Œ Overview

React Scientific Calculator is a modern web application for performing basic, scientific and graph-based calculations.

The project includes a glassmorphism-inspired responsive interface, dark and light mode, calculation history, memory operations, keyboard support, unit conversion and an interactive graphing mode for visualizing mathematical functions.

The application was created to practice building a structured React project with Vite, JavaScript, CSS, React Hooks, localStorage and the HTML Canvas API.


โœจ Features

๐Ÿงฎ Basic Calculator

  • addition, subtraction, multiplication and division
  • percentage calculations
  • decimal numbers
  • delete and clear actions
  • result formatting
  • keyboard input support
  • calculation history saved in localStorage

๐Ÿง  Memory Operations

  • MC โ€” clear memory
  • MR โ€” recall memory
  • M+ โ€” add current result to memory
  • M- โ€” subtract current result from memory
  • memory value saved in localStorage

๐Ÿ”ฌ Scientific Functions

  • trigonometric functions: sin, cos, tan
  • additional trigonometric functions: sec, csc, cot
  • inverse trigonometric functions: asin, acos, atan
  • hyperbolic functions: sinh, cosh, tanh
  • logarithmic functions: log, ln
  • constants: ฯ€ and e
  • powers and roots
  • factorial
  • absolute value
  • exponential function
  • floor, ceil and round
  • random number function
  • modulo operation
  • previous result usage with ANS

๐Ÿ“Š Graphing Mode

  • draw function graphs directly in the browser
  • support for multiple functions at the same time
  • add and remove function rows
  • edit each function expression separately
  • choose graph color per function
  • change line thickness per function
  • use function presets
  • zoom in and zoom out with buttons
  • zoom with mouse wheel
  • pan the graph by dragging
  • display cursor coordinates
  • reset graph view
  • manually set X/Y axis range
  • responsive canvas rendering
  • separate graph colors for dark and light theme

๐Ÿ” Unit Converter

  • convert length units
  • convert mass units
  • convert temperature units
  • convert time units
  • convert data units
  • convert speed units
  • swap source and target units
  • custom styled dropdowns
  • responsive converter layout

๐ŸŽจ Interface

  • modern glassmorphism UI
  • dark and light theme
  • animated background
  • responsive layout
  • custom dropdown menus
  • clean scientific calculator layout
  • premium-style buttons and cards

๐Ÿ“ˆ Graphing Mode

The graphing mode allows the user to create and compare multiple function graphs.

Each function row includes:

  • function label, such as f1(x), f2(x), f3(x)
  • editable expression input
  • preset selector
  • color picker
  • line thickness control
  • add or delete function controls

Example expressions:

sin(x)
cos(x)
tan(x)
x^2
x^3 - 3*x
sqrt(x)
log(x)
exp(x/4)

The graph is rendered with the HTML Canvas API.
The canvas updates when the function list, axis range, zoom level, theme or cursor position changes.

Interactive graph controls:

Drag mouse      -> pan graph
Mouse wheel     -> zoom graph
Reset button    -> reset graph view
X/Y range input -> manually set graph window
Cursor move     -> show graph coordinates

๐Ÿ” Unit Converter

The application includes a separate converter mode for common unit conversions.

Supported categories:

Length
Mass
Temperature
Time
Data
Speed

The converter allows selecting source and target units, entering a numeric value and swapping units with one button.


๐Ÿ› ๏ธ Tech Stack

Area Technology
Frontend React
Build Tool Vite
Language JavaScript
Styling CSS
Graph Rendering HTML Canvas API
State Management React Hooks
Storage localStorage
Deployment GitHub Pages
Platform Web Browser

โš™๏ธ Requirements

To run the project locally, you need:

  • Node.js
  • npm
  • modern web browser

๐Ÿš€ Getting Started

  1. Clone the repository
git clone https://github.com/Avuii/react-scientific-calculator.git
cd react-scientific-calculator
  1. Install dependencies
npm install
  1. Run the development server
npm run dev
  1. Build the project
npm run build
  1. Preview the production build locally
npm run preview

๐Ÿ“ Project Structure

react-scientific-calculator/
โ”œโ”€โ”€ public/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ CalcButton.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ Calculator.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ ConverterPanel.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ Display.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ GraphPanel.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ HistoryPanel.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ ScienceToolbar.jsx
โ”‚   โ”‚   โ””โ”€โ”€ ThemeToggle.jsx
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”œโ”€โ”€ useCalculator.js
โ”‚   โ”‚   โ”œโ”€โ”€ useKeyboard.js
โ”‚   โ”‚   โ””โ”€โ”€ useLocalStorage.js
โ”‚   โ”œโ”€โ”€ logic/
โ”‚   โ”‚   โ”œโ”€โ”€ calculator.js
โ”‚   โ”‚   โ””โ”€โ”€ constants.js
โ”‚   โ”œโ”€โ”€ styles/
โ”‚   โ”‚   โ””โ”€โ”€ global.css
โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ””โ”€โ”€ main.jsx
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ vite.config.js
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .gitignore

๐Ÿšง Future Improvements

  • add better error messages for invalid expressions
  • add support for saving graph presets
  • add graph export as image
  • add more calculator themes
  • add unit tests for calculator logic
  • improve accessibility for keyboard and screen reader users

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Created by Katarzyna Staล„czyk.

About

Scientific calculator web app with graphing mode built in React and Vite.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors