Skip to content

Commit

Permalink
fix: fix my git,Idk what's going on
Browse files Browse the repository at this point in the history
  • Loading branch information
Buffett111 committed Feb 13, 2025
1 parent 6748bc2 commit 790a492
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 733 deletions.
26 changes: 20 additions & 6 deletions src/lib/components/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
return () => clearInterval(interval);
});
function toggleLanguage() {
language.update((value) => (value === 'en' ? 'zh' : 'en'));
console.log('Language:', $language);
function setLanguage(lang: 'en' | 'zh') {
language.set(lang);
}
</script>

Expand All @@ -56,9 +55,6 @@
</span>
</NavBrand>
<div class="ml-auto flex items-center">
<Button on:click={toggleLanguage} class="mr-2">
{$language === 'en' ? 'English' : '中文'}
</Button>
{#if $user}
<Avatar id="user-menu" src={$user.photoURL || ''} alt="User" class="cursor-pointer" />
<Dropdown triggeredBy="#user-menu" class="w-48">
Expand All @@ -79,5 +75,23 @@
{:else if !page.url.pathname.startsWith('/login')}
<Button href="/login" class="">{translations[$language].login}</Button>
{/if}

<!-- Remove the old toggle button and add a dropdown for language selection(PM requested) -->
<Avatar
id="language-menu"
src={$language === 'en' ? '/icons/flag-us.png' : '/icons/flag-zh.jpg'}
alt="Lang"
class="ml-2 cursor-pointer"
/>
<Dropdown triggeredBy="#language-menu" class="w-36">
<DropdownItem class="flex items-center" on:click={() => setLanguage('en')}>
<img src="/icons/flag-us.png" alt="English" class="mr-2 h-4 w-4" />
English
</DropdownItem>
<DropdownItem class="flex items-center" on:click={() => setLanguage('zh')}>
<img src="/icons/flag-zh.jpg" alt="中文" class="mr-2 h-4 w-4" />
繁體中文
</DropdownItem>
</Dropdown>
</div>
</Navbar>
Loading

0 comments on commit 790a492

Please sign in to comment.