Skip to content
Merged
30 changes: 30 additions & 0 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,34 @@ test.describe('Git Catalogue App', () => {

expect(errors).toEqual([]);
});

test('should not scroll the tab content sideways', async ({ page }) => {
const repository = {
id: 1,
name: 'mod-example',
full_name: 'azerothcore/mod-example',
description: 'Example module',
stargazers_count: 5,
created_at: '2024-01-01T00:00:00Z',
default_branch: 'master',
owner: { login: 'azerothcore' },
html_url: 'https://github.com/azerothcore/mod-example',
forks_count: 0,
watchers_count: 0,
topics: ['azerothcore-module'],
};
const config = await (await page.request.get('/assets/config.json')).json();
const organizations: Record<string, Record<string, unknown[]>> = {};
for (const { org, topic } of Object.values<{ org: string; topic: string }>(config.tabs)) {
organizations[org] = { ...organizations[org], [topic]: [repository] };
}
// the paginators only render with results, and the CI fixture has none
await page.route('**/catalogue.json', (route) => route.fulfill({ json: { organizations } }));

await page.goto('/');
await expect(page.locator('a.repo-row').first()).toBeVisible();

const tabBody = page.locator('.mat-mdc-tab-body-active .mat-mdc-tab-body-content');
expect(await tabBody.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
});
});
10 changes: 10 additions & 0 deletions src/app/catalogue/catalogue.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
@if (veilVisible) {
<div class="route-veil" aria-hidden="true">
<div class="route-veil-brand">
<span class="route-veil-mark"></span>
<span class="route-veil-name">AzerothCore</span>
<span class="route-veil-label">Catalogue</span>
</div>
</div>
}

<div class="container mt-5">
<router-outlet></router-outlet>
</div>
76 changes: 76 additions & 0 deletions src/app/catalogue/catalogue.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.route-veil {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
background: #0f1217;
color: #f6f7f9;
pointer-events: none;
animation: veil-sweep 0.85s cubic-bezier(0.76, 0, 0.24, 1) both;
will-change: transform;
}

.route-veil-brand {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.7rem;
}

.route-veil-mark {
width: 46px;
height: 2px;
background: #b4232a;
transform-origin: center;
animation: veil-mark 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) 0.18s both;
}

.route-veil-name {
font-size: 0.95rem;
font-weight: 700;
letter-spacing: 0.34em;
text-transform: uppercase;
}

.route-veil-label {
color: rgba(246, 247, 249, 0.5);
font-size: 0.6rem;
letter-spacing: 0.44em;
text-transform: uppercase;
}

@keyframes veil-sweep {
0% {
transform: translateY(-100%);
}

30% {
transform: translateY(0);
}

62% {
transform: translateY(0);
}

100% {
transform: translateY(-100%);
}
}

@keyframes veil-mark {
from {
transform: scaleX(0);
}

to {
transform: scaleX(1);
}
}

@media (prefers-reduced-motion: reduce) {
.route-veil {
display: none;
}
}
53 changes: 51 additions & 2 deletions src/app/catalogue/catalogue.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
import { Component } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { Subscription } from 'rxjs';

@Component({
selector: 'app-catalogue',
templateUrl: './catalogue.component.html',
styleUrls: ['./catalogue.component.scss'],
standalone: false
})
export class CatalogueComponent {}
export class CatalogueComponent implements OnDestroy {
veilVisible = false;

private readonly subscription = new Subscription();
private showTimer?: number;
private hideTimer?: number;
private readonly reduceMotion =
typeof window !== 'undefined' && !!window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;

constructor(private readonly router: Router) {
document.body.classList.remove('catalogue-ready');

if (!this.reduceMotion) {
this.veilVisible = true;
this.hideTimer = window.setTimeout(() => this.finishTransition(), 900);
} else {
document.body.classList.add('catalogue-ready');
}

this.subscription.add(
this.router.events.subscribe((event) => {
if (!(event instanceof NavigationStart) || this.reduceMotion) {
return;
}

window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer);
document.body.classList.remove('catalogue-ready');
this.veilVisible = false;
this.showTimer = window.setTimeout(() => (this.veilVisible = true), 20);
this.hideTimer = window.setTimeout(() => this.finishTransition(), 900);
}),
);
}

ngOnDestroy(): void {
this.subscription.unsubscribe();
window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer);
document.body.classList.remove('catalogue-ready');
}

private finishTransition(): void {
this.veilVisible = false;
document.body.classList.add('catalogue-ready');
}
}
Loading
Loading