Skip to content

Commit 1a7775c

Browse files
authored
Merge pull request #1 from iamfaizall20/byFaizal
Add new Mini Project "Temperature Converter"
2 parents 75b7f59 + edd2ce1 commit 1a7775c

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

30 - Temperature Converter/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Temperature Converter | WebDev Journey</title>
8+
<link rel="stylesheet" href="style.css">
9+
</head>
10+
11+
<body>
12+
<div class="container">
13+
<h1>Temperature Converter</h1>
14+
<div class="inputFields">
15+
<input type="text" placeholder="Enter Degree" id="degreeInput">
16+
<select name="Scale" id="ScaleInput">
17+
<option value="Fehrenheit" selected>Fehrenheit</option>
18+
<option value="Celcius">Celcius</option>
19+
</select>
20+
</div>
21+
<button onclick="Convert()">Convert</button>
22+
<h2 class="showTemperature"></h2>
23+
</div>
24+
25+
<script src="script.js"></script>
26+
</body>
27+
28+
</html>

30 - Temperature Converter/script.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function Convert() {
2+
3+
let degreeInput = document.getElementById('degreeInput').value;
4+
let scaleInput = document.getElementById('ScaleInput').value;
5+
6+
if (degreeInput === '') {
7+
return
8+
}
9+
10+
degreeInput = parseFloat(degreeInput);
11+
12+
if (scaleInput.toLowerCase() === 'fehrenheit') {
13+
let fehrenheit = (degreeInput * (9 / 5) + 32);
14+
document.querySelector('.showTemperature').textContent = `${fehrenheit.toFixed(1)}\u00B0F`;
15+
} else {
16+
let celsuis = (degreeInput - 32) * (5 / 9);
17+
document.querySelector('.showTemperature').textContent = `${celsuis.toFixed(1)}\u00B0C`;
18+
}
19+
document.getElementById('degreeInput').value = '';
20+
}

30 - Temperature Converter/style.css

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Special+Gothic+Expanded+One&display=swap');
2+
3+
*{
4+
margin: 0;
5+
padding: 0;
6+
box-sizing: border-box;
7+
font-family: 'Poppins';
8+
}
9+
body{
10+
min-height: 100svh;
11+
display: grid;
12+
place-items: center;
13+
background: #143D60;
14+
}
15+
.container{
16+
display: flex;
17+
flex-direction: column;
18+
background: #F1F0E9;
19+
padding: 20px;
20+
width: 370px;
21+
border-radius: 5px;
22+
}
23+
.container h1{
24+
font-size: 22px;
25+
margin-bottom: 20px;
26+
}
27+
.container .inputFields{
28+
margin-bottom: 15px;
29+
display: flex;
30+
justify-content: space-between;
31+
}
32+
.container input{
33+
border: 1px solid #ccc;
34+
background: none;
35+
outline: none;
36+
font-size: 15px;
37+
padding: 3px 10px;
38+
}
39+
.container select {
40+
padding: 3px 30px 3px 10px;
41+
font-size: 15px;
42+
appearance: none;
43+
background: url('data:image/svg+xml;utf8,<svg fill="black" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>') no-repeat right 6px center;
44+
border: 1px solid #ccc;
45+
cursor: pointer;
46+
}
47+
.container button{
48+
padding: 5px;
49+
font-size: 15.5px;
50+
border: none;
51+
outline: none;
52+
background: #255F38;
53+
color: white;
54+
font-weight: 450;
55+
cursor: pointer;
56+
margin-bottom: 20px;
57+
}
58+
.container h2{
59+
font-size: 23px;
60+
font-family: 'Cascadia mono';
61+
}
62+
@media (max-width:750px){
63+
.container{
64+
width: 350px;
65+
}
66+
.container input{
67+
width: 185px;
68+
}
69+
.container select{
70+
width: 120px;
71+
padding: 3px 25px 3px 10px;
72+
}
73+
}

0 commit comments

Comments
 (0)