File tree Expand file tree Collapse file tree 3 files changed +41
-8
lines changed Expand file tree Collapse file tree 3 files changed +41
-8
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,18 @@ <h1>Temperature convertor</h1>
13
13
< form action ="" method ="post " id ="form ">
14
14
< h2 > Type of conversion</ h2 >
15
15
< 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 >
18
22
</ div >
19
23
< div class ="input-section ">
20
24
< label for ="response "> Temperature</ label >
21
25
< input type ="text " name ="response " id ="response " placeholder ="12 ">
22
26
</ div >
23
- < button type ="button " onclick ="getSentenceResult(); "> Submit</ button >
27
+ < button id =" btn-submit " type ="button " onclick ="getSentenceResult(); "> Submit</ button >
24
28
< section id ="element_result " style ="font-size: larger; ">
25
29
26
30
</ section >
Original file line number Diff line number Diff line change 2
2
3
3
const res = document . getElementById ( 'response' ) ;
4
4
const form = document . getElementById ( 'form' ) ;
5
-
5
+ const celsiusBtn = document . querySelector ( '.Celsius' ) ;
6
+ const fahrenheitBtn = document . querySelector ( '.Fahrenheit' ) ;
6
7
const element_result = document . getElementById ( 'element_result' ) ;
7
8
let sentence = '' ;
8
9
let temperatureInput = '' ;
10
+
9
11
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
+ }
10
19
return temperatureInput = ipt ;
11
20
}
12
21
function transformCelsiusToFahrenheit ( degCel ) {
@@ -31,6 +40,6 @@ function getSentenceResult(){
31
40
}
32
41
const val = temperatureInput === 'Celsius' ? transformCelsiusToFahrenheit ( value ) : transformFahrenheitToCelsius ( value ) ;
33
42
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>` ;
35
44
36
45
}
Original file line number Diff line number Diff line change @@ -69,10 +69,9 @@ button{
69
69
min-height : 200px ;
70
70
display : flex;
71
71
flex-direction : column;
72
- justify-content : space-between ;
73
- height : 300 px ;
72
+ justify-content : space-around ;
73
+ height : 400 px ;
74
74
padding : 35px ;
75
-
76
75
border : 1px solid rgba (255 , 255 , 255 , .25 );
77
76
border-radius : 20px ;
78
77
background-color : rgba (255 , 255 , 255 , 0.45 );
@@ -81,8 +80,29 @@ button{
81
80
.input-section {
82
81
display : flex;
83
82
flex-direction : column;
83
+ margin : 10px 3px ;
84
84
}
85
85
.input-section label {
86
86
font-weight : bold;
87
87
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 ;
88
108
}
You can’t perform that action at this time.
0 commit comments