* padding fix for header container * collapse menu hover and fade transition added * Update front/src/modules/ui/navbar/components/NavWorkspaceButton.tsx Co-authored-by: Emilien Chauvet <emilien.chauvet.enpc@gmail.com> * Update front/src/modules/ui/navbar/components/NavWorkspaceButton.tsx Co-authored-by: Emilien Chauvet <emilien.chauvet.enpc@gmail.com> * Update front/src/modules/ui/navbar/components/NavCollapseButton.tsx Co-authored-by: Emilien Chauvet <emilien.chauvet.enpc@gmail.com> * Update isVisible * Update requested proposals for naming --------- Co-authored-by: Emilien Chauvet <emilien.chauvet.enpc@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5a5ee1ff8d
commit
69e0917338
@ -95,7 +95,7 @@ export function PageBar({
|
|||||||
<StyledLeftContainer>
|
<StyledLeftContainer>
|
||||||
{!isNavbarOpened && (
|
{!isNavbarOpened && (
|
||||||
<StyledTopBarButtonContainer>
|
<StyledTopBarButtonContainer>
|
||||||
<NavCollapseButton direction="right" />
|
<NavCollapseButton direction="right" hide={true} />
|
||||||
</StyledTopBarButtonContainer>
|
</StyledTopBarButtonContainer>
|
||||||
)}
|
)}
|
||||||
{hasBackButton && (
|
{hasBackButton && (
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import NavItemsContainer from './NavItemsContainer';
|
import NavItemsContainer from './NavItemsContainer';
|
||||||
@ -18,10 +19,20 @@ const StyledContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default function MainNavbar({ children }: OwnProps) {
|
export default function MainNavbar({ children }: OwnProps) {
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
|
const handleHover = () => {
|
||||||
|
setIsHovered(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseLeave = () => {
|
||||||
|
setIsHovered(false);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<div>
|
<div onMouseEnter={handleHover} onMouseLeave={handleMouseLeave}>
|
||||||
<NavWorkspaceButton />
|
<NavWorkspaceButton hideCollapseButton={isHovered} />
|
||||||
<NavItemsContainer>{children}</NavItemsContainer>
|
<NavItemsContainer>{children}</NavItemsContainer>
|
||||||
</div>
|
</div>
|
||||||
<SupportChat />
|
<SupportChat />
|
||||||
|
|||||||
@ -10,8 +10,11 @@ import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
|||||||
|
|
||||||
import { navbarIconSize } from '../constants';
|
import { navbarIconSize } from '../constants';
|
||||||
|
|
||||||
const StyledCollapseButton = styled.button`
|
const StyledCollapseButton = styled.button<{
|
||||||
|
hide: boolean;
|
||||||
|
}>`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
animation: ${({ hide }) => (hide ? 'fadeIn 150ms' : 'none')};
|
||||||
background: inherit;
|
background: inherit;
|
||||||
border: 0;
|
border: 0;
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -29,15 +32,27 @@ const StyledCollapseButton = styled.button`
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
visibility: ${({ hide }) => (hide ? 'visible' : 'hidden')};
|
||||||
width: 32px;
|
width: 32px;
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type CollapseButtonProps = {
|
type CollapseButtonProps = {
|
||||||
direction?: 'left' | 'right';
|
direction?: 'left' | 'right';
|
||||||
|
hide: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function NavCollapseButton({
|
export default function NavCollapseButton({
|
||||||
direction = 'left',
|
direction = 'left',
|
||||||
|
hide,
|
||||||
}: CollapseButtonProps) {
|
}: CollapseButtonProps) {
|
||||||
const [isNavOpen, setIsNavOpen] = useRecoilState(isNavbarOpenedState);
|
const [isNavOpen, setIsNavOpen] = useRecoilState(isNavbarOpenedState);
|
||||||
|
|
||||||
@ -48,11 +63,17 @@ export default function NavCollapseButton({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{direction === 'left' ? (
|
{direction === 'left' ? (
|
||||||
<StyledCollapseButton onClick={() => setIsNavOpen(!isNavOpen)}>
|
<StyledCollapseButton
|
||||||
|
hide={hide}
|
||||||
|
onClick={() => setIsNavOpen(!isNavOpen)}
|
||||||
|
>
|
||||||
<IconLayoutSidebarLeftCollapse size={iconSize} />
|
<IconLayoutSidebarLeftCollapse size={iconSize} />
|
||||||
</StyledCollapseButton>
|
</StyledCollapseButton>
|
||||||
) : (
|
) : (
|
||||||
<StyledCollapseButton onClick={() => setIsNavOpen(!isNavOpen)}>
|
<StyledCollapseButton
|
||||||
|
hide={hide}
|
||||||
|
onClick={() => setIsNavOpen(!isNavOpen)}
|
||||||
|
>
|
||||||
<IconLayoutSidebarRightCollapse size={iconSize} />
|
<IconLayoutSidebarRightCollapse size={iconSize} />
|
||||||
</StyledCollapseButton>
|
</StyledCollapseButton>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -14,10 +14,8 @@ const StyledContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-left: ${({ theme }) => theme.spacing(1)};
|
padding: ${({ theme }) => theme.spacing(1)};
|
||||||
padding: ${({ theme }) => theme.spacing(2)};
|
padding-bottom: ${({ theme }) => theme.spacing(2)};
|
||||||
padding-right: ${({ theme }) => theme.spacing(1)};
|
|
||||||
padding-top: ${({ theme }) => theme.spacing(1)};
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -47,7 +45,11 @@ const StyledName = styled.div`
|
|||||||
margin-left: ${({ theme }) => theme.spacing(2)};
|
margin-left: ${({ theme }) => theme.spacing(2)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function NavWorkspaceButton() {
|
type OwnProps = {
|
||||||
|
hideCollapseButton: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
function NavWorkspaceButton({ hideCollapseButton }: OwnProps) {
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
|
|
||||||
const currentWorkspace = currentUser?.workspaceMember?.workspace;
|
const currentWorkspace = currentUser?.workspaceMember?.workspace;
|
||||||
@ -66,7 +68,7 @@ function NavWorkspaceButton() {
|
|||||||
></StyledLogo>
|
></StyledLogo>
|
||||||
<StyledName>{currentWorkspace?.displayName ?? 'Twenty'}</StyledName>
|
<StyledName>{currentWorkspace?.displayName ?? 'Twenty'}</StyledName>
|
||||||
</StyledLogoAndNameContainer>
|
</StyledLogoAndNameContainer>
|
||||||
<NavCollapseButton direction="left" />
|
<NavCollapseButton direction="left" hide={hideCollapseButton} />
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user