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

adding feature of anchor links #960

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

shining-bluemoon-11
Copy link
Contributor

@shining-bluemoon-11 shining-bluemoon-11 commented Feb 28, 2025

RESOLVE #926

Tasks Completed:

  • Added anchor links to major blocks.
  • Implemented smooth scrolling.
  • Updated navigation to use anchor links.
  • Added hover-based visual indicators for anchors.
VID20250228221656.mp4

@shining-bluemoon-11
Copy link
Contributor Author

@arkid15r done

Copy link
Contributor

coderabbitai bot commented Mar 1, 2025

Summary by CodeRabbit

  • New Features
    • Integrated clickable anchor titles across multiple sections, enabling direct navigation to specific page content.
    • Updated placeholder messaging for empty lists to provide a clearer user experience.
  • Style
    • Enabled smooth scrolling for seamless navigation.
    • Introduced visual enhancements for icon alignment and text color inheritance.

Walkthrough

The pull request introduces modifications primarily in testing and component presentation. Test files for project and repository details now use a more specific selector (a div with class mb-8) to identify the contributors section. Several components have been updated to integrate an AnchorTitle component for clickable, scrollable headings, and prop types for title-related properties have been changed from string to React.ReactNode. Additionally, new CSS rules for smooth scrolling and color inheritance were added, and a new AnchorTitle component was introduced to manage anchor-based navigation.

Changes

File(s) Change Summary
frontend/__tests__/.../ProjectDetails.test.tsx, frontend/__tests__/.../RepositoryDetails.test.tsx Updated test selectors for contributorsSection to explicitly target div.mb-8 for precise DOM identification.
frontend/src/components/CardDetailsPage.tsx, frontend/src/pages/Home.tsx, frontend/src/components/ToggleContributors.tsx Integrated the AnchorTitle component to replace static headings with clickable links that facilitate smooth scrolling.
frontend/src/components/ItemCardList.tsx, frontend/src/components/SecondaryCard.tsx, frontend/src/components/ToggleableList.tsx Changed prop types for titles/labels from string to React.ReactNode for increased flexibility; updated the fallback message in ItemCardList.
frontend/src/index.css Added three new CSS rules: html { scroll-behavior: smooth; }, .inherit-color { color: inherit; }, and .custom-icon { display: inline-flex; align-items: center; vertical-align: middle; }.
frontend/src/components/AnchorTitle.tsx Introduced a new functional component that generates anchor links with smooth scrolling behavior upon click.
frontend/__tests__/e2e/pages/... Updated visibility assertions for headings to use .first() method for more precise targeting in tests across multiple files.

Possibly related PRs

Suggested reviewers

  • kasya
  • arkid15r

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f22366 and 6c9d866.

📒 Files selected for processing (2)
  • frontend/src/components/ItemCardList.tsx (3 hunks)
  • frontend/src/index.css (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/ItemCardList.tsx
  • frontend/src/index.css
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run frontend unit tests

🪧 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.
  • @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.

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

🧹 Nitpick comments (5)
frontend/src/components/ItemCardList.tsx (1)

52-52: Text formatting inconsistency in fallback message.

The fallback message has inconsistent spacing with extra spaces before and after commas and periods.

-      <p>Currently , Nothing to Display . </p>
+      <p>Currently, Nothing to Display.</p>
frontend/src/pages/Home.tsx (1)

169-182: Well-implemented anchor link for New Projects section.

The implementation follows the same pattern as other sections, providing consistent navigation.

The ID new-Projects has inconsistent capitalization. Consider maintaining all-lowercase or kebab-case for IDs:

-            <div id="new-Projects" className="relative scroll-mt-20">
+            <div id="new-projects" className="relative scroll-mt-20">

Also update the corresponding href attribute on line 174.

frontend/src/components/CardDetailsPage.tsx (3)

128-164: Consider enhancing anchor links accessibility for keyboard users.

The implementation for Languages and Topics sections looks good, but the hover-only visibility of the anchor links might present accessibility issues for keyboard or touch device users.

Consider making the link icon visible when the element receives keyboard focus as well:

- className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
+ className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-within:opacity-100"

195-218: Consider adding aria-label to anchor links for better screen reader support.

The anchor links implementation for Recent Releases is good, but lacks explicit screen reader support.

Add an aria-label to improve accessibility:

<a
  href="#recent-releases"
  className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
+ aria-label="Link to Recent Releases section"
>

41-240: Consider creating a reusable component for section headers with anchor links.

There is significant repetition in the anchor link pattern across multiple sections. This could be refactored into a reusable component to reduce duplication and make future maintenance easier.

Example implementation:

// SectionHeader component
const SectionHeader = ({ id, title }: { id: string; title: string }) => (
  <div id={id} className="relative scroll-mt-20">
    <div className="group relative flex items-center">
      {title}
      <a
        href={`#${id}`}
        className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
        aria-label={`Link to ${title} section`}
      >
        <FontAwesomeIcon icon={faLink} className="h-7 w-5" />
      </a>
    </div>
  </div>
);

// Usage
<SecondaryCard title={<SectionHeader id="summary" title="Summary" />}>
  <p>{summary}</p>
</SecondaryCard>
🧰 Tools
🪛 Biome (1.9.4)

[error] 76-81: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e41cd8 and 39af270.

📒 Files selected for processing (9)
  • frontend/__tests__/unit/pages/ProjectDetails.test.tsx (1 hunks)
  • frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (1 hunks)
  • frontend/src/components/CardDetailsPage.tsx (7 hunks)
  • frontend/src/components/ItemCardList.tsx (3 hunks)
  • frontend/src/components/SecondaryCard.tsx (1 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/components/ToggleableList.tsx (1 hunks)
  • frontend/src/index.css (1 hunks)
  • frontend/src/pages/Home.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
🔇 Additional comments (24)
frontend/src/components/SecondaryCard.tsx (1)

8-8: Good type enhancement for title prop

Changing the type from string to React.ReactNode improves flexibility by allowing the title to accept complex JSX elements including anchor links, which aligns with the PR objective of adding anchor links to major blocks.

frontend/__tests__/unit/pages/ProjectDetails.test.tsx (1)

101-101: Improved test selector precision

The change from .closest('div') to .closest('div.mb-8') provides a more specific DOM selector, ensuring the test correctly identifies the contributors section with its new anchor link structure.

frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (1)

102-102: Improved test selector precision

The change from .closest('div') to .closest('div.mb-8') provides a more specific DOM selector, ensuring the test correctly identifies the contributors section with its new anchor link structure.

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

5-5: Added React import for JSX support

Adding the React import is necessary when using React.ReactNode type and JSX syntax in the component.


13-13: Good type enhancement for label prop

Changing the type from string to React.ReactNode improves flexibility by allowing the label to accept complex JSX elements including anchor links, which aligns with the PR objective of adding anchor links to major blocks.

frontend/src/index.css (2)

297-299: Good addition of smooth scrolling behavior!

The scroll-behavior: smooth property provides a better user experience by adding a smooth animation when users navigate to anchor links, rather than jumping abruptly to the target location.


301-303: Well implemented utility class for color inheritance.

This .inherit-color class allows elements (like the anchor links) to take on the color of their parent elements, maintaining visual consistency while still being interactive elements.

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

2-2: Clean addition of the link icon import.

The FontAwesome link icon is appropriately imported alongside the existing icons.


32-42: Well-structured anchor link implementation.

This implementation:

  1. Creates a proper anchor point with ID top-contributors
  2. Uses scroll-mt-20 to offset the scroll position and prevent the heading from being hidden under any fixed headers
  3. Implements a clean hover effect where the link icon only appears when hovering over the section heading
  4. Uses the inherit-color class to maintain style consistency

The grouping of elements and relative positioning is also well done.

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

2-2: Appropriate addition of React import.

The React import is necessary for using the React.ReactNode type.


11-11: Good type update to support JSX in title.

Changing the title prop type from string to React.ReactNode enables passing JSX elements, which is necessary for implementing the anchor links with icons.

frontend/src/pages/Home.tsx (5)

8-8: Clean addition of the link icon import.

The FontAwesome link icon is correctly imported alongside the existing icons.


132-144: Well-implemented anchor link for New Chapters section.

The structure provides a good user experience with:

  • Proper ID-based anchor
  • Scroll margin to prevent header overlap
  • Hover effect for the link icon
  • Consistent styling using the inherit-color class

211-221: Well-structured anchor link for Chapters Nearby section.

The implementation maintains consistency with the other sections while correctly wrapping the h2 element.


230-243: Properly implemented anchor link for Recent Issues section.

The anchor structure is well implemented with appropriate hover effects and styling.


254-267: Properly implemented anchor link for Recent Releases section.

The anchor is correctly structured with consistent styling and behavior matching the other sections.

frontend/src/components/CardDetailsPage.tsx (8)

1-1: FontAwesome import updated to include faLink icon.

Good addition of the faLink icon which is used for the anchor links throughout the component.


41-57: Anchor link implementation for Summary section adds navigation improvement.

The addition of anchor links provides a nice way for users to link directly to specific sections. The implementation using hover-based visibility is clean and unobtrusive.


60-85: Anchor link implementation for Details section follows consistent pattern.

The same anchor link pattern is consistently applied to the Details section.

🧰 Tools
🪛 Biome (1.9.4)

[error] 76-81: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


87-107: Statistics section anchor link looks good.

The anchor implementation for the Statistics section maintains the consistent pattern seen throughout the component.


171-194: Recent Issues section anchor link implementation is consistent.

The anchor link implementation follows the same pattern as other sections, maintaining consistency throughout the UI.


222-240: Repositories section anchor link implemented consistently.

The anchor link pattern is maintained for the Repositories section, ensuring a consistent user experience.


48-48:

❓ Verification inconclusive

Verify that the 'inherit-color' class is defined in your global CSS.

The inherit-color class is used for the anchor links, but it's not defined in this file. Ensure it's properly defined in your global CSS to avoid styling issues.

Also applies to: 67-67, 94-94, 137-137, 155-155, 178-178, 202-202, 229-229


🏁 Script executed:

#!/bin/bash
# Check if the inherit-color class is defined in the CSS files

echo "Searching for inherit-color class definition..."
rg "\.inherit-color" -t css -t scss

echo "Searching for inherit-color in tailwind config..."
rg "inheritColor|inherit-color" -t js -t ts tailwind

Length of output: 384


Action Required: Verify Global CSS Definition for "inherit-color"

The automated search did not provide conclusive evidence that the "inherit-color" class is defined in your global CSS. It appears either the definition is missing or is located in a file/type not covered by the search. Please manually verify that the global stylesheet includes a definition for .inherit-color (e.g., .inherit-color { color: inherit; }) to ensure the anchor link styling works as intended.


43-43:

❓ Verification inconclusive

Ensure smooth scrolling behavior is enabled in your global CSS.

The scroll-mt-20 class suggests you're implementing smooth scrolling with an offset. Make sure you have defined smooth scrolling behavior in your global CSS.

Also applies to: 62-62, 89-89, 132-132, 150-150, 173-173, 197-197, 224-224


🏁 Script executed:

#!/bin/bash
# Check if smooth scrolling is defined in the CSS files

echo "Searching for scroll-behavior definition..."
rg "scroll-behavior:\s*smooth" -t css -t scss

echo "Checking for smooth scroll in global HTML/CSS..."
rg "html\s*{[^}]*scroll-behavior:\s*smooth" -t css -t scss

echo "Checking for scroll-mt-20 class in tailwind config..."
rg "scrollMargin|scroll-mt" -t js -t ts tailwind

Length of output: 687


Ensure global CSS implements smooth scrolling behavior

The file at frontend/src/components/CardDetailsPage.tsx (line 43) applies the scroll-mt-20 class to create an offset for smooth scrolling. However, our automated search did not conclusively locate a global CSS rule—such as html { scroll-behavior: smooth; }—that enables smooth scrolling. This might be due to configuration differences or search limitations.

Please manually verify that:

  • Your global CSS (e.g., a file like styles/global.css) contains a rule similar to:
    html {
      scroll-behavior: smooth;
    }
  • Your Tailwind configuration is correctly set up to support custom scroll margin classes. Similar usages were found on lines 62, 89, 132, 150, 173, 197, and 224, so consistency across the codebase is important.

If the smooth scrolling behavior is not defined globally, add the necessary CSS rule to ensure consistent behavior.

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

Thank you!
Left some comments:

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

🧹 Nitpick comments (5)
frontend/src/components/TitleWithIcon.tsx (5)

4-8: Props interface looks good but consider making title more flexible.

The interface is well-defined, but you might want to consider using React.ReactNode instead of string for the title prop to allow for more complex title content including nested elements.

interface TitleWithIconProps {
  href: string
  icon: IconProp
-  title: string
+  title: React.ReactNode
}

1-38: Consider adding CSS transition for smoother interactions.

The current implementation only has a transition for opacity. Consider adding transitions for other properties to make the interaction smoother.

<a
  href={href}
- className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
+ className="inherit-color ml-2 opacity-0 transform scale-95 transition-all duration-200 group-hover:opacity-100 group-hover:scale-100"
  onClick={handleClick}
  aria-label={`Link to ${typeof title === 'string' ? title : 'this section'}`}
  title={`Link to ${typeof title === 'string' ? title : 'this section'}`}
>

4-38: Add JSDoc comments for better code documentation.

Adding JSDoc comments would improve documentation and provide better IDE hints for users of this component.

+/**
+ * Props for the TitleWithIcon component
+ */
interface TitleWithIconProps {
  href: string
  icon: IconProp
  title: React.ReactNode
}

+/**
+ * A component that renders a title with an anchor link icon that appears on hover.
+ * Clicking the icon smoothly scrolls to the corresponding section.
+ * 
+ * @param props - The component props
+ * @param props.href - The href attribute for the anchor link (should start with #)
+ * @param props.icon - The FontAwesome icon to display
+ * @param props.title - The title content to display
+ * @returns A React component
+ */
const TitleWithIcon: React.FC<TitleWithIconProps> = ({ href, icon, title }) => {
  // Component implementation...
}

22-23: Improve screen reader compatibility.

The current implementation uses items-top which is not a standard Tailwind class. Additionally, the class structure could be improved for better accessibility and maintainability.

- <div id={id} className="relative scroll-mt-20">
-   <div className="group relative flex items-top">
+ <div id={id} className="relative scroll-mt-20 group">
+   <div className="relative flex items-start">

21-34: Enhance user experience with focus states.

Consider adding focus states for better keyboard navigation support, ensuring the component is fully accessible.

  return (
    <div id={id} className="relative scroll-mt-20">
      <div className="group relative flex items-top">
        <h2 className="mb-4 text-2xl font-semibold">{title}</h2>
        <a
          href={href}
-         className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
+         className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100 focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
          onClick={handleClick}
          aria-label={`Link to ${typeof title === 'string' ? title : 'this section'}`}
        >
          <FontAwesomeIcon icon={icon} className="h-7 w-5" />
        </a>
      </div>
    </div>
  )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39af270 and daf3979.

📒 Files selected for processing (4)
  • frontend/src/components/CardDetailsPage.tsx (8 hunks)
  • frontend/src/components/TitleWithIcon.tsx (1 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/pages/Home.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/components/ToggleContributors.tsx
  • frontend/src/pages/Home.tsx
  • frontend/src/components/CardDetailsPage.tsx
🔇 Additional comments (1)
frontend/src/components/TitleWithIcon.tsx (1)

1-2:

❓ Verification inconclusive

Verify FontAwesome dependency inclusion.

Ensure that the FontAwesome packages are correctly listed in your package.json and that you're importing only the icons you need to minimize bundle size.


🏁 Script executed:

#!/bin/bash
# Check FontAwesome packages in package.json
echo "Checking FontAwesome packages in package.json..."
grep -E "@fortawesome" package.json || echo "FontAwesome packages not found in package.json"

# Check if there's a central icon import file
echo "Checking for central icon imports..."
find . -type f -name "*.ts" -o -name "*.tsx" | xargs grep -l "import.*from.*@fortawesome" | sort

# Check if faLink is imported somewhere
echo "Checking for faLink imports..."
find . -type f -name "*.ts" -o -name "*.tsx" | xargs grep -l "faLink" | sort

Length of output: 1912


Action: Validate your FontAwesome dependency setup.

In frontend/src/components/TitleWithIcon.tsx (lines 1–2), you're importing modules from FontAwesome. However, our check for a package.json at the repository root did not find any FontAwesome-related dependencies. If your project uses a separate package.json (for example, within the frontend/ directory), please confirm that packages such as @fortawesome/react-fontawesome and @fortawesome/fontawesome-svg-core are listed there. Also, ensure you import only the icons you truly need to reduce bundle size.

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

🔭 Outside diff range comments (1)
frontend/src/pages/Home.tsx (1)

131-234: ⚠️ Potential issue

Missing ID attributes for anchor links.

While you've added anchor links with hrefs (e.g., "#new-chapters", "#recent-issues"), I don't see corresponding ID attributes on the target HTML elements. For the anchor links to work correctly, you need to add matching ID attributes to the elements they should navigate to.

Add ID attributes to each section that corresponds to the anchor href. For example:

-      <div className="grid gap-4 md:grid-cols-2">
+      <div id="new-chapters" className="grid gap-4 md:grid-cols-2">

Apply this pattern to all sections that need anchor links:

  • Add id="new-chapters" to the div at line 131
  • Add id="new-projects" to the div at line 157
  • Add id="chapters-nearby" to the div at line 187
  • Add id="recent-issues" to the div at line 195
  • Add id="recent-releases" to the div at line 207
🧹 Nitpick comments (5)
frontend/src/pages/Home.tsx (5)

158-158: Fix capitalization inconsistency in the anchor ID.

There's an inconsistency in the anchor ID format. All other anchor IDs use lowercase, but this one has a capital 'P' in "Projects".

-          title={<TitleWithIcon href="#new-Projects" icon={faLink} title="New Projects" />}
+          title={<TitleWithIcon href="#new-projects" icon={faLink} title="New Projects" />}

112-253: Consider implementing smooth scrolling for anchor links.

Adding smooth scrolling behavior would enhance the user experience when navigating between sections using the anchor links. This can be done using CSS.

You can add the following CSS to your global styles:

html {
  scroll-behavior: smooth;
}

Or add it to your styled component/CSS-in-JS solution if you're using one. This will ensure smooth scrolling when users click on anchor links.


188-193: Implement a more semantic section structure for "OWASP Chapters Nearby".

For better accessibility and semantic HTML structure, consider wrapping this section in a <section> element or using appropriate ARIA roles.

-      <div className="mb-20">
+      <section id="chapters-nearby" className="mb-20">
        <TitleWithIcon href="#chapters-nearby" icon={faLink} title="OWASP Chapters Nearby" />
        <ChapterMap
          geoLocData={geoLocData}
          style={{ height: '400px', width: '100%', zIndex: '0' }}
        />
-      </div>
+      </section>

194-223: Implement a consistent approach to container elements.

For "Recent Issues" and "Recent Releases", consider adding a wrapper with an ID to each section, rather than relying on the ItemCardList component to serve as the anchor target. This would create a more consistent approach with the other sections.

-      <div className="grid gap-4 md:grid-cols-2">
+      <div className="grid gap-4 md:grid-cols-2">
+        <div id="recent-issues">
          <ItemCardList
            title={<TitleWithIcon href="#recent-issues" icon={faLink} title="Recent Issues" />}
            data={data.recentIssues}
            renderDetails={(item) => (
              /* ... existing code ... */
            )}
          />
+        </div>
+        <div id="recent-releases">
          <ItemCardList
            title={<TitleWithIcon href="#recent-releases" icon={faLink} title="Recent Releases" />}
            data={data.recentReleases}
            renderDetails={(item) => (
              /* ... existing code ... */
            )}
          />
+        </div>
       </div>

132-223: Consider making the anchor link icon more accessible.

For better accessibility, consider adding more context to the anchor links, such as screen reader text that explains the purpose of the links.

In your TitleWithIcon component, you could enhance accessibility with:

<a 
  href={href} 
  className="anchor-link" 
  aria-label={`Link to ${title} section`}
>
  <FontAwesomeIcon icon={icon} />
  <span className="sr-only">Link to {title} section</span>
</a>

This ensures screen readers can properly convey the purpose of these anchor links to users with visual impairments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63e5c44 and b2c8854.

📒 Files selected for processing (4)
  • frontend/src/components/CardDetailsPage.tsx (8 hunks)
  • frontend/src/components/TitleWithIcon.tsx (1 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/pages/Home.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/components/ToggleContributors.tsx
  • frontend/src/components/CardDetailsPage.tsx
  • frontend/src/components/TitleWithIcon.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend e2e tests
🔇 Additional comments (3)
frontend/src/pages/Home.tsx (3)

8-8: The imports for faLink and TitleWithIcon look good.

These imports properly support the anchor link functionality being added to the page.

Also applies to: 27-27


132-134: Anchor link implementation for "New Chapters" looks correct.

The title has been properly updated to use the TitleWithIcon component with appropriate parameters.


132-159: Address the scrolling issue mentioned in previous review.

In previous reviews, it was noted that clicking anchor links in the two-column layout (specifically the second card) causes the page to scroll to the top instead of staying in place. This issue was acknowledged but doesn't appear to be fixed in this update.

To properly test this issue, we need to check if clicking the anchor link for "New Projects" (which is in the second column) causes undesired scrolling behavior.

#!/bin/bash
# Look for any scroll prevention measures or anchor-related JS in the codebase

echo "Checking for scroll prevention measures in TitleWithIcon component..."
fd "TitleWithIcon" -t f --exec cat {} \; | grep -A 10 -B 10 "onClick\|preventDefault\|scroll"

echo "Checking for any smooth scroll implementations..."
rg "scroll-behavior|scrollIntoView" --type=css
rg "scrollIntoView|preventDefault" --type=ts --type=tsx

@shining-bluemoon-11
Copy link
Contributor Author

@arkid15r @kasya done
(as @arkid15r mentioned that the e2e test ( making problem ) so he disabled as a merge requirement
rest all checks passes

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

This is much better! A few more comments:

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 (3)
frontend/src/components/AnchorTitle.tsx (3)

5-8: Consider making the title prop more flexible.

The title prop is currently typed as a string, which limits flexibility. Consider allowing React nodes (ReactNode type) to support more complex title content like formatted text or nested elements.

interface AnchorTitleProps {
  href: string
- title: string
+ title: React.ReactNode
}

11-11: Add more robust ID generation.

The current ID generation simply removes '#' characters, but IDs should be unique and valid HTML IDs. Consider a more comprehensive approach to handle special characters and ensure valid ID generation.

- const id = href.replace('#', '')
+ const id = href.replace('#', '').replace(/[^a-zA-Z0-9-_:]/g, '-').toLowerCase()

22-33: Enhance accessibility of the anchor link component.

While the component functions well visually, it could benefit from additional accessibility attributes for screen readers and keyboard navigation.

<div id={id} className="relative scroll-mt-20">
  <div className="items-top group relative flex">
    <h2 className="mb-4 text-2xl font-semibold">{title}</h2>
    <a
      href={href}
      className="inherit-color ml-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100"
      onClick={handleClick}
+     aria-label={`Link to ${typeof title === 'string' ? title : 'this section'}`}
+     title={`Link to ${typeof title === 'string' ? title : 'this section'}`}
    >
      <FontAwesomeIcon icon={faLink} className="h-7 w-5" />
    </a>
  </div>
</div>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2c8854 and a58ff4e.

📒 Files selected for processing (4)
  • frontend/src/components/AnchorTitle.tsx (1 hunks)
  • frontend/src/components/CardDetailsPage.tsx (7 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/pages/Home.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/components/ToggleContributors.tsx
  • frontend/src/pages/Home.tsx
  • frontend/src/components/CardDetailsPage.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run backend tests
🔇 Additional comments (3)
frontend/src/components/AnchorTitle.tsx (3)

13-19: Good implementation of smooth scrolling functionality.

The click handler properly prevents default behavior and uses the smooth scrolling API. The null check before accessing the element is also a good practice.


22-22: Good use of scroll-mt-20 for scroll positioning.

The scroll-mt-20 class ensures the element isn't hidden under fixed headers when scrolled to. This is a thoughtful implementation detail for a better user experience.


27-27:

✅ Verification successful

Verify the color inheritance styling.

The class inherit-color is used for the anchor element, but it's not a standard Tailwind class. Ensure this class is properly defined in your CSS to prevent styling issues.


🏁 Script executed:

#!/bin/bash
# Check if the inherit-color class is defined in the project's CSS files
echo "Searching for inherit-color class definition..."
rg -t css "inherit-color" --no-heading

Length of output: 183


Action: Confirm CSS Definition for "inherit-color"

The verification shows that the inherit-color class is defined in frontend/src/index.css, so there are no styling issues with the anchor element. No further changes are needed.

@shining-bluemoon-11
Copy link
Contributor Author

@kasya done
all checks passes except e2e

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

Almost there! 2 small requests!

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@shining-bluemoon-11 hi! How's it going? Just 2 small updates left (and one conflicting file)

@shining-bluemoon-11
Copy link
Contributor Author

@kasya it's completed
Today I will submit : )

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/__tests__/e2e/pages/Home.spec.ts (1)

25-25: Update test selectors to handle potential duplicates

These changes add .first() to heading selectors across the test file, which appears to be related to the addition of anchor links to the application. Using .first() helps ensure that tests consistently target the first instance of each heading, preventing potential failures if duplicate elements exist on the page after implementing anchor links.

While this approach works, consider whether more specific selectors (like unique data attributes or specific CSS classes) might provide even more robust tests for these anchor-enabled headings.

Instead of relying on .first(), consider adding data attributes specifically for testing:

- await expect(page.getByRole('heading', { name: 'New Chapters' }).first()).toBeVisible()
+ await expect(page.getByTestId('new-chapters-heading')).toBeVisible()

Then in your component:

<h2 data-testid="new-chapters-heading">New Chapters</h2>

Also applies to: 32-32, 40-40, 48-48, 55-55, 72-72

frontend/__tests__/e2e/pages/ProjectDetails.spec.ts (1)

23-23: Update test selectors for consistent handling of anchor links

Similar to the Home page tests, you've added .first() to all heading selectors in this file. This change makes the tests more explicit about which element they're targeting, which is important after implementing anchor links that may introduce duplicate heading elements in the DOM.

While this approach works, it would be beneficial to add tests that specifically validate the anchor link functionality (e.g., clicking an anchor and verifying that the page scrolls to the correct section).

Consider adding a test case that validates the anchor link navigation functionality:

test('should navigate to sections using anchor links', async ({ page }) => {
  // Click on an anchor link
  await page.getByRole('link', { name: 'Project Details' }).click();
  
  // Verify the page scrolled to the correct section
  // This could be done by checking if the element is in view
  // or by checking the URL hash
  expect(page.url()).toContain('#project-details');
  
  // You may also want to verify the scrolling behavior
  // by checking the element's position in the viewport
});

Also applies to: 39-39, 46-46, 53-53, 71-71, 79-79, 86-86

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a8e6e1 and ccb5315.

📒 Files selected for processing (15)
  • frontend/__tests__/e2e/pages/ChapterDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/CommitteeDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/Home.spec.ts (2 hunks)
  • frontend/__tests__/e2e/pages/ProjectDetails.spec.ts (3 hunks)
  • frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (3 hunks)
  • frontend/__tests__/e2e/pages/UserDetails.spec.ts (1 hunks)
  • frontend/__tests__/unit/pages/ProjectDetails.test.tsx (1 hunks)
  • frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (1 hunks)
  • frontend/src/components/AnchorTitle.tsx (1 hunks)
  • frontend/src/components/CardDetailsPage.tsx (6 hunks)
  • frontend/src/components/ItemCardList.tsx (3 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/components/ToggleableList.tsx (1 hunks)
  • frontend/src/index.css (1 hunks)
  • frontend/src/pages/Home.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • frontend/src/pages/Home.tsx
  • frontend/src/components/ToggleableList.tsx
  • frontend/src/components/ToggleContributors.tsx
  • frontend/tests/unit/pages/ProjectDetails.test.tsx
  • frontend/src/components/ItemCardList.tsx
  • frontend/src/components/CardDetailsPage.tsx
  • frontend/src/index.css
  • frontend/src/components/AnchorTitle.tsx
  • frontend/tests/unit/pages/RepositoryDetails.test.tsx
🔇 Additional comments (6)
frontend/__tests__/e2e/pages/CommitteeDetails.spec.ts (2)

21-21: Updated selectors for heading elements to use .first()

This change ensures the test consistently targets the first matching heading element when multiple elements might share the same name. This modification supports the anchor links feature mentioned in the PR objectives by accommodating potential DOM structure changes.


28-28: Updated selectors for heading elements to use .first()

Similar to the previous change, this ensures the test is targeting the first "Top Contributors" heading element. This modification maintains test reliability when multiple heading elements with the same text might exist in the DOM.

frontend/__tests__/e2e/pages/ChapterDetails.spec.ts (1)

35-35: Updated selector for "Top Contributors" heading to use .first()

The addition of .first() ensures the test precisely targets the first "Top Contributors" heading element, improving test reliability in the context of the anchor links implementation. This change is consistent with similar modifications in other test files.

frontend/__tests__/e2e/pages/UserDetails.spec.ts (2)

28-28: Updated selector for "Recent Issues" heading to use .first()

The addition of .first() ensures the test precisely targets the first "Recent Issues" heading element. This modification supports the anchor links feature implementation by making the test more resilient to DOM structure changes.


34-34: Updated selector for "Recent Releases" heading to use .first()

Similar to the previous change, this ensures the test targets the first "Recent Releases" heading element. This maintains consistency with the selector pattern used in other test files following the anchor links implementation.

frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1)

21-21: Updated all heading selectors to use .first()

All heading element selectors have been consistently updated to use the .first() method. This systematic change ensures tests reliably target the first instance of each heading when multiple elements with the same name might exist, particularly important after implementing anchor links which could affect the DOM structure.

The modification follows the same pattern applied in other test files and supports the PR objective of adding anchor links to major blocks within the project.

Also applies to: 37-37, 43-43, 48-48, 66-66, 74-74

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 (3)
frontend/src/components/AnchorTitle.tsx (3)

5-8: Consider accepting a heading level prop for better flexibility.

While using h2 works in current contexts, allowing consumers to specify the heading level (h1-h6) would make this component more reusable across different scenarios. This is especially important for maintaining proper document outline and accessibility.

interface AnchorTitleProps {
  href: string
  title: string
+ headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
}

23-24: Use a more semantic element structure.

The current implementation has nested divs that could be simplified. Also, the heading is always h2, which could be made more flexible using the proposed headingLevel prop.

- <div className="items-top group relative flex">
-   <h2 className="mb-4 text-2xl font-semibold">{title}</h2>
+ <div className="items-center group relative flex">
+   {React.createElement(headingLevel || 'h2', { className: "mb-4 text-2xl font-semibold" }, title)}

13-19: Add error handling for element not found.

The click handler doesn't provide feedback when the target element isn't found. Consider adding error handling or telemetry to track such occurrences.

const handleClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
  const element = document.getElementById(id)
  if (element) {
    event.preventDefault()
    element.scrollIntoView({ behavior: 'smooth' })
+  } else {
+    console.warn(`Target element with id "${id}" not found`)
  }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccb5315 and 0f22366.

📒 Files selected for processing (3)
  • frontend/src/components/AnchorTitle.tsx (1 hunks)
  • frontend/src/components/ToggleableList.tsx (1 hunks)
  • frontend/src/pages/Home.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/ToggleableList.tsx
  • frontend/src/pages/Home.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend e2e tests
🔇 Additional comments (2)
frontend/src/components/AnchorTitle.tsx (2)

29-31: Vertically center the icon with the text.

As mentioned in the previous review, the icon doesn't appear to be vertically centered with the text. Update the icon's positioning to ensure proper vertical alignment.

- <FontAwesomeIcon icon={faLink} className="custom-icon h-7 w-5" />
+ <FontAwesomeIcon icon={faLink} className="custom-icon h-7 w-5 align-middle mt-0.5" />

1-38: LGTM: Well-implemented component for anchor links.

The AnchorTitle component efficiently implements the required anchor link functionality with smooth scrolling and hover effects. The implementation aligns well with the PR objectives of adding anchor links to major blocks and implementing smooth scrolling.

@shining-bluemoon-11
Copy link
Contributor Author

@kasya
finally done
i have changed the suggested updates
and also corrected the e2e test , it passes
here i learned a lot while doing correction in the e2e test as well
only the code duplication checks fails rest all passes
finally completed 🙃
thanks : )

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

New issues popped up!

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
13.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@shining-bluemoon-11
Copy link
Contributor Author

@kasya done
fixed the issues
now is that acceptable or needs improvement
let me know : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Entity Details Component with Anchors for Direct Linking
2 participants