Skip to content

Commit

Permalink
fix settings button
Browse files Browse the repository at this point in the history
  • Loading branch information
istudyatuni committed Oct 11, 2023
1 parent 770e600 commit df6c12c
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,31 @@
const defaultData = {
name: 'city',
}
const settingsToggleRoutes = [
{
from: '/',
to: '/settings',
},
{
from: '/settings',
to: '/',
},
]
</script>

<script>
$: data = $weather?.current?.content || defaultData
// hack
// it works, but have strange behaviour:
//
// <a href="/" /> will open <Route path="/settings" />
// and vice versa
let settingsNotOpened = true
</script>
<div class="grid-item">
<div class="inline">
<h4 class="city">{data.name}</h4>
<div class="inline">
{#each settingsToggleRoutes as { from, to }}
<Route path={from}>
<a href={to} class="settings" alt="settings toggle">
<SettingsIcon />
</a>
</Route>
{/each}
<a
href={settingsNotOpened ? '/' : '/settings'}
class="settings"
alt="settings toggle"
on:click={() => (settingsNotOpened = !settingsNotOpened)}>
<SettingsIcon />
</a>
<a
href="https://github.com/istudyatuni/weather-site"
Expand Down

0 comments on commit df6c12c

Please sign in to comment.