-
-
Notifications
You must be signed in to change notification settings - Fork 183
Resolved Issue [#1742] Implemented MUI Tooltip for the UserAvatar com… #1743
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?
Changes from all commits
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 |
|---|---|---|
| @@ -1,40 +1,45 @@ | ||
| import { Box, Link, Avatar, Typography } from '@mui/material'; | ||
| import { Box, Link, Avatar, Typography, Tooltip } from '@mui/material'; | ||
|
|
||
| function UserAvatar({ auth }) { | ||
| if (!auth?.isAuthenticated) { | ||
| return null; | ||
| } | ||
|
|
||
| const userName = auth?.user?.profile.preferred_username[0] || null; | ||
|
|
||
| return ( | ||
| <Box> | ||
| <Link | ||
| href="https://dev-k8s.treetracker.org/keycloak/realms/treetracker/account/#/personal-info" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| sx={{ | ||
| color: ({ palette }) => palette.text.primary, | ||
| }} | ||
| > | ||
| <Avatar | ||
| <Tooltip title={userName} arrow> | ||
|
Member
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. Currently the arrow tooltip will show up behind the header/banner of the website. This is likely due to the header having a z-index of '9999'. I am hesitant to suggest changing the header zindex to anything lower in the event it ruins the format in some place I'm unaware of. I am open to suggestions or ideas. @dadiorchen ? |
||
| <Box> | ||
| <Link | ||
| href="https://dev-k8s.treetracker.org/keycloak/realms/treetracker/account/#/personal-info" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| sx={{ | ||
| width: 24, | ||
| height: 24, | ||
| background: ({ palette }) => palette.background.greenGradient, | ||
| color: ({ palette }) => palette.text.primary, | ||
| }} | ||
| > | ||
| <Typography | ||
| variant="caption" | ||
| <Avatar | ||
| sx={{ | ||
| textTransform: 'uppercase', | ||
| fontSize: 16, | ||
| textDecoration: 'none', | ||
| color: ({ palette }) => palette.text.contrast, | ||
| width: 24, | ||
| height: 24, | ||
| background: ({ palette }) => palette.background.greenGradient, | ||
| }} | ||
| > | ||
| {auth?.user?.profile.preferred_username[0] || null} | ||
| </Typography> | ||
| </Avatar> | ||
| </Link> | ||
| </Box> | ||
| <Typography | ||
| variant="caption" | ||
| sx={{ | ||
| textTransform: 'uppercase', | ||
| fontSize: 16, | ||
| textDecoration: 'none', | ||
| color: ({ palette }) => palette.text.contrast, | ||
| }} | ||
| > | ||
| {userName} | ||
|
Member
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. We can change this to {userName ? userName[0] : null} to conform with the idea on line 8. |
||
| </Typography> | ||
| </Avatar> | ||
| </Link> | ||
| </Box> | ||
| </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.
I think userName should be set to auth?.user?.profile.preferred_username || null.
That way, when you highlight the tooltip--which is currently just the first letter of their username--it will give new information, instead of repeating information the user already has.