Skip to content

Commit

Permalink
improved locale selector tray
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Sep 25, 2024
1 parent f9dd422 commit 7fa2d24
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
36 changes: 20 additions & 16 deletions addon/components/locale-selector-tray.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@
</dd.Trigger>
<dd.Content class="{{@contentClass}} locale-selector-tray-content {{if (media 'isMobile') 'is-mobile'}}">
<div class="next-dd-menu {{@dropdownMenuClass}} {{if dd.isOpen 'is-open'}}">
{{#each-in this.availableLocales as |key country|}}
<div class="px-1">
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.changeLocale key)}}>
<div class="flex flex-row items-center justify-between w-full">
<div class="flex-1">
<span class="mr-1">{{country.emoji}}</span>
<span>{{country.language}}</span>
</div>
{{#if (eq this.currentLocale key)}}
<div>
<FaIcon @icon="check" class="text-green-400" />
{{#if this.loadAvailableCountries.isRunning}}
<Spinner />
{{else}}
{{#each-in this.availableLocales as |key country|}}
<div class="px-1">
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.changeLocale key)}}>
<div class="flex flex-row items-center justify-between w-full">
<div class="flex-1">
<span class="mr-1">{{country.emoji}}</span>
<span>{{country.language}}</span>
</div>
{{/if}}
</div>
</a>
</div>
{{/each-in}}
{{#if (eq this.currentLocale key)}}
<div>
<FaIcon @icon="check" class="text-green-400" />
</div>
{{/if}}
</div>
</a>
</div>
{{/each-in}}
{{/if}}
</div>
</dd.Content>
</BasicDropdown>
Expand Down
6 changes: 5 additions & 1 deletion addon/components/locale-selector-tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export default class LocaleSelectorTrayComponent extends Component {
* @generator
*/
@task *loadAvailableCountries() {
this.countries = yield this.fetch.get('lookup/countries', { columns: ['name', 'cca2', 'flag', 'emoji', 'languages'] });
this.countries = yield this.fetch.get(
'lookup/countries',
{ columns: ['name', 'cca2', 'flag', 'emoji', 'languages'] },
{ fromCache: true, expirationInterval: 1, expirationIntervalUnit: 'week' }
);
this.availableLocales = this._createAvailableLocaleMap();
}

Expand Down

0 comments on commit 7fa2d24

Please sign in to comment.