Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor(frontend): re-structure pages with old structure #91

Open
wants to merge 1 commit into
base: fix(frontend)/apply-feedback-round-1
Choose a base branch
from
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
33 changes: 33 additions & 0 deletions frontend/src/app/brand-assets/components/Badges/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import ImageDownload from "@/components/ImageDownload";

import { IBadgesQuery } from "./queries";

interface IBadges {
badgesData: IBadgesQuery["brandAssetsPageKlerosBadgesSection"];
}

const Badges: React.FC<IBadges> = ({ badgesData }) => {
return (
<div
className={
"relative space-y-8 bg-background-1 px-6 py-12 lg:px-32 lg:py-24"
}
>
<h1 className="text-xl font-medium text-primary-text lg:text-2xl">
{badgesData.header}
</h1>
<p className="pb-4 text-secondary-text lg:pb-8 lg:text-lg">
{badgesData.subtitle}
</p>
<div className="flex flex-row flex-wrap justify-center gap-8 lg:gap-y-16">
{badgesData.imageDownloads.map((imageDownload) => {
return (
<ImageDownload key={imageDownload.image.url} {...imageDownload} />
);
})}
</div>
</div>
);
};

export default Badges;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { gql } from "graphql-request";

export const klerosBadgesSectionQuery = gql`
import { IImageDownload } from "@/components/ImageDownload";

export const badgesQuery = gql`
{
brandAssetsPageKlerosBadgesSection {
header
Expand All @@ -17,19 +19,10 @@ export const klerosBadgesSectionQuery = gql`
}
`;

export type KlerosBadgesSectionQueryType = {
export type IBadgesQuery = {
brandAssetsPageKlerosBadgesSection: {
header: string;
subtitle: string;
imageDownloads: ImageDownloadType[];
};
};

export type ImageDownloadType = {
name: string;
image: {
url: string;
imageDownloads: IImageDownload[];
};
svgDownloadLink: string;
pngDownloadLink: string;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import clsx from "clsx";

interface IColorCard {
name: string;
hexColor: string;
Expand All @@ -8,7 +10,10 @@ interface IColorCard {
const ColorCard: React.FC<IColorCard> = ({ name, hexColor }) => {
return (
<div
className="flex h-[200px] w-[380px] flex-col items-center justify-center gap-3 rounded-2xl shadow-md"
className={clsx(
"flex h-[200px] w-[380px] flex-col items-center justify-center gap-3",
"rounded-2xl shadow-md",
)}
style={{ backgroundColor: hexColor }}
>
<span className="text-lg text-white">{name}</span>
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/app/brand-assets/components/Colors/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import clsx from "clsx";

import ColorCard from "./ColorCard";
import { IColorsQuery } from "./queries";

interface IColors {
colorsData: IColorsQuery["brandAssetsPageKlerosColorsSection"];
}

const KlerosColorsSection: React.FC<IColors> = ({ colorsData }) => {
return (
<div
className={
"relative space-y-8 bg-background-2 px-6 py-12 lg:px-32 lg:py-24"
}
>
<h1 className="text-xl font-medium text-primary-text lg:text-2xl">
{colorsData.header}
</h1>
<p
className={clsx(
"pb-4 text-sm font-medium text-secondary-text",
"lg:pb-8 lg:text-lg lg:font-normal",
)}
>
{colorsData.subtitle}
</p>
<div className="flex flex-row flex-wrap justify-center gap-8">
{colorsData?.colorCards?.map((colorCard) => (
<ColorCard
key={colorCard.name}
name={colorCard.name}
hexColor={colorCard.hexColor}
/>
))}
</div>
</div>
);
};

export default KlerosColorsSection;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from "graphql-request";

export const klerosColorsSectionQuery = gql`
export const colorsQuery = gql`
{
brandAssetsPageKlerosColorsSection {
header
Expand All @@ -13,7 +13,7 @@ export const klerosColorsSectionQuery = gql`
}
`;

export type KlerosColorsSectionQueryType = {
export type IColorsQuery = {
brandAssetsPageKlerosColorsSection: {
header: string;
subtitle: string;
Expand Down
33 changes: 33 additions & 0 deletions frontend/src/app/brand-assets/components/Fonts/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import clsx from "clsx";

import CtaCard from "@/components/CtaCard";

import { IFontsQuery } from "./queries";

interface IFonts {
fontsData: IFontsQuery["brandAssetsPageKlerosFontsSection"];
}

const Fonts: React.FC<IFonts> = ({ fontsData }) => {
return (
<div
className={clsx(
"relative space-y-8 bg-background-1 px-6 pb-12",
"lg:space-y-16 lg:px-32 lg:pb-24 lg:pt-8",
)}
>
<h1 className="text-xl font-medium text-primary-text lg:text-2xl">
{fontsData.header}
</h1>
<CtaCard
className="max-w-[583px] [&>p]:mb-14 [&>p]:text-base"
key={fontsData.linkCard.title}
title={fontsData.linkCard.title}
description={fontsData.linkCard.subtitle}
arrowLink={fontsData.linkCard.link}
/>
Comment on lines +22 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using title as a key and consider more robust styling.

Using the title as a React key can lead to issues if titles change or if you have multiple cards with the same title. Additionally, direct child selectors in styling make the component more brittle to changes in the CtaCard's internal structure.

For the key issue:

<CtaCard
  className="max-w-[583px] [&>p]:mb-14 [&>p]:text-base"
- key={fontsData.linkCard.title}
+ key="fonts-cta-card" // Since there's only one card, a static key is sufficient
  title={fontsData.linkCard.title}
  description={fontsData.linkCard.subtitle}
  arrowLink={fontsData.linkCard.link}
/>

And consider adding a more robust approach to styling by using a specific class name instead of direct child selectors, which would require changes to the CtaCard component as well.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<CtaCard
className="max-w-[583px] [&>p]:mb-14 [&>p]:text-base"
key={fontsData.linkCard.title}
title={fontsData.linkCard.title}
description={fontsData.linkCard.subtitle}
arrowLink={fontsData.linkCard.link}
/>
<CtaCard
className="max-w-[583px] [&>p]:mb-14 [&>p]:text-base"
key="fonts-cta-card" // Since there's only one card, a static key is sufficient
title={fontsData.linkCard.title}
description={fontsData.linkCard.subtitle}
arrowLink={fontsData.linkCard.link}
/>

</div>
);
};

export default Fonts;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from "graphql-request";

export const klerosFontsSectionQuery = gql`
export const fontsQuery = gql`
{
brandAssetsPageKlerosFontsSection {
header
Expand All @@ -18,7 +18,7 @@ export const klerosFontsSectionQuery = gql`
}
`;

export type KlerosFontsSectionQueryType = {
export type IFontsQuery = {
brandAssetsPageKlerosFontsSection: {
header: string;
linkCard: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import React from "react";
import Image from "next/image";

import Button from "@/components/Button";
import { HeroQueryType } from "@/queries/brand-assets/hero";
import CustomLink from "@/components/CustomLink";

import CustomLink from "../CustomLink";
import { IHeroQuery } from "./queries";

interface IHero {
heroData: HeroQueryType["brandAssetsPageHero"];
heroData: IHeroQuery["brandAssetsPageHero"];
}

const Hero: React.FC<IHero> = ({ heroData }) => {
return (
<div className="relative px-6 pb-28 pt-44 md:pt-52 lg:px-32 lg:pb-[302px]">
<div className="space-y-6">
<h1 className="pt-1 text-2xl font-medium text-primary-text lg:pt-3 lg:text-4xl">
<h1
className={
"pt-1 text-2xl font-medium text-primary-text lg:pt-3 lg:text-4xl"
}
>
{heroData.header}
</h1>
<p className="max-w-[685px] text-lg text-primary-text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const heroQuery = gql`
}
`;

export type HeroQueryType = {
export type IHeroQuery = {
brandAssetsPageHero: {
header: string;
subtitle: string;
Expand Down
35 changes: 35 additions & 0 deletions frontend/src/app/brand-assets/components/Logos/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import clsx from "clsx";

import ImageDownload from "@/components/ImageDownload";

import { ILogosQuery } from "./queries";

interface ILogos {
logosData: ILogosQuery["brandAssetsPageKlerosLogoSection"];
}

const Logos: React.FC<ILogos> = ({ logosData }) => {
return (
<div
className={clsx(
"relative space-y-12 bg-background-1 px-6 py-12",
"lg:space-y-16 lg:px-32 lg:py-24",
)}
>
<h1 className="text-xl font-medium text-primary-text lg:text-3xl">
{logosData.header}
</h1>
<div
className={
"flex flex-row flex-wrap justify-center gap-x-8 gap-y-12 lg:gap-y-16"
}
>
{logosData.imageDownloads.map((imageDownload) => {
return <ImageDownload key={imageDownload.name} {...imageDownload} />;
})}
</div>
</div>
);
};

export default Logos;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { gql } from "graphql-request";

export const klerosLogoSectionQuery = gql`
import { IImageDownload } from "@/components/ImageDownload";

export const logosQuery = gql`
{
brandAssetsPageKlerosLogoSection {
header
Expand All @@ -16,18 +18,9 @@ export const klerosLogoSectionQuery = gql`
}
`;

export type KlerosLogoSectionQueryType = {
export type ILogosQuery = {
brandAssetsPageKlerosLogoSection: {
header: string;
imageDownloads: ImageDownloadType[];
};
};

export type ImageDownloadType = {
name: string;
image: {
url: string;
imageDownloads: IImageDownload[];
};
svgDownloadLink?: string;
pngDownloadLink?: string;
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { LogosPackageSectionQueryType } from "@/queries/brand-assets/logos-package-section";
import Button from "@/components/Button";
import CustomLink from "@/components/CustomLink";
import ExternalLink from "@/components/ExternalLink";

import Button from "../Button";
import CustomLink from "../CustomLink";
import ExternalLink from "../ExternalLink";
import { ILogosPackageQuery } from "./queries";

interface ILogosPackageSection {
logosPackageData: LogosPackageSectionQueryType["brandAssetsPageLogosPackageSection"];
logosPackageData: ILogosPackageQuery["brandAssetsPageLogosPackageSection"];
}

const LogosPackageSection: React.FC<ILogosPackageSection> = ({
logosPackageData,
}) => {
return (
<div className="relative space-y-6 bg-background-2 px-6 py-12 lg:px-32 lg:py-24">
<div
className={
"relative space-y-6 bg-background-2 px-6 py-12 lg:px-32 lg:py-24"
}
>
<h1 className="text-xl font-medium text-primary-text lg:text-3xl">
{logosPackageData.header}
</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from "graphql-request";

export const logosPackageSectionQuery = gql`
export const logosPackageQuery = gql`
{
brandAssetsPageLogosPackageSection {
header
Expand All @@ -21,7 +21,7 @@ export const logosPackageSectionQuery = gql`
}
`;

export type LogosPackageSectionQueryType = {
export type ILogosPackageQuery = {
brandAssetsPageLogosPackageSection: {
header: string;
subtitle: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { PnkTokenSectionQueryType } from "@/queries/brand-assets/pnk-token-section";
import clsx from "clsx";

import ImageDownload from "../ImageDownload";
import ImageDownload from "@/components/ImageDownload";

import { IPnkTokenQuery } from "./queries";

interface IPnkTokenSection {
pnkTokenData: PnkTokenSectionQueryType["brandAssetsPagePnkTokenSection"];
pnkTokenData: IPnkTokenQuery["brandAssetsPagePnkTokenSection"];
}

const PnkTokenSection: React.FC<IPnkTokenSection> = ({ pnkTokenData }) => {
return (
<div className="relative space-y-6 bg-background-1 px-6 py-12 lg:space-y-8 lg:px-32 lg:py-24">
<div
className={clsx(
"relative space-y-6 bg-background-1 px-6 py-12",
"lg:space-y-8 lg:px-32 lg:py-24",
)}
>
<h1 className="text-xl font-medium text-primary-text lg:text-3xl">
{pnkTokenData.header}
</h1>
Expand All @@ -17,7 +24,7 @@ const PnkTokenSection: React.FC<IPnkTokenSection> = ({ pnkTokenData }) => {
</p>
<ImageDownload
key={pnkTokenData.imageDownload.name}
{...{ imageDownload: pnkTokenData.imageDownload }}
{...pnkTokenData.imageDownload}
/>
</div>
);
Expand Down
Loading