-
Couldn't load subscription status.
- Fork 9
Feat/carousel #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/carousel #485
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,28 +5,88 @@ import { | |
| input, | ||
| OnInit, | ||
| } from '@angular/core'; | ||
| import { TranslocoDirective } from '@jsverse/transloco'; | ||
| import { CarouselModule, OwlOptions } from 'ngx-owl-carousel-o'; | ||
|
|
||
| import { RelatedArticleListStore } from '@angular-love/blog/articles/data-access'; | ||
| import { UiArticleCardComponent } from '@angular-love/blog/articles/ui-article-card'; | ||
| import { ButtonComponent } from '@angular-love/blog/shared/ui-button'; | ||
|
|
||
| @Component({ | ||
| selector: 'al-related-articles', | ||
| template: ` | ||
| @if (store.isFetchRelatedArticleListLoaded()) { | ||
| <strong class="text-3xl">Related Articles</strong> | ||
| <div class="mt-4 grid grid-cols-1 gap-6 p-2 md:grid-cols-2"> | ||
| @for (article of store.relatedArticles(); track $index) { | ||
| <al-article-card [article]="article" cardType="compact" /> | ||
| } | ||
| </div> | ||
| <ng-container *transloco="let t; read: 'relatedArticles'"> | ||
| <h2 class="mb-4 text-3xl font-bold">{{ t('title') }}</h2> | ||
| <div class="relative lg:px-14"> | ||
| <owl-carousel-o #carousel role="list" [options]="customOptions"> | ||
| @for (article of store.relatedArticles(); track $index) { | ||
| <ng-template carouselSlide> | ||
| <!-- Prevents focus rings from being cut off --> | ||
| <li class="list-none py-1"> | ||
| <al-article-card [article]="article" cardType="compact" /> | ||
| </li> | ||
| </ng-template> | ||
| } | ||
| </owl-carousel-o> | ||
| <div | ||
| class="absolute left-0 top-1/2 hidden w-full -translate-y-1/2 justify-between lg:flex" | ||
| > | ||
| <button | ||
| al-button | ||
| type="button" | ||
| class="bg-al-pink text-white" | ||
| [attr.aria-label]="t('previousSlide')" | ||
| (click)="carousel.prev()" | ||
| size="small" | ||
| > | ||
| <span class="text-2xl">‹</span> | ||
|
||
| </button> | ||
| <button | ||
| al-button | ||
| type="button" | ||
| class="bg-al-pink text-white" | ||
| [attr.aria-label]="t('nextSlide')" | ||
| (click)="carousel.next()" | ||
| size="small" | ||
| > | ||
| <span class="text-2xl">›</span> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </ng-container> | ||
| } | ||
| `, | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| providers: [RelatedArticleListStore], | ||
| imports: [UiArticleCardComponent], | ||
| imports: [ | ||
| UiArticleCardComponent, | ||
| CarouselModule, | ||
| ButtonComponent, | ||
| TranslocoDirective, | ||
| ], | ||
| }) | ||
| export class RelatedArticlesComponent implements OnInit { | ||
| readonly id = input.required<number>(); | ||
| readonly customOptions: OwlOptions = { | ||
| loop: true, | ||
| mouseDrag: false, | ||
| touchDrag: true, | ||
| pullDrag: true, | ||
| dots: true, | ||
| margin: 24, | ||
| navSpeed: 700, | ||
| navText: ['', ''], | ||
| responsive: { | ||
| // Keep in mind these breakpoints refer to container width, not the viewport width | ||
| 0: { | ||
| items: 1, | ||
| }, | ||
| 540: { | ||
| items: 2, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| readonly store = inject(RelatedArticleListStore); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.