File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff line change 22
33const res = document . getElementById ( 'response' ) ;
44const form = document . getElementById ( 'form' ) ;
5-
5+ const celsiusBtn = document . querySelector ( '.Celsius' ) ;
6+ const fahrenheitBtn = document . querySelector ( '.Fahrenheit' ) ;
67const element_result = document . getElementById ( 'element_result' ) ;
78let sentence = '' ;
89let temperatureInput = '' ;
10+
911function 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}
1221function 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}
Original file line number Diff line number Diff 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 : 300 px ;
72+ justify-content : space-around ;
73+ height : 400 px ;
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}
You can’t perform that action at this time.
0 commit comments