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

fix(web): sidebar layout #1194

Merged
merged 3 commits into from
Oct 24, 2024
Merged

fix(web): sidebar layout #1194

merged 3 commits into from
Oct 24, 2024

Conversation

airslice
Copy link
Contributor

@airslice airslice commented Oct 24, 2024

Overview

Sidebar layout was not flex enough, this PR refactor the structure and optimize the styles.
This PR fixed the active gql indicator's position on workspace settings page as well.

What I've done

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced sidebar organization with new components: SidebarMainSection, SidebarButtonsWrapper, and SidebarFooterSection.
    • Improved styling for sidebar elements, including new layout properties and visual dividers.
  • Bug Fixes

    • Resolved styling inconsistencies in various components, ensuring a more cohesive user interface.
  • Documentation

    • Updated component structure to reflect the latest changes in sidebar organization and styling.

These updates aim to improve user experience by streamlining navigation and enhancing visual clarity within the application.

@airslice airslice requested a review from mkumbobeaty as a code owner October 24, 2024 10:45
Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request implements several modifications across multiple components in the dashboard, primarily focusing on restructuring and styling. Key changes include the reorganization of sidebar components, such as replacing SidebarSection with SidebarMainSection and introducing SidebarButtonsWrapper. The StarredProject component has been updated for better clarity in variable naming and styling adjustments. Other components, including Profile, ProjectSettings, and WorkspaceSetting, have undergone minor structural changes, while the Collapse component received styling enhancements. Overall, these changes aim to improve the organization and maintainability of the dashboard components.

Changes

File Change Summary
web/src/beta/features/Dashboard/ContentsContainer/Projects/StarredProject.tsx Updated Collapse properties, variable naming for starredProjects, added title attribute to TitleWrapper, and modified styles in Wrapper and ProjectsWrapper.
web/src/beta/features/Dashboard/LeftSidePanel/index.tsx Replaced SidebarSection and SidebarTopSectionWrapper with SidebarMainSection, SidebarDivider, and SidebarButtonsWrapper, reorganized sidebar layout.
web/src/beta/features/Dashboard/LeftSidePanel/profile.tsx Removed borderBottom property from Wrapper styled component in Profile.
web/src/beta/features/ProjectSettings/index.tsx Replaced SidebarSection with SidebarMainSection and added SidebarButtonsWrapper, modified sidebar structure.
web/src/beta/features/ProjectSettings/innerPages/PublicSettings/index.tsx Replaced SidebarSection with SidebarMainSection and added SidebarButtonsWrapper, updated sidebar structure.
web/src/beta/features/WorkspaceSetting/index.tsx Wrapped SettingBase in a fragment to include CursorStatus component.
web/src/beta/lib/reearth-ui/components/Collapse/index.tsx Updated IconWrapper styling, corrected transition syntax, no changes to core logic.
web/src/beta/ui/components/SettingBase/index.tsx Replaced SidebarSection with SidebarMainSection and added SidebarButtonsWrapper, modified sidebar organization.
web/src/beta/ui/components/Sidebar/index.tsx Updated styles for SidebarWrapper, renamed components, added SidebarFooterSection and SidebarDivider.

Possibly related PRs

Suggested reviewers

  • mkumbobeaty
  • pyshx

Poem

🐰 In the dashboard where projects gleam,
A rabbit hops, chasing a dream.
With stars that shine and panels anew,
Organization blooms, like morning dew.
Sidebars dance, components play,
Hooray for changes that brighten the day! 🌟


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.

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 763fde1
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/671a26272e18120008b288c3
😎 Deploy Preview https://deploy-preview-1194--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@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)
web/src/beta/features/Dashboard/ContentsContainer/Projects/StarredProject.tsx (1)

17-26: LGTM: Improved naming and accessibility

Good improvements:

  • Fixed variable naming from statredProject to project
  • Added title attribute for better accessibility

Consider using nullish coalescing for the project name for consistency:

-                <TitleWrapper title={project?.name}>
-                  {project?.name}
+                <TitleWrapper title={project?.name ?? ""}>
+                  {project?.name ?? ""}
web/src/beta/features/Dashboard/LeftSidePanel/index.tsx (2)

Line range hint 42-66: Consider adding ARIA landmarks for improved accessibility

The new structure with SidebarMainSection and visual dividers improves the layout organization. However, consider adding ARIA landmarks to enhance accessibility.

-      <SidebarMainSection>
+      <SidebarMainSection role="navigation" aria-label="Main navigation">

Line range hint 68-84: Enhance footer section accessibility

The footer section implementation maintains consistency with the main section's structure. Consider adding ARIA landmarks here as well.

-      <SidebarFooterSection>
+      <SidebarFooterSection role="contentinfo" aria-label="Sidebar footer">
web/src/beta/lib/reearth-ui/components/Collapse/index.tsx (2)

160-165: LGTM! IconWrapper styling improvements enhance icon positioning and animation.

The changes improve the icon's layout and animation:

  • Fixed transition property syntax
  • Added explicit dimensions (16x16)
  • Centered icon using flex layout

Consider using theme variables for the icon dimensions to maintain consistency:

-  width: 16,
-  height: 16,
+  width: theme.metrics.icon.small,
+  height: theme.metrics.icon.small,

Line range hint 146-159: Simplify the rotation logic for better maintainability.

The nested ternary operators for rotation calculation make the code harder to read.

Consider extracting the rotation logic into a helper function:

const IconWrapper = styled("div")<{
  isCollapsed?: boolean;
  iconPosition?: "left" | "right";
-}>(({ isCollapsed, iconPosition }) => ({
-  rotate:
-    iconPosition === "left"
-      ? isCollapsed
-        ? "-180deg"
-        : "-90deg"
-      : isCollapsed
-        ? "0deg"
-        : "-90deg",
+}>(({ isCollapsed, iconPosition }) => {
+  const getRotation = () => {
+    if (iconPosition === "left") {
+      return isCollapsed ? "-180deg" : "-90deg";
+    }
+    return isCollapsed ? "0deg" : "-90deg";
+  };
+  return {
+    rotate: getRotation(),
web/src/beta/features/ProjectSettings/index.tsx (1)

88-100: LGTM: Improved sidebar structure with better component organization.

The new structure using SidebarMainSection and SidebarButtonsWrapper provides better organization and flexibility. Consider extracting the tabs mapping to a separate component if this pattern is reused across other settings pages.

Example refactor:

const SettingsTabs: React.FC<{ tabs: typeof tabs }> = ({ tabs }) => (
  <SidebarButtonsWrapper>
    {tabs?.map((t) => (
      <SidebarMenuItem
        key={t.id}
        path={t.path}
        text={t.text}
        active={t.id === tab}
        icon={t.icon}
      />
    ))}
  </SidebarButtonsWrapper>
);

Then use it as:

<SidebarMainSection>
  <SettingsTabs tabs={tabs} />
</SidebarMainSection>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6a0d08d and 763fde1.

📒 Files selected for processing (9)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/StarredProject.tsx (2 hunks)
  • web/src/beta/features/Dashboard/LeftSidePanel/index.tsx (5 hunks)
  • web/src/beta/features/Dashboard/LeftSidePanel/profile.tsx (0 hunks)
  • web/src/beta/features/ProjectSettings/index.tsx (2 hunks)
  • web/src/beta/features/ProjectSettings/innerPages/PublicSettings/index.tsx (2 hunks)
  • web/src/beta/features/WorkspaceSetting/index.tsx (1 hunks)
  • web/src/beta/lib/reearth-ui/components/Collapse/index.tsx (1 hunks)
  • web/src/beta/ui/components/SettingBase/index.tsx (2 hunks)
  • web/src/beta/ui/components/Sidebar/index.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • web/src/beta/features/Dashboard/LeftSidePanel/profile.tsx
🔇 Additional comments (16)
web/src/beta/features/WorkspaceSetting/index.tsx (2)

28-40: LGTM! Clean component structure with proper separation of concerns.

The component structure follows React best practices with proper use of fragments, conditional rendering, and clean prop passing.


39-40: Verify CursorStatus positioning.

The CursorStatus component has been moved outside of SettingBase. Please ensure this change doesn't affect its visual positioning on the workspace settings page.

✅ Verification successful

Let me try different commands to gather more information about the CursorStatus component and its styling.


Based on the search results, I can now provide a conclusive response about the CursorStatus positioning:

CursorStatus positioning is properly maintained

The CursorStatus component has absolute positioning built into its implementation, making it independent of its parent container's structure. From the search results:

  • The component has its own Wrapper styled component with position: "absolute" and explicit left/top positioning
  • It's consistently used as a top-level component in multiple pages (Dashboard, WorkspaceSetting, ProjectSettings, Editor, AccountSetting)
  • Moving it outside SettingBase won't affect its positioning as it uses absolute positioning relative to the viewport
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any related styling or positioning logic for CursorStatus

# Test 1: Look for CursorStatus component definition and its styles
rg -A 5 "CursorStatus" --type tsx --type css --type scss

# Test 2: Check for any z-index or positioning styles that might affect CursorStatus
ast-grep --pattern 'styled.$_`
  $$$
  position: $_
  $$$
`'

Length of output: 147


Script:

#!/bin/bash
# Search for CursorStatus component and its usage
rg -A 5 "CursorStatus"

# Search for styled-components definitions related to CursorStatus
rg -A 5 "styled.*CursorStatus"

# Look for the previous location of CursorStatus in SettingBase
rg -A 5 "SettingBase"

Length of output: 8743

web/src/beta/features/Dashboard/ContentsContainer/Projects/StarredProject.tsx (2)

15-15: LGTM: Improved padding control

The switch to noPadding on the Collapse component provides better control over spacing through the wrapper components, aligning with the PR's layout flexibility goals.


38-43: Verify layout behavior across browsers

The combination of height: 0 and flexGrow: 1 on the Wrapper, along with flex: 1 on ProjectsWrapper, might cause inconsistent layout behavior across different browsers.

Please verify the following scenarios:

  1. The sidebar content scrolls properly when it overflows
  2. The layout remains stable when resizing the window
  3. The component behaves consistently across different browsers

Would you like me to provide a more robust CSS solution that ensures consistent behavior?

Also applies to: 48-50

web/src/beta/features/Dashboard/LeftSidePanel/index.tsx (2)

2-5: LGTM: Clean import organization

The new Sidebar component imports are well-organized and follow consistent naming conventions.


Line range hint 42-84: Verify consistent usage of new sidebar components

The refactored sidebar structure looks good, but let's verify that these components are used consistently across other parts of the application.

✅ Verification successful

Let me try a different search strategy to verify the component usage.


Sidebar components are consistently used across the application

The verification shows that the sidebar components (SidebarMainSection, SidebarFooterSection, and SidebarButtonsWrapper) are properly defined in web/src/beta/ui/components/Sidebar/index.tsx and consistently used across multiple features:

  • Dashboard's LeftSidePanel
  • Project Settings (main and public settings)
  • Setting Base component

The implementation follows a consistent pattern across all usages, maintaining the same structural hierarchy and component relationships. The changes align well with the existing codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new sidebar components
echo "Checking usage of new sidebar components:"
rg "Sidebar(MainSection|FooterSection|ButtonsWrapper)" -t tsx

Length of output: 184


Script:

#!/bin/bash
# Search for usage of the sidebar components with broader file patterns
echo "Checking usage of sidebar components:"
rg "SidebarMainSection|SidebarFooterSection|SidebarButtonsWrapper" --type-add 'tsx:*.tsx' --type-add 'ts:*.ts' --type tsx --type ts

# Also check for styled-components definitions
echo -e "\nChecking component definitions:"
rg "styled\.(div|section|aside)" -A 2 --type-add 'tsx:*.tsx' --type-add 'ts:*.ts' --type tsx --type ts | grep -i "sidebar"

Length of output: 3277

web/src/beta/ui/components/SettingBase/index.tsx (2)

6-9: LGTM: Import changes align with the sidebar refactoring.

The new imports are properly organized and consistent with the sidebar layout improvements.


34-47: LGTM: Improved sidebar structure with better component organization.

The new structure using SidebarMainSection and SidebarButtonsWrapper provides better semantic organization while maintaining the original functionality.

Let's verify that this new sidebar structure is consistently applied across the codebase:

✅ Verification successful

Based on the shell script results, I can now generate the final response:

✅ Sidebar structure changes are consistently implemented

The verification shows that:

  • SidebarMainSection and SidebarButtonsWrapper are defined in web/src/beta/ui/components/Sidebar/index.tsx and used consistently across all sidebar implementations
  • No legacy SidebarSection usage remains in the codebase
  • The new structure is uniformly applied in:
    • Dashboard's LeftSidePanel
    • ProjectSettings
    • PublicSettings
    • SettingBase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of new sidebar components

# Test 1: Find all files using SidebarMainSection
echo "Files using SidebarMainSection:"
rg "SidebarMainSection"

# Test 2: Find any remaining usage of old SidebarSection
echo -e "\nChecking for remaining SidebarSection usage:"
rg "SidebarSection"

# Test 3: Find all files using SidebarButtonsWrapper
echo -e "\nFiles using SidebarButtonsWrapper:"
rg "SidebarButtonsWrapper"

Length of output: 2826

web/src/beta/ui/components/Sidebar/index.tsx (5)

81-86: LGTM! Good improvements to spacing and naming.

The renaming from SidebarTopSectionWrapper to SidebarButtonsWrapper better reflects its purpose, and the spacing improvements using theme values ensure consistency.


89-94: LGTM! Good improvements to layout and naming.

The renaming to SidebarMainSection and the addition of flex: 1 improve both clarity and layout behavior. The consistent use of theme spacing values maintains design consistency.


96-101: LGTM! Well-structured footer section.

Good implementation with flexShrink: 0 to prevent compression and consistent theme-based spacing.


103-107: LGTM! Clean divider implementation.

Good use of theme values for colors and spacing, ensuring consistency with the design system.


123-123: LGTM! Consistent spacing implementation.

Good use of theme spacing values for padding, maintaining design consistency.

web/src/beta/features/ProjectSettings/innerPages/PublicSettings/index.tsx (2)

3-5: LGTM: Import changes align with sidebar refactoring

The new sidebar component imports align with the PR's objective to improve sidebar layout flexibility.


113-126: LGTM: Improved sidebar structure with better component organization

The new nested structure using SidebarMainSection and SidebarButtonsWrapper provides better organization while maintaining the existing functionality.

Let's verify the consistent usage of this new sidebar structure across other components:

✅ Verification successful

Let me try a different approach to verify the sidebar structure usage across components.

This should help us understand:

  1. Which files use these components
  2. Whether they are consistently used together
  3. The actual implementation patterns in different files

Sidebar structure is consistently implemented across components

The verification results show that the sidebar structure is consistently implemented across the codebase:

  1. Both SidebarMainSection and SidebarButtonsWrapper components are used together in all relevant files:

    • web/src/beta/features/ProjectSettings/index.tsx
    • web/src/beta/features/ProjectSettings/innerPages/PublicSettings/index.tsx
    • web/src/beta/features/Dashboard/LeftSidePanel/index.tsx
    • web/src/beta/ui/components/SettingBase/index.tsx
  2. The components follow the same nesting pattern (SidebarMainSection > SidebarButtonsWrapper) in all implementations, maintaining a consistent structure.

  3. The base components are properly defined in the shared UI components directory (web/src/beta/ui/components/Sidebar/index.tsx).

The new sidebar structure is properly standardized across the application, ensuring a consistent UI pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent sidebar structure implementation
# Expected: Similar nesting pattern of SidebarMainSection and SidebarButtonsWrapper

# Search for similar sidebar structure patterns
ast-grep --pattern 'SidebarMainSection {
  $$$
  SidebarButtonsWrapper {
    $$$
  }
  $$$
}'

Length of output: 95


Script:

#!/bin/bash
# Search for SidebarMainSection and SidebarButtonsWrapper components separately
echo "=== Files using SidebarMainSection ==="
rg "SidebarMainSection" -l

echo -e "\n=== Files using SidebarButtonsWrapper ==="
rg "SidebarButtonsWrapper" -l

echo -e "\n=== Sample implementations ==="
# Show some context around the usage
rg "SidebarMainSection" -A 5 -B 2

Length of output: 9753

web/src/beta/features/ProjectSettings/index.tsx (1)

5-5: LGTM: Import changes align with sidebar restructuring.

The replacement of SidebarSection with SidebarMainSection and addition of SidebarButtonsWrapper align well with the PR's objective to improve sidebar layout flexibility.

Also applies to: 7-8

web/src/beta/ui/components/Sidebar/index.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant