Skip to content

feat(frontend): brand assets page #54

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

Merged
merged 6 commits into from
Jan 18, 2025
Merged

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Jan 16, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new components for the Brand Assets page: BrandAssets, Hero, LogosPackageSection, KlerosLogoSection, KlerosBadgesSection, KlerosColorsSection, KlerosFontsSection, StyledImagesSection, PnkTokenSection, DownloadButton, and ImageDownload.
    • Implemented GraphQL queries for new sections: heroQuery, logosPackageSectionQuery, klerosLogoSectionQuery, klerosBadgesSectionQuery, klerosColorsSectionQuery, klerosFontsSectionQuery, styledImagesSectionQuery, and pnkTokenSectionQuery.
  • Improvements

    • Enhanced type safety for brand assets queries and components.
    • Added optional chaining in For Builders hero component to prevent potential runtime errors.
  • Changes

    • Removed background field from For Builders hero query and type definition.
    • Updated CtaCard component to allow optional icon property.

@kemuru kemuru changed the title feat: brand assets page hero feat: brand assets page Jan 16, 2025
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Walkthrough

The pull request introduces a new Brand Assets page featuring a BrandAssets component that fetches data via GraphQL queries. It includes the creation of several new React components such as Hero, LogosPackageSection, KlerosLogoSection, DownloadButton, and ImageDownload, each designed to display specific sections of the brand assets. Additionally, it modifies the existing ForBuilders hero component to utilize optional chaining and removes the background field from the relevant GraphQL query and type definition.

Changes

File Change Summary
frontend/src/app/brand-assets/page.tsx Added new BrandAssets React component for fetching and rendering hero data
frontend/src/components/BrandAssets/Hero.tsx Created new Hero component with props for rendering hero section
frontend/src/components/BrandAssets/KlerosLogoSection.tsx Added new KlerosLogoSection component for displaying Kleros logos
frontend/src/components/BrandAssets/LogosPackageSection.tsx Added new LogosPackageSection component for displaying logos package
frontend/src/components/DownloadButton.tsx Introduced new DownloadButton component for file downloads
frontend/src/components/ImageDownload.tsx Created new ImageDownload component for handling image downloads
frontend/src/components/ForBuilders/Hero.tsx Added optional chaining for heroData.arrowLink mapping
frontend/src/queries/brand-assets/hero.tsx Introduced GraphQL query and TypeScript type for Brand Assets hero data
frontend/src/queries/brand-assets/kleros-logo-section.tsx Added GraphQL query and types for Kleros logo section
frontend/src/queries/brand-assets/logos-package-section.tsx Added GraphQL query and types for logos package section
frontend/src/queries/for-builders/hero.tsx Removed background field from query and type definition

Possibly related PRs

  • Feat/earn page #42: The changes in this PR involve the introduction of a new React functional component named Hero, which is directly related to the heroData fetched in the main PR's BrandAssets component. Both components utilize the HeroQueryType for their data structure.
  • Feat/r d page #51: This PR introduces a new ResearchDevelopment component that also fetches heroData using a similar query structure as the main PR. The connection lies in the use of the heroQuery to retrieve data for rendering a hero section.
  • feat(cms): types for brand assets page #53: This PR adds a new content type schema for the brand-assets-page-hero, which aligns with the heroData structure used in the main PR. The schema defines attributes that are likely utilized in the BrandAssets component's rendering logic.

Suggested reviewers

  • Harman-singh-waraich

Poem

🐰 A Rabbit's Ode to Brand New Pages 🎨
With queries sharp and components bright,
Our hero leaps into the digital light.
GraphQL dances, data takes flight,
Brand assets shine, oh what a sight!
Code hops forward with pure delight 🚀


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for kleros-website-v2 ready!

Name Link
🔨 Latest commit 1ba00c0
🔍 Latest deploy log https://app.netlify.com/sites/kleros-website-v2/deploys/678b7ce3b5ae460008352741
😎 Deploy Preview https://deploy-preview-54--kleros-website-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
frontend/src/components/ForBuilders/Hero.tsx (1)

Line range hint 32-45: Add aria-labels and improve accessibility for arrow links.

The arrow links should have proper aria-labels and keyboard navigation support.

           {heroData.arrowLink?.map((arrowLink) => (
             <Link
               key={arrowLink.text}
               href={arrowLink.link.url}
               target="_blank"
               rel="noopener noreferrer"
+              aria-label={`${arrowLink.text} - opens in new tab`}
+              className="inline-flex items-center hover:underline focus:outline-none focus:ring-2 focus:ring-offset-2"
             >
               <span className="mr-2">{arrowLink.text}</span>
               <Image
                 src={LinkArrow}
-                width="24"
-                height="24"
+                width={24}
+                height={24}
                 alt="Arrow link image"
+                aria-hidden="true"
                 className="inline"
               />
             </Link>
           ))}
🧹 Nitpick comments (3)
frontend/src/app/brand-assets/page.tsx (1)

13-13: Simplify props passing syntax.

The object spread syntax is unnecessary here. Directly pass the prop.

-      <Hero {...{ heroData: heroData.brandAssetsPageHero }} />
+      <Hero heroData={heroData.brandAssetsPageHero} />
frontend/src/components/BrandAssets/Hero.tsx (2)

13-40: Consider creating a shared base Hero component.

The Hero component shares significant code with ForBuilders/Hero.tsx. Consider extracting common functionality into a base component to avoid duplication.

Create a new BaseHero component that both heroes can extend:

// components/shared/BaseHero.tsx
interface BaseHeroProps {
  header: string;
  subtitle: string;
  button?: {
    text: string;
    link: {
      url: string;
    };
  };
  background?: {
    url: string;
    alt: string;
  };
  children?: React.ReactNode;
}

const BaseHero: React.FC<BaseHeroProps> = ({
  header,
  subtitle,
  button,
  background,
  children
}) => {
  return (
    <div className="relative px-6 pb-12 pt-32">
      <div className="space-y-6">
        <h1 className="w-min text-3xl">{header}</h1>
        <p className="text-lg">{subtitle}</p>
        {button && (
          <div>
            <Link
              href={button.link.url}
              target="_blank"
              rel="noopener noreferrer"
            >
              <Button variant="secondary">
                <span>{button.text}</span>
              </Button>
            </Link>
          </div>
        )}
        {children}
      </div>
      {background && (
        <Image
          src={background.url}
          alt={background.alt}
          fill
          className="absolute left-0 top-0 z-[-1] object-cover object-left"
        />
      )}
    </div>
  );
};

20-29: Add aria-label to the link for better accessibility.

The link should have an aria-label for better screen reader support.

           <Link
             href={heroData.button?.link?.url}
             target="_blank"
             rel="noopener noreferrer"
+            aria-label={`${heroData.button?.text} - opens in new tab`}
           >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d47f2a and 9fcbd9b.

📒 Files selected for processing (5)
  • frontend/src/app/brand-assets/page.tsx (1 hunks)
  • frontend/src/components/BrandAssets/Hero.tsx (1 hunks)
  • frontend/src/components/ForBuilders/Hero.tsx (1 hunks)
  • frontend/src/queries/brand-assets/hero.tsx (1 hunks)
  • frontend/src/queries/for-builders/hero.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • frontend/src/queries/for-builders/hero.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-website-v2
  • GitHub Check: Header rules - kleros-website-v2
  • GitHub Check: Pages changed - kleros-website-v2

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (1)
frontend/src/app/brand-assets/page.tsx (1)

15-23: ⚠️ Potential issue

Add error handling for GraphQL requests.

The component should handle potential GraphQL request failures gracefully.

 const BrandAssets: React.FC = async () => {
+  try {
     const heroData = await request<HeroQueryType>(heroQuery);
     const logosPackageData = await request<LogosPackageSectionQueryType>(
       logosPackageSectionQuery,
     );
     const klerosLogoSection = await request<KlerosLogoSectionQueryType>(
       klerosLogoSectionQuery,
     );
+  } catch (error) {
+    console.error('Failed to fetch brand assets data:', error);
+    return <div>Failed to load brand assets. Please try again later.</div>;
+  }
🧹 Nitpick comments (8)
frontend/src/queries/brand-assets/kleros-logo-section.tsx (2)

9-11: Consider adding more image metadata.

The image object could benefit from additional metadata fields like dimensions, file size, or aspect ratio to help with optimized rendering and user expectations before download.

 image {
   url
+  width
+  height
+  size
 }

26-33: Add JSDoc comments for better documentation.

Consider adding JSDoc comments to describe the purpose and usage of the ImageDownloadType interface.

+/**
+ * Represents a downloadable image asset with its metadata and download links
+ * @property name - Display name of the image
+ * @property image - Image preview data
+ * @property svgDownloadLink - URL to download SVG version
+ * @property pngDownloadLink - URL to download PNG version
+ */
 export type ImageDownloadType = {
frontend/src/components/BrandAssets/KlerosLogoSection.tsx (1)

13-24: Add semantic HTML structure and loading state.

Consider using semantic HTML elements and handling loading states:

  1. Use section with ARIA label
  2. Add loading state handling
-<div className="relative bg-background-1 px-6 pb-12 pt-32">
+<section 
+  aria-label="Kleros Logo Downloads"
+  className="relative bg-background-1 px-6 pb-12 pt-32"
+>
   <div className="space-y-6">
     <h1 className="max-w-full text-3xl break-words">{klerosLogoData.header}</h1>
     <div className="flex flex-row flex-wrap justify-center gap-8">
       {klerosLogoData.imageDownloads.map((imageDownload) => {
         return (
           <ImageDownload key={imageDownload.name} {...{ imageDownload }} />
         );
       })}
     </div>
   </div>
-</div>
+</section>
frontend/src/components/ImageDownload.tsx (1)

19-24: Simplify conditional rendering.

The conditional rendering of download buttons can be simplified using optional chaining.

-        {imageDownload.svgDownloadLink ? (
-          <DownloadButton name="SVG" url={imageDownload.svgDownloadLink} />
-        ) : null}
-        {imageDownload.pngDownloadLink ? (
-          <DownloadButton name="PNG" url={imageDownload.pngDownloadLink} />
-        ) : null}
+        {imageDownload.svgDownloadLink && 
+          <DownloadButton name="SVG" url={imageDownload.svgDownloadLink} />
+        }
+        {imageDownload.pngDownloadLink && 
+          <DownloadButton name="PNG" url={imageDownload.pngDownloadLink} />
+        }
frontend/src/components/BrandAssets/LogosPackageSection.tsx (2)

21-31: Add aria-label to improve accessibility.

The Link component wrapping the Button should have an aria-label to improve accessibility for screen readers.

 <Link
   href={logosPackageData.button?.link?.url}
   target="_blank"
   rel="noopener noreferrer"
+  aria-label={`Download ${logosPackageData.button?.text}`}
 >

16-16: Consider responsive padding adjustments.

The padding classes could be adjusted for different screen sizes to maintain visual balance.

-    <div className="relative bg-background-2 px-6 pb-12 pt-32">
+    <div className="relative bg-background-2 px-4 sm:px-6 pb-8 sm:pb-12 pt-24 sm:pt-32">
frontend/src/app/brand-assets/page.tsx (2)

16-22: Optimize GraphQL requests using parallel execution.

The sequential GraphQL requests can be optimized using Promise.all for parallel execution.

-  const heroData = await request<HeroQueryType>(heroQuery);
-  const logosPackageData = await request<LogosPackageSectionQueryType>(
-    logosPackageSectionQuery,
-  );
-  const klerosLogoSection = await request<KlerosLogoSectionQueryType>(
-    klerosLogoSectionQuery,
-  );
+  const [heroData, logosPackageData, klerosLogoSection] = await Promise.all([
+    request<HeroQueryType>(heroQuery),
+    request<LogosPackageSectionQueryType>(logosPackageSectionQuery),
+    request<KlerosLogoSectionQueryType>(klerosLogoSectionQuery),
+  ]);

24-34: Add loading states for progressive enhancement.

Consider adding loading states or skeletons while data is being fetched.

+import { Suspense } from 'react';
+import LoadingSkeleton from '@/components/LoadingSkeleton';

 return (
   <>
+    <Suspense fallback={<LoadingSkeleton type="hero" />}>
       <Hero {...{ heroData: heroData.brandAssetsPageHero }} />
+    </Suspense>
+    <Suspense fallback={<LoadingSkeleton type="section" />}>
       <LogosPackageSection
         logosPackageData={logosPackageData.brandAssetsPageLogosPackageSection}
       />
+    </Suspense>
+    <Suspense fallback={<LoadingSkeleton type="section" />}>
       <KlerosLogoSection
         klerosLogoData={klerosLogoSection.brandAssetsPageKlerosLogoSection}
       />
+    </Suspense>
   </>
 );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fcbd9b and 14554dd.

⛔ Files ignored due to path filters (1)
  • frontend/src/assets/svgs/icons/download.svg is excluded by !**/*.svg
📒 Files selected for processing (7)
  • frontend/src/app/brand-assets/page.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosLogoSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/LogosPackageSection.tsx (1 hunks)
  • frontend/src/components/DownloadButton.tsx (1 hunks)
  • frontend/src/components/ImageDownload.tsx (1 hunks)
  • frontend/src/queries/brand-assets/kleros-logo-section.tsx (1 hunks)
  • frontend/src/queries/brand-assets/logos-package-section.tsx (1 hunks)
🔇 Additional comments (2)
frontend/src/components/BrandAssets/LogosPackageSection.tsx (1)

33-37: Verify arrowLink property access.

The code assumes arrowLink and its nested properties always exist, but the type suggests they might be optional. This could cause runtime errors.

frontend/src/components/DownloadButton.tsx (1)

48-54: 🛠️ Refactor suggestion

Improve button accessibility and loading state.

The button needs ARIA attributes and should reflect loading/error states.

 <button
   onClick={handleDownload}
-  className={clsx(primaryStyle, "flex flex-row gap-2")}
+  className={clsx(
+    primaryStyle,
+    "flex flex-row gap-2",
+    isLoading && "opacity-50 cursor-not-allowed"
+  )}
+  disabled={isLoading}
+  aria-busy={isLoading}
+  aria-label={`Download ${name}`}
 >
-  {name}
+  {isLoading ? "Downloading..." : name}
   <Image src={DownloadIcon} alt={name} width="14" height="14" />
+  {error && <span className="text-red-500 text-sm mt-2">{error}</span>}
 </button>

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (14)
frontend/src/queries/brand-assets/kleros-colors-section.tsx (1)

21-23: Consider adding hex color validation.

The hexColor field should be validated to ensure it contains a valid hex color format.

Consider using a more specific type with validation:

type HexColor = `#${string}`;  // Or more strictly: `#${string & { length: 6 }}`;

type ColorCard = {
  name: string;
  hexColor: HexColor;
};
frontend/src/components/BrandAssets/KlerosColorsSection/ColorCard.tsx (1)

10-16: Improve accessibility and maintainability.

A few suggestions for improvement:

  1. Add color contrast check to ensure text is readable against the background color
  2. Consider extracting dimensions to CSS variables for better maintainability
  3. Add ARIA labels for better accessibility

Here's a suggested implementation:

import { useMemo } from "react";
import { getContrastYIQ } from "@/utils/colors"; // You'll need to implement this

const ColorCard: React.FC<IColorCard> = ({ name, hexColor }) => {
  const textColor = useMemo(() => 
    getContrastYIQ(hexColor) ? "text-black" : "text-white"
  , [hexColor]);

  return (
    <div
      className="flex h-[--card-height] w-[--card-width] flex-col items-center justify-center gap-3 rounded-lg shadow-md"
      style={{ 
        backgroundColor: hexColor,
        "--card-height": "200px",
        "--card-width": "380px"
      }}
      role="article"
      aria-label={`Color card for ${name}`}
    >
      <span className={`text-lg ${textColor}`}>{name}</span>
      <span className={textColor}>{hexColor}</span>
    </div>
  );
};
frontend/src/queries/brand-assets/kleros-fonts-section.tsx (1)

7-16: Simplify nested link structure.

The current link structure has unnecessary nesting (link.link.url). This could be simplified for better maintainability.

Consider flattening the structure:

export const klerosFontsSectionQuery = gql`
  {
    brandAssetsPageKlerosFontsSection {
      header
      linkCard {
        title
        subtitle
        linkText
        linkUrl
      }
    }
  }
`;

export type KlerosFontsSectionQueryType = {
  brandAssetsPageKlerosFontsSection: {
    header: string;
    linkCard: {
      title: string;
      subtitle: string;
      linkText: string;
      linkUrl: string;
    };
  };
};

Also applies to: 24-33

frontend/src/queries/brand-assets/kleros-badges-section.tsx (1)

28-35: Enhance type safety for image downloads.

Consider the following improvements:

  1. Add URL validation for download links
  2. Create an enum for supported file types
  3. Make image type more specific

Here's a suggested implementation:

export enum ImageFormat {
  SVG = 'svg',
  PNG = 'png'
}

type ValidUrl = `http${'s' | ''}://${string}`;

export type ImageDownloadType = {
  name: string;
  image: {
    url: ValidUrl;
    width: number;
    height: number;
    alt: string;
  };
  downloads: {
    [format in ImageFormat]: ValidUrl;
  };
};
frontend/src/components/BrandAssets/KlerosFontsSection.tsx (2)

15-15: Use semantic heading levels appropriately

The h1 tag should be used for the main heading of the page. Since this is a section component, consider using h2 or a lower level heading to maintain proper document outline.

-<h1 className="w-min text-3xl">{klerosFontsData.header}</h1>
+<h2 className="w-min text-3xl">{klerosFontsData.header}</h2>

13-13: Add semantic section wrapper

Since this is a distinct section of content, wrap it with a section element and add appropriate ARIA attributes.

-<div className="relative bg-background-1 px-6 pb-12 pt-32">
+<section aria-labelledby="fonts-section-header" className="relative bg-background-1 px-6 pb-12 pt-32">
frontend/src/components/BrandAssets/KlerosColorsSection/index.tsx (2)

20-27: Optimize null checks and add fallback for empty state

The optional chaining on colorCards could be replaced with a more robust null check, and an empty state should be handled explicitly.

-          {klerosColorsData?.colorCards?.map((colorCard) => (
+          {klerosColorsData.colorCards?.length ? (
+            klerosColorsData.colorCards.map((colorCard) => (
             <ColorCard
               key={colorCard.name}
               name={colorCard.name}
               hexColor={colorCard.hexColor}
             />
-          ))}
+            ))
+          ) : (
+            <p>No color cards available</p>
+          )}

15-15: Use semantic heading levels consistently

Similar to the fonts section, use appropriate heading levels for document outline.

-<h1 className="w-min text-3xl">{klerosColorsData.header}</h1>
+<h2 className="w-min text-3xl">{klerosColorsData.header}</h2>
frontend/src/components/CtaCard.tsx (2)

29-36: Enhance Image component configuration

The Next.js Image component should include additional optimization props and better alt text handling.

 <Image
   width={90}
   height={90}
   src={icon.url}
+  quality={90}
+  priority={false}
   className="mb-4 aspect-square object-contain"
-  alt="Icon"
+  alt={`${title} icon`}
 />

27-27: Add ARIA attributes for better accessibility

The card should be more accessible with proper ARIA attributes and role.

-<div className="flex flex-col items-start rounded-2xl border border-stroke bg-background-2 p-6">
+<div 
+  role="article"
+  aria-labelledby="cta-title"
+  className="flex flex-col items-start rounded-2xl border border-stroke bg-background-2 p-6"
+>
frontend/src/components/BrandAssets/KlerosBadgesSection.tsx (2)

15-15: Remove w-min class from header to prevent text truncation.

The w-min class on the header could cause text truncation for longer headers. Consider removing it or using a more flexible width constraint.

-<h1 className="w-min text-3xl">{klerosBadgesData.header}</h1>
+<h1 className="text-3xl">{klerosBadgesData.header}</h1>

22-25: Avoid spreading the entire imageDownload object.

Using the spread operator with imageDownload could pass unnecessary props. Be explicit about which props are needed.

-<ImageDownload
-  key={imageDownload.image.url}
-  {...{ imageDownload }}
-/>
+<ImageDownload
+  key={imageDownload.image.url}
+  image={imageDownload.image}
+  name={imageDownload.name}
+  svgDownloadLink={imageDownload.svgDownloadLink}
+  pngDownloadLink={imageDownload.pngDownloadLink}
+/>
frontend/src/queries/brand-assets/kleros-logo-section.tsx (1)

19-24: Add JSDoc comments and make required fields explicit.

Consider adding documentation and making the type definitions more explicit about required fields.

+/** Type representing the response from the kleros logo section query */
 export type KlerosLogoSectionQueryType = {
   brandAssetsPageKlerosLogoSection: {
     header: string;
     imageDownloads: ImageDownloadType[];
   };
 };

+/** Type representing an image download with optional format-specific download links */
 export type ImageDownloadType = {
   name: string;
   image: {
     url: string;
   };
+  // Optional download links for different formats
   svgDownloadLink?: string;
   pngDownloadLink?: string;
 };

Also applies to: 26-33

frontend/src/app/brand-assets/page.tsx (1)

33-36: Clean up commented code.

Either remove the commented code or add a TODO comment explaining why it's temporarily disabled.

-// import {
-//   pnkTokenSectionQuery,
-//   PnkTokenSectionQueryType,
-// } from "@/queries/brand-assets/pnk-token-section";
-
-// import PnkTokenSection from "@/components/BrandAssets/PnkTokenSection";
+// TODO: PNK token section temporarily disabled - will be enabled in future PR #XX

Also applies to: 40-40, 62-64

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14554dd and 323a1df.

📒 Files selected for processing (14)
  • frontend/src/app/brand-assets/page.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosBadgesSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosColorsSection/ColorCard.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosColorsSection/index.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosFontsSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosLogoSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/LogosPackageSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/StyledImagesSection.tsx (1 hunks)
  • frontend/src/components/CtaCard.tsx (2 hunks)
  • frontend/src/queries/brand-assets/kleros-badges-section.tsx (1 hunks)
  • frontend/src/queries/brand-assets/kleros-colors-section.tsx (1 hunks)
  • frontend/src/queries/brand-assets/kleros-fonts-section.tsx (1 hunks)
  • frontend/src/queries/brand-assets/kleros-logo-section.tsx (1 hunks)
  • frontend/src/queries/brand-assets/styled-images-section.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/BrandAssets/LogosPackageSection.tsx
  • frontend/src/components/BrandAssets/KlerosLogoSection.tsx
🔇 Additional comments (5)
frontend/src/queries/brand-assets/kleros-badges-section.tsx (1)

8-15: Consider adding error states for failed downloads.

The current implementation doesn't handle cases where download links might be invalid or temporarily unavailable.

Run this script to check if all download links are accessible:

frontend/src/queries/brand-assets/styled-images-section.tsx (1)

41-47: Add URL validation for image and download links

The ImageDownloadType should include runtime validation to ensure URLs are properly formatted and point to expected domains.

Consider implementing URL validation or using a validation library. Here's a script to check current URL patterns:

frontend/src/components/BrandAssets/StyledImagesSection.tsx (1)

23-24: Avoid spreading the imageDownload object in both sections.

Similar to the previous component, be explicit about which props are passed to ImageDownload.

-<ImageDownload key={imageDownload.name} {...{ imageDownload }} />
+<ImageDownload
+  key={imageDownload.name}
+  image={imageDownload.image}
+  name={imageDownload.name}
+  svgDownloadLink={imageDownload.svgDownloadLink}
+  pngDownloadLink={imageDownload.pngDownloadLink}
+/>

Also applies to: 37-40

frontend/src/app/brand-assets/page.tsx (2)

66-94: 🛠️ Refactor suggestion

Add loading and error states to the UI.

The component should handle loading and error states gracefully.

+  } catch (error) {
+    console.error('Failed to fetch brand assets data:', error);
+    return (
+      <div className="p-4 text-center">
+        <h1 className="text-xl text-red-500">Failed to load brand assets</h1>
+        <p>Please try again later</p>
+      </div>
+    );
+  }

Likely invalid or redundant comment.


42-65: ⚠️ Potential issue

Add error handling and optimize data fetching.

  1. Add error handling for GraphQL requests
  2. Use Promise.all for parallel requests to improve performance
  3. Remove or document commented code
 const BrandAssets: React.FC = async () => {
-  const heroData = await request<HeroQueryType>(heroQuery);
-  const logosPackageData = await request<LogosPackageSectionQueryType>(
-    logosPackageSectionQuery,
-  );
-  // ... more sequential requests
+  try {
+    const [
+      heroData,
+      logosPackageData,
+      klerosLogoSection,
+      klerosFontsSection,
+      klerosColorsSection,
+      klerosBadgesSection,
+      styledImagesSection,
+    ] = await Promise.all([
+      request<HeroQueryType>(heroQuery),
+      request<LogosPackageSectionQueryType>(logosPackageSectionQuery),
+      request<KlerosLogoSectionQueryType>(klerosLogoSectionQuery),
+      request<KlerosFontsSectionQueryType>(klerosFontsSectionQuery),
+      request<KlerosColorsSectionQueryType>(klerosColorsSectionQuery),
+      request<KlerosBadgesSectionQueryType>(klerosBadgesSectionQuery),
+      request<StyledImagesSectionQueryType>(styledImagesSectionQuery),
+    ]);

Likely invalid or redundant comment.

@kemuru kemuru marked this pull request as ready for review January 17, 2025 12:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
frontend/src/app/brand-assets/page.tsx (1)

40-95: ⚠️ Potential issue

Add error handling for GraphQL requests.

The component should handle potential GraphQL request failures gracefully.

🧹 Nitpick comments (4)
frontend/src/queries/brand-assets/pnk-token-section.tsx (1)

28-35: Consider extracting ImageDownloadType to a shared types file.

The implementation looks clean and well-typed. Since ImageDownloadType might be reused across different sections of the brand assets page, consider moving it to a shared types file.

frontend/src/components/BrandAssets/PnkTokenSection.tsx (1)

16-19: Simplify ImageDownload props and remove unnecessary key.

The component renders a single ImageDownload, making the key prop unnecessary. Also, the spread operator usage could be more explicit.

-          <ImageDownload
-            key={pnkTokenData.imageDownload.name}
-            {...{ imageDownload: pnkTokenData.imageDownload }}
-          />
+          <ImageDownload imageDownload={pnkTokenData.imageDownload} />
frontend/src/app/brand-assets/page.tsx (2)

65-65: Make props passing more explicit.

Avoid props spreading for better code maintainability and readability.

-      <Hero {...{ heroData: heroData.brandAssetsPageHero }} />
+      <Hero heroData={heroData.brandAssetsPageHero} />

1-38: Organize imports for better readability.

Consider grouping related imports together (components, queries, utilities) and sorting them alphabetically within each group.

+// Components
 import Hero from "@/components/BrandAssets/Hero";
 import KlerosBadgesSection from "@/components/BrandAssets/KlerosBadgesSection";
 import KlerosColorsSection from "@/components/BrandAssets/KlerosColorsSection/index";
 import KlerosFontsSection from "@/components/BrandAssets/KlerosFontsSection";
 import KlerosLogoSection from "@/components/BrandAssets/KlerosLogoSection";
 import LogosPackageSection from "@/components/BrandAssets/LogosPackageSection";
 import PnkTokenSection from "@/components/BrandAssets/PnkTokenSection";
 import StyledImagesSection from "@/components/BrandAssets/StyledImagesSection";
 
+// Queries and Types
 import { heroQuery, HeroQueryType } from "@/queries/brand-assets/hero";
 import {
   klerosBadgesSectionQuery,
   KlerosBadgesSectionQueryType,
 } from "@/queries/brand-assets/kleros-badges-section";
 // ... other query imports
 
+// Utilities
 import { request } from "@/utils/graphQLClient";
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 323a1df and 26e7906.

📒 Files selected for processing (3)
  • frontend/src/app/brand-assets/page.tsx (1 hunks)
  • frontend/src/components/BrandAssets/PnkTokenSection.tsx (1 hunks)
  • frontend/src/queries/brand-assets/pnk-token-section.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-website-v2
  • GitHub Check: Header rules - kleros-website-v2
  • GitHub Check: Pages changed - kleros-website-v2

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
frontend/src/app/brand-assets/page.tsx (1)

40-61: 🛠️ Refactor suggestion

⚠️ Potential issue

Add error handling for the GraphQL requests.

The component should handle potential GraphQL request failures gracefully.

Optimize data fetching with Promise.all.

Multiple sequential GraphQL requests can impact page load time. Consider using Promise.all to fetch data concurrently.

🧹 Nitpick comments (4)
frontend/src/queries/brand-assets/pnk-token-section.tsx (1)

20-35: Consider adding field validation constraints.

The types are well-defined, but consider adding validation for the URL fields to ensure they contain valid URLs.

 export type ImageDownloadType = {
   name: string;
   image: {
-    url: string;
+    url: string & { __brand: 'URL' }; // Type branding for URL validation
   };
-  svgDownloadLink?: string;
-  pngDownloadLink?: string;
+  svgDownloadLink?: string & { __brand: 'URL' };
+  pngDownloadLink?: string & { __brand: 'URL' };
 };
frontend/src/components/BrandAssets/PnkTokenSection.tsx (2)

13-14: Add semantic HTML and ARIA attributes for better accessibility.

The heading and paragraph could benefit from improved accessibility.

-        <h1 className="w-min text-3xl">{pnkTokenData.header}</h1>
-        <p className="text-lg text-secondary-text">{pnkTokenData.subtitle}</p>
+        <h1 className="w-min text-3xl" role="heading" aria-level="1">{pnkTokenData.header}</h1>
+        <p className="text-lg text-secondary-text" aria-label="Section subtitle">{pnkTokenData.subtitle}</p>

16-19: Avoid using object spread for component props.

The ImageDownload component props could be more explicitly defined.

-          <ImageDownload
-            key={pnkTokenData.imageDownload.name}
-            {...{ imageDownload: pnkTokenData.imageDownload }}
-          />
+          <ImageDownload
+            key={pnkTokenData.imageDownload.name}
+            imageDownload={pnkTokenData.imageDownload}
+          />
frontend/src/app/brand-assets/page.tsx (1)

65-92: Avoid prop spreading and use explicit prop passing.

The Hero component uses prop spreading which makes it harder to track prop dependencies.

-      <Hero {...{ heroData: heroData.brandAssetsPageHero }} />
+      <Hero heroData={heroData.brandAssetsPageHero} />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 323a1df and 76fbcc2.

📒 Files selected for processing (4)
  • frontend/src/app/brand-assets/page.tsx (1 hunks)
  • frontend/src/components/BrandAssets/PnkTokenSection.tsx (1 hunks)
  • frontend/src/queries/brand-assets/pnk-token-section.tsx (1 hunks)
  • frontend/src/queries/for-builders/hero.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/queries/for-builders/hero.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-website-v2
  • GitHub Check: Header rules - kleros-website-v2
  • GitHub Check: Pages changed - kleros-website-v2
🔇 Additional comments (1)
frontend/src/queries/brand-assets/pnk-token-section.tsx (1)

3-18: LGTM! Well-structured GraphQL query.

The query is well-organized and includes all necessary fields for the PNK token section.

Copy link
Contributor

@tractorss tractorss left a comment

Choose a reason for hiding this comment

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

looks good, left some comments

@kemuru kemuru changed the title feat: brand assets page feat(frontend): brand assets page Jan 18, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
frontend/src/components/BrandAssets/PnkTokenSection.tsx (2)

14-17: Simplify ImageDownload props and remove unnecessary key.

The key prop is unnecessary here as the component isn't rendered in a list. Also, the object spread syntax could be simplified.

-      <ImageDownload
-        key={pnkTokenData.imageDownload.name}
-        {...{ imageDownload: pnkTokenData.imageDownload }}
-      />
+      <ImageDownload imageDownload={pnkTokenData.imageDownload} />

11-11: Consider extracting utility classes into a reusable Tailwind class.

The container div has multiple utility classes that could be extracted into a reusable class in your Tailwind config to maintain consistency across similar sections.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76fbcc2 and 1ba00c0.

📒 Files selected for processing (9)
  • frontend/src/components/BrandAssets/KlerosBadgesSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosColorsSection/ColorCard.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosColorsSection/index.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosFontsSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/KlerosLogoSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/LogosPackageSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/PnkTokenSection.tsx (1 hunks)
  • frontend/src/components/BrandAssets/StyledImagesSection.tsx (1 hunks)
  • frontend/src/components/DownloadButton.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • frontend/src/components/BrandAssets/KlerosColorsSection/ColorCard.tsx
  • frontend/src/components/BrandAssets/KlerosColorsSection/index.tsx
  • frontend/src/components/BrandAssets/KlerosFontsSection.tsx
  • frontend/src/components/BrandAssets/KlerosBadgesSection.tsx
  • frontend/src/components/BrandAssets/LogosPackageSection.tsx
  • frontend/src/components/BrandAssets/KlerosLogoSection.tsx
  • frontend/src/components/BrandAssets/StyledImagesSection.tsx
  • frontend/src/components/DownloadButton.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-website-v2
  • GitHub Check: Header rules - kleros-website-v2
  • GitHub Check: Pages changed - kleros-website-v2
🔇 Additional comments (4)
frontend/src/components/BrandAssets/PnkTokenSection.tsx (4)

1-7: LGTM! Well-structured imports and type definitions.

The imports are properly organized and the interface is well-typed using the GraphQL query type.


22-22: LGTM! Proper component export.

The default export follows React component export conventions.


11-18: Container styles are now justified.

Addressing @Harman-singh-waraich's previous comment: The container div is now necessary as it provides consistent spacing and background for multiple children (header, subtitle, and image download).


12-12: Reconsider using w-min on header.

The w-min class might restrict the header's width unnecessarily, potentially causing text overflow or wrapping issues with longer content.

Let's check if there are any similar headers in the codebase and how they handle width:

@kemuru kemuru merged commit d68d34d into master Jan 18, 2025
5 checks passed
@kemuru kemuru deleted the feat(frontend)/brand-assets-page branch January 18, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants