-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f1c46a
commit f62f88b
Showing
21 changed files
with
1,112 additions
and
672 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,103 @@ | ||
import DisplayWeather from '@/components/wx-client/DisplayWeather' | ||
'use client' | ||
|
||
export const runtime = 'edge' | ||
import {useWeatherContext} from '@/components/wx-client/WeatherProvider' | ||
import { | ||
formatDate, | ||
formatDistance, | ||
formatSpeed, | ||
formatTemp, | ||
getTempColor | ||
} from '@/lib/functions' | ||
|
||
/** | ||
* The weather (client) homepage. | ||
*/ | ||
export default async function WxClientHome() { | ||
return <DisplayWeather /> | ||
export default function WxClientHome() { | ||
// Get the unit and forecast from the weather context. | ||
const {unit, weather} = useWeatherContext() | ||
|
||
// If there is no weather data, return null. | ||
if (!weather.location) { | ||
return null | ||
} | ||
|
||
// Desctructure the weather object. | ||
const {current, forecast, location} = weather | ||
const {forecastday} = forecast | ||
const {name, region, localtime_epoch, tz_id} = location | ||
const { | ||
temp_f, | ||
condition: {text}, | ||
wind_mph, | ||
wind_dir, | ||
pressure_in, | ||
humidity, | ||
feelslike_f, | ||
vis_miles, | ||
uv | ||
} = current | ||
return ( | ||
<section | ||
className="weather not-prose" | ||
style={ | ||
{ | ||
'--angle': '0deg', | ||
'--minTemp': getTempColor(forecastday[0]?.day?.mintemp_f), | ||
'--maxTemp': getTempColor(forecastday[0]?.day?.maxtemp_f), | ||
'--currentTemp': getTempColor(temp_f), | ||
'--feelsLikeTemp': getTempColor(feelslike_f) | ||
} as React.CSSProperties | ||
} | ||
> | ||
<h1>Current Conditions</h1> | ||
<time className="time">{formatDate(localtime_epoch, tz_id)}</time> | ||
|
||
<div className="row"> | ||
<div className="column"> | ||
<div className="temp-box"> | ||
<div className="temp-range"> | ||
<span>{formatTemp(forecastday[0]?.day?.mintemp_f, unit)}</span>- | ||
<span>{formatTemp(forecastday[0]?.day?.maxtemp_f, unit)}</span> | ||
</div> | ||
<span className="current-temp">{formatTemp(temp_f, unit)}</span> | ||
<span>Feels Like {formatTemp(feelslike_f, unit)}</span> | ||
</div> | ||
</div> | ||
|
||
<div className="column"> | ||
<div className="weather-table"> | ||
<div className="column" style={{textAlign: 'right'}}> | ||
<p>Location</p> | ||
<p>Sky</p> | ||
<p>Wind</p> | ||
<p>Pressure</p> | ||
<p>Humidity</p> | ||
<p>Visibility</p> | ||
<p>UV Index</p> | ||
<p>Sunrise</p> | ||
<p>Sunset</p> | ||
<p>Moon Phase</p> | ||
</div> | ||
|
||
<div className="column"> | ||
<p> | ||
{name}, {region} | ||
</p> | ||
<p>{text}</p> | ||
<p> | ||
{formatSpeed(wind_mph, unit)} {wind_dir} | ||
</p> | ||
<p>{pressure_in} inHg</p> | ||
<p>{humidity}%</p> | ||
<p>{formatDistance(vis_miles, unit)}</p> | ||
<p>{uv}</p> | ||
<p>{forecastday[0]?.astro?.sunrise}</p> | ||
<p>{forecastday[0]?.astro?.sunset}</p> | ||
<p>{forecastday[0]?.astro?.moon_phase}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import DisplayWeather from '@/components/wx-server/DisplayWeather' | ||
import {getForecast} from '@/lib/functions' | ||
import {getForecast} from '@/lib/queries' | ||
import {notFound} from 'next/navigation' | ||
|
||
export const runtime = 'edge' | ||
|
||
/** | ||
* The weather (server) homepage. | ||
* | ||
* @see https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts | ||
*/ | ||
export default async function WxServerHome() { | ||
// Get the weather forecast. | ||
const {weather} = await getForecast('Enterprise, AL') | ||
const data = await getForecast('Enterprise, AL') | ||
|
||
// No forecast? Bail... | ||
if (!weather) { | ||
if (!data) { | ||
notFound() | ||
} | ||
|
||
return <DisplayWeather weather={weather} /> | ||
return <DisplayWeather weather={data} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.