Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ <h1 class="title flip-animation">
><span style="--i: 9">N</span>
</h1>
<h2 class="subtitle swap-animation">
<span class="display-none">Software Engineer</span>
<span>Software Engineer</span>
<span>Avid Reader</span>
<span>Tech Enthusiast</span>
<span>Gamer</span>
<span>Amateur Guitarist</span>
</h2>
<br />
<span class="subnote">
Expand Down
117 changes: 103 additions & 14 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,37 +102,126 @@ body,
}
}

.swap-animation:before {
content: '';
animation: swap-text 6s linear infinite;
.swap-animation {
display: grid;
place-items: center;
}

@keyframes swap-text {
0% {
content: 'Software Engineer';
}
.swap-animation span {
grid-area: 1 / 1;
opacity: 0;
visibility: hidden;
animation-duration: 6s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}

.swap-animation span:nth-child(1) {
animation-name: swap-1;
}

.swap-animation span:nth-child(2) {
animation-name: swap-2;
}

.swap-animation span:nth-child(3) {
animation-name: swap-3;
}

.swap-animation span:nth-child(4) {
animation-name: swap-4;
}

.swap-animation span:nth-child(5) {
animation-name: swap-5;
}

@keyframes swap-1 {
0%,
50% {
content: 'Software Engineer';
opacity: 1;
visibility: visible;
}
50.01%,
90% {
opacity: 0;
visibility: hidden;
}
90.01%,
100% {
opacity: 1;
visibility: visible;
}
}

@keyframes swap-2 {
0%,
50% {
opacity: 0;
visibility: hidden;
}
50.01%,
60% {
content: 'Avid Reader';
opacity: 1;
visibility: visible;
}
60.01%,
100% {
opacity: 0;
visibility: hidden;
}
}

@keyframes swap-3 {
0%,
60% {
opacity: 0;
visibility: hidden;
}
60.01%,
70% {
content: 'Tech Enthusiast';
opacity: 1;
visibility: visible;
}
70.01%,
100% {
opacity: 0;
visibility: hidden;
}
}

@keyframes swap-4 {
0%,
70% {
opacity: 0;
visibility: hidden;
}
70.01%,
80% {
content: 'Gamer';
opacity: 1;
visibility: visible;
}
80.01%,
100% {
opacity: 0;
visibility: hidden;
}
}

@keyframes swap-5 {
0%,
80% {
opacity: 0;
visibility: hidden;
}
80.01%,
90% {
content: 'Amateur Guitarist';
opacity: 1;
visibility: visible;
}

90.01%,
100% {
content: 'Software Engineer';
opacity: 0;
visibility: hidden;
}
}
17 changes: 17 additions & 0 deletions tests/animation-verification.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { test, expect } from '@playwright/test';

test('animation container and items exist', async ({ page }) => {
await page.goto('/');

// Check that the container exists
const container = page.locator('.swap-animation');
await expect(container).toBeVisible();

// Initially, before changes, checking for "Software Engineer" text
// The current implementation uses ::before, so the text might be in the display-none span
// or just invisible.
// We just want to ensure the page loads and the container is there.

// After changes, we expect 5 spans.
// For now, let's just verify the container is present.
});
10 changes: 6 additions & 4 deletions tests/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ test('has social links', async ({ page }) => {
await page.goto('/');

// Check for social links
await expect(page.getByLabel('Stack Overflow')).toBeVisible();
await expect(page.getByLabel('Linkedin')).toBeVisible();
await expect(page.getByLabel('Github')).toBeVisible();
await expect(page.getByLabel('Twitter')).toBeVisible();
await Promise.all([
expect(page.getByLabel('Stack Overflow')).toBeVisible(),
expect(page.getByLabel('Linkedin')).toBeVisible(),
expect(page.getByLabel('Github')).toBeVisible(),
expect(page.getByLabel('Twitter')).toBeVisible(),
]);
});
23 changes: 7 additions & 16 deletions tests/font-performance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@ test('verify font-display property', async ({ page }) => {

const fontDisplay = await page.evaluate(async () => {
await document.fonts.ready;
const faces = Array.from(document.fonts.values());
const targetFont = faces.find(
(face) => face.family === 'Cormorant Garamond'
);
return targetFont ? targetFont.display : 'font not found';
for (const face of document.fonts) {
if (face.family === 'Cormorant Garamond') {
return face.display;
}
}
return 'font not found';
});

console.log(`Current font-display: ${fontDisplay}`);

// In Firefox, document.fonts might behave differently or be slower to report,
// sometimes returning "font not found" or incomplete lists in this test context.
// We skip the assertion if the font is not found to avoid flakiness in that browser,
// but strictly assert 'swap' if the font IS found.
if (fontDisplay !== 'font not found') {
expect(fontDisplay).toBe('swap');
} else {
// If you want to enforce it works on all browsers, you might need to wait/retry or debug Firefox specifics.
// For now, we log a warning but don't fail if the font isn't detected (flakiness prevention).
console.warn('Font Cormorant Garamond was not found in document.fonts');
}
expect(fontDisplay).toBe('swap');
});