Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions Temperature convertor/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
body {
margin-top: 150px;
background-image: linear-gradient(to bottom right, lightseagreen, white);
}

.container {
margin: auto;
width: 500px;
padding-top: 10px;
background-color: white;
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.5);
height: 50px;
justify-content: space-between;
font-size: 29px;
text-align: center;
border-radius: 10px;
font-family: 'Libre Baskerville', serif;
margin-bottom: 20px;

}

span{

display: block;
width: 500px;
height: 40px;
border-radius: 10px;
border: 1px solid lightcyan;
background-color: lightcyan;
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.2);
padding-top: 15px;
align-items: center;
text-align: center;
cursor: pointer;
font-family: 'Libre Baskerville', serif;
margin: auto;
margin-top: 20px;
}
#tempCalc{
margin: auto;
width: 500px;
background-color: white;
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.5);
height: 250px;
justify-content: space-between;
font-size: 0px;
text-align: center;
border-radius: 10px;
padding-top: 10px;

}

.container h3 {
font-family: 'Aboreto', cursive;
width: 500px;
font-size: 10px;
}

label {
padding-top: 30px;
}
.hash{
position: relative;
display: inline-block;
font-size: 25px;
color: black;
}
input {
width: 450px;
height: 50px;
border-radius: 10px;
border: 1px solid lightcyan;
background-color: lightcyan;
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.2);
margin-top: 10px;
align-items: center;
text-align: center;
cursor: pointer;
margin-top: 20px;
font-family: 'Libre Baskerville', serif;
font-weight: bolder;
font-size: 15px;
}

select#temp_diff {
display: inline-block;
width: 130px;
min-height: 35px;
background:lightseagreen;
border-radius: 10px;
border: 2px solid lightseagreen;
margin-top: 0px;
text-align: center;
color: white;
font-size: 17px;
font-family: 'Libre Baskerville', serif;
cursor: pointer;


}
select#temp_diff:hover{
background-color:white;
color: black;

}



46 changes: 46 additions & 0 deletions Temperature convertor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temperature Convertor</title>
<link rel="stylesheet" href="index.css">

<!--heading font-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Aboreto&display=swap" rel="stylesheet">

<!--button font-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Libre+Baskerville&display=swap" rel="stylesheet">

</head>
<body>
<div class="container">Temperature Convertor</div>
<form id="tempCalc" onsubmit="calculateTemp(); return false">

<label for="temp">Enter Temperature</label>

<input id="temp" placeholder="Enter Temperature" type="number" name="temp">

<label class="hash">Select Temperature unit:
<select name="temp_diff" id="temp_diff">
<option value="cel">°Celsius</option>
<option value="Fah">℉ahrenheit</option>
</select>
</label>



<input type="submit" name="temp" value="Convert" id="submit">


</form>
<span id="resultContainer">
</span>

<script src="script.js"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions Temperature convertor/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const calculateTemp = () => {
const numberTemp = document.getElementById('temp').value;

const tempSelected= document.getElementById('temp_diff');

const valueTemp = temp_diff.options[tempSelected.selectedIndex].value;

const celToFah = (cel) =>{
let fahrenheit = Math.round((cel * 9 / 5) + 32);
return fahrenheit;
}
const FahTocel = (Fah) =>{
let celsius = Math.round((Fah -32) * 5/9);
return celsius;
}

let result;

if(valueTemp == 'cel'){
result = celToFah(numberTemp);
document.getElementById('resultContainer').innerHTML= `= ${result} ℉ahrenheit` ;}
else{
result = FahTocel(numberTemp);
document.getElementById('resultContainer').innerHTML= `= ${result} °Celsius` ;}
}