-
-
Notifications
You must be signed in to change notification settings - Fork 786
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request applies several formatting and refactoring changes without altering any core functionality. The Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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.
❌ Deploy Preview for asyncapi-website failed.Built without sensitive environment variables
|
We require all PRs to follow Conventional Commits specification.
|
There was a problem hiding this 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 (afterdepth = 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 thedata-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 theclassName
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, theclassName
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 thecurrentClassName
andcomponentTag
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 thedata-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
📒 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
components/TOC.tsx
Outdated
// 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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
.toLowerCase(), | |
.toLowerCase() |
🧰 Tools
🪛 ESLint
[error] 55-55: Delete ,
(prettier/prettier)
[error] 55-55: Unexpected trailing comma.
(comma-dangle)
components/TOC.tsx
Outdated
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}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
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.
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}`} |
0929df4
to
26d87de
Compare
There was a problem hiding this 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:
- Using
outline
for animation might impact performance. Consider usingborder-color
instead.- 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
andoutline
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:
- Makes border-radius configurable via CSS variable
- Simplifies the implementation by using only border
- Reduces animation duration for better UX
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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" |
There was a problem hiding this comment.
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?
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:-

Summary by CodeRabbit
Style
Chores