File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 55 import {Icon } from ' $lib/components/ui/icon' ;
66 import {IsMobile } from ' $lib/hooks/is-mobile.svelte' ;
77 import {setLanguage } from ' $lib/i18n' ;
8+ import {SidebarMenuButton } from ' $lib/components/ui/sidebar' ;
9+
10+ type Props = {
11+ inSidebar? : boolean ;
12+ };
13+
14+ let {
15+ inSidebar
16+ }: Props = $props ();
817
918 const languages: Record <string , string > = {
1019 ' en' : ' English' ,
1524 };
1625 const currentLanguage = $derived (languages [$locale ] ?? ' Unknown: ' + $locale );
1726 </script >
27+
1828<DropdownMenu .Root >
1929 <DropdownMenu .Trigger >
2030 {#snippet child ({props })}
21- <Button {...props } icon ="i-mdi-translate" size ={IsMobile .value ? ' icon' : undefined } variant =" ghost" >
22- {#if ! IsMobile .value }
23- {currentLanguage }
31+ {#if inSidebar }
32+ <SidebarMenuButton {...props }>
33+ <Icon icon =" i-mdi-translate" />
34+ <span >{currentLanguage }</span >
35+ <span class =" grow" ></span >
2436 <Icon icon =" i-mdi-menu-down" />
25- {/if }
26- </Button >
37+ </SidebarMenuButton >
38+ {:else }
39+ <Button {...props } icon ="i-mdi-translate" size ={IsMobile .value ? ' icon' : undefined } variant =" ghost" >
40+ {#if ! IsMobile .value }
41+ {currentLanguage }
42+ <Icon icon =" i-mdi-menu-down" />
43+ {/if }
44+ </Button >
45+ {/if }
2746 {/ snippet }
2847 </DropdownMenu .Trigger >
29- <DropdownMenu .Content >
48+ <DropdownMenu .Content align = " end " >
3049 <DropdownMenu .RadioGroup bind:value ={() => $locale , l => setLanguage (l )}>
3150 {#each Object .entries (languages ) as [lang, label] (lang )}
3251 <DropdownMenu .RadioItem class ="cursor-pointer" value ={lang }>{label }</DropdownMenu .RadioItem >
Original file line number Diff line number Diff line change 182182 </Sidebar .MenuButton >
183183 </Sidebar .MenuItem >
184184 <Sidebar .MenuItem >
185- <LocalizationPicker />
185+ <LocalizationPicker inSidebar />
186186 </Sidebar .MenuItem >
187187 </Sidebar .Menu >
188188 </Sidebar .Group >
You can’t perform that action at this time.
0 commit comments