-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat: Introducing avatar tooltip #7143
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1024e8a
feat: tooltip component and avatar tooltip
canerakdas 4a82887
chore: metabar story props updated
canerakdas 683fe09
chore: self review
canerakdas ef4be2f
chore: self review
canerakdas f87e418
refactor: class names
canerakdas ed52e02
refactor: horizontal margin added
canerakdas 672e2cb
feat: accessible avatars on mobile
canerakdas 047e3c9
chore: resolve conflict
canerakdas 0f48558
feat: default author url
canerakdas 6ae4ebf
refactor: review updates
canerakdas 728bfde
chore: self review
canerakdas 1d1587d
Merge branch 'main' into feat/avatar-tooltip
ovflowd b8d9607
refactor: design and review updates
canerakdas 9365d1d
Merge branch 'feat/avatar-tooltip' of https://github.com/canerakdas/n…
canerakdas 667cfda
fix: Avatars in MetaBar story
canerakdas 6611dc0
refactor: review updates
canerakdas b0012da
fix: opening the tooltip portal within the dialog
canerakdas 17f3be9
Merge branch 'main' into feat/avatar-tooltip
canerakdas 816b7da
fix: adjusting visible avatar count
canerakdas 5a76b83
chore: resolve conflict
canerakdas a37d2dc
refactor: review updates
canerakdas b062f39
Update apps/site/util/authorUtils.ts
canerakdas 7c8f95e
refactor: enhancing code readability
canerakdas 912d47d
refactor: review update
canerakdas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,53 @@ | ||
| import * as RadixAvatar from '@radix-ui/react-avatar'; | ||
| import type { FC } from 'react'; | ||
| import classNames from 'classnames'; | ||
| import type { ComponentPropsWithoutRef, ElementRef } from 'react'; | ||
| import { forwardRef } from 'react'; | ||
|
|
||
| import Link from '@/components/Link'; | ||
|
|
||
| import styles from './index.module.css'; | ||
|
|
||
| export type AvatarProps = { | ||
| src: string; | ||
| alt: string; | ||
| fallback: string; | ||
| image?: string; | ||
| name?: string; | ||
| nickname: string; | ||
| fallback?: string; | ||
| size?: 'small' | 'medium'; | ||
| url?: string; | ||
| }; | ||
|
|
||
| const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => ( | ||
| <RadixAvatar.Root className={styles.avatarRoot}> | ||
| <RadixAvatar.Image | ||
| loading="lazy" | ||
| src={src} | ||
| alt={alt} | ||
| title={alt} | ||
| className={styles.avatar} | ||
| /> | ||
| <RadixAvatar.Fallback delayMs={500} className={styles.avatar}> | ||
| {fallback} | ||
| </RadixAvatar.Fallback> | ||
| </RadixAvatar.Root> | ||
| ); | ||
| const Avatar = forwardRef< | ||
| ElementRef<typeof RadixAvatar.Root>, | ||
| ComponentPropsWithoutRef<typeof RadixAvatar.Root> & AvatarProps | ||
| >(({ image, nickname, name, fallback, url, size = 'small', ...props }, ref) => { | ||
| const Wrapper = url ? Link : 'div'; | ||
|
|
||
| return ( | ||
| <RadixAvatar.Root | ||
| {...props} | ||
| className={classNames(styles.avatar, styles[size], props.className)} | ||
| ref={ref} | ||
| > | ||
| <Wrapper | ||
| href={url || undefined} | ||
| target={url ? '_blank' : undefined} | ||
| className={styles.wrapper} | ||
| > | ||
| <RadixAvatar.Image | ||
| loading="lazy" | ||
| src={image} | ||
| alt={name || nickname} | ||
| className={styles.item} | ||
| /> | ||
| <RadixAvatar.Fallback | ||
| delayMs={500} | ||
| className={classNames(styles.item, styles[size])} | ||
| > | ||
| {fallback} | ||
| </RadixAvatar.Fallback> | ||
| </Wrapper> | ||
| </RadixAvatar.Root> | ||
| ); | ||
| }); | ||
|
|
||
| export default Avatar; | ||
29 changes: 29 additions & 0 deletions
29
apps/site/components/Common/AvatarGroup/Overlay/index.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| .overlay { | ||
| @apply flex | ||
| min-w-56 | ||
| items-center | ||
| gap-2 | ||
| p-3; | ||
| } | ||
|
|
||
| .user { | ||
| @apply grow; | ||
| } | ||
|
|
||
| .name { | ||
| @apply font-semibold | ||
| text-neutral-900 | ||
| dark:text-neutral-300; | ||
| } | ||
|
|
||
| .nickname { | ||
| @apply font-medium | ||
| text-neutral-700 | ||
| dark:text-neutral-500; | ||
| } | ||
|
|
||
| .arrow { | ||
| @apply w-3 | ||
| fill-neutral-600 | ||
| dark:fill-white; | ||
| } |
21 changes: 21 additions & 0 deletions
21
apps/site/components/Common/AvatarGroup/Overlay/index.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type { Meta as MetaObj, StoryObj } from '@storybook/react'; | ||
|
|
||
| import AvatarOverlay from '@/components/Common/AvatarGroup/Overlay'; | ||
| import { getAuthorWithId, getAuthorWithName } from '@/util/authorUtils'; | ||
|
|
||
| type Story = StoryObj<typeof AvatarOverlay>; | ||
| type Meta = MetaObj<typeof AvatarOverlay>; | ||
|
|
||
| export const Default: Story = { | ||
| args: getAuthorWithId(['nodejs'], true)[0], | ||
| }; | ||
|
|
||
| export const FallBack: Story = { | ||
| args: getAuthorWithName(['Node.js'], true)[0], | ||
| }; | ||
|
|
||
| export const WithoutName: Story = { | ||
| args: getAuthorWithId(['canerakdas'], true)[0], | ||
| }; | ||
|
|
||
| export default { component: AvatarOverlay } as Meta; |
canerakdas marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { ArrowUpRightIcon } from '@heroicons/react/24/solid'; | ||
| import type { ComponentProps, FC } from 'react'; | ||
|
|
||
| import Avatar from '@/components/Common/AvatarGroup/Avatar'; | ||
| import Link from '@/components/Link'; | ||
|
|
||
| import styles from './index.module.css'; | ||
|
|
||
| export type AvatarOverlayProps = ComponentProps<typeof Avatar> & { | ||
| url?: string; | ||
| }; | ||
|
|
||
| const AvatarOverlay: FC<AvatarOverlayProps> = ({ | ||
| image, | ||
| name, | ||
| nickname, | ||
| fallback, | ||
| url, | ||
| }) => ( | ||
| <Link className={styles.overlay} href={url} target="_blank"> | ||
| <Avatar | ||
| image={image} | ||
| name={name} | ||
| nickname={nickname} | ||
| fallback={fallback} | ||
| size="medium" | ||
| /> | ||
| <div className={styles.user}> | ||
| {name && <div className={styles.name}>{name}</div>} | ||
| {nickname && <div className={styles.nickname}>{nickname}</div>} | ||
| </div> | ||
| <ArrowUpRightIcon className={styles.arrow} /> | ||
| </Link> | ||
| ); | ||
|
|
||
| export default AvatarOverlay; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.