Skip to content

Commit 379c811

Browse files
committed
feat: improve a11y
1 parent a25d94b commit 379c811

File tree

4 files changed

+60
-19
lines changed

4 files changed

+60
-19
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,10 @@
312312
"section1": "We’ll transfer your article to the CMS and schedule its publication.",
313313
"section2": "We’ll also promote it on social media to maximize its reach."
314314
}
315+
},
316+
"relatedArticles": {
317+
"title": "Related Articles",
318+
"previousSlide": "Previous slide",
319+
"nextSlide": "Next slide"
315320
}
316321
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,10 @@
315315
"section1": "Teraz my zajmiemy się przeniesieniem twojego artykułu do CMS’a i zaplanujemy jego opublikowanie",
316316
"section2": "Zajmiemy się również jego promowaniem w mediach społecznościowych, aby jak najwięcej osób mogło skorzystać z wiedzy, którą w nim zawarłeś!"
317317
}
318+
},
319+
"relatedArticles": {
320+
"title": "Powiązane artykuły",
321+
"previousSlide": "Poprzedni slajd",
322+
"nextSlide": "Następny slajd"
318323
}
319324
}

libs/blog/articles/feature-related-articles/src/lib/related-articles.component.ts

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,87 @@ import {
55
input,
66
OnInit,
77
} from '@angular/core';
8+
import { TranslocoDirective } from '@jsverse/transloco';
89
import { CarouselModule, OwlOptions } from 'ngx-owl-carousel-o';
910

1011
import { RelatedArticleListStore } from '@angular-love/blog/articles/data-access';
1112
import { UiArticleCardComponent } from '@angular-love/blog/articles/ui-article-card';
13+
import { ButtonComponent } from '@angular-love/blog/shared/ui-button';
1214

1315
@Component({
1416
selector: 'al-related-articles',
1517
template: `
1618
@if (store.isFetchRelatedArticleListLoaded()) {
17-
<strong class="text-3xl">Related Articles</strong>
18-
<owl-carousel-o [options]="customOptions">
19-
@for (article of store.relatedArticles(); track $index) {
20-
<ng-template carouselSlide>
21-
<al-article-card [article]="article" cardType="compact" />
22-
</ng-template>
23-
<ng-template carouselSlide>
24-
<al-article-card [article]="article" cardType="compact" />
25-
</ng-template>
26-
}
27-
</owl-carousel-o>
19+
<ng-container *transloco="let t; read: 'relatedArticles'">
20+
<h2 class="mb-4 text-3xl font-bold">{{ t('title') }}</h2>
21+
<div class="relative lg:px-14">
22+
<owl-carousel-o #carousel role="list" [options]="customOptions">
23+
@for (article of store.relatedArticles(); track $index) {
24+
<ng-template carouselSlide>
25+
<!-- Prevents focus rings from being cut off -->
26+
<li class="list-none py-1">
27+
<al-article-card [article]="article" cardType="compact" />
28+
</li>
29+
</ng-template>
30+
}
31+
</owl-carousel-o>
32+
<div
33+
class="absolute left-0 top-1/2 hidden w-full -translate-y-1/2 justify-between lg:flex"
34+
>
35+
<button
36+
al-button
37+
type="button"
38+
class="bg-al-pink text-white"
39+
[attr.aria-label]="t('previousSlide')"
40+
(click)="carousel.prev()"
41+
size="small"
42+
>
43+
<span class="text-2xl">‹</span>
44+
</button>
45+
<button
46+
al-button
47+
type="button"
48+
class="bg-al-pink text-white"
49+
[attr.aria-label]="t('nextSlide')"
50+
(click)="carousel.next()"
51+
size="small"
52+
>
53+
<span class="text-2xl">›</span>
54+
</button>
55+
</div>
56+
</div>
57+
</ng-container>
2858
}
2959
`,
3060
changeDetection: ChangeDetectionStrategy.OnPush,
3161
providers: [RelatedArticleListStore],
32-
imports: [UiArticleCardComponent, CarouselModule],
62+
imports: [
63+
UiArticleCardComponent,
64+
CarouselModule,
65+
ButtonComponent,
66+
TranslocoDirective,
67+
],
3368
})
3469
export class RelatedArticlesComponent implements OnInit {
3570
readonly id = input.required<number>();
3671
customOptions: OwlOptions = {
3772
loop: true,
3873
mouseDrag: false,
3974
touchDrag: true,
40-
pullDrag: false,
75+
pullDrag: true,
4176
dots: true,
42-
margin: 24, // Add spacing between items
77+
margin: 24,
4378
navSpeed: 700,
4479
navText: ['', ''],
4580
responsive: {
4681
// Keep in mind these breakpoints refer to container width, not the viewport width
4782
0: {
4883
items: 1,
4984
},
50-
640: {
85+
540: {
5186
items: 2,
5287
},
5388
},
54-
nav: true,
5589
};
5690

5791
readonly store = inject(RelatedArticleListStore);

libs/blog/shared/ui-avatar/src/lib/avatar.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ type AvatarSize = '32' | '96';
99
styleUrls: ['./avatar.component.scss'],
1010
changeDetection: ChangeDetectionStrategy.OnPush,
1111
imports: [NgOptimizedImage],
12-
host: {
13-
class: 'block',
14-
},
1512
})
1613
export class AvatarComponent {
1714
readonly imageSrc = input.required<string>();

0 commit comments

Comments
 (0)