Skip to content

Commit b08a498

Browse files
committed
chore: add contributors image on the hero section and add hero-section test
1 parent 74b7717 commit b08a498

File tree

9 files changed

+128
-7
lines changed

9 files changed

+128
-7
lines changed

e2e-tests/herosection.spec.ts

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+
3+
//Test for the HeroSection component
4+
test.describe("HeroSection Component", () => {
5+
test.beforeEach(async ({ page }) => {
6+
//go to the page containing the HeroSection component
7+
await page.goto("http://localhost:3000");
8+
});
9+
10+
test("should render the HeroSection component", async ({ page }) => {
11+
const heroSection = await page.locator('[data-test="HeroSection"]');
12+
await expect(heroSection).toBeVisible();
13+
});
14+
15+
test("should display the heading ", async ({ page }) => {
16+
const heading = await page.getByRole("heading", {
17+
name: "Making open-source contribution fun again",
18+
});
19+
await expect(heading).toBeVisible();
20+
});
21+
22+
test("should display the description correctly", async ({ page }) => {
23+
// Locate the description paragraph within the HeroSection
24+
const description = await page.locator(
25+
'[data-test="HeroSection"] p.font-ff-inconsolata',
26+
);
27+
28+
// Wait for the paragraph to be visible
29+
await expect(description).toBeVisible();
30+
31+
// Verify the description text
32+
await expect(description).toHaveText(
33+
"Open-source is the fastest way to get the job experience you need. Colabs is the platform that makes open-source contribution fun and competitive.",
34+
);
35+
});
36+
37+
test("should display the collaborator images correctly", async ({ page }) => {
38+
const collaborators = await page.locator(
39+
'[data-test="HeroSection"] img[alt="Collaborator"]',
40+
);
41+
42+
//check the number of collaborators image displayed
43+
await expect(collaborators).toHaveCount(4);
44+
45+
//check that they are all visible
46+
for (let i = 0; i < 4; i++) {
47+
const collaborator = collaborators.nth(i);
48+
await expect(collaborator).toBeVisible();
49+
await expect(collaborator).toHaveClass(/rounded-full/);
50+
}
51+
});
52+
53+
test("should display the contributor text", async ({ page }) => {
54+
const contributorText = await page.locator(
55+
'[data-test="HeroSection"] p.font-text-brand-gray-10',
56+
);
57+
await expect(contributorText).toHaveText("500+ contributors and counting");
58+
});
59+
60+
test("should render the action buttons correctly", async ({ page }) => {
61+
// Verify the "Join Colabs" button
62+
const joinButton = await page.locator(
63+
"data-test=HeroSection >> text=Join Colabs",
64+
);
65+
await expect(joinButton).toBeVisible();
66+
await expect(joinButton).toHaveAttribute(
67+
"href",
68+
"/auth/signup?returnTo=%2Fdashboard",
69+
);
70+
71+
// Verify the "Launch a Hackathon" button
72+
const hackathonButton = await page.locator(
73+
"data-test=HeroSection >> text=Launch a Hackathon",
74+
);
75+
await expect(hackathonButton).toBeVisible();
76+
await expect(hackathonButton).toHaveAttribute(
77+
"href",
78+
"/dashboard/hackathons",
79+
);
80+
});
81+
82+
test("should display the astronaut image", async ({ page }) => {
83+
// Verify the astronaut image
84+
const astronautImage = await page.locator(
85+
'[data-test="HeroSection"] img[alt="Standing robot"]',
86+
);
87+
await expect(astronautImage).toBeVisible();
88+
await expect(astronautImage).toHaveClass(/object-contain/);
89+
});
90+
});

src/assets/hero-section/fred.png

3.54 KB
Loading

src/assets/hero-section/ian.png

3.26 KB
Loading

src/assets/hero-section/katrina.png

3.12 KB
Loading

src/assets/hero-section/sharon.png

3.1 KB
Loading

src/routes/-components/FooterCTA.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const FooterCTA = () => {
66
return (
77
<div
88
data-test="FooterCTA"
9-
className="relative flex flex-col items-center gap-4 border border-red-600 p-4 md:gap-10 md:p-10 lg:flex lg:flex-row lg:justify-around"
9+
className="relative flex flex-col items-center gap-4 p-4 md:gap-10 md:p-10 lg:flex lg:flex-row lg:justify-around"
1010
>
11-
<div className="lg:flex-0 z-10 p-4 lg:flex lg:w-1/2 lg:flex-col lg:gap-6">
11+
<div className="z-10 p-4 lg:ml-[4%] lg:flex lg:w-1/2 lg:flex-col lg:gap-6">
1212
<h1 className="text-[32px] font-bold text-heading lg:text-[55px] lg:leading-[60.5px]">
1313
Experience counts. Get it on Colabs.
1414
</h1>

src/routes/-components/HeroSection.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import astronaut from "../../assets/Astronaut-herosection.png";
22
import rocketIcon from "../../assets/rocket.png";
3+
import fred from "../../assets/hero-section/fred.png";
4+
import ian from "../../assets/hero-section/ian.png";
5+
import katrina from "../../assets/hero-section/katrina.png";
6+
import sharon from "../../assets/hero-section/sharon.png";
37
import { Link } from "@tanstack/react-router";
48

59
export const HeroSection = () => {
10+
//array of collaborators
11+
const collaborators = [fred, ian, katrina, sharon];
612
return (
13+
//border border-red-500
714
<div
815
data-test="HeroSection"
9-
className="flex flex-col items-center gap-4 p-4 md:gap-1 md:p-4 lg:flex lg:flex-row lg:justify-around"
16+
className="flex flex-col items-center gap-4 p-4 md:mt-2 md:p-5 lg:mt-4 lg:flex lg:flex-row lg:justify-around"
1017
>
11-
<div className="lg:flex-0 p-4 lg:flex lg:w-1/2 lg:flex-col lg:gap-6">
18+
<div className="flex flex-col gap-4 p-4 lg:flex lg:w-1/2 lg:flex-col lg:gap-6">
1219
<h1 className="pb-2 text-[25px] font-bold text-heading md:text-[30px] lg:text-[55px] lg:leading-[60.5px]">
1320
Making open-source contribution fun again
1421
</h1>
@@ -17,6 +24,27 @@ export const HeroSection = () => {
1724
Colabs is the platform that makes open-source contribution fun and
1825
competitive.
1926
</p>
27+
28+
{/* collaborators */}
29+
<div className="mt-2 flex flex-col items-start justify-center gap-2 md:flex-row md:items-center md:justify-center lg:justify-start">
30+
{/* Loop thru the array of collaborators to display them */}
31+
<div className="relative flex">
32+
{collaborators.map((collaborator, index) => (
33+
<img
34+
key={index}
35+
src={collaborator}
36+
alt="Collaborator"
37+
className={`h-12 w-12 rounded-full object-cover ${
38+
index !== 0 ? "-ml-2" : ""
39+
}`}
40+
/>
41+
))}
42+
</div>
43+
44+
<p className="font-text-brand-gray-10 text-sm font-medium">
45+
500+ contributors and counting
46+
</p>
47+
</div>
2048
<div className="mt-5 flex flex-col gap-2 md:flex-row md:justify-around lg:justify-start lg:gap-4">
2149
<Link
2250
to="/auth/signup"
@@ -37,7 +65,7 @@ export const HeroSection = () => {
3765
<img
3866
src={astronaut}
3967
alt="Standing robot"
40-
className="mt-4 md:mt-6 lg:h-auto lg:max-w-[30%] lg:flex-1 lg:items-center lg:justify-center lg:object-contain"
68+
className="mt-4 md:h-auto md:max-w-[50%] lg:max-w-[30%] lg:items-center lg:justify-center lg:object-contain"
4169
/>
4270
</div>
4371
);

src/routes/-components/HomePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export function HomePage() {
1212
return (
1313
<div className="flex h-full min-h-screen w-full flex-col">
1414
<LandingPageNavbar />
15+
<HeroSection />
1516
<div className="flex h-full min-h-screen w-full flex-col items-center justify-center gap-3 font-ff-poppins">
16-
<HeroSection />
1717
{/* landing page goes here */}
1818
<p className="rounded-2xl border border-primary p-5 text-3xl">
1919
Landing page goes here

tailwind.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default {
2323
7: "#635D5D",
2424
8: "#B3B8B7",
2525
9: "#f3faf8", //#B3B8B7CC
26+
10: "D9D9D9",
2627
},
2728
green: {
2829
1: "#14A97C",
@@ -35,6 +36,9 @@ export default {
3536
8: "#294740CC",
3637
},
3738
},
39+
// Text colors
40+
heading: "E9EDEC",
41+
3842
sidebar: {
3943
DEFAULT: "oklch(var(--sidebar-background))",
4044
foreground: "oklch(var(--sidebar-foreground))",
@@ -45,7 +49,6 @@ export default {
4549
border: "oklch(var(--sidebar-border))",
4650
ring: "oklch(var(--sidebar-ring))",
4751
},
48-
heading: "E9EDEC",
4952
},
5053
},
5154
},

0 commit comments

Comments
 (0)