From 899cf3612f5b95d6364127703ab665add13fd016 Mon Sep 17 00:00:00 2001 From: mhkeller Date: Sat, 15 Apr 2023 00:24:22 -0400 Subject: [PATCH] Create vertical layout --- package.json | 2 +- src/App.svelte | 33 +++--- src/SettingsModal.svelte | 2 +- src/components/CurrentDetails.svelte | 17 ++- src/components/DailyDetails.svelte | 34 ++++-- src/components/HourlyDetails.svelte | 135 +++++++++++++++------- src/components/scalars/Temperature.svelte | 7 +- src/providers/Provider.ts | 5 + 8 files changed, 161 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index f7d5863..77b3490 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "vite build", "preview": "vite preview", "format": "prettier --write --plugin-search-dir . .", diff --git a/src/App.svelte b/src/App.svelte index 0d52a01..9267628 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -110,9 +110,10 @@
{#if weather} - + {@const { sunset_timestamp, sunrise_timestamp } = weather.daily[0]} +
- +
- {#each weather.daily as daily} - - - d.temperature_low))} - global_high={Math.max(...weather.daily.map((d) => d.temperature_high))} - /> - - - - + {#each weather.daily as daily, i} + {#if ($configuration.layout === 'vertical' && i) > 0 || $configuration.layout === 'horizontal'} + + + d.temperature_low))} + global_high={Math.max(...weather.daily.map((d) => d.temperature_high))} + /> + + + + + {/if} {/each} {:else if error} diff --git a/src/SettingsModal.svelte b/src/SettingsModal.svelte index 954e385..0bf6b87 100644 --- a/src/SettingsModal.svelte +++ b/src/SettingsModal.svelte @@ -173,7 +173,7 @@ id="select-layout" items={[ { name: 'Horizontal', value: 'horizontal' }, - { name: 'Vertical', value: 'vertial' }, + { name: 'Vertical', value: 'vertical' }, ]} bind:value={layout} /> diff --git a/src/components/CurrentDetails.svelte b/src/components/CurrentDetails.svelte index 1278572..a56e65c 100644 --- a/src/components/CurrentDetails.svelte +++ b/src/components/CurrentDetails.svelte @@ -1,5 +1,7 @@
@@ -23,7 +27,7 @@
-
+
Wind:
Humidity:
Dew Point:
@@ -34,4 +38,13 @@
Visibility:
{/if}
Pressure:
+
+ + Sunrise: +
+
+ + Sunset: +
+
diff --git a/src/components/DailyDetails.svelte b/src/components/DailyDetails.svelte index fd9eb5d..6dffeac 100644 --- a/src/components/DailyDetails.svelte +++ b/src/components/DailyDetails.svelte @@ -14,22 +14,32 @@
-
-
- - - - -
- {#if daily.precipitation_probability !== undefined} +
+ {#if daily.precipitation_probability !== undefined && daily.precipitation_amount !== undefined}
Precipitation: {daily.precipitation_probability}%
- {/if} - {#if daily.precipitation_amount !== undefined}
- Precipitation: - + Amount: +
+ {:else if daily.precipitation_probability !== undefined} +
+ Precipitation: {daily.precipitation_probability}% +
+ {:else if daily.precipitation_amount !== undefined} +
+ Precipitation:
{/if}
+ +
+
+ + Sunrise: +
+
+ + Sunset: +
+
diff --git a/src/components/HourlyDetails.svelte b/src/components/HourlyDetails.svelte index 5be2173..dda1b2b 100644 --- a/src/components/HourlyDetails.svelte +++ b/src/components/HourlyDetails.svelte @@ -1,6 +1,7 @@ -
- {#each aggregation as entry} -
- {#if entry.duration > 4} -
{CLASS_TEXT_MAP[entry.conditions][1]}
- {:else if entry.duration > 2} - - {/if} -
- {/each} -
-
- {#each Array(25) as _, i} -
- {/each} -
-
-
- +{#if $configuration.layout === 'horizontal'} +
+ {#each aggregation as entry} +
+ {#if entry.duration > 4} +
{CLASS_TEXT_MAP[entry.conditions][1]}
+ {:else if entry.duration > 2} + + {/if} +
+ {/each} +
+
+ {#each Array(25) as _, i} +
+ {/each}
- {#each Array(11) as _, i} - {@const timestamp = hourly[2 * (i + 1)].timestamp} -
-
- +
+
+
- {/each} -
-
-
-
-