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

Feat(frontend): add home hero #16

Merged
merged 4 commits into from
Nov 4, 2024
Merged

Conversation

alcercu
Copy link
Collaborator

@alcercu alcercu commented Oct 31, 2024

image

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new Hero component for the homepage, displaying a title, subtitle, and buttons with enhanced styling options.
    • Added a new GraphQL query to fetch hero section data, including buttons and background image.
    • Enhanced image loading capabilities by allowing optimized images from a specified remote source.
  • Bug Fixes

    • Improved button styling with new primary and secondary variants for better visual consistency.
  • Documentation

    • Updated Tailwind CSS configuration to include new font sizes for improved typography.

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Walkthrough

The changes in this pull request introduce several enhancements to a Next.js application. A new image configuration is added to optimize remote images, while a new button component is created with flexible styling options. Additionally, a Hero component is introduced to render a hero section on the home page, utilizing data fetched via a new GraphQL query. The Home component is updated to incorporate this new Hero component, and the Tailwind CSS configuration is modified to include new font size settings.

Changes

File Change Summary
frontend/next.config.mjs Added images property to nextConfig with remotePatterns for a specified remote image source.
frontend/src/components/Button.tsx Introduced a new button component with variant prop for styling; added primaryStyle and secondaryStyle.
frontend/src/components/home/Hero.tsx Added a new Hero component that accepts heroData prop and renders a structured layout with buttons and a background image.
frontend/src/pages/index.tsx Updated Home component to include heroData prop; rendered Hero component and modified getStaticProps to fetch heroData.
frontend/src/queries/home/hero.tsx Introduced heroQuery for fetching hero section data and defined HeroQueryType for type safety.
frontend/tailwind.config.ts Added new fontSize configuration with specified sizes and line heights for various categories.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Home
    participant Hero
    participant GraphQL

    User->>Home: Request Home Page
    Home->>GraphQL: Fetch heroData
    GraphQL-->>Home: Return heroData
    Home->>Hero: Render Hero Component with heroData
    Hero-->>User: Display Hero Section
Loading

🐰 "In the garden where changes bloom,
A hero rises, dispelling gloom.
With buttons bright and styles anew,
Our app now shines, a vibrant view!
Remote images dance with grace,
In this lovely, digital space!" 🌼


🪧 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 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 Oct 31, 2024

Deploy Preview for kleros-website-v2 ready!

Name Link
🔨 Latest commit bfbfe38
🔍 Latest deploy log https://app.netlify.com/sites/kleros-website-v2/deploys/6728a169f0924e0008a5a85c
😎 Deploy Preview https://deploy-preview-16--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.

@alcercu alcercu requested a review from kemuru October 31, 2024 14:07
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: 7

🧹 Outside diff range and nitpick comments (4)
frontend/src/components/Button.tsx (2)

27-36: Consider simplifying the className composition

The current implementation is correct, but the className composition could be more concise.

-    className={
-        clsx(variant === "primary" ? primaryStyle : secondaryStyle, className)
-      }
+    className={clsx(
+      variant === "primary" ? primaryStyle : secondaryStyle,
+      className
+    )}

19-25: Consider extending button functionality for common use cases

As this appears to be a foundational button component, consider adding these commonly needed features:

  1. type prop for form submission control (submit, button, reset)
  2. disabled state handling
  3. Loading state for async operations
  4. Icon support (left/right)

Example interface extension:

interface IButton {
  children: React.ReactNode;
  onClick?: () => void;
  variant?: "primary" | "secondary";
  className?: string;
  type?: "button" | "submit" | "reset";
  disabled?: boolean;
  isLoading?: boolean;
  leftIcon?: React.ReactNode;
  rightIcon?: React.ReactNode;
}
frontend/src/pages/index.tsx (1)

18-18: Consider more explicit prop passing.

While {...{ heroData }} works, direct prop passing would be more readable.

-      <Hero {...{ heroData }} />
+      <Hero heroData={heroData} />
frontend/src/components/home/Hero.tsx (1)

1-12: Consider organizing imports and improving interface name

Consider organizing imports into groups (external/internal) and using a more descriptive interface name like IHeroProps or HeroProps to better indicate its purpose as props interface.

 import React from "react";
-
 import Image from "next/image";
 import Link from "next/link";

+import Button from "@/components/Button";
 import LinkArrow from "@/assets/svgs/icons/link-arrow.svg"
-import Button from "@/components/Button";
 import { HeroQueryType } from "@/queries/home/hero"

-interface IHero {
+interface HeroProps {
   heroData: HeroQueryType["homePageHero"];
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 72a546f and 2aea58f.

⛔ Files ignored due to path filters (1)
  • frontend/src/assets/svgs/icons/link-arrow.svg is excluded by !**/*.svg
📒 Files selected for processing (6)
  • frontend/next.config.mjs (1 hunks)
  • frontend/src/components/Button.tsx (1 hunks)
  • frontend/src/components/home/Hero.tsx (1 hunks)
  • frontend/src/pages/index.tsx (2 hunks)
  • frontend/src/queries/home/hero.tsx (1 hunks)
  • frontend/tailwind.config.ts (1 hunks)
🔇 Additional comments (10)
frontend/next.config.mjs (2)

4-11: LGTM! Secure image configuration.

The configuration properly restricts remote images to HTTPS protocol and a specific hostname, following Next.js security best practices.


8-8: Verify if this is the production Strapi hostname.

The hostname "delicate-eggs-595f0e58b8.media.strapiapp.com" appears to be an auto-generated development URL. Please confirm if this is the correct production hostname to avoid deployment issues.

frontend/src/components/Button.tsx (2)

23-23: LGTM! Well-typed interface extension

The variant prop is properly typed with a union type, making it type-safe and self-documenting.


5-17: ⚠️ Potential issue

Consider accessibility improvements for button styles

While the styling structure is well-organized, there are potential accessibility concerns:

  1. No explicit text color is defined, which could lead to poor contrast ratios
  2. The secondary button's transparent background might not provide sufficient contrast in all contexts

Consider adding these improvements:

 const baseStyle = clsx("px-8 py-2 rounded-full transition duration-75");

 const primaryStyle = clsx(
   baseStyle,
   "bg-primary-blue",
+  "text-white",
   "hover:bg-primary-blue/90"
 );

 const secondaryStyle = clsx(
   baseStyle,
   "bg-transparent border-2 border-white",
+  "text-white",
   "hover:bg-white/10"
 );
frontend/tailwind.config.ts (1)

10-17: Verify the larger font sizes in responsive layouts.

The font size configuration follows good practices with rem units and appropriate line heights. However, the larger sizes (especially 4xl at 6rem/96px) should be tested across different viewport sizes.

Let's verify the usage of these large font sizes:

frontend/src/queries/home/hero.tsx (2)

1-1: LGTM!

Clean and focused import statement.


33-59: 🛠️ Refactor suggestion

Consider improving type safety and reusability.

  1. Extract the button type to reduce duplication
  2. Consider URL validation for security

Here's a suggested refactor:

+type ButtonType = {
+  text: string;
+  link: {
+    url: string;
+  };
+};
+
 export type HeroQueryType = {
   homePageHero: {
     title: string;
     subtitle: string;
-    primaryButton: {
-      text: string;
-      link: {
-        url: string;
-      };
-    };
-    secondaryButton: {
-      text: string;
-      link: {
-        url: string;
-      };
-    };
-    arrowLink: {
-      text: string;
-      link: {
-        url: string;
-      };
-    };
+    primaryButton: ButtonType;
+    secondaryButton: ButtonType;
+    arrowLink: ButtonType;
     background: {
       url: string;
     };
   };
 };

Let's verify if URL validation is implemented elsewhere:

frontend/src/pages/index.tsx (3)

2-2: LGTM: Imports are well-organized.

The new imports follow the project's conventions and are logically grouped.

Also applies to: 5-5


12-12: LGTM: Type-safe interface extension.

Good use of index access type to ensure type safety with the GraphQL response.


15-15: LGTM: Component signature properly updated.

The signature correctly reflects the interface changes and follows React best practices.

frontend/tailwind.config.ts Show resolved Hide resolved
frontend/src/queries/home/hero.tsx Show resolved Hide resolved
frontend/src/queries/home/hero.tsx Show resolved Hide resolved
frontend/src/pages/index.tsx Show resolved Hide resolved
frontend/src/components/home/Hero.tsx Show resolved Hide resolved
frontend/src/components/home/Hero.tsx Show resolved Hide resolved
frontend/src/components/home/Hero.tsx Show resolved Hide resolved
@alcercu alcercu merged commit 5950a82 into master Nov 4, 2024
1 check was pending
@alcercu alcercu deleted the feat(frontend)/add-home-hero branch November 4, 2024 10:27
This was referenced Nov 5, 2024
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