commit 16a89777bbdcaf7221fd44d535d28d5999050a3d61dd15b6ec6f9b2e18979d05 Author: William Cardoso Simas Date: Wed Nov 18 09:59:18 2026 -0300 first commit diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..4746f47 --- /dev/null +++ b/Readme.md @@ -0,0 +1,21 @@ +## Conversor de temperatura + +Projeto desenvolvido na imersão JavaScript da Alura, realizada entre os dias 13/11/2023 e 17/11/2023. Trata-se de um conversor de temperatura proposto como desafio no primeiro dia da imersão (13/11/2023), tendo como base o layout do conversor de moedas desenvolvido durante a aula. + +# Desafios +Os desafios foram atividades deixadas ao fim da aula para serem resolvidas. + + + +# Melhorias +As melhorias são itens incluídos no projeto e que não foram solicitados na proposta do desafio. + + diff --git a/calc.js b/calc.js new file mode 100644 index 0000000..b0c6e27 --- /dev/null +++ b/calc.js @@ -0,0 +1,72 @@ +document.getElementById("form").addEventListener('submit', (e) => { + converterValores(); + e.preventDefault(); +}); + +function converterValores() { + var retorno = ""; + + var tipoConversao = document.getElementById("tipoConversao"); + var nome = document.getElementById("nome").value; + var valor = document.getElementById("valor").value; + + if (nome == "") { + retorno = "Informe seu nome"; + } + else if (valor == "") { + retorno = "Informe um valor para converter"; + } + else if (isNaN(Number(valor))) { + retorno = "A temperatura deve ser um número"; + } + else { + var chave = tipoConversao.value; + valor = Number(valor); + + retorno = "Olá " + nome + '
' + if (chave == "C-F") { + retorno += valor.toFixed(2) + " ºC = " + celsiusParaFahrenheit(valor).toFixed(2) + " ºF
"; + } + else if (chave == "C-K") { + retorno += valor.toFixed(2) + " ºC = " + celsiusParaKelvin(valor).toFixed(2) + " K
"; + } + else if (chave == "F-C") { + retorno += valor.toFixed(2) + " ºF = " + fahrenheitParaCelsius(valor).toFixed(2) + " ºC
"; + } + else if (chave == "F-K") { + retorno += valor.toFixed(2) + " ºF = " + fahrenheitParaKelvin(valor).toFixed(2) + " K
"; + } + else if (chave == "K-C") { + retorno += valor.toFixed(2) + " K = " + kelvinParaCelsius(valor).toFixed(2) + " ºC
"; + } + else if (chave == "K-F") { + retorno += valor.toFixed(2) + " K = " + kelvinParaFahrenheit(valor).toFixed(2) + " ºF
"; + } + } + + document.getElementById("resultado").innerHTML = retorno; +} + +function celsiusParaKelvin(temperatura) { + return temperatura + 273.15; +} + +function fahrenheitParaCelsius(temperatura) { + return (temperatura - 32) * 5 / 9; +} + +function fahrenheitParaKelvin(temperatura) { + return ((temperatura - 32) * 5 / 9) + 273.15; +} + +function celsiusParaFahrenheit(temperatura) { + return (9 * temperatura / 5) + 32; +} + +function kelvinParaCelsius(temperatura) { + return temperatura - 273.15; +} + +function kelvinParaFahrenheit(temperatura) { + return ((temperatura - 273.15) * 9 / 5) + 32; +} \ No newline at end of file diff --git a/img/Background.jpg b/img/Background.jpg new file mode 100644 index 0000000..fd1c935 Binary files /dev/null and b/img/Background.jpg differ diff --git a/img/alura-logo.svg b/img/alura-logo.svg new file mode 100644 index 0000000..1c6fb30 --- /dev/null +++ b/img/alura-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/img/logo-imersao-aluraflix.svg b/img/logo-imersao-aluraflix.svg new file mode 100644 index 0000000..21821a0 --- /dev/null +++ b/img/logo-imersao-aluraflix.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/img/splash.png b/img/splash.png new file mode 100644 index 0000000..800ecb6 Binary files /dev/null and b/img/splash.png differ diff --git a/img/thermometer.png b/img/thermometer.png new file mode 100644 index 0000000..f3f6470 Binary files /dev/null and b/img/thermometer.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..a8dfc79 --- /dev/null +++ b/index.html @@ -0,0 +1,57 @@ + + + + + + + + + Conversor de temperatura + + + +
+
+
+

+ Conversor de temperatura +

+ +
+ + + + +
+ +
+
+ + + + + + + + + + +
+
+ +
+ + +
+ + + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..396f775 --- /dev/null +++ b/style.css @@ -0,0 +1,102 @@ +*{ + font-family: "Roboto Mono", monospace; + font-size: 16px; +} + +body { + text-align: center; + background-image: url("img/Background.jpg"); + background-color: #000000; + background-size: cover; + background-position: center top; + background-repeat: no-repeat; + /*height: 100vh;*/ +} + +.container { + text-align: center; + padding: 20px; +} + +.page-title { + color: #ffffff; + margin: 0 0 5px; +} + +.page-subtitle { + color: #ffffff; + margin-top: 5px; +} + +.page-logo { + width: 200px; +} + +.alura-logo { + width: 40px; + position: absolute; + top: 10px; + right: 10px; +} + +body>img { + margin: 0 10px; +} + +img { + max-height: 250px; +} + +form{ + margin-left: auto; + margin-right: auto; + display: flex; + flex-direction: column; + max-width: 400px; + text-align: center; + +} + +form label{ + color:white; + margin-top: 10px; +} + +form input{ + text-align: center; +} + +select{ + text-align: center; +} + +#resultado +{ + color: white; + margin-top: 10px; + margin-bottom: 25px; +} + +button +{ + margin-top: 10px; + padding: 10px; + border: 0; + border-radius: 5px; + background-color: greenyellow; + border-color: greenyellow; + box-shadow: none; + font-size: 16px; +} + +.pagina +{ + max-width: 50vw; + margin-left: auto; + margin-right: auto; + background-color: rgba(0, 0, 0, 0.8); + padding: 1vw; + border-radius: 10px; + margin-top: 3vh; + height: 90vh; +} \ No newline at end of file