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

chore: Update size of sidebar + remove using sheet #37638

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Nov 21, 2024

CleanShot.2024-11-21.at.17.21.35.mp4

/ok-to-test tags="@tag.Anvil"

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced styling for the sidebar title for improved visual presentation.
    • Streamlined sidebar component stories for simplicity and focus on core functionality.
  • Bug Fixes

    • Removed unnecessary mobile state handling, resulting in a more efficient sidebar rendering.
  • Style

    • Updated CSS for sidebar components to improve responsiveness and visual consistency.
    • Adjusted display properties for sidebar classes to enhance visibility.
  • Chores

    • Removed the SidebarInset component to simplify the sidebar structure.
    • Introduced a new side property to the sidebar provider for better contextual control.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11953544047
Commit: 40e6057
Cypress dashboard.
Tags: @tag.Anvil
Spec:


Thu, 21 Nov 2024 13:11:13 UTC

Copy link
Contributor

coderabbitai bot commented Nov 21, 2024

Walkthrough

The pull request introduces several modifications to the sidebar components in the design system. Key changes include the removal of the isMobile state from the _Sidebar component, enhancing the component's logic. The _SidebarContent component's title rendering is improved with additional styling props. The SidebarInset component is entirely removed, and adjustments are made to the _SidebarProvider regarding sidebar width styling. The CSS for the sidebar is updated for better responsiveness, and various story exports for the sidebar are simplified by removing the SidebarInset and variant properties.

Changes

File Change Summary
app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx Removed isMobile state and related conditional rendering for mobile view. Focused on rendering with CSSTransition.
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarContent.tsx Enhanced title rendering with additional props for styling. Removed padding from the containing Flex component.
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarInset.tsx Deleted the SidebarInset component entirely.
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx Added side prop to _SidebarProvider, updated context value and removed sidebar width inline style.
app/client/packages/design-system/widgets/src/components/Sidebar/src/index.ts Removed export of SidebarInset.
app/client/packages/design-system/widgets/src/components/Sidebar/src/styles.module.css Updated CSS for .mainSidebar and .sidebar classes. Introduced new .sidebarTitle class and refined styles overall.
app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx Removed SidebarInset from imports and stories. Simplified Default and SideRight story exports, introducing SideLeft.
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarTrigger.tsx Updated icon rendering logic based on sidebar state and position.
app/client/packages/design-system/widgets/src/components/Sidebar/src/types.ts Added new types SidebarState and SidebarSide, updated related interfaces to enhance type safety.

Possibly related PRs

Suggested labels

Task, Enhancement, IDE Product, IDE Pod, ok-to-test

Suggested reviewers

  • albinAppsmith
  • hetunandu

🎉 In the sidebar's realm, changes unfold,
With titles more vibrant, and stories retold.
The inset departs, while transitions take flight,
A cleaner design, oh what a delight!
CSS dances, responsive and bright,
In the land of components, everything feels right! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 21, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx (2)

27-27: LGTM! Good simplification of state management.

The removal of isMobile from useSidebar hook aligns with modern responsive design practices, making the component more maintainable.

Consider documenting the responsive behavior in the component's documentation to help other developers understand how the sidebar adapts across different viewport sizes.


Line range hint 64-89: Consider consolidating the nested CSSTransitions

The nested CSSTransitions with identical timeouts and handlers might cause animation conflicts or race conditions.

Consider combining the state transitions into a single CSSTransition using a compound state:

-    <CSSTransition
-      in={state === "full-width"}
-      nodeRef={sidebarRef}
-      onEnter={onEnter}
-      onEntered={onEntered}
-      onExit={onExit}
-      onExited={onExited}
-      timeout={300}
-    >
-      <CSSTransition
-        in={state === "expanded"}
-        nodeRef={sidebarRef}
-        onEnter={onEnter}
-        onEntered={onEntered}
-        onExit={onExit}
-        onExited={onExited}
-        timeout={300}
-      >
+    <CSSTransition
+      in={state === "full-width" || state === "expanded"}
+      nodeRef={sidebarRef}
+      onEnter={onEnter}
+      onEntered={onEntered}
+      onExit={onExit}
+      onExited={onExited}
+      timeout={300}
+    >
app/client/packages/design-system/widgets/src/components/Sidebar/src/styles.module.css (4)

16-17: Consider using a more semantic initial width value

Instead of 100cqw, consider using 100% as it's more commonly used and better supported across browsers.

- --sidebar-width: 100cqw;
+ --sidebar-width: 100%;

25-27: Redundant full-width state

This selector appears redundant since the initial width is already 100%. Consider removing it unless there's a specific use case.


75-75: Consider adding will-change property

Since the sidebar has transitions, adding will-change could optimize performance.

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  height: 100%;
  width: var(--sidebar-width);
+ will-change: transform, width;
  transition:
    left 300ms ease-in-out,
    right 300ms ease-in-out,
    width 300ms ease-in-out;

Also applies to: 76-76, 77-77, 78-78, 79-79, 80-80, 81-81, 82-82


105-112: Consider consolidating border styles

The border styles could be simplified using logical properties.

@container (width > 550px) {
  .mainSidebar[data-side="start"] .sidebar,
  .mainSidebar[data-side="end"] .sidebar {
-   border-inline-end: var(--border-width-1) solid var(--color-bd-elevation-1);
-   border-inline-start: var(--border-width-1) solid var(--color-bd-elevation-1);
+   border-inline: var(--border-width-1) solid var(--color-bd-elevation-1);
  }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cc83b16 and 19c34df.

📒 Files selected for processing (7)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarContent.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarInset.tsx (0 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx (0 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/index.ts (0 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/styles.module.css (4 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx (3 hunks)
💤 Files with no reviewable changes (3)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarInset.tsx
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/index.ts
🔇 Additional comments (6)
app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx (1)

Line range hint 1-108: Verify cleanup of mobile-specific code

Let's ensure all mobile-specific code has been properly cleaned up across related files.

app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx (3)

3-3: LGTM: Import cleanup aligns with component removal

The removal of SidebarInset from imports is consistent with the component's removal.


125-127: LGTM: Simplified story structure

The simplified structure with direct placement of SidebarTrigger in Flex component improves readability.


25-25: Verify the impact of defaultState change

Setting defaultState to "collapsed" by default could be a breaking change for existing implementations.

app/client/packages/design-system/widgets/src/components/Sidebar/src/styles.module.css (2)

29-33: LGTM! Good use of container queries

The container query implementation is a good choice for component-level responsive design.


165-175: Verify header height accessibility

The fixed header height of var(--sizing-13) might cause text overflow issues with larger font sizes. Consider testing with different text sizes and ensuring the header adapts accordingly.

✅ Verification successful

Let me search for any dynamic height adjustments or accessibility-related styles in the sidebar component.


Let me check the Text component's properties to understand how it handles text scaling and overflow.


Let me check the Text component's implementation to understand its text handling capabilities.


Let me check the Text component's styles to understand how it handles text overflow and line clamping.


The header height is accessibility-compliant

The sidebar header implementation is safe from text overflow issues because:

  1. The Text component used for the title has built-in line clamping (lineClamp={1}) and overflow handling
  2. The header has sufficient padding (var(--inner-spacing-2)) to accommodate larger font sizes
  3. The title text is center-aligned with absolute positioning, allowing it to adapt to the container
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any dynamic font size adjustments or text scaling in the codebase
rg -g '*.{css,ts,tsx}' -i '(font-size|text-size|scale|zoom)'

Length of output: 154815


Script:

#!/bin/bash
# Search for height-related styles and accessibility features in the sidebar component
rg -g '*.{css,tsx,ts}' -A 3 -B 3 'sidebarTitle|\.sidebar' app/client/packages/design-system/widgets/src/

Length of output: 15888


Script:

#!/bin/bash
# Search for Text component implementation and its properties
rg -g '*.{tsx,ts}' "export.*Text.*=.*" app/client/packages/design-system/widgets/src/

Length of output: 343


Script:

#!/bin/bash
# Get the Text component implementation
cat app/client/packages/design-system/widgets/src/components/Text/src/Text.tsx

Length of output: 1457


Script:

#!/bin/bash
# Get the Text component styles
cat app/client/packages/design-system/widgets/src/components/Text/src/styles.module.css

Length of output: 773

Copy link
Contributor

@ichik ichik left a comment

Choose a reason for hiding this comment

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

  1. With the default direction of opening the icons should reflect it, otherwise, they're pointing in the opposite direction now (the correct one for side=end)
  2. Default position for sidebar expand button should be end/right

@jsartisan
Copy link
Contributor Author

@ichik updated the icons based on side.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarTrigger.tsx (1)

18-24: Consider simplifying the icon selection logic

While the current nested ternary operators work, the logic could be more maintainable.

Here's a cleaner approach using an object lookup:

-        state === "collapsed"
-          ? side === "start"
-            ? "layout-sidebar-left-expand"
-            : "layout-sidebar-right-expand"
-          : side === "start"
-            ? "layout-sidebar-left-collapse"
-            : "layout-sidebar-right-collapse"
+        {
+          'collapsed-start': 'layout-sidebar-left-expand',
+          'collapsed-end': 'layout-sidebar-right-expand',
+          'expanded-start': 'layout-sidebar-left-collapse',
+          'expanded-end': 'layout-sidebar-right-collapse'
+        }[`${state}-${side}`]
app/client/packages/design-system/widgets/src/components/Sidebar/src/types.ts (1)

Line range hint 13-21: Consider documenting the default side value

The optional side prop with a required context value implies a default. Consider adding a JSDoc comment to document this default value.

 export interface SidebarProviderProps {
+  /** The side of the sidebar. Defaults to "end" */
   side?: SidebarSide;
app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx (1)

Line range hint 69-84: Consider documenting the side prop values.

The implementation looks good, but it would be helpful to document the possible values for the side prop in the story description.

Add a comment above the story:

+/**
+ * Demonstrates sidebar positioning with side="start".
+ * Possible values for side prop: "start" | "end"
+ */
 export const SideLeft: Story = {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 19c34df and 40e6057.

📒 Files selected for processing (5)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarTrigger.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/types.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/Sidebar.tsx
  • app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx
🔇 Additional comments (7)
app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarTrigger.tsx (1)

12-12: LGTM: Clean integration of sidebar position support

The addition of the side property enhances the component's flexibility by supporting both left and right sidebars.

app/client/packages/design-system/widgets/src/components/Sidebar/src/types.ts (3)

3-5: Well-defined type aliases for sidebar states and positions

The type definitions are clear, concise, and follow TypeScript best practices.


Line range hint 23-37: Verify if 'variant' prop should be removed

Since the PR mentions removing "using sheet", should we also remove the "floating" and "inset" variants from the variant prop?


6-11: Verify the impact of required 'side' property

The addition of the required side property is logical, but we should verify that all consumers of this context are updated accordingly.

✅ Verification successful

The previous pattern didn't yield results, so I'm trying different approaches to find context consumers. I'm looking for:

  1. Direct useContext calls with SidebarContext
  2. General usage and imports of SidebarContext
  3. Files that might be using the context

This will help us verify the impact of the required 'side' property addition.


I need to verify how the SidebarProvider handles the 'side' property since it's the main component that provides the context. This will help determine if the required property is properly initialized and passed to the context value.


Addition of required 'side' property is safe and properly handled

The SidebarProvider component already handles the 'side' property with a default value of "end" (side = "end"), and correctly passes it to the context value. The change is backward compatible since:

  • All existing consumers will receive a valid "end" value by default
  • The property is properly memoized in the context value
  • The implementation in SidebarProvider.tsx shows proper handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for components consuming SidebarContextType
ast-grep --pattern 'const $_ = useContext<SidebarContextType>($_)'

Length of output: 68


Script:

#!/bin/bash
# Search for SidebarContext usage with different patterns
rg -U "useContext\(.*SidebarContext.*\)" -A 2

# Search for SidebarContext imports and usage
rg "SidebarContext" -A 2

# Find files that might be consuming the context
fd -e ts -e tsx -x grep -l "SidebarContext"

Length of output: 6576


Script:

#!/bin/bash
# Check SidebarProvider implementation to verify side property handling
cat app/client/packages/design-system/widgets/src/components/Sidebar/src/SidebarProvider.tsx

# Check the interface of SidebarProviderProps
rg "interface SidebarProviderProps" -A 5

Length of output: 3276

app/client/packages/design-system/widgets/src/components/Sidebar/stories/Sidebar.stories.tsx (3)

33-35: Clean and focused implementation.

Good simplification of the Default story by removing unnecessary variant options.


97-99: Clean implementation of render props pattern.

Good job simplifying the structure while maintaining clear state management demonstration.


3-3: LGTM! Verify impact of defaultState change.

The simplified imports and addition of defaultState="collapsed" look good.

Let's verify this doesn't affect existing sidebar implementations:

Also applies to: 24-24

✅ Verification successful

The defaultState change is safe and backwards compatible

The codebase scan shows that defaultState is properly defined as an optional prop in types.ts with a default value of "expanded" in SidebarProvider.tsx. The change to "collapsed" in the story doesn't affect existing implementations since they'll continue using the default "expanded" state.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing SidebarProvider usage to ensure compatibility
rg -l "SidebarProvider" --type ts --type tsx | xargs rg "defaultState"

Length of output: 1586

@jsartisan jsartisan added the ok-to-test Required label for CI label Nov 21, 2024
@jsartisan jsartisan requested a review from ichik November 21, 2024 12:47
@@ -81,7 +83,6 @@ export const _SidebarProvider = (
ref={ref}
style={
{
"--sidebar-width": SIDEBAR_CONSTANTS.WIDTH.DESKTOP,
"--sidebar-width-icon": SIDEBAR_CONSTANTS.WIDTH.ICON,
Copy link
Collaborator

Choose a reason for hiding this comment

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

SIDEBAR_CONSTANTS.WIDTH.DESKTOP — it is no longer used and can be removed from the constants.
SIDEBAR_CONSTANTS.WIDTH.ICON — It seems that this can also be placed in CSS, right?

@jsartisan
Copy link
Contributor Author

@KelvinOm @znamenskii-ilia I'll merge this on monday. I am expecting type issue on ee repo because of this PR. So will need to handle that as well once we merge this.

@jsartisan jsartisan merged commit baef6aa into release Nov 25, 2024
59 checks passed
@jsartisan jsartisan deleted the chore/sidebar-responsive-fix branch November 25, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants