-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
Changes from all commits
3f05be8
f7dc308
0abf626
d08cec0
789d49a
abd92d6
ac838b9
a6fc158
cd40a70
7d4d2c9
492b733
fd1b5c3
8e22a08
4326543
07b1613
b287aa4
939d6d1
731cd67
68f3204
1e8dc6a
a3b9183
cca71a2
6f76ff9
ea6bb54
70af050
a867408
9bbb25d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ import { IconKeys, Icons } from 'utils/data' | |
| import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' | ||
|
|
||
| export default function DisplayIcon({ item, icons }: { item: string; icons: IconType }) { | ||
| // className for the container | ||
| const containerClassName = [ | ||
| 'flex flex-row-reverse items-center justify-center gap-1 px-4 pb-1 -ml-2', | ||
| item === 'stars_count' || item === 'starsCount' ? 'rotate-container' : '', | ||
|
|
@@ -19,9 +18,10 @@ export default function DisplayIcon({ item, icons }: { item: string; icons: Icon | |
| .filter(Boolean) | ||
| .join(' ') | ||
|
|
||
| // className for the FontAwesome icon | ||
| const iconClassName = [ | ||
| 'text-gray-600 dark:text-gray-300', | ||
| 'transition-transform duration-200', | ||
| 'hover:scale-110', | ||
| getBrandColorClass(item), | ||
|
Comment on lines
+22
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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())
} |
||
| item === 'stars_count' || item === 'starsCount' ? 'icon-rotate' : '', | ||
srinjoy933 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| item === 'forks_count' || | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| item === 'contributors_count' || | ||
|
|
@@ -34,27 +34,37 @@ export default function DisplayIcon({ item, icons }: { item: string; icons: Icon | |
| .join(' ') | ||
|
|
||
| return icons[item] ? ( | ||
| <Tooltip | ||
| content={`${Icons[item as keyof typeof Icons]?.label}`} | ||
| delay={150} | ||
| closeDelay={100} | ||
| showArrow | ||
| placement="top" | ||
| > | ||
| <div className={containerClassName}> | ||
| {/* Display formatted number if the value is a number */} | ||
| <span className="text-gray-600 dark:text-gray-300"> | ||
| {typeof icons[item] === 'number' | ||
| ? millify(icons[item], { precision: 1 }) // Format large numbers using 'millify' library | ||
| : icons[item]} | ||
| </span> | ||
| <div className={containerClassName}> | ||
| <span className="text-gray-600 dark:text-gray-300"> | ||
| {typeof icons[item] === 'number' | ||
| ? millify(icons[item], { precision: 1 }) | ||
| : icons[item]} | ||
| </span> | ||
| <Tooltip | ||
| content={`${Icons[item as keyof typeof Icons]?.label}`} | ||
| delay={150} | ||
| closeDelay={100} | ||
| showArrow | ||
| placement="bottom" | ||
| > | ||
| <span> | ||
| <FontAwesomeIconWrapper | ||
| className={iconClassName} | ||
| icon={Icons[item as IconKeys]?.icon} // Display corresponding icon | ||
| icon={Icons[item as IconKeys]?.icon} | ||
| /> | ||
| </span> | ||
| </div> | ||
| </Tooltip> | ||
| </Tooltip> | ||
| </div> | ||
| ) : null | ||
| } | ||
|
|
||
| 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]', | ||
| } | ||
|
|
||
| return brandColors[item.toLowerCase()] || 'text-gray-600 dark:text-gray-300' | ||
| } | ||
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'm not sure I like these new colorful icons 🤔 Can we keep them in the same color? Possibly, showing brand colors on hover.


This is how they looked like before. We can keep blue, or the grey that you have by default.
Uh oh!
There was an error while loading. Please reload this page.
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 👍🏼