Skip to content

Commit 7c7f159

Browse files
committed
feat: add videos
1 parent 719121c commit 7c7f159

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

public/data/events.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@
271271
"topic": "Condivisione delle ultime novità riguardo il linguaggio Python.",
272272
"topicEn": "Sharing the latest news about the Python language.",
273273
"image": "/images/about/SalvoRapisarda.jpeg"
274+
},
275+
{
276+
"name": "Dario Camonita",
277+
"topic": "GUI desktop application development (with PySide6)",
278+
"topicEn": "GUI desktop application development (with PySide6)",
279+
"image": "/images/events-speakers/DarioCamonita.jpeg"
280+
},
281+
{
282+
"name": "Raffaele Barone",
283+
"topic": "PyDivertimento (AoC & SpeechLess)",
284+
"topicEn": "PyDivertimento (AoC & SpeechLess)",
285+
"image": "/images/events-speakers/RaffaeleBarone.jpeg"
274286
}
275287
]
276288
},
89.4 KB
Loading

src/app/pages/events/event-detail/event-detail.component.html

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,25 @@ <h2 class="mb-4 text-xl font-semibold">{{ 'events.speakers' | transloco }}</h2>
6969
<h2 class="mb-4 text-xl font-semibold">{{ 'events.videos' | transloco }}</h2>
7070
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
7171
@for (videoId of event()!.videos!; track videoId) {
72-
<div class="aspect-video w-full overflow-hidden rounded-(--radius) shadow">
73-
<iframe
74-
[src]="embedUrl(videoId)"
75-
class="h-full w-full"
76-
allowfullscreen
77-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
78-
title="Video"
79-
></iframe>
80-
</div>
72+
<a
73+
[href]="videoWatchUrl(videoId)"
74+
target="_blank"
75+
rel="noopener"
76+
class="group relative block aspect-video w-full overflow-hidden rounded-(--radius) shadow"
77+
>
78+
<img
79+
[src]="videoThumbnail(videoId)"
80+
alt="Video thumbnail"
81+
class="h-full w-full object-cover transition-opacity group-hover:opacity-80"
82+
/>
83+
<div class="absolute inset-0 flex items-center justify-center">
84+
<div class="flex h-14 w-14 items-center justify-center rounded-full bg-black/60 text-white transition-colors group-hover:bg-black/80">
85+
<svg viewBox="0 0 24 24" fill="currentColor" class="h-7 w-7 translate-x-0.5" aria-hidden="true">
86+
<path d="M8 5v14l11-7z"/>
87+
</svg>
88+
</div>
89+
</div>
90+
</a>
8191
}
8292
</div>
8393
</div>

src/app/pages/events/event-detail/event-detail.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
22
import { NgOptimizedImage } from '@angular/common';
3-
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
43
import { ActivatedRoute, RouterLink } from '@angular/router';
54
import { HttpClient } from '@angular/common/http';
65
import { toSignal } from '@angular/core/rxjs-interop';
@@ -40,7 +39,6 @@ interface MeetupEvent {
4039
export class EventDetailComponent {
4140
private readonly http = inject(HttpClient);
4241
private readonly route = inject(ActivatedRoute);
43-
private readonly sanitizer = inject(DomSanitizer);
4442
private readonly translocoService = inject(TranslocoService);
4543
protected readonly baseUrl = inject(BASE_URL);
4644

@@ -58,10 +56,13 @@ export class EventDetailComponent {
5856
});
5957
}
6058

61-
protected embedUrl(videoId: string): SafeResourceUrl {
62-
return this.sanitizer.bypassSecurityTrustResourceUrl(
63-
`https://www.youtube.com/embed/${videoId}`
64-
);
59+
protected videoThumbnail(videoId: string): string {
60+
return `https://img.youtube.com/vi/${videoId.split('?')[0]}/0.jpg`;
61+
}
62+
63+
protected videoWatchUrl(videoId: string): string {
64+
const [id, params] = videoId.split('?');
65+
return params ? `https://www.youtube.com/watch?v=${id}&${params}` : `https://www.youtube.com/watch?v=${id}`;
6566
}
6667

6768
protected openLightbox(index: number): void {

0 commit comments

Comments
 (0)