Skip to content

Commit 14554dd

Browse files
committed
feat: add imagedownload, downloadbutton, kleroslogosection, logospackagesection components
1 parent 9fcbd9b commit 14554dd

File tree

8 files changed

+265
-4
lines changed

8 files changed

+265
-4
lines changed

frontend/src/app/brand-assets/page.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
import Hero from "@/components/BrandAssets/Hero";
2-
// import TabSection from "@/components/BrandAssets/TabSection";
2+
import KlerosLogoSection from "@/components/BrandAssets/KlerosLogoSection";
3+
import LogosPackageSection from "@/components/BrandAssets/LogosPackageSection";
34
import { heroQuery, HeroQueryType } from "@/queries/brand-assets/hero";
4-
// import { tabSectionQuery, TabSectionQueryType } from "@/queries/brand-assets/tabs-data";
5+
import {
6+
klerosLogoSectionQuery,
7+
KlerosLogoSectionQueryType,
8+
} from "@/queries/brand-assets/kleros-logo-section";
9+
import {
10+
logosPackageSectionQuery,
11+
LogosPackageSectionQueryType,
12+
} from "@/queries/brand-assets/logos-package-section";
513
import { request } from "@/utils/graphQLClient";
614

715
const BrandAssets: React.FC = async () => {
816
const heroData = await request<HeroQueryType>(heroQuery);
9-
// const tabsData = await request<TabSectionQueryType>(tabSectionQuery);
17+
const logosPackageData = await request<LogosPackageSectionQueryType>(
18+
logosPackageSectionQuery,
19+
);
20+
const klerosLogoSection = await request<KlerosLogoSectionQueryType>(
21+
klerosLogoSectionQuery,
22+
);
1023

1124
return (
1225
<>
1326
<Hero {...{ heroData: heroData.brandAssetsPageHero }} />
14-
{/* <TabSection {...{ tabsData }} /> */}
27+
<LogosPackageSection
28+
logosPackageData={logosPackageData.brandAssetsPageLogosPackageSection}
29+
/>
30+
<KlerosLogoSection
31+
klerosLogoData={klerosLogoSection.brandAssetsPageKlerosLogoSection}
32+
/>
1533
</>
1634
);
1735
};
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { KlerosLogoSectionQueryType } from "@/queries/brand-assets/kleros-logo-section";
2+
3+
import ImageDownload from "../ImageDownload";
4+
5+
interface IKlerosLogoSection {
6+
klerosLogoData: KlerosLogoSectionQueryType["brandAssetsPageKlerosLogoSection"];
7+
}
8+
9+
const KlerosLogoSection: React.FC<IKlerosLogoSection> = ({
10+
klerosLogoData,
11+
}) => {
12+
return (
13+
<div className="relative bg-background-1 px-6 pb-12 pt-32">
14+
<div className="space-y-6">
15+
<h1 className="w-min text-3xl">{klerosLogoData.header}</h1>
16+
<div className="flex flex-row flex-wrap justify-center gap-8">
17+
{klerosLogoData.imageDownloads.map((imageDownload) => {
18+
return (
19+
<ImageDownload key={imageDownload.name} {...{ imageDownload }} />
20+
);
21+
})}
22+
</div>
23+
</div>
24+
</div>
25+
);
26+
};
27+
28+
export default KlerosLogoSection;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Link from "next/link";
2+
3+
import { LogosPackageSectionQueryType } from "@/queries/brand-assets/logos-package-section";
4+
5+
import Button from "../Button";
6+
import ExternalLink from "../ExternalLink";
7+
8+
interface ILogosPackageSection {
9+
logosPackageData: LogosPackageSectionQueryType["brandAssetsPageLogosPackageSection"];
10+
}
11+
12+
const LogosPackageSection: React.FC<ILogosPackageSection> = ({
13+
logosPackageData,
14+
}) => {
15+
return (
16+
<div className="relative bg-background-2 px-6 pb-12 pt-32">
17+
<div className="space-y-6">
18+
<h1 className="w-min text-3xl">{logosPackageData.header}</h1>
19+
<p className="text-lg">{logosPackageData.subtitle}</p>
20+
<div>
21+
<Link
22+
href={logosPackageData.button?.link?.url}
23+
target="_blank"
24+
rel="noopener noreferrer"
25+
>
26+
<Button variant="primary">
27+
<span className="text-background-2">
28+
{logosPackageData.button?.text}
29+
</span>
30+
</Button>
31+
</Link>
32+
</div>
33+
<ExternalLink
34+
url={logosPackageData.arrowLink.link.url}
35+
text={logosPackageData.arrowLink.text}
36+
className="z-[1] flex-wrap"
37+
/>
38+
</div>
39+
</div>
40+
);
41+
};
42+
43+
export default LogosPackageSection;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"use client";
2+
3+
import React from "react";
4+
5+
import clsx from "clsx";
6+
import Image from "next/image";
7+
8+
import DownloadIcon from "@/assets/svgs/icons/download.svg";
9+
10+
const baseStyle = clsx("px-4 py-1 rounded transition duration-75");
11+
12+
const primaryStyle = clsx(
13+
baseStyle,
14+
"bg-primary-blue",
15+
"hover:bg-primary-blue/90",
16+
"disabled:bg-stroke",
17+
"text-background-2",
18+
);
19+
20+
interface IDownloadButton {
21+
name: string;
22+
url: string;
23+
}
24+
25+
const DownloadButton: React.FC<IDownloadButton> = ({ name, url }) => {
26+
const handleDownload = async () => {
27+
try {
28+
const response = await fetch(url);
29+
if (!response.ok) throw new Error("Failed to fetch the file.");
30+
31+
const blob = await response.blob();
32+
const blobUrl = window.URL.createObjectURL(blob);
33+
const filename = url.split("/").pop() || "download";
34+
35+
const link = Object.assign(document.createElement("a"), {
36+
href: blobUrl,
37+
download: filename,
38+
});
39+
40+
link.click();
41+
window.URL.revokeObjectURL(blobUrl);
42+
} catch (error) {
43+
console.error("Error downloading the file:", error);
44+
}
45+
};
46+
47+
return (
48+
<button
49+
onClick={handleDownload}
50+
className={clsx(primaryStyle, "flex flex-row gap-2")}
51+
>
52+
{name}
53+
<Image src={DownloadIcon} alt={name} width="14" height="14" />
54+
</button>
55+
);
56+
};
57+
58+
export default DownloadButton;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react";
2+
3+
import Image from "next/image";
4+
5+
import { ImageDownloadType } from "@/queries/brand-assets/kleros-logo-section";
6+
7+
import DownloadButton from "./DownloadButton";
8+
9+
interface IImageDownload {
10+
imageDownload: ImageDownloadType;
11+
}
12+
13+
const ImageDownload: React.FC<IImageDownload> = ({ imageDownload }) => {
14+
return (
15+
<div className="flex flex-col gap-4">
16+
<Image src={imageDownload.image.url} alt="" width="378" height="200" />
17+
<div className="flex flex-row items-center gap-4">
18+
<span>{imageDownload.name}</span>
19+
{imageDownload.svgDownloadLink ? (
20+
<DownloadButton name="SVG" url={imageDownload.svgDownloadLink} />
21+
) : null}
22+
{imageDownload.pngDownloadLink ? (
23+
<DownloadButton name="PNG" url={imageDownload.pngDownloadLink} />
24+
) : null}
25+
</div>
26+
</div>
27+
);
28+
};
29+
export default ImageDownload;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { gql } from "graphql-request";
2+
3+
export const klerosLogoSectionQuery = gql`
4+
{
5+
brandAssetsPageKlerosLogoSection {
6+
header
7+
imageDownloads {
8+
name
9+
image {
10+
url
11+
}
12+
svgDownloadLink
13+
pngDownloadLink
14+
}
15+
}
16+
}
17+
`;
18+
19+
export type KlerosLogoSectionQueryType = {
20+
brandAssetsPageKlerosLogoSection: {
21+
header: string;
22+
imageDownloads: ImageDownloadType[];
23+
};
24+
};
25+
26+
export type ImageDownloadType = {
27+
name: string;
28+
image: {
29+
url: string;
30+
};
31+
svgDownloadLink: string;
32+
pngDownloadLink: string;
33+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { gql } from "graphql-request";
2+
3+
export const logosPackageSectionQuery = gql`
4+
{
5+
brandAssetsPageLogosPackageSection {
6+
header
7+
subtitle
8+
button {
9+
text
10+
link {
11+
url
12+
}
13+
}
14+
arrowLink {
15+
text
16+
link {
17+
url
18+
}
19+
}
20+
}
21+
}
22+
`;
23+
24+
export type LogosPackageSectionQueryType = {
25+
brandAssetsPageLogosPackageSection: {
26+
header: string;
27+
subtitle: string;
28+
button: {
29+
text: string;
30+
link: {
31+
url: string;
32+
};
33+
};
34+
arrowLink: {
35+
text: string;
36+
link: {
37+
name: string;
38+
url: string;
39+
};
40+
};
41+
};
42+
};

0 commit comments

Comments
 (0)