-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add: objectName in fav folder #8785
Merged
+114
−44
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b01821
add: objectName in fav folder
harshrajeevsingh efbfa86
refactor
harshrajeevsingh d49f1a0
Merge remote-tracking branch 'upstream/main' into add/fav-object-name
ehconitin 7b60d6f
Merge branch 'main' into add/fav-object-name
martmull 91301ba
Add objectName in root favorites
martmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/ | |
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded'; | ||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; | ||
import isPropValid from '@emotion/is-prop-valid'; | ||
import { useTheme } from '@emotion/react'; | ||
import { css, useTheme } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import { ReactNode } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
@@ -18,6 +18,7 @@ import { | |
TablerIconsProps, | ||
} from 'twenty-ui'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
import { capitalize } from '~/utils/string/capitalize'; | ||
|
||
const DEFAULT_INDENTATION_LEVEL = 1; | ||
|
||
|
@@ -26,6 +27,7 @@ export type NavigationDrawerItemIndentationLevel = 1 | 2; | |
export type NavigationDrawerItemProps = { | ||
className?: string; | ||
label: string; | ||
objectName?: string; | ||
indentationLevel?: NavigationDrawerItemIndentationLevel; | ||
subItemState?: NavigationDrawerSubItemState; | ||
to?: string; | ||
|
@@ -87,13 +89,15 @@ const StyledItem = styled('button', { | |
|
||
width: ${(props) => | ||
!props.isNavigationDrawerExpanded | ||
? `${NAV_DRAWER_WIDTHS.menu.desktop.collapsed - 24}px` | ||
: '100%'}; | ||
? `calc(${NAV_DRAWER_WIDTHS.menu.desktop.collapsed}px - ${props.theme.spacing(6)})` | ||
: `calc(100% - ${props.theme.spacing(2)})`}; | ||
|
||
${({ isDragging }) => | ||
isDragging && | ||
` | ||
cursor: grabbing; | ||
`} | ||
` | ||
cursor: grabbing; | ||
`} | ||
|
||
:hover { | ||
background: ${({ theme }) => theme.background.transparent.light}; | ||
color: ${(props) => | ||
|
@@ -111,19 +115,37 @@ const StyledItem = styled('button', { | |
} | ||
`; | ||
|
||
const StyledItemElementsContainer = styled.span` | ||
const StyledItemElementsContainer = styled.div` | ||
align-items: center; | ||
display: flex; | ||
gap: ${({ theme }) => theme.spacing(2)}; | ||
width: 100%; | ||
`; | ||
|
||
const StyledItemLabel = styled.span` | ||
font-weight: ${({ theme }) => theme.font.weight.medium}; | ||
const StyledLabelParent = styled.div` | ||
display: flex; | ||
align-items: center; | ||
flex: 1 1 auto; | ||
white-space: nowrap; | ||
min-width: 0px; | ||
overflow: hidden; | ||
text-overflow: clip; | ||
`; | ||
const StyledEllipsisContainer = styled.div` | ||
color: ${({ theme }) => theme.font.color.light}; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
|
||
const StyledItemLabel = styled.span` | ||
color: ${({ theme }) => theme.font.color.secondary}; | ||
font-weight: ${({ theme }) => theme.font.weight.medium}; | ||
`; | ||
const StyledItemObjectName = styled.span` | ||
color: ${({ theme }) => theme.font.color.light}; | ||
font-weight: ${({ theme }) => theme.font.weight.regular}; | ||
`; | ||
|
||
const StyledItemCount = styled.span` | ||
align-items: center; | ||
background-color: ${({ theme }) => theme.color.blue}; | ||
|
@@ -149,7 +171,7 @@ const StyledKeyBoardShortcut = styled.span` | |
visibility: hidden; | ||
`; | ||
|
||
const StyledNavigationDrawerItemContainer = styled.span` | ||
const StyledNavigationDrawerItemContainer = styled.div` | ||
display: flex; | ||
width: 100%; | ||
`; | ||
|
@@ -158,30 +180,58 @@ const StyledSpacer = styled.span` | |
flex-grow: 1; | ||
`; | ||
|
||
const StyledRightOptionsContainer = styled.div<{ | ||
isMobile: boolean; | ||
active: boolean; | ||
}>` | ||
margin-left: auto; | ||
visibility: ${({ isMobile, active }) => | ||
isMobile || active ? 'visible' : 'hidden'}; | ||
const StyledIcon = styled.div` | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
margin-right: ${({ theme }) => theme.spacing(2)}; | ||
`; | ||
|
||
const StyledRightOptionsContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
:hover { | ||
background: ${({ theme }) => theme.background.transparent.light}; | ||
} | ||
width: ${({ theme }) => theme.spacing(6)}; | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
height: ${({ theme }) => theme.spacing(6)}; | ||
border-radius: ${({ theme }) => theme.border.radius.sm}; | ||
`; | ||
|
||
const visibleStateStyles = css` | ||
clip-path: unset; | ||
display: flex; | ||
height: unset; | ||
opacity: 1; | ||
overflow: unset; | ||
position: unset; | ||
width: unset; | ||
`; | ||
|
||
const StyledRightOptionsVisbility = styled.div<{ | ||
isMobile: boolean; | ||
active: boolean; | ||
}>` | ||
display: block; | ||
opacity: 0; | ||
transition: opacity 150ms; | ||
position: absolute; | ||
padding-left: ${({ theme }) => theme.spacing(2)}; | ||
overflow: hidden; | ||
clip-path: inset(1px); | ||
white-space: nowrap; | ||
height: 1px; | ||
width: 1px; | ||
|
||
${({ isMobile, active }) => (isMobile || active) && visibleStateStyles} | ||
|
||
.navigation-drawer-item:hover & { | ||
visibility: visible; | ||
${visibleStateStyles} | ||
} | ||
`; | ||
|
||
export const NavigationDrawerItem = ({ | ||
className, | ||
label, | ||
objectName, | ||
indentationLevel = DEFAULT_INDENTATION_LEVEL, | ||
Icon, | ||
to, | ||
|
@@ -228,28 +278,41 @@ export const NavigationDrawerItem = ({ | |
isNavigationDrawerExpanded={isNavigationDrawerExpanded} | ||
isDragging={isDragging} | ||
> | ||
{showBreadcrumb && ( | ||
<NavigationDrawerAnimatedCollapseWrapper> | ||
<NavigationDrawerItemBreadcrumb state={subItemState} /> | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
)} | ||
<StyledItemElementsContainer> | ||
{showBreadcrumb && ( | ||
<NavigationDrawerAnimatedCollapseWrapper> | ||
<NavigationDrawerItemBreadcrumb state={subItemState} /> | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
)} | ||
|
||
{Icon && ( | ||
<Icon | ||
style={{ minWidth: theme.icon.size.md }} | ||
size={theme.icon.size.md} | ||
stroke={theme.icon.stroke.md} | ||
color={ | ||
showBreadcrumb && !isSettingsPage && !isNavigationDrawerExpanded | ||
? theme.font.color.light | ||
: 'currentColor' | ||
} | ||
/> | ||
<StyledIcon> | ||
<Icon | ||
style={{ minWidth: theme.icon.size.md }} | ||
size={theme.icon.size.md} | ||
stroke={theme.icon.stroke.md} | ||
color={ | ||
showBreadcrumb && | ||
!isSettingsPage && | ||
!isNavigationDrawerExpanded | ||
? theme.font.color.light | ||
: 'currentColor' | ||
} | ||
/> | ||
</StyledIcon> | ||
)} | ||
|
||
<NavigationDrawerAnimatedCollapseWrapper> | ||
<StyledItemLabel>{label}</StyledItemLabel> | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
<StyledLabelParent> | ||
<StyledEllipsisContainer> | ||
<StyledItemLabel>{label}</StyledItemLabel> | ||
{objectName && ( | ||
<StyledItemObjectName> | ||
{' · '} | ||
{capitalize(objectName)} | ||
</StyledItemObjectName> | ||
)} | ||
</StyledEllipsisContainer> | ||
</StyledLabelParent> | ||
|
||
<StyledSpacer /> | ||
|
||
|
@@ -275,14 +338,17 @@ export const NavigationDrawerItem = ({ | |
<NavigationDrawerAnimatedCollapseWrapper> | ||
{rightOptions && ( | ||
<StyledRightOptionsContainer | ||
isMobile={isMobile} | ||
active={active || false} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
}} | ||
Comment on lines
341
to
344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: stopPropagation and preventDefault could interfere with keyboard navigation. Consider handling keyboard events separately. |
||
> | ||
{rightOptions} | ||
<StyledRightOptionsVisbility | ||
isMobile={isMobile} | ||
active={active || false} | ||
> | ||
{rightOptions} | ||
</StyledRightOptionsVisbility> | ||
</StyledRightOptionsContainer> | ||
)} | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need that back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martmull I looked into it. But it was not possible. As I described in the description that having
NavigationDrawerAnimatedCollapseWrapper
on top of any text or div won't let the truncation property work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seen with @Bonapara. We are ok to remove the animated effect