-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Digital Detox Calculator (#1229)
- Loading branch information
1 parent
cf844fa
commit f601e93
Showing
7 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# <p align="center">Digital Detox Calculator</p> | ||
|
||
## Description :- | ||
|
||
Calculates the amount of time we spend on digital devices and suggests a plan for a balanced digital detox. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/40f2d1e3-9598-4f9f-9ff3-1e20fb30b7e4) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!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>Digital Detox Calculator</title> | ||
</head> | ||
<body> | ||
<div class="main-container"> | ||
<img src="assets/left-image.jpg" alt="Left Image" class="side-image"> | ||
<div class="container"> | ||
<h1>Digital Detox Calculator</h1> | ||
<form id="detoxForm"> | ||
<div class="form-group"> | ||
<label for="hoursSpent">Hours spent on devices daily:</label> | ||
<input type="number" id="hoursSpent" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="daysPerWeek">Days per week:</label> | ||
<input type="number" id="daysPerWeek" required> | ||
</div> | ||
<button type="button" onclick="calculateDetox()">Calculate</button> | ||
</form> | ||
<div id="result"></div> | ||
</div> | ||
<img src="assets/right-image.jpg" alt="Right Image" class="side-image"> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function calculateDetox() { | ||
const hoursSpent = parseFloat(document.getElementById('hoursSpent').value); | ||
const daysPerWeek = parseFloat(document.getElementById('daysPerWeek').value); | ||
const resultDiv = document.getElementById('result'); | ||
|
||
if (isNaN(hoursSpent) || isNaN(daysPerWeek) || hoursSpent <= 0 || daysPerWeek <= 0) { | ||
resultDiv.innerHTML = "<p>Please enter valid inputs.</p>"; | ||
return; | ||
} | ||
|
||
const weeklyUsage = hoursSpent * daysPerWeek; | ||
const monthlyUsage = weeklyUsage * 4; | ||
const yearlyUsage = weeklyUsage * 52; | ||
|
||
const detoxRecommendation = hoursSpent > 5 ? "Consider reducing your daily screen time gradually." : | ||
hoursSpent > 3 ? "Your screen time is moderate, but it's good to take regular breaks." : | ||
"Your screen time is within healthy limits."; | ||
|
||
resultDiv.innerHTML = ` | ||
<p><strong>Weekly Device Usage:</strong> ${weeklyUsage.toFixed(2)} hours</p> | ||
<p><strong>Monthly Device Usage:</strong> ${monthlyUsage.toFixed(2)} hours</p> | ||
<p><strong>Yearly Device Usage:</strong> ${yearlyUsage.toFixed(2)} hours</p> | ||
<p>${detoxRecommendation}</p> | ||
`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
body { | ||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
background: linear-gradient(to right, #246d8a, #cc65cf); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.main-container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 90%; | ||
height: 90%; | ||
} | ||
|
||
.side-image { | ||
flex: 1; | ||
max-width: 25%; | ||
height: 100%; | ||
object-fit: cover; | ||
margin: 0 60px; | ||
border-radius: 4%; | ||
transition: transform 0.3s ease, filter 0.3s ease; | ||
} | ||
|
||
.side-image:hover{ | ||
transform: scale(1.05); | ||
filter: brightness(1.1); | ||
} | ||
.container { | ||
background-color: #ffffff; | ||
padding: 25px 30px; | ||
border-radius: 10px; | ||
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1); | ||
width: 60%; | ||
max-width: 450px; | ||
text-align: center; | ||
z-index: 1; | ||
} | ||
|
||
h1 { | ||
font-size: 28px; | ||
margin-bottom: 25px; | ||
color: #00796b; | ||
} | ||
|
||
.form-group { | ||
margin-bottom: 20px; | ||
text-align: left; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 8px; | ||
font-weight: bold; | ||
color: #004d40; | ||
} | ||
|
||
input { | ||
width: calc(100% - 20px); | ||
padding: 10px; | ||
border: 1px solid #b0bec5; | ||
border-radius: 5px; | ||
outline: none; | ||
font-size: 16px; | ||
} | ||
|
||
input:focus { | ||
border-color: #4db6ac; | ||
} | ||
|
||
button { | ||
background-color: #00796b; | ||
color: white; | ||
padding: 10px 25px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
button:hover { | ||
background-color: #004d40; | ||
} | ||
|
||
#result { | ||
margin-top: 25px; | ||
font-size: 18px; | ||
color: #004d40; | ||
line-height: 1.5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters