Skip to content

Commit 2a95de6

Browse files
Add Lottie engine
1 parent b01c270 commit 2a95de6

12 files changed

Lines changed: 63 additions & 86 deletions

.htmlhintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"attr-lowercase": [
44
"*ngTemplateOutlet",
55
"#logoImage",
6+
"#lottieCanvas",
67
"#renderContent",
78
"(ngSubmit)",
89
"[ariaLabel]",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"@fortawesome/free-brands-svg-icons": "7.1.0",
101101
"@fortawesome/free-regular-svg-icons": "7.1.0",
102102
"@fortawesome/free-solid-svg-icons": "7.1.0",
103-
"@lottiefiles/dotlottie-wc": "0.9.8",
103+
"@lottiefiles/dotlottie-web": "0.67.0",
104104
"@ngx-translate/core": "17.0.0",
105105
"@ngx-translate/http-loader": "17.0.0",
106106
"rxjs": "7.8.2",

pnpm-lock.yaml

Lines changed: 3 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/.htaccess

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
RewriteRule . /index.html [L]
1414
</IfModule>
1515

16+
<IfModule mod_mime.c>
17+
# Allows Apache to properly serve Lottie animations and its engine
18+
AddType application/wasm .wasm
19+
AddType application/zip .lottie
20+
AddType application/json .json
21+
</IfModule>
22+
1623
<IfModule mod_headers.c>
1724
# Tell browser to only communicate via HTTPS
1825
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
@@ -31,5 +38,5 @@
3138

3239
# ONLY allow scripts from your own site, YouTube AND dicebear
3340
# Note : If you are using Google fonts or external APIs, you will need to add them here.
34-
Header set Content-Security-Policy "default-src 'self'; script-src 'self' https://www.youtube.com https://s.ytimg.com; style-src 'self' 'unsafe-inline'; img-src 'self' https://i.ytimg.com https://api.dicebear.com; connect-src 'self' https://api.votre-domaine.com; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; object-src 'none'; base-uri 'self';"
41+
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval' https://www.youtube.com https://s.ytimg.com; style-src 'self' 'unsafe-inline'; img-src 'self' https://i.ytimg.com https://api.dicebear.com; connect-src 'self' https://api.votre-domaine.com; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; object-src 'none'; base-uri 'self';"
3542
</IfModule>

src/app/app.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
23
import { ComponentFixture, TestBed } from '@angular/core/testing';
34
import { ActivatedRoute, NavigationEnd, Router, RouterOutlet } from '@angular/router';
45
import { By } from '@angular/platform-browser';

src/app/app.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { provideTranslateService, TranslateLoader, TranslateService } from '@ngx
44
import { provideClientHydration } from '@angular/platform-browser';
55
import { provideRouter } from '@angular/router';
66
import { catchError, firstValueFrom, Observable, of } from 'rxjs';
7+
import { DotLottie } from '@lottiefiles/dotlottie-web';
78

89
import { ROUTES } from '@app/app.routes';
910
import { authInterceptor } from '@core/interceptor/auth/auth.interceptor';
@@ -36,6 +37,8 @@ export const APP_CONFIG: ApplicationConfig = {
3637
withInterceptors(HTTP_INTERCEPTORS)
3738
),
3839
provideAppInitializer(async() => {
40+
DotLottie.setWasmUrl('/assets/wasm/dotlottie-player.wasm');
41+
3942
const AUTH_SERVICE = inject(AuthService);
4043
const TRANSLATE = inject(TranslateService);
4144

src/app/shared/error-handler/error-views/unknown-error/unknown-error.component.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<section class="unknown-error">
22
<div class="unknown-error__content">
33
<div class="unknown-error__animation-wrapper">
4-
<dotlottie-wc
5-
src="assets/animations/unknown-error-abduction.lottie"
6-
autoplay
7-
loop
4+
<canvas
5+
#lottieCanvas
86
role="img"
97
[attr.aria-label]="'PAGES.ERROR.UNKNOWN.IMG.ALT.ABDUCTION' | translate"
10-
class="unknown-error__lottie" />
8+
class="unknown-error__lottie">
9+
</canvas>
1110
</div>
1211

1312
<h4 class="unknown-error__title">

src/app/shared/error-handler/error-views/unknown-error/unknown-error.component.scss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
align-items: center;
1010
justify-content: center;
1111
text-align: center;
12-
background-color: var(--bg-color);
12+
padding-top: 1rem;
13+
background-color: ar(--bg-color);
1314

1415
&__content {
1516
display: flex;
@@ -22,19 +23,24 @@
2223

2324
&__animation-wrapper {
2425
width: 100%;
26+
aspect-ratio: 1 / 1;
2527
max-width: 300px;
2628
margin: 0 auto;
29+
border-radius: 16px;
30+
border: solid 2px var(--primary-color);
31+
background-color: #0c2522;
2732
animation: float 6s ease-in-out infinite;
33+
transform: translateZ(0);
34+
overflow: hidden;
2835
}
2936

3037
&__lottie {
3138
display: block;
32-
aspect-ratio: 1 / 1;
3339
width: 100%;
34-
height: auto;
35-
border-radius: 16px;
36-
border: solid 2px var(--primary-color);
37-
overflow: hidden;
40+
height: 100%;
41+
border-radius: 0;
42+
border: none;
43+
transform: scale(1.02);
3844
}
3945

4046
&__title {

src/app/shared/error-handler/error-views/unknown-error/unknown-error.component.spec.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,17 @@ describe('UnknownErrorComponent', () => {
5555
});
5656

5757
describe('UI & Media Rendering', () => {
58-
it('should render the UFO animation correctly', () => {
58+
it('should render the UFO animation canvas correctly', () => {
5959
// --- ARRANGE ---
6060
fixture.detectChanges();
6161

6262
// --- ACT ---
6363
const lottieAnim = fixture.debugElement.query(By.css('.unknown-error__lottie')).nativeElement;
6464

6565
// --- ASSERT ---
66-
expect(lottieAnim.getAttribute('src')).toBe('assets/animations/unknown-error-abduction.lottie');
66+
expect(lottieAnim.tagName.toLowerCase()).toBe('canvas');
6767
expect(lottieAnim.getAttribute('aria-label')).toBe('Une soucoupe volante aspirant une chenille');
6868
});
69-
70-
it('should render the Lottie animation correctly', () => {
71-
fixture.detectChanges();
72-
73-
const lottiePlayer = fixture.debugElement.query(By.css('dotlottie-wc'));
74-
75-
if (lottiePlayer) {
76-
expect(lottiePlayer.nativeElement.getAttribute('src')).toContain('unknown-error-abduction.lottie');
77-
}
78-
});
7969
});
8070

8171
describe('Internationalization (i18n)', () => {
Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
1-
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
22
import { TranslateModule } from '@ngx-translate/core';
33

4-
import '@lottiefiles/dotlottie-wc';
4+
import { DotLottie } from '@lottiefiles/dotlottie-web';
5+
6+
const ALIGN_CENTER = 0.5;
57

68
@Component({
79
selector: 'unknown-error',
8-
imports: [
9-
TranslateModule,
10-
],
10+
imports: [TranslateModule],
1111
templateUrl: './unknown-error.component.html',
1212
styleUrl: './unknown-error.component.scss',
13-
changeDetection: ChangeDetectionStrategy.OnPush,
14-
schemas: [CUSTOM_ELEMENTS_SCHEMA]
13+
changeDetection: ChangeDetectionStrategy.OnPush
1514
})
15+
export class UnknownErrorComponent implements OnInit, OnDestroy {
16+
17+
@ViewChild('lottieCanvas', { static: true }) lottieCanvas!: ElementRef<HTMLCanvasElement>;
18+
19+
private dotLottieInstance?: DotLottie;
20+
21+
ngOnInit(): void {
22+
this.dotLottieInstance = new DotLottie({
23+
canvas: this.lottieCanvas.nativeElement,
24+
src: 'assets/animations/unknown-error-abduction.lottie',
25+
loop: true,
26+
autoplay: true,
27+
layout: {
28+
fit: 'contain',
29+
align: [ALIGN_CENTER, ALIGN_CENTER],
30+
}
31+
});
32+
}
1633

17-
export class UnknownErrorComponent {}
34+
ngOnDestroy(): void {
35+
this.dotLottieInstance?.destroy();
36+
}
37+
}

0 commit comments

Comments
 (0)