Skip to content

Commit b1bc8a6

Browse files
committed
feat(calculator): adding classes css
1 parent 53bca67 commit b1bc8a6

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

Temperature-convertor/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ <h1>Temperature convertor</h1>
1313
<form action="" method="post" id="form">
1414
<h2 >Type of conversion</h2>
1515
<div class="btn-section">
16-
<button type="button" onclick="getTypeTemperatureInput('Celsius');">Celsius</button>
17-
<button type="button" onclick="getTypeTemperatureInput('Fahrenheit');">Fahrenheit </button>
16+
<button type="button"
17+
class="Celsius"
18+
onclick="getTypeTemperatureInput('Celsius');">Celsius</button>
19+
<button
20+
class="Fahrenheit"
21+
type="button" onclick="getTypeTemperatureInput('Fahrenheit');">Fahrenheit </button>
1822
</div>
1923
<div class="input-section">
2024
<label for="response">Temperature</label>
2125
<input type="text" name="response" id="response" placeholder="12">
2226
</div>
23-
<button type="button" onclick="getSentenceResult();">Submit</button>
27+
<button id="btn-submit" type="button" onclick="getSentenceResult();">Submit</button>
2428
<section id="element_result" style="font-size: larger;">
2529

2630
</section>

Temperature-convertor/main.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
const res = document.getElementById('response');
44
const form = document.getElementById('form');
5-
5+
const celsiusBtn = document.querySelector('.Celsius');
6+
const fahrenheitBtn = document.querySelector('.Fahrenheit');
67
const element_result = document.getElementById('element_result');
78
let sentence = '';
89
let temperatureInput = '';
10+
911
function getTypeTemperatureInput(ipt){
12+
if(ipt === 'Celsius'){
13+
fahrenheitBtn.classList.remove('selected')
14+
celsiusBtn.classList.add('selected');
15+
}else{
16+
fahrenheitBtn.classList.add('selected');
17+
celsiusBtn.classList.remove('selected')
18+
}
1019
return temperatureInput = ipt;
1120
}
1221
function transformCelsiusToFahrenheit(degCel){
@@ -31,6 +40,6 @@ function getSentenceResult(){
3140
}
3241
const val = temperatureInput === 'Celsius' ? transformCelsiusToFahrenheit(value) : transformFahrenheitToCelsius(value);
3342
const labelTemperature = (temperatureInput === 'Celsius') ? ' Fahrenheit' : ' Celsius' ;
34-
return element_result.innerHTML = `<p>${value} ${temperatureInput} give ${parseInt(val)} ${labelTemperature}</p>`;
43+
return element_result.innerHTML = `<p class='response'>${value} ${temperatureInput} give ${parseInt(val)} ${labelTemperature}</p>`;
3544

3645
}

Temperature-convertor/style.css

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ button{
6969
min-height: 200px;
7070
display: flex;
7171
flex-direction: column;
72-
justify-content: space-between;
73-
height: 300px;
72+
justify-content: space-around;
73+
height: 400px;
7474
padding: 35px;
75-
7675
border: 1px solid rgba(255, 255, 255, .25);
7776
border-radius: 20px;
7877
background-color: rgba(255, 255, 255, 0.45);
@@ -81,8 +80,29 @@ button{
8180
.input-section{
8281
display: flex;
8382
flex-direction: column;
83+
margin: 10px 3px;
8484
}
8585
.input-section label{
8686
font-weight: bold;
8787
margin-bottom: 5px;
88+
}
89+
#btn-submit{
90+
width: 120px;
91+
text-align: center;
92+
margin: 10px auto;
93+
}
94+
.response{
95+
color: red;
96+
font-size: x-large;
97+
font-weight: 900;
98+
text-align: center;
99+
background-color: #dddddd;
100+
display: block;
101+
text-align: center;
102+
height: 50px; /* Exemple de hauteur fixe */
103+
line-height: 50px; /* La même que la hauteur */
104+
}
105+
button.selected {
106+
color: #3300ff;
107+
border-color: #3300ff;
88108
}

0 commit comments

Comments
 (0)