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 Home page and replace current index /quests #962

Merged
merged 22 commits into from
Nov 28, 2024

Conversation

baitcode
Copy link
Contributor

@baitcode baitcode commented Nov 24, 2024

Task list

  • Create new directory app/quests
  • Move current app/page.tsx to app/quests/page.tsx
  • Create new app/page.tsx for the landing page
  • Update navbar links to point to new /quests route
  • Create new components for landing page sections:
    • Hero section
      ❌ Features grid
    • Call-to-action section
  • Implement responsive design following Figma specs
  • Add animations and transitions as shown in design
  • Ensure proper image optimization for new assets
  • remove TODO(baitcode)

Testing

  • Test all navigation flows
  • Verify responsive behavior
  • Check accessibility
  • Ensure no broken links

Fixed dependency resolution problem

Moved old page, created new one.
Added animation library Motion.
Implemented requested effect. To implement effect I had to cut svg's, as I don't have an expensive software I came up with the idea to use svg's clip-path functionality, and generated clip-paths for every svg.

Other information

Script for split generation: GIST

Summary by CodeRabbit

  • New Features
    • Introduced a new user interface for displaying quests, including a featured quest banner and navigation options.
    • Added components for quests and categories, statistics display, and user participation guidance.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new Page component for displaying quests, featuring a banner, tabs, and statistics.
    • Added CallToAction, Card, Hero, and SplitTitle components for enhanced user interaction and visual appeal.
  • UI Enhancements

    • Updated the Navbar with a new "DeFi" link and improved notification handling.
    • Enhanced styling and responsiveness across various components, including cards and navbar.
  • Bug Fixes

    • Updated import paths for wallet-related functions to ensure compatibility with new modules.
  • Chores

    • Updated package dependencies and Tailwind CSS configuration for improved performance and styling capabilities.

Copy link

vercel bot commented Nov 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 5:55pm

Copy link

vercel bot commented Nov 24, 2024

@baitcode is attempting to deploy a commit to the LFG Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Nov 24, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces a new Page component in app/quests/page.tsx to display quests and related information, utilizing context data and navigation hooks. The existing app/page.tsx has been modified to remove quest-related imports and simplify its layout while enhancing navigation. New components such as CallToAction, Card, Hero, and SplitTitle have been created to structure the landing page. Additionally, the Navbar component has been updated to reflect navigation changes, and various CSS modules have been added or modified to support the new design.

Changes

File Path Change Summary
app/quests/page.tsx Added new Page component to display quests with context data and navigation features.
app/page.tsx Removed quest-related imports, simplified layout, and updated navigation logic with new callbacks.
components/UI/navbar.tsx Updated logo size, changed "Quests" link to "DeFi", and refined notification logic.
components/pages/home/callToAction.tsx Introduced CallToAction component for flexible layout.
components/pages/home/card.tsx Created Card component for displaying quest cards with image and title.
components/pages/home/hero.tsx Added Hero component for the landing page title and description.
components/pages/home/splitTitle.tsx Introduced SplitTitle component for animated SVG titles.
package.json Updated dependencies, added new libraries, and removed outdated packages.
styles/components/navbar.module.css Modified navbar styles for responsiveness and visual updates.
styles/components/pages/home/card.module.css Added styles for the new Card component.
styles/components/pages/home/hero.module.css Added styles for the new Hero component.
styles/components/pages/home/splittitle.module.css Created styles for the new SplitTitle component.
tailwind.config.js Extended configuration to add a custom line height.
components/UI/changeWallet.tsx Updated import path for getDiscoveryWallets function.
hooks/useGetDiscoveryWallets.ts Updated import path for WalletProvider.

Assessment against linked issues

Objective Addressed Explanation
Create new index page and move current app/page.tsx to app/quests/page.tsx (951)
Update navbar links to point to new /quests route (951)
Create new components for landing page sections (951)
Implement responsive design following Figma specs (951)
Add animations and transitions as shown in design (951) No specific animations or transitions implemented.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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
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: 3

🧹 Outside diff range and nitpick comments (1)
app/quests/page.tsx (1)

52-58: Consider making statistics dynamic.

The statistics are currently hardcoded. These values should ideally be fetched from an API or provided through context to ensure they stay up-to-date.

-<Stats
-  stats={[
-    { name: "Quests NFT minted", value: "+1M" },
-    { name: "Unique addresses", value: "398K" },
-    { name: "Unique visitors", value: "+200K" },
-  ]}
-/>
+<Stats stats={statsFromContext} />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 41254de and 3334b86.

📒 Files selected for processing (1)
  • app/quests/page.tsx (1 hunks)
🔇 Additional comments (2)
app/quests/page.tsx (2)

1-12: LGTM! Clean imports with proper client-side directive.

The imports are well-organized and the "use client" directive is correctly placed at the top of the file.


19-23: LGTM! Clean layout structure with proper styling.

The layout is well-organized with appropriate use of CSS modules and decorative elements (Blur components).

Also applies to: 59-61

app/quests/page.tsx Show resolved Hide resolved
app/quests/page.tsx Show resolved Hide resolved
app/quests/page.tsx Show resolved Hide resolved
- added new card component, header and split header
- implemented style
- fixed css for navbar
- added card images
- added cut word for split effect
- extended tailwinf with padding needed (should not be doing this, but realized too late that tailwind is conflicting)
Implemented EARN animation
* removed TODO
* implemented animations
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: 3

🧹 Outside diff range and nitpick comments (2)
components/pages/home/splitTitle.tsx (2)

351-357: Enhance type documentation with JSDoc comments

While the type properties have inline comments, using JSDoc would provide better IDE support and documentation generation.

 type SplitTitleProps = {
+  /** Additional class for component container */
   className?: string;
+  /** Value in pixels identifying the radius of splits to fly around */
   spread?: number;
+  /** Amount of seconds fade duration will take */
   fadeDuration?: number;
+  /** Child staggering amount (small timeout before every children that offsets animation start) */
   stagger?: number;
+  /** Amount of seconds between fadeIn animation finish and fadeOut animation start */
   interval?: number;
 };

21-349: Consider code-splitting SVG constants

The SVG constants contain large amounts of path data which could impact initial bundle size. Consider moving these to a separate file and potentially lazy-loading them.

You could:

  1. Move the SVG data to a separate file (e.g., splitTitlePaths.ts)
  2. Use dynamic imports to load the paths when needed
  3. Show a simpler placeholder during the loading state
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9b0e9a4 and 6c559bb.

📒 Files selected for processing (1)
  • components/pages/home/splitTitle.tsx (1 hunks)
🔇 Additional comments (2)
components/pages/home/splitTitle.tsx (2)

394-403: Add missing dependency array to useEffect

This issue was already identified in a past review comment. The useEffect hook is missing a dependency array, which can cause unnecessary re-renders and multiple timeouts.


373-392: Use consistent random values for animations

This issue was already identified in a past review comment. Using Math.random() directly in the variants can cause unpredictable animations and make testing difficult.

components/pages/home/splitTitle.tsx Show resolved Hide resolved
components/pages/home/splitTitle.tsx Outdated Show resolved Hide resolved
components/pages/home/splitTitle.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

Have a look at AI suggestion, Code doesn't compile, please make sure it compiles before sending the PR

app/page.tsx Outdated

return (
<div className={styles.screen}>
<div className={styles.container}>
<div className={`flex flex-col items-center justify-center`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

delete {``} to use ""

components/UI/navbar.tsx Outdated Show resolved Hide resolved
components/UI/navbar.tsx Show resolved Hide resolved
splits: Array<ClipPath> // Polygon ClipPaths describing shattered shapes
}

const svgAttributes: Record<string, SvgSettings> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

To add in another file as an SVG to /icons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pardon. I do not understand what are you trying to say.

@fricoben fricoben added the ❌ Change request Change requested from reviewer label Nov 27, 2024
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

🧹 Outside diff range and nitpick comments (9)
components/pages/home/card.tsx (1)

7-13: Add JSDoc documentation for the CardProps type.

Consider adding JSDoc documentation to improve code maintainability and IDE support.

+/**
+ * Props for the Card component
+ * @property {React.ReactNode} children - Child elements to render inside the card
+ * @property {string} imgSrc - URL of the card's background image
+ * @property {string} title - Title text for the card
+ * @property {() => void} onClick - Click handler function
+ * @property {boolean} [disabled] - Whether the card is disabled
+ */
 type CardProps = {
   children: React.ReactNode;
   imgSrc: string;
   title: string;
   onClick: () => void;
   disabled?: boolean;
 };
eslint.config.mjs (2)

24-27: Reconsider globally disabled Next.js rules

Disabling @next/next/no-img-element globally might lead to accessibility and performance issues. Consider:

  1. Using next/image for optimized images
  2. Only disabling these rules in specific files where necessary
 rules: {
-    "@next/next/no-img-element": "off",
+    "@next/next/no-img-element": "warn", // Consider enabling and fixing issues
     "@next/next/no-document-import-in-page": "off",
 },

1-41: Consider adding modern ESLint features

The configuration could benefit from these modern ESLint features:

  1. Explicit file ignores
  2. Linting performance optimization
+// Add at the beginning of the configuration array
+{
+    ignores: [
+        '**/node_modules/**',
+        '**/dist/**',
+        '**/build/**',
+        '**/.next/**'
+    ]
+},
+{
+    linterOptions: {
+        reportUnusedDisableDirectives: true,
+        noInlineConfig: true
+    }
+},
components/pages/home/hero.tsx (2)

1-1: Remove unused import.

The FunctionComponent type is imported but never used since the component uses React.FC.

-import React, { FunctionComponent } from "react";
+import React from "react";
🧰 Tools
🪛 eslint

[error] 1-1: 'FunctionComponent' is defined but never used.

(@typescript-eslint/no-unused-vars)


23-23: Escape the apostrophe in the text content.

The apostrophe in "Starknet's" should be escaped to ensure consistent rendering across different environments.

-        for individuals, DAOs, and protocols to grow their assets and explore Starknet's
+        for individuals, DAOs, and protocols to grow their assets and explore Starknet&apos;s
🧰 Tools
🪛 eslint

[error] 23-23: ' can be escaped with &apos;, &lsquo;, &#39;, &rsquo;.

(react/no-unescaped-entities)

hooks/useGetDiscoveryWallets.ts (2)

Line range hint 4-42: Add error handling and improve type safety

The current implementation has several areas that could be improved:

  1. Error handling for the Promise
  2. Type safety for browser-specific downloads
  3. Loading state management

Consider applying these improvements:

 export default function useGetDiscoveryWallets(
   getDiscoveryWallets: Promise<WalletProvider[]>
 ) {
   const [argentX, setArgentX] = useState<string>("");
   const [braavos, setBraavos] = useState<string>("");
   const [bitkeep, setBitkeep] = useState<string>("");
+  const [isLoading, setIsLoading] = useState(true);
+  const [error, setError] = useState<Error | null>(null);
 
   useEffect(() => {
     if (typeof navigator !== "undefined") {
-      getDiscoveryWallets.then((wallets) => {
-        const browser = getBrowser(navigator.userAgent);
+      setIsLoading(true);
+      getDiscoveryWallets
+        .then((wallets) => {
+          const browser = getBrowser(navigator.userAgent);
+          if (!browser) {
+            throw new Error("Unsupported browser detected");
+          }
 
-        wallets.map((wallet) => {
-          if (wallet.id === "argentX") {
-            setArgentX(
-              browser
-                ? wallet.downloads[browser as keyof typeof wallet.downloads]
-                : "https://www.argent.xyz/argent-x/"
-            );
-          } else if (wallet.id === "braavos") {
-            setBraavos(
-              browser
-                ? wallet.downloads[browser as keyof typeof wallet.downloads]
-                : "https://braavos.app/download-braavos-wallet/"
-            );
-          } else if (wallet.id === "bitkeep") {
-            setBitkeep(
-              browser
-                ? wallet.downloads[browser as keyof typeof wallet.downloads]
-                : "https://web3.bitget.com/en/wallet-download"
-            );
-          }
-        });
-      });
+          wallets.forEach((wallet) => {
+            const downloads = wallet.downloads;
+            if (!downloads || !(browser in downloads)) {
+              throw new Error(`No download URL found for ${wallet.id} on ${browser}`);
+            }
+            
+            switch (wallet.id) {
+              case "argentX":
+                setArgentX(downloads[browser] ?? "https://www.argent.xyz/argent-x/");
+                break;
+              case "braavos":
+                setBraavos(downloads[browser] ?? "https://braavos.app/download-braavos-wallet/");
+                break;
+              case "bitkeep":
+                setBitkeep(downloads[browser] ?? "https://web3.bitget.com/en/wallet-download");
+                break;
+            }
+          });
+        })
+        .catch((err) => {
+          setError(err);
+          console.error("Failed to fetch wallet information:", err);
+        })
+        .finally(() => {
+          setIsLoading(false);
+        });
     }
   }, [getDiscoveryWallets]);
 
-  return { argentX, braavos, bitkeep };
+  return { argentX, braavos, bitkeep, isLoading, error };

Line range hint 4-42: Consider extracting configuration to a separate file

The hardcoded fallback URLs should be moved to a configuration file to improve maintainability.

Create a new configuration file config/wallets.ts:

export const WALLET_CONFIGS = {
  argentX: {
    defaultUrl: "https://www.argent.xyz/argent-x/",
    id: "argentX"
  },
  braavos: {
    defaultUrl: "https://braavos.app/download-braavos-wallet/",
    id: "braavos"
  },
  bitkeep: {
    defaultUrl: "https://web3.bitget.com/en/wallet-download",
    id: "bitkeep"
  }
} as const;

Then update the hook to use these configurations.

app/page.tsx (1)

15-22: Consider consolidating navigation handlers.

The navigation handlers could be consolidated into a single reusable function to reduce code duplication.

Here's a suggested implementation:

-  const handleNavigateToDefi = useCallback(() => {
-    router.push("/discover/defi");
-  }, [router]);
-
-  const handleNavigateToQuests = useCallback(() => {
-    router.push("/quests");
-  }, [router]);
+  const handleNavigate = useCallback((path: string) => {
+    router.push(path);
+  }, [router]);

Then update the onClick handlers:

onClick={() => handleNavigate("/discover/defi")}
onClick={() => handleNavigate("/quests")}
components/pages/home/splitTitle.tsx (1)

396-396: Use 'const' instead of 'let' for 'timeout' variable

The variable timeout is never reassigned after its initial declaration. Using const instead of let signals that this variable should not change, improving code readability and maintainability.

Apply this diff to fix the issue:

@@ -396,7 +396,7 @@
   // This effects allow for initial interval timeout
-  let timeout = setTimeout(() => {
+  const timeout = setTimeout(() => {
     setFirstLaunch(false);
   }, interval * 1000);

@@ -422,7 +422,7 @@
   } else {
-    let timeout = setTimeout(() => setVisible(true), interval * 1000)
+    const timeout = setTimeout(() => setVisible(true), interval * 1000)
     return () => { window.clearTimeout(timeout) };
   }

Also applies to: 422-422

🧰 Tools
🪛 eslint

[error] 396-396: 'timeout' is never reassigned. Use 'const' instead.

(prefer-const)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6c559bb and 5c2f170.

📒 Files selected for processing (8)
  • app/page.tsx (1 hunks)
  • components/UI/changeWallet.tsx (1 hunks)
  • components/UI/navbar.tsx (2 hunks)
  • components/pages/home/card.tsx (1 hunks)
  • components/pages/home/hero.tsx (1 hunks)
  • components/pages/home/splitTitle.tsx (1 hunks)
  • eslint.config.mjs (1 hunks)
  • hooks/useGetDiscoveryWallets.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/UI/changeWallet.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/UI/navbar.tsx
🧰 Additional context used
📓 Learnings (1)
components/pages/home/splitTitle.tsx (2)
Learnt from: baitcode
PR: lfglabs-dev/starknet.quest#962
File: components/pages/home/splitTitle.tsx:3-3
Timestamp: 2024-11-27T07:26:15.265Z
Learning: In the file `components/pages/home/splitTitle.tsx`, the `motion` library is correctly imported from `motion/react` rather than `framer-motion`.
Learnt from: baitcode
PR: lfglabs-dev/starknet.quest#962
File: components/pages/home/splitTitle.tsx:373-392
Timestamp: 2024-11-27T07:25:07.612Z
Learning: In the `SplitTitle` component (`components/pages/home/splitTitle.tsx`), the use of `Math.random()` in the `getVariants` function is intentional to create unpredictable animations.
🪛 eslint
components/pages/home/card.tsx

[error] 1-1: 'FunctionComponent' is defined but never used.

(@typescript-eslint/no-unused-vars)

components/pages/home/hero.tsx

[error] 1-1: 'FunctionComponent' is defined but never used.

(@typescript-eslint/no-unused-vars)


[error] 23-23: ' can be escaped with &apos;, &lsquo;, &#39;, &rsquo;.

(react/no-unescaped-entities)

components/pages/home/splitTitle.tsx

[error] 396-396: 'timeout' is never reassigned. Use 'const' instead.

(prefer-const)


[error] 422-422: 'timeout' is never reassigned. Use 'const' instead.

(prefer-const)

🔇 Additional comments (10)
components/pages/home/card.tsx (1)

15-28: ⚠️ Potential issue

Enhance accessibility and user interaction.

The component needs improvements for better accessibility and user experience.

-const Card: React.FC<CardProps> = ({ children, title, imgSrc, onClick, disabled }) => {
+const Card: React.FC<CardProps> = ({ children, title, imgSrc, onClick, disabled }) => {
+  const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
+    if (disabled) return;
+    if (event.key === 'Enter' || event.key === ' ') {
+      event.preventDefault();
+      onClick();
+    }
+  };
+
+  const [imageError, setImageError] = React.useState(false);
+
   return (
     <div 
       className={styles.card} 
-      onClick={onClick} 
+      onClick={disabled ? undefined : onClick}
+      onKeyDown={handleKeyDown}
       aria-disabled={disabled}
+      role="button"
+      tabIndex={disabled ? -1 : 0}
+      aria-label={`${title} card`}
     >
       <div
-        style={{ backgroundImage: `url('${cdnize(imgSrc)}')` }}
+        style={{ 
+          backgroundImage: !imageError ? `url('${cdnize(imgSrc)}')` : 'none',
+          backgroundColor: imageError ? '#f0f0f0' : undefined 
+        }}
         className={styles.cardImage}
+        role="img"
+        aria-label={title}
+        onError={() => setImageError(true)}
       />
       <div className={`${styles.cardInfos}`}>
         <Typography 
           type={TEXT_TYPE.H3} 
           color="secondary" 
           className={styles.cardTitle}
+          id={`card-title-${title.toLowerCase().replace(/\s+/g, '-')}`}
         >
           {title}
         </Typography>
         {children}
       </div>
     </div>
   );
 };

Also ensure that the CSS includes proper focus styles:

.card:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}
eslint.config.mjs (2)

1-13: LGTM: Imports and FlatCompat setup are well-structured

The imports are properly organized and the FlatCompat setup correctly uses the module's directory as the base.


35-40: Verify the need to disable react/no-unknown-property

While disabling react/prop-types is reasonable when using TypeScript, disabling react/no-unknown-property might hide real issues. Let's verify the actual usage:

✅ Verification successful

After analyzing the codebase, I can now provide a final response regarding the need to disable the react/no-unknown-property rule.

Disabling react/no-unknown-property is necessary for Three.js/React-Three-Fiber props

The rule disable is justified as the codebase uses React-Three-Fiber (R3F) and Three.js, which require several custom properties that ESLint's React plugin doesn't recognize by default:

  • Custom WebGL properties in the Canvas component like gl={{ antialias, toneMapping, alpha }}
  • Three.js-specific mesh properties like attach="material", map, transparent, depthWrite, etc.
  • R3F-specific props like manual in PerspectiveCamera

These properties are valid for Three.js/R3F components but would trigger false positives with the ESLint rule.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for custom attributes in land components that might trigger the rule
ast-grep --pattern 'JSXAttribute' components/lands/*.tsx

Length of output: 394


Script:

#!/bin/bash
# Search for JSX attributes in land components using ripgrep for better context
rg -U --type tsx "<[^>]+\s+[a-zA-Z]+=.*?>" components/lands/

Length of output: 90


Script:

#!/bin/bash
# Search for content of land components to analyze JSX usage
rg -l "\.tsx$" components/lands/ | xargs cat

Length of output: 46


Script:

#!/bin/bash
# First find the files
fd ".tsx$" components/lands/
# Then try to read their content
echo "=== Content of land components ==="
fd ".tsx$" components/lands/ -x cat {}

Length of output: 30654

components/pages/home/hero.tsx (2)

9-28: Implementation follows best practices!

The Hero component is well-structured with:

  • Semantic HTML and proper accessibility attributes
  • Consistent use of the design system components
  • Responsive design through utility classes
🧰 Tools
🪛 eslint

[error] 23-23: ' can be escaped with &apos;, &lsquo;, &#39;, &rsquo;.

(react/no-unescaped-entities)


14-17: Verify Typography component usage and text content.

The component uses Typography with different types (H1 and BODY_MICRO). Let's verify that these types exist and the text content matches the design specifications.

Also applies to: 20-25

✅ Verification successful

Typography component usage is correctly implemented

The Typography component in hero.tsx uses valid TEXT_TYPE values:

  • TEXT_TYPE.H1 for the main heading
  • TEXT_TYPE.BODY_MICRO for the descriptive text

Both types are properly defined in constants/typography.ts and the component implementation correctly handles these types with appropriate HTML tags (h1 and p respectively) and styling classes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Typography component types and usage

# Check Typography component for supported types
ast-grep --pattern 'export const TEXT_TYPE = {
  $$$
}'

# Check for consistent usage of these Typography types across the app
ast-grep --pattern '<Typography type={TEXT_TYPE.$_}'

Length of output: 112


Script:

#!/bin/bash
# Let's try a different approach to find Typography related constants and components

# Search for Typography component definition and type declarations
rg -l "TEXT_TYPE" --type ts --type tsx

# Search for Typography component usage
rg "<Typography" --type tsx -A 2

# Search for any enum or constant declarations related to Typography
rg "export (type|const|enum).*(Typography|TEXT)" --type ts --type tsx

Length of output: 229


Script:

#!/bin/bash
# Let's try without file type specifications since tsx isn't recognized

# Search for Typography component definition and type declarations
rg -l "TEXT_TYPE"

# Search for Typography component usage
rg "<Typography" -A 2

# Search for any enum or constant declarations related to Typography
rg "export (type|const|enum).*(Typography|TEXT)"

# Also search for the specific file we're reviewing
fd "hero.tsx"

Length of output: 54138


Script:

#!/bin/bash
# Let's check the TEXT_TYPE definition to verify the types used in hero.tsx

# Check the content of typography constants
cat constants/typography.ts

# Also check the Typography component implementation
cat components/UI/typography/typography.tsx

Length of output: 2488

hooks/useGetDiscoveryWallets.ts (1)

2-2: Verify package migration across the codebase

The import statement has been updated from get-starknet-core to @starknet-io/get-starknet-core.

Let's verify this change is consistent across the codebase:

✅ Verification successful

The initial results show consistent usage of the new import path @starknet-io/get-starknet-core and no instances of the old import. However, let's verify this is part of a proper package migration by checking the package.json and related commits.


Import change is properly implemented

The verification confirms that:

  • The new package @starknet-io/get-starknet-core is properly listed in package.json dependencies
  • All imports consistently use the new @starknet-io/get-starknet-core path
  • No instances of the old get-starknet-core import remain in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old imports and verify new imports
echo "Checking for old imports..."
rg "from ['\"]get-starknet-core['\"]"

echo "Verifying new imports..."
rg "from ['\"]@starknet-io/get-starknet-core['\"]"

Length of output: 418


Script:

#!/bin/bash
# Let's check for any package.json changes to verify the migration
echo "Checking package.json for dependencies..."
cat package.json | jq '.dependencies, .devDependencies'

# Let's also check git history for any related changes
echo "Checking recent changes related to get-starknet-core..."
git log -n 5 --grep="starknet" --pretty=format:"%h %s"

Length of output: 2109

app/page.tsx (3)

1-10: LGTM! Imports are well-organized and properly utilized.

The imports are logically grouped and all imported components/utilities are used within the component.


24-48: LGTM! Component structure aligns with requirements.

The implementation successfully:

  • Creates a new landing page with Hero and CTA sections
  • Uses modular components for maintainability
  • Follows Next.js best practices
  • Implements responsive design with flex layout

33-44: Ensure proper accessibility attributes.

The CallToAction section and Card components should have appropriate ARIA labels and roles for accessibility.

Let's check the implementation of these components:

✅ Verification successful

Let me gather more information about these components by checking their full implementation.


Let me try a different approach to find these component implementations.


Based on the component implementations found, I can now provide the final response:

Accessibility attributes are properly implemented

The Card component in components/pages/home/card.tsx already implements the necessary accessibility attributes:

  • Uses semantic HTML structure
  • Includes aria-disabled attribute for disabled state
  • Implements proper interactive elements with onClick handlers
  • Contains proper heading hierarchy with Typography components using H3 type
  • Provides proper text contrast with color props

The CallToAction component in components/pages/home/callToAction.tsx is a simple layout wrapper that doesn't require additional accessibility attributes as it:

  • Uses semantic div element appropriately for its layout purpose
  • Properly passes through children components
  • Implements flex layout for proper spacing and alignment
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for accessibility attributes in CallToAction and Card components

# Check CallToAction component
echo "Checking CallToAction component:"
rg -A 10 "export.*CallToAction" "components/pages/home/callToAction.tsx" || echo "File not found"

# Check Card component
echo "Checking Card component:"
rg -A 10 "export.*Card" "components/pages/home/card.tsx" || echo "File not found"

Length of output: 315


Script:

#!/bin/bash
# Search for the full implementation of CallToAction and Card components
echo "CallToAction Component Implementation:"
ast-grep --pattern 'const CallToAction = $_' || rg -B2 -A20 "const CallToAction" "components/pages/home/callToAction.tsx"

echo -e "\nCard Component Implementation:"
ast-grep --pattern 'const Card = $_' || rg -B2 -A20 "const Card" "components/pages/home/card.tsx"

Length of output: 249


Script:

#!/bin/bash
# Try to find the component files first
echo "Finding component files:"
fd -e tsx -e ts -e jsx -e js "callToAction|card" components/

echo -e "\nCallToAction Component Content:"
cat $(fd -e tsx -e ts -e jsx -e js "callToAction" components/) 2>/dev/null || echo "File not found"

echo -e "\nCard Component Content:"
cat $(fd -e tsx -e ts -e jsx -e js "card" components/) 2>/dev/null || echo "File not found"

Length of output: 29896

components/pages/home/splitTitle.tsx (1)

417-425: ⚠️ Potential issue

Fix improper cleanup of timeouts in 'onAnimationComplete' handler

Returning a cleanup function from an event handler, such as onAnimationComplete, has no effect because React does not utilize the return value of event handlers. This means the timeout is not properly cleared, potentially leading to memory leaks or unexpected behavior due to multiple timeouts being set.

To manage the timeout correctly, consider using a useRef hook to store the timeout ID. This allows you to clear any existing timeouts before setting a new one and ensures that the timeout is cleared when the component unmounts.

Apply this diff to refactor the timeout handling:

+import React, { useState, FunctionComponent, useEffect, useRef } from "react";
 ...

+  const timeoutRef = useRef<number | null>(null);

   return (
     ...
     <motion.svg
       ...
       onAnimationComplete={(definition: "visible" | "hidden") => {
         if (definition === "hidden") {
           setCurrentWordIdx((currentWordIdx + 1) % words.length);
           setVisible(false);
         } else {
-          let timeout = setTimeout(() => setVisible(true), interval * 1000)
-          return () => { window.clearTimeout(timeout) };
+          if (timeoutRef.current) {
+            clearTimeout(timeoutRef.current);
+          }
+          timeoutRef.current = window.setTimeout(() => {
+            setVisible(true);
+            timeoutRef.current = null;
+          }, interval * 1000);
         }
       }}
       ...
     />
     ...
   );

+  useEffect(() => {
+    return () => {
+      if (timeoutRef.current) {
+        clearTimeout(timeoutRef.current);
+      }
+    };
+  }, []);
🧰 Tools
🪛 eslint

[error] 422-422: 'timeout' is never reassigned. Use 'const' instead.

(prefer-const)

components/pages/home/card.tsx Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
app/page.tsx Show resolved Hide resolved
@baitcode
Copy link
Contributor Author

baitcode commented Nov 27, 2024

Have a look at AI suggestion, Code doesn't compile, please make sure it compiles before sending the PR

I've checked the issue description and contribution guidelines. I don't understand what do you mean by compilation error. npm build - does not produce error. npm dev - runs devserver without any problem. CI workflows are blocked by your approval, so I don't see what is going on there. If you have Idea how am I supposed to check for that, please let me know. Thank you!

Ok. I guess it has something to do with the linter.

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: 2

🧹 Outside diff range and nitpick comments (1)
components/pages/home/card.tsx (1)

17-20: Improve image handling and optimization.

Consider enhancing the image implementation with:

  1. Error handling for failed image loads
  2. Loading state indication
  3. Image optimization hints (sizes, loading priority)
       <div
         style={{ backgroundImage: `url('${cdnize(imgSrc)}')` }}
         className={styles.cardImage}
+        role="img"
+        aria-label={title}
+        data-testid="card-image"
       />

Consider adding an error boundary or fallback UI for failed image loads:

const [imageError, setImageError] = useState(false);

useEffect(() => {
  const img = new Image();
  img.src = cdnize(imgSrc);
  img.onerror = () => setImageError(true);
}, [imgSrc]);

// In render:
{imageError ? (
  <div className={styles.imageFallback}>
    <Typography type={TEXT_TYPE.BODY}>Failed to load image</Typography>
  </div>
) : (
  <div style={{...}} className={styles.cardImage} />
)}
🧰 Tools
🪛 eslint

[error] 17-20: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5c2f170 and 360173d.

📒 Files selected for processing (2)
  • components/pages/home/card.tsx (1 hunks)
  • eslint.config.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eslint.config.mjs
🧰 Additional context used
🪛 eslint
components/pages/home/card.tsx

[error] 14-14: 'children' is missing in props validation

(react/prop-types)


[error] 14-14: 'title' is missing in props validation

(react/prop-types)


[error] 14-14: 'imgSrc' is missing in props validation

(react/prop-types)


[error] 14-14: 'onClick' is missing in props validation

(react/prop-types)


[error] 14-14: 'disabled' is missing in props validation

(react/prop-types)


[error] 16-16: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 17-20: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 21-21: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 22-22: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

🔇 Additional comments (2)
components/pages/home/card.tsx (2)

14-27: Enhance accessibility and user interaction.

The component needs improvements for better accessibility and user experience.

🧰 Tools
🪛 eslint

[error] 14-14: 'children' is missing in props validation

(react/prop-types)


[error] 14-14: 'title' is missing in props validation

(react/prop-types)


[error] 14-14: 'imgSrc' is missing in props validation

(react/prop-types)


[error] 14-14: 'onClick' is missing in props validation

(react/prop-types)


[error] 14-14: 'disabled' is missing in props validation

(react/prop-types)


[error] 16-16: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 17-20: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 21-21: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 22-22: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


1-29: Verify component integration with other landing page sections.

Since this component is part of the new landing page implementation, let's verify its usage across other components.

✅ Verification successful

Let me gather more information about the landing page components and their integration.


Let me try one more search with a different approach to find the Card component usage.


Card component is properly integrated in the landing page

The verification shows that:

  • The Card component is correctly imported and used in app/page.tsx
  • It's used within the CallToAction section as intended
  • The implementation follows consistent patterns with proper props usage (title, imgSrc, onClick)
  • The styling module is properly scoped to the component
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Card component usage in other landing page components
echo "Searching for Card component usage..."
rg -l "import.*Card.*from.*card'" app/
rg -l "import.*Card.*from.*card'" components/pages/home/

# Check for consistent styling
echo "Checking for consistent styling..."
rg -l "card\.module\.css" components/pages/home/

Length of output: 351


Script:

#!/bin/bash
# Search for any imports or usage of Card component with different import paths
echo "Searching for Card component usage with different paths..."
rg -l "import.*Card.*from.*@components/pages/home/card"
rg -l "import.*Card.*from.*components/pages/home/card"

# Search for files in home directory to understand the landing page structure
echo "Checking landing page structure..."
fd . components/pages/home/ -t f

# Search for potential Card usage without explicit imports
echo "Searching for Card component usage in JSX/TSX..."
rg "<Card\b" --type tsx

Length of output: 888


Script:

#!/bin/bash
# Search for Card usage in specific files with context
echo "Searching for Card usage in app/page.tsx..."
rg -A 5 "<Card" app/page.tsx

echo "Searching for Card usage in callToAction.tsx..."
rg -A 5 "<Card" components/pages/home/callToAction.tsx

# Check the content of callToAction component
echo "Checking callToAction component implementation..."
cat components/pages/home/callToAction.tsx

Length of output: 1427

🧰 Tools
🪛 eslint

[error] 14-14: 'children' is missing in props validation

(react/prop-types)


[error] 14-14: 'title' is missing in props validation

(react/prop-types)


[error] 14-14: 'imgSrc' is missing in props validation

(react/prop-types)


[error] 14-14: 'onClick' is missing in props validation

(react/prop-types)


[error] 14-14: 'disabled' is missing in props validation

(react/prop-types)


[error] 16-16: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 17-20: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 21-21: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 22-22: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

components/pages/home/card.tsx Outdated Show resolved Hide resolved
components/pages/home/card.tsx Show resolved Hide resolved
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 20cecf0 and 4aa7ec1.

📒 Files selected for processing (1)
  • components/pages/home/card.tsx (1 hunks)
🧰 Additional context used
🪛 eslint
components/pages/home/card.tsx

[error] 14-14: 'children' is missing in props validation

(react/prop-types)


[error] 14-14: 'title' is missing in props validation

(react/prop-types)


[error] 14-14: 'imgSrc' is missing in props validation

(react/prop-types)


[error] 14-14: 'onClick' is missing in props validation

(react/prop-types)


[error] 14-14: 'disabled' is missing in props validation

(react/prop-types)


[error] 16-16: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 17-20: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 21-21: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 22-22: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

🔇 Additional comments (3)
components/pages/home/card.tsx (3)

1-4: Add React import to fix JSX usage.

The React import is required when using JSX syntax.

+import React from "react";
 import styles from "@styles/components/pages/home/card.module.css";
 import cdnize from "@utils/cdnize";
 import Typography from "@components/UI/typography/typography";
 import { TEXT_TYPE } from "@constants/typography";

6-12: LGTM! Well-defined type interface.

The CardProps type definition is comprehensive and properly typed with React.ReactNode for children and optional disabled prop.


29-29: LGTM! Clean export.

The default export is properly implemented.

components/pages/home/card.tsx Show resolved Hide resolved
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

Capture d’écran 2024-11-28 à 09 45 32

Title + description are not super fit with responsive. Fix this and we're good to merge !

Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

lgtm

@fricoben fricoben merged commit 0716060 into lfglabs-dev:testnet Nov 28, 2024
2 of 3 checks passed
@baitcode
Copy link
Contributor Author

@all-contributors please add baitcode for new home page design

Copy link
Contributor

@baitcode

I've put up a pull request to add @baitcode! 🎉

@baitcode
Copy link
Contributor Author

Great job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌ Change request Change requested from reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Home page and replace current index /quests
2 participants