mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 14:28:48 +00:00
refactor css and tsx files
This commit is contained in:
parent
241eab70e6
commit
c3695b240f
2 changed files with 56 additions and 0 deletions
46
code/frontend/src/components/Username.tsx
Normal file
46
code/frontend/src/components/Username.tsx
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { Popover, Typography } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import "./username.css";
|
||||
|
||||
export default function Username({ username }: { username: string }) {
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||
|
||||
const openPopover = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
|
||||
const closePopover = () => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
const isPopoverOpen = Boolean(anchorEl);
|
||||
const id = isPopoverOpen ? "simple-popover" : undefined;
|
||||
|
||||
useEffect(() => {
|
||||
console.log("Username component mounted");
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<Popover
|
||||
className="profile-popover"
|
||||
onClose={closePopover}
|
||||
id={id}
|
||||
open={isPopoverOpen}
|
||||
anchorEl={anchorEl}
|
||||
anchorOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "left",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "left",
|
||||
}}
|
||||
>
|
||||
<Typography sx={{ p: 1 }}>{username}</Typography>
|
||||
</Popover>
|
||||
<span className="profile-username body-bold" onClick={openPopover}>
|
||||
{username}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
}
|
10
code/frontend/src/components/username.css
Normal file
10
code/frontend/src/components/username.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
.profile-username {
|
||||
color: var(--Rotkehlchen-orange-default);
|
||||
max-width: 10rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.profile-popover {
|
||||
padding: 1rem;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue