A comprehensive, professional-grade calculator suite built with React, TypeScript, and Tailwind CSS. SwiftCalc provides multiple calculator modes including Standard, Scientific, Graphing, Financial, and Unit Conversion calculators - all in one swift, elegant interface.
- Standard Calculator: Basic arithmetic operations with memory functions
- Scientific Calculator: Advanced mathematical functions, trigonometry, logarithms, and more
- Graphing Calculator: Plot mathematical functions with customizable viewing windows
- Financial Calculator: Loan payments, compound interest, and investment calculations
- Unit Converter: Convert between various units (length, weight, temperature, area, volume, time)
- Dark/Light Mode: Toggle between themes for comfortable viewing
- Calculation History: Track and reuse previous calculations
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Professional UI: Clean, modern interface with smooth animations
- Memory Functions: Store and recall values across calculations
- Real-time Graphing: Interactive function plotting with Chart.js
- Mathematical Expression Parsing: Powered by Math.js for accurate calculations
- Type Safety: Full TypeScript implementation
- Performance Optimized: Efficient rendering and state management
- Accessibility: Keyboard navigation and screen reader support
- Node.js (version 16 or higher)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/seehiong/swift-calc.git cd swift-calc
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
to view the application.
# Build the application
npm run build
# Preview the production build
npm run preview
- Basic arithmetic operations (+, -, ร, รท)
- Memory functions (MC, MR, M+, M-)
- Percentage calculations
- Sign toggle and decimal operations
- Trigonometric functions (sin, cos, tan) with degree/radian modes
- Logarithmic functions (log, ln)
- Power and root operations
- Constants (ฯ, e)
- Factorial and inverse functions
- Plot multiple functions simultaneously
- Customizable viewing window (X/Y min/max)
- Function visibility toggle
- Color-coded function lines
- Interactive zoom and pan
- Loan Calculator: Calculate monthly payments, total interest
- Compound Interest: Calculate growth with various compounding frequencies
- Investment Calculator: Plan future value with regular contributions
- Length: Meters, kilometers, inches, feet, miles, etc.
- Weight: Kilograms, pounds, ounces, stones, etc.
- Temperature: Celsius, Fahrenheit, Kelvin
- Area: Square meters, acres, hectares, etc.
- Volume: Liters, gallons, cups, fluid ounces, etc.
- Time: Seconds, minutes, hours, days, years, etc.
- Frontend Framework: React 18
- Language: TypeScript
- Styling: Tailwind CSS
- Mathematical Engine: Math.js
- Charting: Chart.js with React-Chart.js-2
- Icons: Lucide React
- Build Tool: Vite
- Linting: ESLint with TypeScript support
src/
โโโ components/
โ โโโ calculators/
โ โ โโโ StandardCalculator.tsx
โ โ โโโ ScientificCalculator.tsx
โ โ โโโ GraphingCalculator.tsx
โ โ โโโ FinancialCalculator.tsx
โ โ โโโ ConversionCalculator.tsx
โ โโโ BoltBadge.tsx
โ โโโ CalculatorButton.tsx
โ โโโ Display.tsx
โ โโโ History.tsx
โ โโโ ModeSelector.tsx
โโโ hooks/
โ โโโ useCalculator.ts
โโโ types/
โ โโโ calculator.ts
โโโ App.tsx
โโโ main.tsx
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
sin | 30 โ sin โ = |
0.5 (DEG mode) |
sin(30) |
sinโปยน | INV โ 0.5 โ sin โ = |
30 (DEG mode) |
asin(0.5) |
cos | 60 โ cos โ = |
0.5 (DEG mode) |
cos(60) |
cosโปยน | INV โ 0.5 โ cos โ = |
60 (DEG mode) |
acos(0.5) |
tan | 45 โ tan โ = |
1 (DEG mode) |
tan(45) |
tanโปยน | INV โ 1 โ tan โ = |
45 (DEG mode) |
atan(1) |
log | 100 โ log โ = |
2 |
log10(100) |
10หฃ | INV โ 2 โ log โ = |
100 |
10^(2) |
ln | e โ ln โ = |
1 |
log(e) |
eหฃ | INV โ 1 โ ln โ = |
2.71828... |
exp(1) |
x! | 5 โ x! โ = |
120 |
5! |
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
ฯ | ฯ โ = |
3.14159265359 |
pi |
e | e โ = |
2.71828182846 |
e |
xยฒ | 5 โ xยฒ |
25 (immediate) |
- |
โx | 9 โ โx |
3 (immediate) |
- |
xสธ | 2 โ xสธ โ 3 โ = |
8 |
2^3 |
( | 5 โ ( โ 2 โ + โ 3 โ ) โ = |
25 |
5(2 + 3) |
Button | Test Input | Expected Result | Notes |
---|---|---|---|
AC | Any calculation โ AC |
0 , clears all |
Resets everything |
C | 123 โ C |
0 |
Clears display only |
) | ( โ 2 โ + โ 3 โ ) |
Shows in expression | Closes parentheses |
รท | 10 โ รท โ 2 โ = |
5 |
10 / 2 |
ร | 6 โ ร โ 7 โ = |
42 |
6 * 7 |
DEL | 123 โ DEL |
12 |
Removes last digit |
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
7,8,9 | 789 |
789 |
Number input |
โ | 10 โ โ โ 3 โ = |
7 |
10 - 3 |
% | 50 โ % |
0.5 (immediate) |
Converts to decimal |
1/x | 4 โ 1/x |
0.25 (immediate) |
Reciprocal |
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
4,5,6 | 456 |
456 |
Number input |
+ | 5 โ + โ 3 โ = |
8 |
5 + 3 |
ยฑ | 5 โ ยฑ |
-5 (immediate) |
Sign toggle |
EXP | 1.5 โ EXP โ 10 |
1.5e10 |
Scientific notation |
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
1,2,3 | 123 |
123 |
Number input |
= | Any expression โ = |
Calculated result | Executes calculation |
Ans | Previous result โ Ans |
Last answer | Recalls last result |
mod | 10 โ mod โ 3 โ = |
1 |
10 mod 3 |
Button | Test Input | Expected Result | Expression Shown |
---|---|---|---|
Rand | Rand |
0.xxxxx |
Random number 0-1 |
0 | 0 or 120 |
0 or 1200 |
Number input (spans 2 cols) |
. | 5 โ . โ 25 |
5.25 |
Decimal point |
|x| | -5 โ |x| |
5 (immediate) |
Absolute value |
Button | Test | Expected Result |
---|---|---|
DEG/RAD | ฯ โ sin โ = |
DEG: 0 , RAD: 0 |
INV | Toggle โ functions change | sinโsinโปยน, etc. |
- Nested Functions:
cos(sin(45))
โ DEG mode โ0.99992384661
- Mixed Operations:
2^3 + sqrt(16) - log(100)
โ8 + 4 - 2 = 10
- Parentheses:
(2 + 3) * (4 - 1)
โ5 * 3 = 15
- Constants:
ฯ * e^2
โโ22.87
- Pi with Functions:
sin(cos(ฯ))
โ DEG mode โ0.017426180743
- Scientific Notation:
1.5e3 + 500
โ2000
Input Sequence | Expected Result | Notes |
---|---|---|
45 โ sin โ cos โ = |
0.99992384661 |
cos(sin(45ยฐ)) in DEG mode |
45 โ cos โ sin โ = |
0.012341028215 |
sin(cos(45ยฐ)) in DEG mode |
ฯ โ cos โ sin โ = |
0.017426180743 |
sin(cos(ฯยฐ)) in DEG mode |
30 โ cos โ sin โ tan โ = |
0.0002637963853 |
tan(sin(cos(30ยฐ))) in DEG mode |
ฯ โ sin โ cos โ = |
TBD | cos(sin(ฯยฐ)) in DEG mode |
Central state management for all calculator operations, including:
- Display state management
- Memory operations
- Calculation history
- Mode switching
- Theme toggling
Each calculator mode is implemented as a separate component with specialized functionality:
- Modular design for easy maintenance
- Consistent UI patterns across modes
- Optimized performance for complex calculations
npm run dev
- Start development servernpm run build
- Build for productionnpm run preview
- Preview production buildnpm run lint
- Run ESLint
- MC (Memory Clear): Clear stored memory
- MR (Memory Recall): Recall stored value
- M+ (Memory Add): Add current display to memory
- M- (Memory Subtract): Subtract current display from memory
- Trigonometric: sin, cos, tan (with inverse functions)
- Logarithmic: log (base 10), ln (natural log)
- Power operations: xยฒ, x^y, โx
- Constants: ฯ (pi), e (Euler's number)
- Special functions: factorial (!), absolute value
- Multiple function plotting
- Real-time function updates
- Customizable axis ranges
- Function visibility controls
- Color-coded function identification
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Developed by seehiong
- Built with Bolt.new - AI-powered development platform
- Mathematical calculations powered by Math.js
- Charts rendered with Chart.js
- Icons provided by Lucide React
- Styling with Tailwind CSS
If you encounter any issues or have questions, please:
- Check the existing issues on GitHub
- Create a new issue with detailed information
- Include steps to reproduce any bugs