Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi-Sudhakar committed Feb 5, 2024
1 parent 622b50f commit 68e9f61
Show file tree
Hide file tree
Showing 8 changed files with 2,413 additions and 0 deletions.
59 changes: 59 additions & 0 deletions calculatorScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
document.addEventListener("DOMContentLoaded", function() {
const display = document.getElementById('display');
const buttons = document.querySelectorAll('.number, .operator');
let displayValue = '';

buttons.forEach(button => {
button.addEventListener('click', () => {
animateButtonClick(button);
displayValue += button.textContent;
display.textContent = displayValue;
});
});

document.getElementById('clear').addEventListener('click', () => {
animateButtonClick(document.getElementById('clear'));
displayValue = '';
display.textContent = '0';
});

document.getElementById('equals').addEventListener('click', () => {
animateButtonClick(document.getElementById('equals'));
try {
displayValue = eval(displayValue);
display.textContent = displayValue;
} catch (error) {
display.textContent = 'Error';
}
});

// Function to animate button click
function animateButtonClick(button) {
button.style.transform = 'scale(0.9)';
setTimeout(() => {
button.style.transform = 'scale(1)';
}, 100);
}
});

// Theme toggle
const themeToggle = document.getElementById('theme-toggle');
const body = document.body;

themeToggle.addEventListener('click', () => {
body.classList.toggle('dark-theme');
const isDarkTheme = body.classList.contains('dark-theme');
localStorage.setItem('theme', isDarkTheme ? 'dark' : 'light');
});

// Apply stored theme preference
const storedTheme = localStorage.getItem('theme');
if (storedTheme === 'dark') {
body.classList.add('dark-theme');
}

// Redirect to welcome page
const backToWelcomeButton = document.getElementById('back-to-welcome');
backToWelcomeButton.addEventListener('click', () => {
window.location.href = 'index.html';
});
179 changes: 179 additions & 0 deletions calculatorStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/* Light theme styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: var(--background-color);
color: var(--text-color);
transition: background-color 0.3s, color 0.3s;
}

#calculator {
width: 320px;
border: 2px solid var(--border-color);
border-radius: 15px;
overflow: hidden;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

#display {
background-color: var(--display-background-color);
padding: 20px;
font-size: 32px;
text-align: right;
color: var(--display-text-color);
border-bottom: 1px solid var(--border-color);
}

#buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10px;
padding: 10px;
}

button {
padding: 20px;
font-size: 24px;
cursor: pointer;
background-color: var(--button-background-color);
border: none;
border-radius: 10px;
transition: background-color 0.3s, transform 0.2s ease-in-out;
color: var(--button-text-color);
}

button:hover {
background-color: var(--button-hover-background-color);
transform: translateY(-3px);
}

.operator {
color: #ff6d00;
}

#equals,
#clear {
background-color: #ff6d00;
color: #fff;
}

#equals:hover,
#clear:hover {
background-color: #ff4500;
}

.tooltip {
position: relative;
display: inline-block;
}

.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}

/* Dark theme styles */
body.dark-theme {
background-color: #222;
color: #fff;
}

#display.dark-theme {
background-color: #333;
color: #fff;
}

button.dark-theme {
background-color: #444;
color: #fff;
}

button.dark-theme:hover {
background-color: #666;
}

.operator.dark-theme {
color: #ff6d00;
}

#equals.dark-theme,
#clear.dark-theme {
background-color: #ff6d00;
color: #fff;
}

#equals.dark-theme:hover,
#clear.dark-theme:hover {
background-color: #ff4500;
}
/* Add this CSS to move the buttons */
#back-to-welcome {
position: absolute;
top: 10px;
left: 10px;
font-size: 24px;
background-color: transparent;
border: none;
cursor: pointer;
z-index: 1;
}

#theme-toggle {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
background-color: transparent;
border: none;
cursor: pointer;
z-index: 1;
border-radius: 50%; /* Make it a circle */
padding: 10px; /* Increase padding for circle appearance */
}

/* Add tooltip styles for the new buttons */
#back-to-welcome.tooltip .tooltiptext,
#theme-toggle.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 150%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}

#back-to-welcome.tooltip:hover .tooltiptext,
#theme-toggle.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
69 changes: 69 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome</title>
<link rel="stylesheet" href="style.css">
<style>
/* Additional styles for a pleasing appearance */
body, html {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #f0f0f0;
margin: 0;
}

.welcome-container {
text-align: center;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
background-color: #fff;
animation: fadeIn 1s ease-in-out;
}

@keyframes fadeIn {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}

h1 {
color: #007bff;
font-size: 36px;
margin-bottom: 10px;
}

p {
color: #555;
font-size: 18px;
margin-bottom: 20px;
}

#welcome-button {
padding: 15px 30px;
font-size: 18px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

#welcome-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="welcome-container">
<h1>Welcome to the Calculator App</h1>
<p>This is a calculator application.</p>
<button id="welcome-button">Enter Calculator</button>
</div>
<script src="welcomePage.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');

let mainWindow;

function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
});

mainWindow.loadFile('index.html');

// Open the DevTools.
// mainWindow.webContents.openDevTools();

mainWindow.on('closed', function () {
mainWindow = null;
});
}

app.on('ready', createWindow);

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', function () {
if (mainWindow === null) {
createWindow();
}
});
Loading

0 comments on commit 68e9f61

Please sign in to comment.