Skip to content

Commit d041702

Browse files
committed
fix(projects): tags should be aligned on the right
1 parent 6ae2c5a commit d041702

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
+++
2+
title = "Example Project Without Links"
3+
description = "A project that only has tags but no demo or github link"
4+
weight = 100
5+
date = 2024-10-25
6+
7+
[extra]
8+
remote_image = "https://images.unsplash.com/photo-1517694712202-14dd9538aa97?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
9+
tags = ["example", "test", "layout"]
10+
+++
11+
12+
This project demonstrates a layout issue where tags should be aligned to the right even when there are no demo or github links.

sass/parts/_cards.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
align-items: center;
8080
gap: 12px;
8181
margin-top: auto;
82+
flex-wrap: wrap;
8283
}
8384

8485
&-links {
@@ -93,6 +94,7 @@
9394
gap: 4px;
9495
justify-content: flex-end;
9596
align-items: center;
97+
margin-left: auto;
9698
}
9799

98100
&-tag {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { test, expect } from '@playwright/test';
2+
import { TestHelpers } from '../helpers';
3+
4+
test.describe('Tag Alignment in Project Cards', () => {
5+
let helpers: TestHelpers;
6+
7+
test.beforeEach(async ({ page }) => {
8+
helpers = new TestHelpers(page);
9+
await page.goto('/projects');
10+
await helpers.waitForPageReady();
11+
});
12+
13+
test('tags should be aligned to the right when there are no github/demo links', async ({ page }) => {
14+
// Find the card for "Example Project Without Links"
15+
const projectCard = page.locator('.card', { has: page.locator('h1:has-text("Example Project Without Links")') });
16+
17+
// Verify the card exists
18+
await expect(projectCard).toBeVisible();
19+
20+
// Get the card footer
21+
const cardFooter = projectCard.locator('.card-footer');
22+
await expect(cardFooter).toBeVisible();
23+
24+
// Verify there are no card links (github/demo buttons)
25+
const cardLinks = cardFooter.locator('.card-links');
26+
await expect(cardLinks).not.toBeVisible();
27+
28+
// Verify there are tags
29+
const cardTags = cardFooter.locator('.card-tags');
30+
await expect(cardTags).toBeVisible();
31+
32+
const tags = cardTags.locator('.card-tag');
33+
const tagCount = await tags.count();
34+
expect(tagCount).toBeGreaterThan(0);
35+
36+
// Get the bounding boxes
37+
const footerBox = await cardFooter.boundingBox();
38+
const tagsBox = await cardTags.boundingBox();
39+
40+
expect(footerBox).toBeTruthy();
41+
expect(tagsBox).toBeTruthy();
42+
43+
if (footerBox && tagsBox) {
44+
// Tags should be aligned to the right (right edge should be close to footer's right edge)
45+
const footerRight = footerBox.x + footerBox.width;
46+
const tagsRight = tagsBox.x + tagsBox.width;
47+
48+
// Allow a small margin for padding (20px is the card padding)
49+
const rightMargin = footerBox.width * 0.1; // 10% tolerance
50+
expect(tagsRight).toBeGreaterThan(footerRight - rightMargin);
51+
}
52+
});
53+
54+
test('tags should still be aligned to the right when github/demo links are present', async ({ page }) => {
55+
// Find a card that has both links and tags (e.g., "Apollo" project)
56+
const projectCard = page.locator('.card', { has: page.locator('h1:has-text("Apollo")') });
57+
58+
// Verify the card exists
59+
await expect(projectCard).toBeVisible();
60+
61+
// Get the card footer
62+
const cardFooter = projectCard.locator('.card-footer');
63+
await expect(cardFooter).toBeVisible();
64+
65+
// Verify there are card links
66+
const cardLinks = cardFooter.locator('.card-links');
67+
await expect(cardLinks).toBeVisible();
68+
69+
// Verify there are tags
70+
const cardTags = cardFooter.locator('.card-tags');
71+
await expect(cardTags).toBeVisible();
72+
73+
// Get the bounding boxes
74+
const footerBox = await cardFooter.boundingBox();
75+
const tagsBox = await cardTags.boundingBox();
76+
77+
expect(footerBox).toBeTruthy();
78+
expect(tagsBox).toBeTruthy();
79+
80+
if (footerBox && tagsBox) {
81+
// Tags should be aligned to the right (right edge should be close to footer's right edge)
82+
const footerRight = footerBox.x + footerBox.width;
83+
const tagsRight = tagsBox.x + tagsBox.width;
84+
85+
// Allow a small margin for padding
86+
const rightMargin = footerBox.width * 0.1; // 10% tolerance
87+
expect(tagsRight).toBeGreaterThan(footerRight - rightMargin);
88+
}
89+
});
90+
});

0 commit comments

Comments
 (0)