Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 30 additions & 25 deletions src/components/UserAvatar.js
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;
Copy link
Member

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.


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>
Copy link
Member

Choose a reason for hiding this comment

The 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'.

Screenshot 2024-01-30 191156

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}
Copy link
Member

Choose a reason for hiding this comment

The 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>
);
}

Expand Down