Update icon on Select when changing country on Photos

This commit is contained in:
2021-10-05 23:39:39 +02:00
parent 4a793b49af
commit d0fedfcc80
2 changed files with 20 additions and 5 deletions

View File

@@ -24,8 +24,18 @@
const defaultCountry = 'all'
const defaultSort = 'latest'
let filtered: boolean = false
let filterCountry = defaultCountry
let filterSort = defaultSort
let filterCountry: any = defaultCountry
let filterSort: string = defaultSort
let countryFlagId: string
// Define country flag from selection
$: {
if (filterCountry !== defaultCountry) {
countryFlagId = countries.find((country: any) => country.slug === filterCountry).flag.id
} else {
countryFlagId = undefined
}
}
/**
@@ -90,7 +100,11 @@
on:change={handleCountryChange}
value={filterCountry}
>
<IconEarth class="icon" />
{#if countryFlagId}
<Image id={countryFlagId} width={26} height={26} alt="{filterCountry} flag" class="icon" />
{:else}
<IconEarth class="icon" />
{/if}
</Select>
</li>
<li>