Skip to content

Commit

Permalink
Fix breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed Oct 14, 2024
1 parent 90001ba commit 855cbcb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const CurrentWorkspaceMemberFavorites = () => {

return (
<StyledContainer>
<NavigationDrawerAnimatedCollapseWrapper animateHeight>
<NavigationDrawerAnimatedCollapseWrapper>
<NavigationDrawerSectionTitle
label="Favorites"
onClick={() => toggleNavigationSection()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const NavigationDrawerSectionForObjectMetadataItems = ({
return (
objectMetadataItems.length > 0 && (
<NavigationDrawerSection>
<NavigationDrawerAnimatedCollapseWrapper animateHeight>
<NavigationDrawerAnimatedCollapseWrapper>
<NavigationDrawerSectionTitle
label={sectionTitle}
onClick={() => toggleNavigationSection()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNaviga
import { useTheme } from '@emotion/react';
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';

const StyledAnimatedContainer = styled(motion.div)`
overflow: hidden;
`;
const StyledAnimatedContainer = styled(motion.div)``;

export const NavigationDrawerAnimatedCollapseWrapper = ({
children,
animateHeight = false,
}: {
children: React.ReactNode;
animateHeight?: boolean;
}) => {
const theme = useTheme();
const isSettingsPage = useIsSettingsPage();
Expand All @@ -26,19 +22,20 @@ export const NavigationDrawerAnimatedCollapseWrapper = ({
return children;
}

let animate: AnimationControls | TargetAndTransition = {};
if (isNavigationDrawerExpanded) {
animate = { opacity: 1, pointerEvents: 'auto' };
} else {
animate = {
width: 0,
opacity: 0,
pointerEvents: 'none',
};
if (animateHeight) {
animate = { ...animate, height: 0 };
}
}
const animate: AnimationControls | TargetAndTransition =
isNavigationDrawerExpanded
? {
opacity: 1,
width: 'auto',
height: 'auto',
pointerEvents: 'auto',
}
: {
opacity: 0,
width: 0,
height: 0,
pointerEvents: 'none',
};

return (
<StyledAnimatedContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from 'twenty-ui';
import { isDefined } from '~/utils/isDefined';
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';

const DEFAULT_INDENTATION_LEVEL = 1;

Expand All @@ -40,7 +41,7 @@ export type NavigationDrawerItemProps = {
type StyledItemProps = Pick<
NavigationDrawerItemProps,
'active' | 'danger' | 'indentationLevel' | 'soon' | 'to'
>;
> & { isNavigationDrawerExpanded: boolean };

const StyledItem = styled('div', {
shouldForwardProp: (prop) =>
Expand Down Expand Up @@ -79,8 +80,12 @@ const StyledItem = styled('div', {
indentationLevel === 2 ? '2px' : '0'};
pointer-events: ${(props) => (props.soon ? 'none' : 'auto')};
width: 100%;
overflow: hidden;
width: ${(props) =>
!props.isNavigationDrawerExpanded
? `${NAV_DRAWER_WIDTHS.menu.desktop.collapsed - 24}px`
: '100%'};
:hover {
background: ${({ theme }) => theme.background.transparent.light};
color: ${(props) =>
Expand All @@ -106,7 +111,6 @@ const StyledItemElementsContainer = styled.div`

const StyledItemLabel = styled.div`
font-weight: ${({ theme }) => theme.font.weight.medium};
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
Expand Down Expand Up @@ -191,6 +195,7 @@ export const NavigationDrawerItem = ({
as={to ? Link : 'div'}
to={to ? to : undefined}
indentationLevel={indentationLevel}
isNavigationDrawerExpanded={isNavigationDrawerExpanded}
>
{showBreadcrumb && (
<NavigationDrawerAnimatedCollapseWrapper>
Expand Down

0 comments on commit 855cbcb

Please sign in to comment.