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

feat - Compact sidebar #7414

Merged
merged 23 commits into from
Oct 15, 2024
Merged

feat - Compact sidebar #7414

merged 23 commits into from
Oct 15, 2024

Conversation

ehconitin
Copy link
Contributor

@ehconitin ehconitin commented Oct 3, 2024

fixes #7143
@Bonapara

2024-10-03.17-04-29.mp4

Recent updates

demo.mov

To Do

  • fix breadcrumb
    image

Copy link

github-actions bot commented Oct 3, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 4C04:D0C2B:4268D8D:7F5CD35:670E5A06.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aehconitin%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Tue, 15 Oct 2024 12:03:18 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'4C04:D0C2B:4268D8D:7F5CD35:670E5A06'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1728993858'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 4C04:D0C2B:4268D8D:7F5CD35:670E5A06.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aehconitin%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.4 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-b6d502c1.json

Generated by 🚫 dangerJS against b97111b

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 pull request implements a compact sidebar feature as requested in issue #7143, transforming the navigation drawer into a collapsible component that displays only icons when collapsed.

  • Introduced isNavigationDrawerExpandedState to replace isNavigationDrawerOpenState for managing drawer expansion
  • Added NavigationDrawerCollapsedGreyBox component for compact view of active items
  • Updated NavigationDrawerHeader, NavigationDrawerItem, and other components to support both expanded and collapsed states
  • Implemented conditional rendering in CurrentWorkspaceMemberFavorites and NavigationDrawerSectionForObjectMetadataItems for compact view
  • Added navigationDrawerExpandedMemorizedState to remember drawer state across navigation

17 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings

@@ -37,6 +44,8 @@ export const MainNavigationDrawerItems = () => {
label="Settings"
to={'/settings/profile'}
onClick={() => {
setNavigationDrawerExpandedMemorized(isNavigationDrawerExpanded);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider moving this logic to a separate function for better readability and reusability

@@ -52,15 +49,15 @@ export const MobileNavigationBar = () => {
if (!isCommandMenuOpened) {
openCommandMenu();
}
setIsNavigationDrawerOpen(false);
setIsNavigationDrawerExpanded(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using 'setIsNavigationDrawerExpanded(false)' instead of 'setIsNavigationDrawerExpanded(false)' for consistency with other state updates

label={sectionTitle}
onClick={() => toggleNavigationSection()}
/>
{isNavigationSectionOpen && renderObjectMetadataItems()}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Ensure renderObjectMetadataItems is only called when the section is open

to={navigationMemorizedUrl}
replace
onClick={() =>
setIsNavigationDrawerExpanded(navigationDrawerExpandedMemorized)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding a comment explaining the purpose of this state change

Comment on lines 5 to 7
background-color: ${({ theme }) => theme.background.transparent.lighter};
border: 1px solid ${({ theme }) => theme.background.transparent.lighter};
border-radius: ${({ theme }) => theme.border.radius.sm};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Using the same color for background and border may not provide enough contrast. Consider using a slightly darker shade for the border.

Comment on lines 160 to 162
const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] =
useRecoilState(isNavigationDrawerExpandedState);
const isSettingsPage = useIsSettingsPage();
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider memoizing this value to prevent unnecessary re-renders

<StyledKeyBoardShortcut className="keyboard-shortcuts">
{keyboard}
</StyledKeyBoardShortcut>
{isNavigationDrawerExpanded || isSettingsPage ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This conditional rendering might cause layout shifts. Consider using CSS to hide/show elements instead

import { atom } from 'recoil';
import { MOBILE_VIEWPORT } from 'twenty-ui';

const isMobile = window.innerWidth <= MOBILE_VIEWPORT;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: isMobile is set only once when the file is loaded. Consider using a hook or event listener for responsive behavior

@ehconitin
Copy link
Contributor Author

@Bonapara
need clarifications on greyboxes border color and background color!
for now I have kept it according to figma theme.background.transparent.lighter for both, but that could be improved

@FelixMalfait
Copy link
Member

Nice 😍

@Bonapara
Copy link
Member

Bonapara commented Oct 9, 2024

@ehconitin what do you mean about the clarification on the colors? We can schedule a quick call to talk about it!

A few fixes:

CleanShot 2024-10-09 at 11 04 29

  • Make sure the border-radius are the same
  • The colors of the "views" icons should be tertiary to distinguish them from objects better. (including the selected view)
CleanShot.2024-10-09.at.11.07.43.mp4
  • The animation should be smooth like this. We shouldn't see that it's two different elements.
  • The gap between sections in compact mode should be smaller.

@martmull
Copy link
Contributor

@ehconitin think we can do something like on figma with animate. We need to animate all the disapearing components in the navBar, not the navBar itself. Here is a quick proof of concept: de77463

Enregistrement.de.l.ecran.2024-10-10.a.17.47.08.mov

@ehconitin
Copy link
Contributor Author

Thanks @martmull ! 🫡
Too good!

@martmull
Copy link
Contributor

last version
https://github.com/user-attachments/assets/058a69d1-f5ad-401a-b964-0178bb0dc7ff

Copy link

@sonukaloshiya sonukaloshiya left a comment

Choose a reason for hiding this comment

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


width: ${(props) =>
!props.isNavigationDrawerExpanded
? `${NAV_DRAWER_WIDTHS.menu.desktop.collapsed - 24}px`
Copy link
Contributor

Choose a reason for hiding this comment

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

could 24 be a shared variable with the existing menu width?

Copy link
Contributor

Choose a reason for hiding this comment

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

will try to

Copy link
Contributor

Choose a reason for hiding this comment

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

difficult tbh

@martmull martmull marked this pull request as ready for review October 15, 2024 10:36
@martmull martmull merged commit a9deede into twentyhq:main Oct 15, 2024
7 of 10 checks passed
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

(updates since last review)

This PR continues the implementation of the compact sidebar feature, focusing on refining navigation components and improving overall functionality. Key changes include:

  • Introduced new hooks and components for managing the compact sidebar state and rendering
  • Updated various components to support both expanded and collapsed sidebar states
  • Improved handling of object metadata items and favorites in the navigation drawer
  • Refined styling and layout for better responsiveness and user experience

While the changes align with the desired behavior, there are a few points to consider:

  • Ensure consistent handling of loading states across components to prevent UI flickering
  • Review and optimize performance for components with complex rendering logic
  • Double-check accessibility features, especially for keyboard navigation in the compact mode

298 file(s) reviewed, 167 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +48 to 51
setNavigationDrawerExpandedMemorized(isNavigationDrawerExpanded);
setIsNavigationDrawerExpanded(true);
setNavigationMemorizedUrl(location.pathname + location.search);
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This logic might cause unexpected behavior if the user navigates directly to the settings page

Comment on lines +6 to +15
export const useIsSettingsDrawer = () => {
const isMobile = useIsMobile();
const isSettingsPage = useIsSettingsPage();
const currentMobileNavigationDrawer = useRecoilValue(
currentMobileNavigationDrawerState,
);
return isMobile
? currentMobileNavigationDrawer === 'settings'
: isSettingsPage;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding a brief comment explaining the purpose of this hook

onClick={() => toggleNavigationSection()}
/>
</NavigationDrawerAnimatedCollapseWrapper>
{isNavigationSectionOpen && renderObjectMetadataItems()}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Ensure renderObjectMetadataItems is only called when the section is open

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

Successfully merging this pull request may close these issues.

Compact sidebar
7 participants