Skip to content
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

refactor: sidebar interaction by onclick #751

Merged
merged 7 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion frontend/webapp/components/side.menu/menu/menu.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const MenuContainer = styled.div`
height: 100%;
border-right: 1px solid rgba(255, 255, 255, 0.04);
background: ${({ theme }) => theme.colors.dark_blue};
&:hover {
&.isExpanded {
width: 234px;
}
`;
Expand Down
15 changes: 8 additions & 7 deletions frontend/webapp/components/side.menu/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Menu() {
const [currentMenuItem, setCurrentMenuItem] = useState<MenuItem>(
MENU_ITEMS[0]
);
const [isHovered, setIsHovered] = useState(false);
const [isExpanded, setIsExpanded] = useState(false);
const router = useRouter();

useEffect(onLoad, []);
Expand All @@ -54,15 +54,17 @@ export function Menu() {
onClick={() => handleMenuItemClick(item)}
focused={currentMenuItem?.id === item.id}
item={item}
expand={isHovered}
expand={isExpanded}
/>
));
}

function renderMenuLogo() {
return (
<LogoWrapper>
{isHovered ? (
<LogoWrapper
onClick={() => setIsExpanded(!isExpanded)}
>
{isExpanded ? (
<KeyvalText size={32} weight={700}>
{OVERVIEW.ODIGOS}
</KeyvalText>
Expand All @@ -76,15 +78,14 @@ export function Menu() {
function renderContactUsButton() {
return (
<ContactUsWrapper>
<ContactUsButton expand={isHovered} />
<ContactUsButton expand={isExpanded} />
</ContactUsWrapper>
);
}

return (
<MenuContainer
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
className={isExpanded ? 'isExpanded' : ''}
HeetVekariya marked this conversation as resolved.
Show resolved Hide resolved
>
{renderMenuLogo()}
<MenuItemsWrapper>{renderMenuItemsList()}</MenuItemsWrapper>
Expand Down