forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISSUE Closes twentyhq#7085 DEMO https://github.com/user-attachments/assets/39692906-c02e-4e4c-9205-82447fa142df --------- Co-authored-by: Lucas Bordeau <[email protected]>
- Loading branch information
1 parent
74291e5
commit e5641c5
Showing
9 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/twenty-front/src/modules/navigation/hooks/useOpenSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState'; | ||
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded'; | ||
import { useRecoilState } from 'recoil'; | ||
|
||
export const useOpenSettingsMenu = () => { | ||
const [, setIsNavigationDrawerExpanded] = useRecoilState( | ||
isNavigationDrawerExpandedState, | ||
); | ||
const [, setCurrentMobileNavigationDrawer] = useRecoilState( | ||
currentMobileNavigationDrawerState, | ||
); | ||
|
||
const openSettingsMenu = () => { | ||
setIsNavigationDrawerExpanded(true); | ||
setCurrentMobileNavigationDrawer('settings'); | ||
}; | ||
|
||
return { openSettingsMenu }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
packages/twenty-front/src/modules/ui/layout/page/components/SubMenuTopBarContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/MobileBreadcrumb.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useOpenSettingsMenu } from '@/navigation/hooks/useOpenSettings'; | ||
import { useTheme } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import { isNonEmptyString } from '@sniptt/guards'; | ||
import { ReactNode } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { IconChevronLeft } from 'twenty-ui'; | ||
|
||
export type MobileBreadcrumbProps = { | ||
className?: string; | ||
links: { children: string | ReactNode; href?: string }[]; | ||
}; | ||
|
||
const StyledWrapper = styled.nav` | ||
align-items: center; | ||
color: ${({ theme }) => theme.font.color.tertiary}; | ||
display: grid; | ||
font-size: ${({ theme }) => theme.font.size.md}; | ||
grid-auto-flow: column; | ||
grid-column-gap: ${({ theme }) => theme.spacing(1)}; | ||
max-width: 100%; | ||
min-width: 0; | ||
height: ${({ theme }) => theme.spacing(8)}; | ||
`; | ||
|
||
const StyledLink = styled(Link)` | ||
color: inherit; | ||
text-decoration: none; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
|
||
const StyledText = styled.span` | ||
color: inherit; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
|
||
export const MobileBreadcrumb = ({ | ||
className, | ||
links, | ||
}: MobileBreadcrumbProps) => { | ||
const theme = useTheme(); | ||
|
||
const { openSettingsMenu } = useOpenSettingsMenu(); | ||
|
||
const handleBackToSettingsClick = () => { | ||
openSettingsMenu(); | ||
}; | ||
|
||
const previousLink = links[links.length - 2]; | ||
const shouldRedirectToSettings = links.length === 2; | ||
|
||
const text = isNonEmptyString(previousLink.children) | ||
? previousLink.children | ||
: ''; | ||
|
||
return ( | ||
<StyledWrapper className={className}> | ||
{shouldRedirectToSettings ? ( | ||
<> | ||
<IconChevronLeft size={theme.icon.size.md} /> | ||
<StyledText onClick={handleBackToSettingsClick}> | ||
Back to Settings | ||
</StyledText> | ||
</> | ||
) : previousLink?.href ? ( | ||
<> | ||
<IconChevronLeft size={theme.icon.size.md} /> | ||
<StyledLink title={text} to={previousLink.href}> | ||
Back to {previousLink.children} | ||
</StyledLink> | ||
</> | ||
) : ( | ||
<StyledText title={text}>{previousLink?.children}</StyledText> | ||
)} | ||
</StyledWrapper> | ||
); | ||
}; |
3 changes: 2 additions & 1 deletion
3
...front/src/modules/ui/navigation/bread-crumb/components/__stories__/Breadcrumb.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters