Skip to content

Commit

Permalink
Added Freelance Rate Calculator (#1303)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahek0620 authored Jun 20, 2024
1 parent 4040fcb commit 95ad86c
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Calculators/Freelance-Rate-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# <p align="center">Freelance Rate Calculator</p>

## Description :-

The Freelance Rate Calculator is a tool that helps freelancers determine their optimal hourly or project-based rates based on various factors like desired annual income, billable hours per week, and vacation weeks per year.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/3064e1c5-5c81-4b82-ba1e-cdc880fe609a)
30 changes: 30 additions & 0 deletions Calculators/Freelance-Rate-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Freelance Rate Calculator</title>
</head>
<body>
<div class="container">
<h1>Freelance Rate Calculator</h1>
<form id="rateCalculator">
<label for="annual-salary">Desired Annual Salary ($):</label>
<input type="number" id="annual-salary" required>

<label for="billable-hours">Billable Hours per Week:</label>
<input type="number" id="billable-hours" required>

<label for="vacation-weeks">Vacation Weeks per Year:</label>
<input type="number" id="vacation-weeks" required>

<button type="submit">Calculate</button>
</form>
<div id="result">
<h2>Your Hourly Rate: $<span id="hourly-rate">0</span></h2>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions Calculators/Freelance-Rate-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
document.getElementById('rateCalculator').addEventListener('submit', function(event) {
event.preventDefault();

const annualSalary = parseFloat(document.getElementById('annual-salary').value);
const billableHours = parseFloat(document.getElementById('billable-hours').value);
const vacationWeeks = parseFloat(document.getElementById('vacation-weeks').value);

if (isNaN(annualSalary) || isNaN(billableHours) || isNaN(vacationWeeks)) {
alert('Please fill in all fields with valid numbers.');
return;
}

const weeksPerYear = 52;
const workingWeeks = weeksPerYear - vacationWeeks;
const totalBillableHours = workingWeeks * billableHours;

if (totalBillableHours <= 0) {
alert('Total billable hours must be greater than zero.');
return;
}

const hourlyRate = annualSalary / totalBillableHours;
document.getElementById('hourly-rate').textContent = hourlyRate.toFixed(2);
});
96 changes: 96 additions & 0 deletions Calculators/Freelance-Rate-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

.container {
background: white;
padding: 30px 20px;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
width: 350px;
position: relative;
z-index: 1;
text-align: center;
}

h1 {
font-size: 26px;
margin-bottom: 20px;
color: #333;
}

form {
display: flex;
flex-direction: column;
align-items: center;
}

label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}

input {
margin-bottom: 15px;
padding: 10px;
width: 100%;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
}

button:hover {
background-color: #0056b3;
}

#result {
margin-top: 20px;
}

#hourly-rate {
font-size: 24px;
color: #007bff;
}

/* Background Animation */
body::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, #ff6b6b, #f8e71c, #7ed321, #50e3c2, #4a90e2, #b8e986, #d0021b);
background-size: 400% 400%;
z-index: 0;
animation: gradientBackground 15s ease infinite;
}

@keyframes gradientBackground {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,20 @@ <h3>Calculates the time and final velocity of object in free fall.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Freelance Rate Calculator</h2>
<h3>Calculator to help freelancers determine optimal hourly or project rates based on various factors.</h3>
<div class="card-footer">
<a href="./Calculators/Freelance-Rate-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Freelance-Rate-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Fuel Cost Calculator</h2>
Expand Down

0 comments on commit 95ad86c

Please sign in to comment.