Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Improved animated border issue for TOC links #3719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PRAteek-singHWY
Copy link

@PRAteek-singHWY PRAteek-singHWY commented Feb 21, 2025

Description:-

Added a live animated gradient border to TOC links.
Ensured consistent spacing between links for better readability.
Applied rounded borders while maintaining smooth transitions.

Related issue(s):-

Resolves #3718

ScreenShots Of Updates:-
Screenshot 2025-02-21 at 17 19 15

Screenshot 2025-02-21 at 18 23 51

Summary by CodeRabbit

  • Style

    • Refined navigation link styling with an enhanced gradient background for a more polished look.
    • Introduced a border animation effect to offer a dynamic interactive experience.
    • Improved readability of CSS rules and selectors.
  • Chores

    • Performed code consistency and formatting improvements for overall maintainability.
    • Added package manager metadata to the project configuration.

Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

The pull request applies several formatting and refactoring changes without altering any core functionality. The TOC component in components/TOC.tsx now presents multi-line destructured props and improved anchor tag styling. In package.json, a new "packageManager" property has been added to record Yarn metadata. The styles/globals.css file has been revised with better formatting, updated selectors, and the introduction of a new CSS keyframe animation and class. Overall, the changes focus on code style, readability, and consistent formatting.

Changes

File(s) Change Summary
components/TOC.tsx, styles/globals.css Refactored formatting and styling: multi-line destructuring in TOC, updated anchor tag class and data attribute quotes; in CSS, adjusted import/selector formatting and added new keyframe animation with .animate-border class.
package.json Added a new "packageManager" property specifying Yarn version and SHA-512 checksum for package management metadata.

Possibly related PRs

  • asyncapi/website#3249: Modifies class names and styling in the TOC component similar to the formatting improvements here.
  • asyncapi/website#3634: Adjusts regex logic for URL slug generation within the TOC component, showing a direct code-level relationship.

Suggested labels

ready-to-merge, bounty

Suggested reviewers

  • derberg
  • magicmatatjahu
  • devilkiller-ag
  • akshatnema
  • sambhavgupta0705
  • asyncapi-bot-eve
  • Mayaleeeee
  • anshgoyalevil

Poem

I'm a bunny with a love for clean code,
Hopping along in a neat, refactored mode.
I nibble on bugs with formatting flair,
CSS and TS now dance in the air.
With every tweak, my heart does sing—
A happy rabbit celebrating code in spring!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai 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

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for asyncapi-website failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 26d87de
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67b880ede5a1210009bc74cf

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Feb 21, 2025

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 The subject "Improved animated border issue for TOC links " found in the pull request title "feat: Improved animated border issue for TOC links " should start with a lowercase character.

@PRAteek-singHWY PRAteek-singHWY changed the title Improved animated border issue for TOC links feat: Improved animated border issue for TOC links Feb 21, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (9)
components/TOC.tsx (9)

27-33: Formatting: Adjust the destructured props signature.
The multi-line signature with a trailing comma (after depth = 2) is causing ESLint (comma-dangle and prettier) errors. For consistency with the project's formatting rules, consider removing the trailing comma and consolidating the formatting if acceptable.

-export default function TOC({
-  className,
-  cssBreakingPoint = 'xl',
-  toc,
-  contentSelector,
-  depth = 2,
-}: ITOCProps) {
+export default function TOC({ className, cssBreakingPoint = 'xl', toc, contentSelector, depth = 2 }: ITOCProps) {
🧰 Tools
🪛 ESLint

[error] 27-33: Replace ⏎··className,⏎··cssBreakingPoint·=·'xl',⏎··toc,⏎··contentSelector,⏎··depth·=·2,⏎ with ·className,·cssBreakingPoint·=·'xl',·toc,·contentSelector,·depth·=·2·

(prettier/prettier)


[error] 32-32: Unexpected trailing comma.

(comma-dangle)


37-40: Format the reduce callback for clarity.
ESLint suggests consolidating the callback and initial value on one line. While the current multi-line format is functionally correct, aligning with the suggested format can eliminate prettier warnings and improve consistency.

-  const minLevel = toc.reduce(
-    (mLevel, item) => (!mLevel || item.lvl < mLevel ? item.lvl : mLevel),
-    0,
-  );
+  const minLevel = toc.reduce((mLevel, item) => (!mLevel || item.lvl < mLevel ? item.lvl : mLevel), 0);
🧰 Tools
🪛 ESLint

[error] 37-40: Replace ⏎····(mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),⏎····0,⏎·· with (mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),·0

(prettier/prettier)


[error] 39-39: Unexpected trailing comma.

(comma-dangle)


45-47: Style Suggestion: Consolidate chained .replace() calls.
The chain of .replace() functions is split across multiple lines, which ESLint flags for consistency. Consider joining them into a single line to satisfy formatting rules:

-      content: item.content
-        .replace(/[\s]?\{#[\w\d\-_]+\}$/, '')
-        .replace(/(<([^>]+)>)/gi, ''),
+      content: item.content.replace(/[\s]?\{#[\w\d\-_]+\}$/, '').replace(/(<([^>]+)>)/gi, ''),
🧰 Tools
🪛 ESLint

[error] 45-47: Replace ⏎········.replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')⏎········ with .replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')

(prettier/prettier)


76-76: Standardize JSX Quotes.
ESLint recommends using single quotes for JSX attribute values. Update the data-testid attribute accordingly.

-          data-testid="TOC-Heading"
+          data-testid='TOC-Heading'
🧰 Tools
🪛 ESLint

[error] 76-76: Replace "TOC-Heading" with 'TOC-Heading'

(prettier/prettier)


[error] 76-76: Unexpected usage of doublequote.

(jsx-quotes)


80-82: Consolidate JSX Attribute Formatting.
For improved readability and to satisfy ESLint's formatting rules, consider writing the className attribute on a single line.

-        <div
-          className={`text-underline p4 text-center ${cssBreakingPoint === 'xl' ? 'xl:hidden' : 'lg:hidden'}`}
-        >
+        <div className={`text-underline p4 text-center ${cssBreakingPoint === 'xl' ? 'xl:hidden' : 'lg:hidden'}`}>
🧰 Tools
🪛 ESLint

[error] 80-82: Replace ⏎··········className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}⏎········ with ·className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}

(prettier/prettier)


89-91: Simplify DIV ClassName Declaration.
Similar to the previous comment, the className for this <div> can be formatted on a single line to eliminate ESLint formatting warnings.

-      <div
-        className={`${!open && 'hidden'} ${cssBreakingPoint === 'xl' ? 'xl:block' : 'lg:block'}`}
-      >
+      <div className={`${!open && 'hidden'} ${cssBreakingPoint === 'xl' ? 'xl:block' : 'lg:block'}`}>
🧰 Tools
🪛 ESLint

[error] 89-91: Replace ⏎········className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}⏎······ with ·className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}

(prettier/prettier)


93-95: Simplify Scrollspy Items Mapping.
ESLint suggests removing the trailing comma by rewriting the mapping callback in a more concise way. This enhances clarity and consistency.

-          items={tocItems.map((item) =>
-            item.slug ? item.slug : item.slugWithATag,
-          )}
+          items={tocItems.map((item) => (item.slug ? item.slug : item.slugWithATag))}
🧰 Tools
🪛 ESLint

[error] 93-95: Replace ⏎············item.slug·?·item.slug·:·item.slugWithATag,⏎·········· with ·(item.slug·?·item.slug·:·item.slugWithATag)

(prettier/prettier)


[error] 94-94: Unexpected trailing comma.

(comma-dangle)


96-97: Use Consistent JSX Quotes for Attributes.
Both the currentClassName and componentTag attributes are using double quotes. To align with the project's conventions, change these to single quotes.

-          currentClassName="text-primary-500 font-bold"
+          currentClassName='text-primary-500 font-bold'
-          componentTag="div"
+          componentTag='div'
🧰 Tools
🪛 ESLint

[error] 96-96: Replace "text-primary-500·font-bold" with 'text-primary-500·font-bold'

(prettier/prettier)


[error] 96-96: Unexpected usage of doublequote.

(jsx-quotes)


[error] 97-97: Replace "div" with 'div'

(prettier/prettier)


[error] 97-97: Unexpected usage of doublequote.

(jsx-quotes)


109-109: Standardize JSX Quotes for Data Attributes.
For consistency, change the data-testid attribute in the anchor tag from double quotes to single quotes.

-              data-testid="TOC-Link"
+              data-testid='TOC-Link'
🧰 Tools
🪛 ESLint

[error] 109-109: Replace "TOC-Link" with 'TOC-Link'

(prettier/prettier)


[error] 109-109: Unexpected usage of doublequote.

(jsx-quotes)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 881a4c7 and 0929df4.

📒 Files selected for processing (3)
  • components/TOC.tsx (2 hunks)
  • package.json (1 hunks)
  • styles/globals.css (7 hunks)
✅ Files skipped from review due to trivial changes (2)
  • styles/globals.css
  • package.json
🧰 Additional context used
🪛 ESLint
components/TOC.tsx

[error] 27-33: Replace ⏎··className,⏎··cssBreakingPoint·=·'xl',⏎··toc,⏎··contentSelector,⏎··depth·=·2,⏎ with ·className,·cssBreakingPoint·=·'xl',·toc,·contentSelector,·depth·=·2·

(prettier/prettier)


[error] 32-32: Unexpected trailing comma.

(comma-dangle)


[error] 37-40: Replace ⏎····(mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),⏎····0,⏎·· with (mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),·0

(prettier/prettier)


[error] 39-39: Unexpected trailing comma.

(comma-dangle)


[error] 45-47: Replace ⏎········.replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')⏎········ with .replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')

(prettier/prettier)


[error] 55-55: Delete ,

(prettier/prettier)


[error] 55-55: Unexpected trailing comma.

(comma-dangle)


[error] 76-76: Replace "TOC-Heading" with 'TOC-Heading'

(prettier/prettier)


[error] 76-76: Unexpected usage of doublequote.

(jsx-quotes)


[error] 80-82: Replace ⏎··········className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}⏎········ with ·className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}

(prettier/prettier)


[error] 89-91: Replace ⏎········className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}⏎······ with ·className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}

(prettier/prettier)


[error] 93-95: Replace ⏎············item.slug·?·item.slug·:·item.slugWithATag,⏎·········· with ·(item.slug·?·item.slug·:·item.slugWithATag)

(prettier/prettier)


[error] 94-94: Unexpected trailing comma.

(comma-dangle)


[error] 96-96: Replace "text-primary-500·font-bold" with 'text-primary-500·font-bold'

(prettier/prettier)


[error] 96-96: Unexpected usage of doublequote.

(jsx-quotes)


[error] 97-97: Replace "div" with 'div'

(prettier/prettier)


[error] 97-97: Unexpected usage of doublequote.

(jsx-quotes)


[error] 109-109: Replace "TOC-Link" with 'TOC-Link'

(prettier/prettier)


[error] 109-109: Unexpected usage of doublequote.

(jsx-quotes)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI

// For TOC rendering in specification files in the spec repo we have "a" tags added manually to the spec
// markdown document MDX takes these "a" tags and uses them to render the "id" for headers like
// a-namedefinitionsapplicationaapplication slugWithATag contains transformed heading name that is later used
// for scroll spy identification
slugWithATag: item.content
.replace(/[<>?!:`'."\\/=@#$%^&*()[\]{}+,;]/gi, '')
.replace(/\s/gi, '-')
.toLowerCase()
.toLowerCase(),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove Trailing Comma.
There is an unexpected trailing comma after .toLowerCase() that ESLint warns about. Removing it keeps the code compliant.

-        .toLowerCase(),
+        .toLowerCase()
📝 Committable suggestion

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

Suggested change
.toLowerCase(),
.toLowerCase()
🧰 Tools
🪛 ESLint

[error] 55-55: Delete ,

(prettier/prettier)


[error] 55-55: Unexpected trailing comma.

(comma-dangle)

Comment on lines 103 to 104
className={`pl- relative${2 ** (item.lvl - 1)} font-normal animate-border bg-gradient-to-r mb-2
block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding
p-2 font-sans text-sm text-gray-900 antialiased transition
duration-100 ease-in-out hover:underline`}
href={`#${item.slug ? item.slug : item.slugWithATag}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fix Tailwind Class Construction for Dynamic Padding.
The class name for the anchor tag begins with "pl- relative${2 ** (item.lvl - 1)} ...". It appears the intention is to apply a dynamic padding value (e.g. pl-2) alongside the relative positioning class. To correctly format these as separate Tailwind classes, move the interpolation immediately after pl- and separate the relative class with a space.

-            <a
-              className={`pl- relative${2 ** (item.lvl - 1)} font-normal animate-border bg-gradient-to-r mb-2 
-                  block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding 
-                  p-2 font-sans text-sm text-gray-900 antialiased transition 
-                  duration-100 ease-in-out hover:underline`}
+            <a
+              className={`pl-${2 ** (item.lvl - 1)} relative font-normal animate-border bg-gradient-to-r mb-2 block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding p-2 font-sans text-sm text-gray-900 antialiased transition duration-100 ease-in-out hover:underline`}
📝 Committable suggestion

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

Suggested change
className={`pl- relative${2 ** (item.lvl - 1)} font-normal animate-border bg-gradient-to-r mb-2
block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding
p-2 font-sans text-sm text-gray-900 antialiased transition
duration-100 ease-in-out hover:underline`}
href={`#${item.slug ? item.slug : item.slugWithATag}`}
<a
className={`pl-${2 ** (item.lvl - 1)} relative font-normal animate-border bg-gradient-to-r mb-2 block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding p-2 font-sans text-sm text-gray-900 antialiased transition duration-100 ease-in-out hover:underline`}
href={`#${item.slug ? item.slug : item.slugWithATag}`}

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 (6)
components/TOC.tsx (4)

27-33: Fix linting issues in function signature.

The multi-line formatting improves readability, but there are linting issues that need to be addressed.

-export default function TOC({
-  className,
-  cssBreakingPoint = 'xl',
-  toc,
-  contentSelector,
-  depth = 2,
-}: ITOCProps) {
+export default function TOC({ className, cssBreakingPoint = 'xl', toc, contentSelector, depth = 2 }: ITOCProps) {
🧰 Tools
🪛 ESLint

[error] 27-33: Replace ⏎··className,⏎··cssBreakingPoint·=·'xl',⏎··toc,⏎··contentSelector,⏎··depth·=·2,⏎ with ·className,·cssBreakingPoint·=·'xl',·toc,·contentSelector,·depth·=·2·

(prettier/prettier)


[error] 32-32: Unexpected trailing comma.

(comma-dangle)


37-40: Fix linting issues in minLevel calculation.

The multi-line formatting improves readability, but there are linting issues that need to be addressed.

-  const minLevel = toc.reduce(
-    (mLevel, item) => (!mLevel || item.lvl < mLevel ? item.lvl : mLevel),
-    0,
-  );
+  const minLevel = toc.reduce((mLevel, item) => (!mLevel || item.lvl < mLevel ? item.lvl : mLevel), 0);
🧰 Tools
🪛 ESLint

[error] 37-40: Replace ⏎····(mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),⏎····0,⏎·· with (mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),·0

(prettier/prettier)


[error] 39-39: Unexpected trailing comma.

(comma-dangle)


103-103: Improve className organization for better readability.

The className string is quite long and combines multiple styling concerns. Consider organizing it into logical groups using template literals.

-            className={`pl-${2 ** (item.lvl - 1)} relative font-normal animate-border bg-gradient-to-r mb-2 block rounded-lg border-transparent from-primary-500 via-pink-500 to-blue-500 bg-clip-padding p-2 font-sans text-sm text-gray-900 antialiased transition duration-100 ease-in-out hover:underline`}
+            className={`
+              pl-${2 ** (item.lvl - 1)}
+              relative block mb-2 p-2
+              font-sans font-normal text-sm text-gray-900 antialiased
+              animate-border bg-gradient-to-r rounded-lg border-transparent
+              from-primary-500 via-pink-500 to-blue-500 bg-clip-padding
+              transition duration-100 ease-in-out hover:underline
+            `}
🧰 Tools
🪛 ESLint

[error] 103-103: Insert ··

(prettier/prettier)


76-76: Fix quote style in data-testid attributes.

The data-testid attributes use double quotes, but ESLint prefers single quotes.

-          data-testid="TOC-Heading"
+          data-testid='TOC-Heading'
-              data-testid="TOC-Link"
+              data-testid='TOC-Link'

Also applies to: 106-106

🧰 Tools
🪛 ESLint

[error] 76-76: Replace "TOC-Heading" with 'TOC-Heading'

(prettier/prettier)


[error] 76-76: Unexpected usage of doublequote.

(jsx-quotes)

styles/globals.css (2)

361-371: Consider performance optimizations for border animation.

The border animation implementation could be optimized:

  1. Using outline for animation might impact performance. Consider using border-color instead.
  2. The 3-second animation duration might feel too slow for a good user experience.
 @keyframes borderAnimation {
   0% {
-    outline-color: #649af0;
+    border-color: #649af0;
   }
   50% {
-    outline-color: #b27bee;
+    border-color: #b27bee;
   }
   100% {
-    outline-color: #649af0;
+    border-color: #649af0;
   }
 }

373-380: Simplify border animation implementation.

The current implementation uses both border and outline properties, which is redundant. Consider simplifying:

 .animate-border {
-  border-radius: 20px; /* Makes the border rounded */
-  border: 2px solid transparent; /* Transparent border to maintain space */
-  outline: 2px solid #3b82f6; /* Apply outline instead */
-  animation: borderAnimation 3s infinite linear; /* Animate the outline */
+  --border-radius: 20px;
+  border-radius: var(--border-radius);
+  border: 2px solid #3b82f6;
+  animation: borderAnimation 2s infinite linear;
   padding: 4px; /* Add padding so content does not touch the border */
   background: white; /* Ensure content background is white */
 }

This change:

  1. Makes border-radius configurable via CSS variable
  2. Simplifies the implementation by using only border
  3. Reduces animation duration for better UX
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0929df4 and 26d87de.

📒 Files selected for processing (3)
  • components/TOC.tsx (2 hunks)
  • package.json (1 hunks)
  • styles/globals.css (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🪛 ESLint
components/TOC.tsx

[error] 27-33: Replace ⏎··className,⏎··cssBreakingPoint·=·'xl',⏎··toc,⏎··contentSelector,⏎··depth·=·2,⏎ with ·className,·cssBreakingPoint·=·'xl',·toc,·contentSelector,·depth·=·2·

(prettier/prettier)


[error] 32-32: Unexpected trailing comma.

(comma-dangle)


[error] 37-40: Replace ⏎····(mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),⏎····0,⏎·· with (mLevel,·item)·=>·(!mLevel·||·item.lvl·<·mLevel·?·item.lvl·:·mLevel),·0

(prettier/prettier)


[error] 39-39: Unexpected trailing comma.

(comma-dangle)


[error] 45-47: Replace ⏎········.replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')⏎········ with .replace(/[\s]?\{#[\w\d\-_]+\}$/,·'')

(prettier/prettier)


[error] 76-76: Replace "TOC-Heading" with 'TOC-Heading'

(prettier/prettier)


[error] 76-76: Unexpected usage of doublequote.

(jsx-quotes)


[error] 80-82: Replace ⏎··········className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}⏎········ with ·className={text-underline·p4·text-center·${cssBreakingPoint·===·'xl'·?·'xl:hidden'·:·'lg:hidden'}}

(prettier/prettier)


[error] 89-91: Replace ⏎········className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}⏎······ with ·className={${!open·&&·'hidden'}·${cssBreakingPoint·===·'xl'·?·'xl:block'·:·'lg:block'}}

(prettier/prettier)


[error] 93-95: Replace ⏎············item.slug·?·item.slug·:·item.slugWithATag,⏎·········· with ·(item.slug·?·item.slug·:·item.slugWithATag)

(prettier/prettier)


[error] 94-94: Unexpected trailing comma.

(comma-dangle)


[error] 96-96: Replace "text-primary-500·font-bold" with 'text-primary-500·font-bold'

(prettier/prettier)


[error] 96-96: Unexpected usage of doublequote.

(jsx-quotes)


[error] 97-97: Replace "div" with 'div'

(prettier/prettier)


[error] 97-97: Unexpected usage of doublequote.

(jsx-quotes)


[error] 103-103: Insert ··

(prettier/prettier)


[error] 106-106: Replace "TOC-Link" with 'TOC-Link'

(prettier/prettier)


[error] 106-106: Unexpected usage of doublequote.

(jsx-quotes)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (1)
styles/globals.css (1)

4-8: LGTM!

The import statements now consistently use single quotes, improving code style consistency.

@@ -160,5 +160,6 @@
"remark-lint": "^10.0.0",
"remark-mdx": "^3.0.1",
"storybook": "^8.2.4"
}
},
"packageManager": "[email protected]+sha512.5383cc12567a95f1d668fbe762dfe0075c595b4bfff433be478dbbe24e05251a8e8c3eb992a986667c1d53b6c3a9c85b8398c35a960587fbd9fa3a0915406728"
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this?

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

Successfully merging this pull request may close these issues.

Improve Table of Contents (TOC) Links with Animated Gradient Border for Better Visibility
3 participants