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

add: related object name to favorite in navigation drawer #8659

Closed

Conversation

harshrajeevsingh
Copy link
Contributor

@harshrajeevsingh harshrajeevsingh commented Nov 21, 2024

Closes: #8549

Screencast.from.2024-11-22.00-35-00.webm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds object type labels to favorites in the navigation drawer, displaying the related object name (e.g. "Company", "Person") next to each favorite item with a bullet point separator.

Key changes:

  • Added objectName prop to NavigationDrawerItem with styled container showing "· ObjectName" format
  • Implemented hover behavior to hide object name when hovering favorite items
  • Added StyledItemObjectName component with proper styling and text capitalization
  • Passed objectNameSingular from favorite objects through to navigation components
  • Fixed display formatting with proper spacing and text overflow handling

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +148 to +150
.navigation-drawer-item:hover & {
display: none;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Hiding content on hover may cause accessibility issues for keyboard/screen reader users

</NavigationDrawerAnimatedCollapseWrapper>
{objectName ? (
<StyledItemObjectName>
{' · '}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Non-breaking space should be used instead of regular space for better typography

@ehconitin
Copy link
Contributor

@Bonapara this looks cool, could you review the behavior!?

@ehconitin ehconitin self-assigned this Nov 22, 2024
@ehconitin
Copy link
Contributor

Screenshot 2024-11-22 at 1 22 36 PM Screenshot 2024-11-22 at 1 26 21 PM

@harshrajeevsingh could you make sure only favorite's label is being truncated and not all of the navigation drawer item.
Everything else should behave as it was :) for eg in the screenshot -- folders and objects are being truncated too :)

@harshrajeevsingh
Copy link
Contributor Author

@ehconitin Oh! I missed that part. I will make changes soon.

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice code, one comment though

{objectName ? (
<StyledItemObjectName>
{' · '}
{objectName.charAt(0).toUpperCase() + objectName.slice(1)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use capitalize from packages/twenty-front/src/utils/string/capitalize.ts

<NavigationDrawerAnimatedCollapseWrapper>
<StyledItemLabel>{label}</StyledItemLabel>
</NavigationDrawerAnimatedCollapseWrapper>
<StyledLabelParent>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the <NavigationDrawerAnimatedCollapseWrapper?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need it for collapse animation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martmull That's the issue. Using NavigationDrawerAnimatedCollapseWrapper won't let the text truncate for any item because a width constraint is needed for the parent element to make it work.
Also, you can find StyledRightOptionsContainer having margin-left: auto, but it doesn't work due to the NavigationDrawerAnimatedCollapseWrapper, we can see it working due to the StyledSpacer.

I will see how I can make changes to the NavigationDrawerAnimatedCollapseWrapper to make flex property work.

${({ hasObjectName }) =>
hasObjectName &&
`
max-width: 12ch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should avoid exotic css properties like this one

@harshrajeevsingh
Copy link
Contributor Author

Hi @martmull
I created a fresh PR for this with an updated code here: #8785
Closing this one as my local branch got messed up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add related object name to the favorite in navigation drawer
3 participants