Use Destructuring variables to avoid repetitions

- Easier to read and write
- Also fixes fullscreen when leaving the viewer, my bad
This commit is contained in:
2020-03-31 10:35:51 +02:00
parent 2dc51a167a
commit 5ac5d6803f
5 changed files with 46 additions and 42 deletions

View File

@@ -1,16 +1,19 @@
<script>
// Props
export let location
// Variables
const { name, slug, country } = location
</script>
<div class="location">
<a href="/location/{location.country.slug}/{location.slug}" rel="prefetch" sapper-noscroll>
<img src={location.country.flag.full_url} alt="Flag of {location.country.name}">
<a href="/location/{country.slug}/{slug}" rel="prefetch" sapper-noscroll>
<img src={country.flag.full_url} alt="Flag of {country.name}">
<div class="anim-mask mask-city">
<h3 class="location__city">{location.name}</h3>
<h3 class="location__city">{name}</h3>
</div>
<div class="anim-mask mask-country">
<p class="location__country style-caps">{location.country.name}</p>
<p class="location__country style-caps">{country.name}</p>
</div>
</a>
</div>