-
-
Notifications
You must be signed in to change notification settings - Fork 95
Enhancing Social Media Icons with Hover Effects and Tooltips for Better UX #1199
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
base: main
Are you sure you want to change the base?
Conversation
Summary by CodeRabbit
WalkthroughThe pull request updates the Changes
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 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
|
can you please review @arkid15r whether any changes are required or not? |
is it okay @arkid15r ? |
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.
Thanks for the update. Left some comments!
frontend/src/components/Card.tsx
Outdated
style={{ backgroundColor: level.color }} | ||
> | ||
<FontAwesomeIconWrapper icon={level.icon} className="text-white" /> | ||
</span> | ||
</Tooltip> | ||
)} | ||
{/* Project title and link */} |
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.
I think we can keep these as they separate logic blocks 👍🏼
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.
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.
@kasya can you clarify a little bit more on this issue, exactly would you like me to change the colours to their brand colurs, or let it be blue or grey?thank you!
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.
@srinjoy933 yes, I meant that we should show a single color - blue or grey, I'm fine with the grey one 👍🏼
frontend/src/components/Card.tsx
Outdated
className={cn( | ||
'flex h-8 w-8 items-center justify-center rounded-full text-xs shadow' | ||
)} | ||
className="flex h-8 w-8 items-center justify-center rounded-full shadow" |
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.
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.
Requested some changes ⬇️
.join(' ') | ||
const iconClassName = `transition-colors duration-200 ${ | ||
hovered ? Icons[item as IconKeys]?.colorClass || 'text-gray-600' : 'text-gray-600 dark:text-gray-300' | ||
}` | ||
|
||
return icons[item] ? ( | ||
<Tooltip |
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.
Also, I no longer see the tooltip actually 🤔
https://www.awesomescreenshot.com/video/38208588?key=39ee952036d49436a885bff2e463aaee
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.
made the changes you suggested.
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.
@srinjoy933 still no tooltips on Social links. I do see tooltips everywhere else.
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.
Still can not see those tooltips 🤔
https://www.awesomescreenshot.com/video/38329070?key=7ad789615a3bfcae2fc8f5934ace0f2b
made some changes ,i guest it will appear now, please see it once @kasya .thank you |
.join(' ') | ||
const iconClassName = `transition-colors duration-200 ${ | ||
hovered ? Icons[item as IconKeys]?.colorClass || 'text-gray-600' : 'text-gray-600 dark:text-gray-300' | ||
}` | ||
|
||
return icons[item] ? ( | ||
<Tooltip |
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.
@srinjoy933 still no tooltips on Social links. I do see tooltips everywhere else.
const iconClassName = [ | ||
'text-gray-600 dark:text-gray-300', | ||
item === 'stars_count' || item === 'starsCount' ? 'icon-rotate' : '', | ||
item === 'forks_count' || |
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.
These don't have animation they had before. I'd prefer we keep it.
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: 3
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/DisplayIcon.tsx
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/components/DisplayIcon.tsx (2)
frontend/src/utils/data.ts (2)
Icons
(66-107)IconKeys
(109-109)frontend/src/components/ui/tooltip.tsx (1)
Tooltip
(13-44)
🔇 Additional comments (5)
frontend/src/components/DisplayIcon.tsx (5)
47-47
: Good improvement to number formatting.Adding precision to millify ensures consistent number formatting with one decimal place.
53-53
: Type safety improvement for icon reference.Using the
IconKeys
type is more type-safe than the previous approach withkeyof typeof Icons
.
22-24
:❓ Verification inconclusive
The hover effects align with PR objectives, but check GitHub metric icons.
The transition, scaling, and brand colors on hover match the PR requirements. However, previous review comments indicated these changes may have affected existing hover animations for GitHub metrics icons (stars, forks, etc.).
🏁 Script executed:
#!/bin/bash # Check if there were specific styles for GitHub metric icons that might have been affected echo "Checking for existing icon styles in CSS files:" find frontend/src -name "*.css" -o -name "*.scss" | xargs grep -l "icon-rotate\|icon-flip" echo -e "\nChecking for any icon-related classes:" find frontend/src -name "*.css" -o -name "*.scss" | xargs grep -l "\.icon-\|rotate-container\|flip-container"Length of output: 448
Action Required: Verify GitHub Metric Icons Hover Behavior
The updated hover classes in
frontend/src/components/DisplayIcon.tsx
(lines 22–24) meet the PR objectives. However, our CSS search shows that the only file referencing potential GitHub metric icon styles (e.g., for rotation/flip effects) isfrontend/src/index.css
. Please double-check that the new hover effects do not inadvertently override or conflict with the hover animations for GitHub metric icons (such as stars and forks):
- Ensure that any rules in
frontend/src/index.css
(or elsewhere) targeting classes likeicon-rotate
,icon-flip
, or similar remain intact.- Confirm via manual QA that GitHub metric icons retain their intended animations without interference from the
transition-transform
,hover:scale-110
, or brand color classes applied to non-metric icons.
39-39
:❓ Verification inconclusive
Update tooltip props to match new package API.
The tooltip props have been adjusted to work with the @heroui/tooltip package, but previous review comments indicate tooltips aren't appearing. Ensure that the new props (
delay
instead ofopenDelay
,placement
instead ofpositioning
) are correct for the new package.Also applies to: 42-42
🏁 Script executed:
#!/bin/bash # Check the documentation or type definitions for @heroui/tooltip echo "Checking tooltip props in @heroui/tooltip:" find node_modules/@heroui/tooltip -name "*.d.ts" | xargs grep -A 20 "interface.*TooltipProps\|type.*TooltipProps" # Look for examples of tooltip usage in the codebase echo -e "\nChecking for other usage examples of @heroui/tooltip:" grep -r "import.*@heroui/tooltip" --include="*.tsx" frontend/src/ | grep -v "DisplayIcon.tsx" grep -r "<Tooltip.*delay=" --include="*.tsx" frontend/src/ | grep -v "DisplayIcon.tsx" grep -r "<Tooltip.*placement=" --include="*.tsx" frontend/src/ | grep -v "DisplayIcon.tsx"Length of output: 669
Action Required: Confirm Tooltip API Prop Changes
The tooltip component in
frontend/src/components/DisplayIcon.tsx
(lines 39 and 42) now uses the new props (delay
instead ofopenDelay
, andplacement
instead ofpositioning
). However, our automated search couldn’t locate the @heroui/tooltip package or usage examples in the codebase to verify these changes. Please manually verify that these updated prop names align with the package’s current API.
- File:
frontend/src/components/DisplayIcon.tsx
- Lines: 39 and 42
- Issue: Tooltip props updated to match @heroui/tooltip API; ensure that using
delay
andplacement
is correct per the package documentation.
60-69
:❓ Verification inconclusive
Brand color hover effects meet requirements but check applicability.
The implementation of brand colors on hover aligns with the PR objectives. However, ensure this is only applied to social media icons and not to GitHub metrics icons per previous review comments.
Also verify there's a consistent approach to color handling by examining:
🏁 Script executed:
#!/bin/bash # Check where this component is used and with what item values echo "Looking for DisplayIcon usage with social media items:" grep -r "<DisplayIcon" --include="*.tsx" frontend/src/ | grep -E "item=['\"]discord|instagram|linkedin|youtube" echo -e "\nLooking for all DisplayIcon usages:" grep -r "<DisplayIcon" --include="*.tsx" frontend/src/Length of output: 440
🌐 Web query:
What are best practices for handling hover effects and brand colors for social media icons in React applications?
💡 Result:
To handle hover effects and brand colors for social media icons in React effectively, follow these best practices:
1. Use Dedicated Icon Libraries
Leverage React-specific libraries like
react-icons
orreact-social-icons
to simplify implementation and ensure performance. These libraries provide optimized SVG icons and eliminate the need to load entire icon sets[5][6][10].// Example using react-social-icons[5] import { SocialIcon } from 'react-social-icons'; <SocialIcon url="https://twitter.com" bgColor="#1DA1F2" />Import icons selectively to reduce bundle size:
// Instead of importing all icons[6][10] import { FaTwitter } from 'react-icons/fa';2. Brand Color Implementation
Apply platform-specific brand colors using official HEX values:
/* CSS class approach[1][8] */ .twitter { color: #1DA1F2; } .youtube { color: #FF0000; }// Inline style method[2][5] <MDBBtn style={{ backgroundColor: '#1DA1F2' }}>Use dynamic props for color theming:
<FontAwesomeIcon icon={faTwitter} color={isDarkMode ? '#fff' : '#1DA1F2'} />[1][4]3. Hover Effects
CSS transitions for smooth animations[1][3][8]:
.social-icon { transition: transform 0.3s ease; } .social-icon:hover { transform: translateY(-3px); opacity: 0.8; }State-driven hover effects for complex interactions[3][9]:
const [hovered, setHovered] = useState(false); <FaTwitter color={hovered ? '#0D8ECF' : '#1DA1F2'} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} />4. Accessibility & Semantics
Add ARIA labels for screen readers[5][10]:
<SocialIcon aria-label="Follow us on Twitter" url="https://twitter.com" />Use semantic HTML:
<a href="https://twitter.com" role="button"> <FaTwitter /> </a>5. Performance Optimization
Global icon configuration with
IconContext.Provider
[6][10]:<IconContext.Provider value={{ size: '2em', className: 'global-icons' }}> <FaTwitter /> <FaFacebook /> </IconContext.Provider>Lazy load non-critical icons using dynamic imports:
const TwitterIcon = React.lazy(() => import('react-icons/fa').then(module => ({ default: module.FaTwitter })));6. Responsive Design
Use relative units for sizing[7][8]:
<FaTwitter size="clamp(1.5rem, 3vw, 2rem)" />Media queries for hover behavior[3]:
@media (hover: hover) { .social-icon:hover { /* styles */ } }Recommended Implementation
import { SocialIcon } from 'react-social-icons'; const SocialIcons = () => ( <div className="social-container"> <SocialIcon url="https://twitter.com" bgColor="transparent" fgColor="#1DA1F2" className="social-icon" aria-label="Twitter" /> <SocialIcon url="https://facebook.com" bgColor="transparent" fgColor="#1877F2" className="social-icon" aria-label="Facebook" /> </div> );.social-icon { transition: transform 0.3s ease, opacity 0.3s ease; margin: 0 12px; } .social-icon:hover { transform: translateY(-3px); opacity: 0.8; } @media (prefers-reduced-motion) { .social-icon { transition: none; } }This approach combines brand authenticity (using official colors[1][5]), accessibility[3][10], and performance[6][7] while maintaining visual polish through CSS transitions[1][8]. For complex use cases, consider combining with state management for dynamic interactions[3][9].
Citations:
- 1: https://www.digitalocean.com/community/tutorials/creating-a-social-follow-component-in-react
- 2: https://mdbootstrap.com/docs/react/extended/social-media/
- 3: https://www.dhiwise.com/post/elevate-your-ui-with-react-style-hover-developers-handbook
- 4: https://dev.to/seanyasno/handling-icons-in-react-best-practices-22c5
- 5: https://www.npmjs.com/package/react-social-icons
- 6: https://www.youtube.com/watch?v=aor9hlcODUE
- 7: https://hugeicons.com/blog/development/top-5-react-icon-library
- 8: https://www.youtube.com/watch?v=oHmz42qRfho
- 9: https://forum.freecodecamp.org/t/issues-with-hover-effect-in-react/615774
- 10: https://www.videosdk.live/blog/react-icons-guide
Action Required: Verify That Hover Effects Are Limited to Social Media Icons
The implementation of hover effects viagetBrandColorClass
conforms to the PR objectives and best practices for social media icon branding. However, please confirm that these brand-specific hover styles are only applied when the icon represents a social media channel (e.g. Discord, Instagram, LinkedIn, YouTube) and are not inadvertently used for GitHub metrics icons. In particular, note that our search located a usage infrontend/src/components/Card.tsx
without clear evidence that it’s a social media icon. Verify that any such usage is appropriate or adjust the logic accordingly.
delay={150} | ||
closeDelay={100} | ||
showArrow | ||
positioning={{ placement: 'top' }} | ||
placement="top" |
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.
Ensure tooltips appear for all icon types.
Previous review comments repeatedly mentioned that tooltips weren't appearing for social links after your changes. Test the tooltip functionality for all icon types, particularly social media icons.
Since multiple reviewers have mentioned this issue, please verify that tooltips appear for all icon types after your changes. Make sure the delay and placement properties are correctly implemented for the @heroui/tooltip package.
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: 3
🧹 Nitpick comments (2)
frontend/src/components/DisplayIcon.tsx (2)
47-47
: Consider making precision configurableAdding precision to millify is good, but consider making it configurable for different contexts.
-? millify(icons[item], { precision: 1 }) +? millify(icons[item], { precision: getPrecisionForItem(item) }) // Add somewhere in the file: function getPrecisionForItem(item: string): number { // Default precision is 1, but can be customized for specific items return 1; }
60-69
: Improve the brand color implementationThe implementation matches the requirements but can be enhanced for better maintainability.
Consider these improvements:
function getBrandColorClass(item: string): string { const brandColors: Record<string, string> = { discord: 'hover:text-[#5865F2]', instagram: 'hover:text-[#E4405F]', linkedin: 'hover:text-[#0077B5]', youtube: 'hover:text-[#FF0000]', + // Add other platforms as needed } - return brandColors[item.toLowerCase()] || 'text-gray-600 dark:text-gray-300' + // Only apply hover color to social media icons + const isSocialMediaIcon = Object.keys(brandColors).includes(item.toLowerCase()) + return isSocialMediaIcon + ? brandColors[item.toLowerCase()] + : 'text-gray-600 dark:text-gray-300' }This approach explicitly checks if the icon is a social media icon before applying brand colors, which is more intentional and maintainable.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/DisplayIcon.tsx
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/components/DisplayIcon.tsx (2)
frontend/src/utils/data.ts (2)
Icons
(66-107)IconKeys
(109-109)frontend/src/components/ui/tooltip.tsx (1)
Tooltip
(13-44)
🔇 Additional comments (1)
frontend/src/components/DisplayIcon.tsx (1)
7-58
:❓ Verification inconclusive
Test tooltip functionality for all icon types
Previous review comments repeatedly mentioned tooltips weren't appearing for social links.
Please verify tooltip functionality for all icon types, particularly social media icons. Run this script to check for potential issues:
🏁 Script executed:
#!/bin/bash # Check if @heroui/tooltip package is installed echo "Checking if @heroui/tooltip is installed:" if [ -d "node_modules/@heroui/tooltip" ]; then echo "Package found in node_modules." else echo "Package NOT found in node_modules. This could explain tooltip issues." fi # Check package.json for dependency echo -e "\nChecking package.json dependencies:" grep -E "@heroui/tooltip" package.json || echo "Not found in package.json" # Check for other tooltip implementations echo -e "\nChecking for tooltip component implementations:" find frontend/src/components -type f -name "*.tsx" | xargs grep -l "Tooltip" | sortLength of output: 984
Action Required: Verify Custom Tooltip Functionality for All Icon Types
The code in
frontend/src/components/DisplayIcon.tsx
now relies on our local Tooltip component (seefrontend/src/components/ui/tooltip.tsx
) rather than the external@heroui/tooltip
package—which is neither installed innode_modules
nor listed in the dependency file. Please manually test the tooltip behavior for all icon types, with particular focus on social media icons. Ensure that on hover the tooltip appears as expected with the correct delay and content. If any issues persist (especially with social links), further investigation into the custom Tooltip implementation may be required.
'transition-transform duration-200', | ||
'hover:scale-110', | ||
getBrandColorClass(item), |
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
Ensure hover effects don't interfere with existing animations
Your implementation adds nice hover effects but might be interfering with existing animations for GitHub metrics icons.
Consider a more contextual approach that preserves original animations:
const iconClassName = [
'transition-transform duration-200',
'hover:scale-110',
- getBrandColorClass(item),
+ // Only apply brand colors to social media icons
+ isSocialMediaIcon(item) ? getBrandColorClass(item) : 'text-gray-600 dark:text-gray-300',
item === 'stars_count' || item === 'starsCount' ? 'icon-rotate' : '',
item === 'forks_count' ||
item === 'contributors_count' ||
item === 'forksCount' ||
item === 'contributionCount'
? 'icon-flip'
: '',
]
Add a helper function to determine if an icon is a social media icon:
function isSocialMediaIcon(item: string): boolean {
return ['discord', 'instagram', 'linkedin', 'youtube'].includes(item.toLowerCase())
}
@@ -1,12 +1,10 @@ | |||
import { Tooltip } from '@heroui/tooltip' |
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.
Resolve the dependency issue with @heroui/tooltip
Previous review comments indicate that this external package may not be installed, causing tooltip functionality issues. The previous version used a local tooltip implementation from frontend/src/components/ui/tooltip.tsx
.
Either:
- Install
@heroui/tooltip
package if that's the intended solution, or - Revert to using the local tooltip implementation:
-import { Tooltip } from '@heroui/tooltip'
+import { Tooltip } from 'components/ui/tooltip'
📝 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.
import { Tooltip } from '@heroui/tooltip' | |
import { Tooltip } from 'components/ui/tooltip' |
<Tooltip | ||
content={`${Icons[item as keyof typeof Icons]?.label}`} | ||
recipe={TooltipRecipe} | ||
openDelay={150} | ||
delay={150} | ||
closeDelay={100} | ||
showArrow | ||
positioning={{ placement: 'top' }} | ||
placement="bottom" | ||
> |
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.
Fix tooltip API incompatibility issues
The tooltip API has changed, which might explain why tooltips aren't appearing for social links as mentioned in previous reviews.
If continuing with the external package, ensure the props match the expected API:
<Tooltip
content={`${Icons[item as keyof typeof Icons]?.label}`}
delay={150}
closeDelay={100}
showArrow
placement="bottom"
+ // Add any other required props from @heroui/tooltip
>
Alternatively, if reverting to the local tooltip implementation:
<Tooltip
content={`${Icons[item as keyof typeof Icons]?.label}`}
- delay={150}
+ openDelay={150}
closeDelay={100}
showArrow
- placement="bottom"
+ positioning="bottom"
>
📝 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.
<Tooltip | |
content={`${Icons[item as keyof typeof Icons]?.label}`} | |
recipe={TooltipRecipe} | |
openDelay={150} | |
delay={150} | |
closeDelay={100} | |
showArrow | |
positioning={{ placement: 'top' }} | |
placement="bottom" | |
> | |
<Tooltip | |
content={`${Icons[item as keyof typeof Icons]?.label}`} | |
delay={150} | |
closeDelay={100} | |
showArrow | |
placement="bottom" | |
// Add any other required props from @heroui/tooltip | |
> |
<Tooltip | |
content={`${Icons[item as keyof typeof Icons]?.label}`} | |
recipe={TooltipRecipe} | |
openDelay={150} | |
delay={150} | |
closeDelay={100} | |
showArrow | |
positioning={{ placement: 'top' }} | |
placement="bottom" | |
> | |
<Tooltip | |
content={`${Icons[item as keyof typeof Icons]?.label}`} | |
openDelay={150} | |
closeDelay={100} | |
showArrow | |
positioning="bottom" | |
> |
|
please have a look at this @kasya. is it ok now? |
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.
@srinjoy933 Could you add a video of how this works on your computer?
I'm still not able to see any tooltips on social media icons for Chapters.
If you check Card.tsx
component there's no Tooltip anywhere near social links
Resolves issues1168
Add the PR description here.
solves the issue:
When hovering over an icon, it should slightly enlarge (scale effect).
The icon's color should change to match the original brand color of the respective app.
A tooltip should appear, showing the platform name (e.g., "Discord", "Instagram", "LinkedIn", "YouTube").