Skip to content

Commit ac48a40

Browse files
authored
Merge pull request #32 from kleros/feat/community-page
feat(frontend): community-page
2 parents b0e2052 + 4e5cad9 commit ac48a40

File tree

5 files changed

+206
-0
lines changed

5 files changed

+206
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import clsx from "clsx";
2+
3+
import CommunityCard from "./CommunityCard";
4+
5+
import { Community } from "@/queries/community/hero";
6+
7+
const baseStyle = clsx(
8+
"-translate-y-40 lg:-translate-y-44 grid grid-cols-1 lg:grid-cols-3 gap-6"
9+
);
10+
11+
interface ICommunitiesSection {
12+
communities: Community[];
13+
}
14+
15+
const CommunitiesSection: React.FC<ICommunitiesSection> = ({ communities }) => {
16+
const rowOneCommunities = communities.slice(0, 2);
17+
const restCommunities = communities.slice(2);
18+
return (
19+
<div className="bg-background-2 w-full px-6 lg:px-32">
20+
<div className={baseStyle}>
21+
{rowOneCommunities.map((community) => (
22+
<CommunityCard key={community.title} {...community} />
23+
))}
24+
</div>
25+
<div className={clsx(baseStyle,"mt-6")}>
26+
{restCommunities.map((community) => (
27+
<CommunityCard key={community.title} {...community} />
28+
))}
29+
</div>
30+
</div>
31+
);
32+
};
33+
34+
export default CommunitiesSection;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Image from "next/image";
2+
import Link from "next/link";
3+
4+
import { Community } from "@/queries/community/hero";
5+
6+
const CommunityCard: React.FC<Community> = ({ title, subtitle, icon, url }) => {
7+
return (
8+
<Link href={url} target="_blank" rel="noreferrer noopener">
9+
<div className="bg-background-2 min-h-[326px] flex flex-col items-center justify-center border border-stroke rounded-2xl hover:scale-[1.01]">
10+
<Image
11+
src={icon.url}
12+
alt={icon.name}
13+
width={76}
14+
height={76}
15+
className="object-contain"
16+
/>
17+
<h2 className="text-xl text-primary-text font-medium text-center mb-4 mt-2">
18+
{title}
19+
</h2>
20+
<label className="text-base text-secondary-text">{subtitle}</label>
21+
</div>
22+
</Link>
23+
);
24+
};
25+
26+
export default CommunityCard;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
3+
import Image from "next/image";
4+
import Link from "next/link";
5+
6+
import Button from "@/components/Button";
7+
import { HeroQueryType } from "@/queries/community/hero";
8+
9+
interface IHero {
10+
heroData: HeroQueryType["communityPageHero"];
11+
}
12+
13+
const Hero: React.FC<IHero> = ({ heroData }) => {
14+
const { header, subtitle, communityButtons, background } =
15+
heroData;
16+
return (
17+
<div className="relative pt-52 pb-[277px] lg:pb-[331px] px-6 lg:px-32">
18+
<div className="space-y-8">
19+
<h1 className="text-3xl lg:text-4xl font-medium">{header}</h1>
20+
<p className="text-lg">{subtitle}</p>
21+
<div className="flex flex-wrap gap-6 items-center">
22+
{communityButtons.map((button) => (
23+
<Link
24+
key={button.text}
25+
href={button.link.url}
26+
target="_blank"
27+
rel="noopener noreferrer"
28+
>
29+
<Button variant="secondary" className=" hover:!bg-primary-blue hover:!border-primary-blue hover:!text-background-2">
30+
<span>{button.text}</span>
31+
</Button>
32+
</Link>
33+
))}
34+
</div>
35+
</div>
36+
<Image
37+
src={background.url}
38+
alt="Hero Image Background"
39+
fill
40+
className="absolute top-0 left-0 h-full z-[-1] object-cover"
41+
/>
42+
</div>
43+
);
44+
};
45+
46+
export default Hero;

frontend/src/pages/community.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import CommunitiesSection from "@/components/Community/CommunitiesSection";
2+
import Hero from "@/components/Community/hero";
3+
import Footer from "@/components/Footer";
4+
import Navbar from "@/components/Navbar";
5+
import { heroQuery, HeroQueryType } from "@/queries/community/hero";
6+
import { footerQuery, FooterQueryType } from "@/queries/footer";
7+
import { navbarQuery, NavbarQueryType } from "@/queries/navbar";
8+
import { graphQLClient } from "@/utils/graphQLClient";
9+
10+
interface ICommunity {
11+
navbarData: NavbarQueryType;
12+
footerData: FooterQueryType;
13+
heroData: HeroQueryType;
14+
}
15+
16+
const ForBuilders: React.FC<ICommunity> = ({
17+
footerData,
18+
heroData,
19+
navbarData,
20+
}) => {
21+
return (
22+
<div>
23+
<Navbar {...{ navbarData }} />
24+
<Hero heroData={heroData.communityPageHero} />
25+
<CommunitiesSection communities={heroData.communities} />
26+
<Footer {...{ footerData }} />
27+
</div>
28+
);
29+
};
30+
31+
export const getStaticProps = async () => {
32+
const navbarData = await graphQLClient.request<NavbarQueryType>(navbarQuery);
33+
const footerData = await graphQLClient.request<FooterQueryType>(footerQuery);
34+
const heroData = await graphQLClient.request<HeroQueryType>(heroQuery);
35+
36+
return {
37+
props: {
38+
navbarData,
39+
footerData,
40+
heroData: heroData,
41+
},
42+
};
43+
};
44+
45+
export default ForBuilders;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { gql } from "graphql-request";
2+
3+
export type Community = {
4+
title: string;
5+
subtitle: string;
6+
url: string;
7+
icon: {
8+
url: string;
9+
name: string;
10+
}
11+
};
12+
13+
export const heroQuery = gql`
14+
{
15+
communityPageHero {
16+
header
17+
subtitle
18+
communityButtons {
19+
text
20+
link {
21+
url
22+
}
23+
}
24+
background {
25+
url
26+
}
27+
}
28+
communities {
29+
title
30+
subtitle
31+
url
32+
icon {
33+
url
34+
name
35+
}
36+
}
37+
}
38+
`;
39+
40+
export type HeroQueryType = {
41+
communityPageHero: {
42+
header: string;
43+
subtitle: string;
44+
communityButtons: {
45+
text: string;
46+
link: {
47+
url: string;
48+
};
49+
}[];
50+
background: {
51+
url: string;
52+
};
53+
};
54+
communities: Community[]
55+
};

0 commit comments

Comments
 (0)