Skip to content

Commit

Permalink
Refactor HTML structure and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
chandler767 committed Oct 29, 2024
1 parent 4b34778 commit 283c938
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 109 deletions.
110 changes: 41 additions & 69 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">

<link rel="manifest" href="site.webmanifest">

<title>Snowmaking Weather Dashboard</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>
<div id="app">
<header>
<img src="https://backyardsnowstorm.com/wp-content/uploads/2022/03/BYSS-Logo-V5-e1687370884510.png" alt="BYSS Logo" style="max-width: 100%;">
<a href="https://backyardsnowstorm.com/" target="_blank">
<img src="https://backyardsnowstorm.com/wp-content/uploads/2022/03/BYSS-Logo-V5-e1687370884510.png"
alt="BYSS Logo" style="max-width: 100%;">
</a>
<h1>Snowmaking Weather Dashboard</h1>
<div class="location-input">
<input type="text" id="locationInput" placeholder="Enter location or use GPS">
Expand All @@ -27,77 +32,44 @@ <h1>Snowmaking Weather Dashboard</h1>
</label>
</div>
</header>

<main>
<section id="loadingData" class="card">
<h2>Loading weather data...</h2>
</section>
<section id="loadingData" class="card">
<h2>Loading weather data...</h2>
</section>
<section id="currentConditions" class="card" hidden>
<h2>Current Conditions</h2>
<p>Temperature: <span id="temp"></span></p>
<p>Humidity: <span id="humidity"></span></p>
<p>Wet Bulb: <span id="wetBulb"></span></p>
<p id="snowQuality">Snow Quality: <span id="quality"></span></p>
</section>
<div class="view-switch" id="viewSwitch" hidden>
<div class="tabs">
<button id="dayForecastBtn" class="tab active">7-Day Forecast</button>
<button id="hourForecastBtn" class="tab">12-Hour Forecast</button>
</div>
</div>

<style>
.view-switch {
text-align: center;
margin-top: 20px;
}

.tabs {
display: inline-block;
border: 1px solid #ccc;
border-radius: 5px;
overflow: hidden;
}

.tab {
background-color: #f1f1f1;
border: none;
padding: 10px 20px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}

.tab:hover {
background-color: #ddd;
}

.tab.active {
background-color: #007bff;
color: white;
}

.tab:not(:last-child) {
border-right: 1px solid #ccc;
}
</style>

<section id="hourforecast" class="card" hidden>
<h2>12-Hour Snowmaking Forecast</h2>
<div id="12forecastContainer">
<!-- Forecast hours will be injected here by JavaScript -->
</div>
</section>
<h2>Current Conditions</h2>
<p>Temperature: <span id="temp"></span></p>
<p>Humidity: <span id="humidity"></span></p>
<p>Wet Bulb: <span id="wetBulb"></span></p>
<p id="snowQuality">Snow Quality: <span id="quality"></span></p>
</section>
<div class="view-switch" id="viewSwitch" hidden>
<div class="tabs">
<button id="dayForecastBtn" class="tab active">7-Day Forecast</button>
<button id="hourForecastBtn" class="tab">12-Hour Forecast</button>
</div>
</div>

<section id="forecast" class="card" hidden>
<h2>7-Day Snowmaking Forecast</h2>
<div id="forecastContainer">
<!-- Forecast days will be injected here by JavaScript -->
</div>
</section>
<section id="hourforecast" class="card" hidden>
<h2>12-Hour Snowmaking Forecast</h2>
<div id="12forecastContainer">
<!-- Forecast hours will be injected here by JavaScript -->
</div>
</section>
<section id="forecast" class="card" hidden>
<h2>7-Day Snowmaking Forecast</h2>
<div id="forecastContainer">
<!-- Forecast days will be injected here by JavaScript -->
</div>
</section>
<footer id="footer" hidden>
<p>V1.0 for the 2024/25 season | Made with ❤️ by <a href="http://chandlermayo.com" target="_blank">Chandler Mayo</a></p>
</footer>
</main>
</div>
<div id="snowflakeContainer"></div> <!-- Container for snowflakes -->
<div id="snowflakeContainer"></div> <!-- Container for snowflakes -->
<script src="script.js"></script>
</body>
</html>

</html>
3 changes: 2 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function switchForecastView(view) {
async function fetchWeatherData(lat, lon) {
try {
const response = await fetch(`${OPEN_METEO_BASE_URL}?latitude=${lat}&longitude=${lon}&hourly=temperature_2m,relative_humidity_2m&daily=temperature_2m_max,temperature_2m_min,relative_humidity_2m_min,relative_humidity_2m_max&temperature_unit=${isCelsius ? 'celsius' : 'fahrenheit'}&timezone=auto`);

if (!response.ok) throw new Error(`Weather data fetch failed: ${response.status}`);

const data = await response.json();
Expand All @@ -80,6 +80,7 @@ async function fetchWeatherData(lat, lon) {
document.getElementById('currentConditions').style.display = 'block';
document.getElementById('forecast').style.display = 'block';
document.getElementById('viewSwitch').style.display = 'block';
document.getElementById('footer').style.display = 'block';
document.getElementById('hourForecastBtn').classList.remove('active');
document.getElementById('dayForecastBtn').classList.add('active');
document.getElementById('hourforecast').style.display = 'none';
Expand Down
Loading

0 comments on commit 283c938

Please sign in to comment.