-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
151 additions
and
131 deletions.
There are no files selected for viewing
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,36 +1,29 @@ | ||
<script> | ||
import { | ||
getIcon, | ||
convertKelvinToFahrenheit, | ||
} from "./utils.svelte"; | ||
import { formatDistanceToNow, lightFormat } from "date-fns"; | ||
import { lightFormat } from 'date-fns'; | ||
/** | ||
* @type {CurrentWeather} | ||
*/ | ||
export let current; | ||
const { feels_like: temp, dt: timestamp, weather, humidity } = current; | ||
/** | ||
* @type {current} | ||
*/ | ||
export let current; | ||
const { feels_like, dt: timestamp, weather, humidity, wind_speed } = current; | ||
const { icon, id } = weather[0]; | ||
const { icon, id } = weather[0]; | ||
const timeOfDay = icon.endsWith("n") ? "night" : "day"; | ||
const timeOfDay = icon.endsWith('n') ? 'night' : 'day'; | ||
const myTemp = `${convertKelvinToFahrenheit(temp)} \xB0F`; | ||
const myTemp = `${Math.round(feels_like)} \xB0F`; | ||
const imgSrc = getIcon(icon); | ||
const date = new Date(); | ||
const formattedTime = lightFormat(timestamp * 1000, "h:mm aaa"); | ||
const formattedTime = lightFormat(timestamp * 1000, 'h:mm aaa'); | ||
</script> | ||
|
||
<!-- <WeatherDisplay temp={temp} timestamp={timestamp} icon={icon} /> --> | ||
<div> | ||
<!-- <img src={imgSrc} alt="" style="vertical-align: middle; width: 100px; height: 100px;" /> --> | ||
<span class={`wi wi-owm-${timeOfDay}-${id}`} style="font-size: 48px;" /> | ||
<span style="font-size: 48px; margin-right: 1em;">{myTemp}</span> | ||
<p style="display: inline-block;"> | ||
{formattedTime} | ||
<span class={`wi wi-owm-${timeOfDay}-${id}`} style="font-size: 48px;" /> | ||
<span style="font-size: 48px; margin-inline-end: 1em;">{myTemp}</span> | ||
<p style="display: inline-block;"> | ||
{formattedTime} | ||
<br /> | ||
Humidity: {humidity}% | ||
<br /> | ||
Humidity: {humidity}% | ||
</p> | ||
Wind: {Math.round(wind_speed)}mph | ||
</p> | ||
</div> |
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,48 +1,32 @@ | ||
<script> | ||
import { format } from "date-fns"; | ||
import { | ||
getIcon, | ||
convertKelvinToFahrenheit, | ||
} from "./utils.svelte"; | ||
import { format } from 'date-fns'; | ||
/** | ||
* @type {WeatherData} | ||
*/ | ||
export let weatherDataInstance; | ||
// export let temp, timestamp, icon; | ||
/** | ||
* @type {daily} | ||
*/ | ||
export let weatherDataInstance; | ||
const { | ||
dt: timestamp, | ||
temp, | ||
feels_like, | ||
weather, | ||
humidity, | ||
rain, | ||
pop, | ||
} = weatherDataInstance; | ||
const { dt: timestamp, feels_like, weather, humidity, pop, wind_speed } = weatherDataInstance; | ||
const { icon, id } = weather[0]; | ||
const { icon, id } = weather[0]; | ||
const timeOfDay = icon.endsWith("n") ? "night" : "day"; | ||
const timeOfDay = icon.endsWith('n') ? 'night' : 'day'; | ||
const { day: day_feels_like } = feels_like; | ||
const { day: day_feels_like } = feels_like; | ||
// const { main: { feels_like }, weather } = data; | ||
// return JSON.stringify(json); | ||
const myTemp = `${convertKelvinToFahrenheit(day_feels_like)} \xB0F`; | ||
const imgSrc = getIcon(icon); | ||
const myTemp = `${Math.round(day_feels_like)} \xB0F`; | ||
</script> | ||
|
||
<div> | ||
<!-- <img src={imgSrc} alt="" style="vertical-align: middle; width: 100px; height: 100px;" /> --> | ||
<span class={`wi wi-owm-${timeOfDay}-${id}`} style="font-size: 48px;" /> | ||
<span style="font-size: 24px;">{myTemp}</span> | ||
<p> | ||
{format(new Date(timestamp * 1000), 'EEEE')} | ||
<br /> | ||
Humidity: {humidity}% | ||
<br /> | ||
Chance of Rain: {pop * 100}% | ||
</p> | ||
<span class={`wi wi-owm-${timeOfDay}-${id}`} style="font-size: 48px;" /> | ||
<span style="font-size: 24px;">{myTemp}</span> | ||
<p> | ||
{format(new Date(timestamp * 1000), 'EEEE')} | ||
<br /> | ||
Humidity: {humidity}% | ||
<br /> | ||
Chance of Rain: {pop * 100}% | ||
<br /> | ||
Wind: {Math.round(wind_speed)}mph | ||
</p> | ||
</div> |
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
18 changes: 7 additions & 11 deletions
18
src/lib/WeatherDisplay.svelte → src/lib/HourlyWeather.svelte
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,42 +1,38 @@ | ||
<script> | ||
import { formatDistanceToNow } from "date-fns"; | ||
import { | ||
getIcon, | ||
convertKelvinToFahrenheit, | ||
} from "./utils.svelte"; | ||
/** | ||
* @type {WeatherData} | ||
* @type {hourly} | ||
*/ | ||
export let weatherDataInstance; | ||
const { | ||
dt: timestamp, | ||
temp, | ||
feels_like, | ||
weather, | ||
humidity, | ||
pop, | ||
wind_speed | ||
} = weatherDataInstance; | ||
const { icon, id } = weather[0]; | ||
const timeOfDay = icon.endsWith("n") ? "night" : "day"; | ||
const myTemp = `${convertKelvinToFahrenheit(feels_like)} \xB0F`; | ||
const temperature = `${Math.round(feels_like)} \xB0F`; | ||
const imgSrc = getIcon(icon); | ||
</script> | ||
|
||
<div> | ||
<!-- <img src={imgSrc} alt="" style="vertical-align: middle; width: 100px; height: 100px;" /> --> | ||
<span class={`wi wi-owm-${timeOfDay}-${id}`} style="font-size: 48px;" /> | ||
<span style="font-size: 32px;">{myTemp}</span> | ||
<span style="font-size: 32px;">{temperature}</span> | ||
<p> | ||
{formatDistanceToNow(new Date(timestamp * 1000), { addSuffix: true })} | ||
<br /> | ||
Humidity: {humidity}% | ||
<br /> | ||
Chance of Rain: {pop * 100}% | ||
<br /> | ||
Wind: {Math.round(wind_speed)}mph | ||
</p> | ||
</div> |
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.