Skip to content

Commit de8c001

Browse files
authored
refactor: language picker as select (#406)
1 parent 9ab4688 commit de8c001

File tree

12 files changed

+106
-99
lines changed

12 files changed

+106
-99
lines changed

apps/blog/src/assets/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
"about": "About us",
2626
"meetups": "Angular Meetups",
2727
"become_author": "Become an author",
28-
"navLinks": "Navigation links"
28+
"navLinks": "Navigation links",
29+
"languagePicker": {
30+
"pl": "Polish",
31+
"en": "English"
32+
}
2933
},
3034
"authorPage": {
3135
"posted_by": "Posted by {{name}}"

apps/blog/src/assets/i18n/pl.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
"about": "O nas",
2626
"meetups": "Angular Meetups",
2727
"become_author": "Zostań autorem",
28-
"navLinks": "Menu"
28+
"navLinks": "Menu",
29+
"languagePicker": {
30+
"pl": "Polski",
31+
"en": "Angielski"
32+
}
2933
},
3034
"home": {
3135
"latest": "Latest articles"
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

libs/blog/layouts/ui-layouts/src/lib/header/components/header-language-button.component.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

libs/blog/layouts/ui-layouts/src/lib/header/components/header-language.component.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

libs/blog/layouts/ui-layouts/src/lib/header/components/header-mobile-menu.component.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {
66
output,
77
} from '@angular/core';
88

9-
import { NavigationComponent } from '@angular-love/blog/layouts/ui-navigation';
9+
import {
10+
LanguagePickerComponent,
11+
NavigationComponent,
12+
} from '@angular-love/blog/layouts/ui-navigation';
1013

1114
@Component({
1215
standalone: true,
@@ -17,14 +20,23 @@ import { NavigationComponent } from '@angular-love/blog/layouts/ui-navigation';
1720
[ngClass]="{ 'translate-y-[100%]': isOpened() }"
1821
[attr.aria-hidden]="isOpened()"
1922
>
20-
<al-navigation (navigated)="closed.emit()" layout="vertical" />
23+
<al-navigation (navigated)="closed.emit()" layout="vertical">
24+
<li class="flex justify-center">
25+
<al-language-picker
26+
[language]="language()"
27+
(languageChange)="languageChange.emit($event)"
28+
/>
29+
</li>
30+
</al-navigation>
2131
</div>
2232
`,
2333
changeDetection: ChangeDetectionStrategy.OnPush,
24-
imports: [NavigationComponent, NgClass],
34+
imports: [NavigationComponent, NgClass, LanguagePickerComponent],
2535
})
2636
export class HeaderMobileMenuComponent {
2737
readonly isOpened = input.required<boolean>();
38+
readonly language = input.required<string>();
2839

40+
protected languageChange = output<string>();
2941
readonly closed = output<void>();
3042
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './header-hamburger.component';
2-
export * from './header-language.component';
32
export * from './header-logo.component';
43
export * from './header-mobile-menu.component';

libs/blog/layouts/ui-layouts/src/lib/header/header.component.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import {
66
signal,
77
} from '@angular/core';
88

9-
import { NavigationComponent } from '@angular-love/blog/layouts/ui-navigation';
9+
import {
10+
LanguagePickerComponent,
11+
NavigationComponent,
12+
} from '@angular-love/blog/layouts/ui-navigation';
1013

1114
import {
1215
HeaderHamburgerComponent,
13-
HeaderLanguageComponent,
1416
HeaderLogoComponent,
1517
HeaderMobileMenuComponent,
1618
} from './components';
@@ -25,10 +27,11 @@ import {
2527
>
2628
<al-header-logo />
2729
28-
<div class="flex flex-row items-center">
29-
<al-navigation class="hidden lg:block" />
30+
<al-navigation class="hidden lg:block" />
3031
31-
<al-header-language
32+
<div class="flex flex-row items-center">
33+
<al-language-picker
34+
class="mr-3 hidden md:block"
3235
[language]="language()"
3336
(languageChange)="languageChange.emit($event)"
3437
/>
@@ -43,15 +46,20 @@ import {
4346
</div>
4447
</header>
4548
46-
<al-header-mobile-menu [isOpened]="showNav()" (closed)="toggleNav()" />
49+
<al-header-mobile-menu
50+
[isOpened]="showNav()"
51+
[language]="language()"
52+
(closed)="toggleNav()"
53+
(languageChange)="languageChange.emit($event)"
54+
/>
4755
`,
4856
changeDetection: ChangeDetectionStrategy.OnPush,
4957
imports: [
5058
NavigationComponent,
5159
HeaderLogoComponent,
52-
HeaderLanguageComponent,
5360
HeaderHamburgerComponent,
5461
HeaderMobileMenuComponent,
62+
LanguagePickerComponent,
5563
],
5664
})
5765
export class HeaderComponent {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './lib/navigation/navigation.component';
2+
export * from './lib/language-picker/language-picker.component';

0 commit comments

Comments
 (0)