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

style(web): move scroll bar styles to theme #1211

Merged
merged 5 commits into from
Nov 1, 2024
Merged

style(web): move scroll bar styles to theme #1211

merged 5 commits into from
Nov 1, 2024

Conversation

mkumbobeaty
Copy link
Contributor

@mkumbobeaty mkumbobeaty commented Oct 30, 2024

Overview

  • Move common style of scroll bar to theme

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

    • Introduced a centralized scrollbar styling approach across various components, enhancing consistency in appearance.
    • Added a new styled component, Window, in the Area layout to improve layout management.
  • Documentation

    • Updated theme definitions to include new scrollbar properties for improved styling management.
  • Chores

    • Removed custom scrollbar styles from multiple components, streamlining styling logic and simplifying maintenance.

Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

The changes in this pull request primarily focus on the removal of custom scrollbar styles across multiple components in the application, replacing them with a centralized approach using theme.scrollBar. This modification is reflected in components such as Dashboard, Editor, ProjectSettings, DataAttribution, PopupMenu, Selector, ManagerContent, SettingBase, and CommonField. Additionally, new scrollbar style configurations have been added to the theme, enhancing maintainability and consistency in scrollbar styling throughout the application.

Changes

File Path Change Summary
web/src/beta/features/Dashboard/index.tsx Removed custom scrollbar styles; incorporated theme.scrollBar.
web/src/beta/features/Editor/Map/shared/SharedComponent.tsx Removed specific scrollbar styles; used theme.scrollBar.
web/src/beta/features/ProjectSettings/index.tsx Replaced custom scrollbar styles with theme.scrollBar.
web/src/beta/features/Visualizer/Crust/Widgets/Widget/builtin/DataAttribution/index.tsx Removed explicit scrollbar styles; utilized theme.scrollBar.
web/src/beta/lib/reearth-ui/components/PopupMenu/index.tsx Removed custom scrollbar styles; applied theme.scrollBar.
web/src/beta/lib/reearth-ui/components/Selector/index.tsx Replaced scrollbar styles with theme.scrollBar.
web/src/beta/ui/components/ManagerBase/ManagerContent.tsx Removed scrollbar styles; incorporated theme.scrollBar.
web/src/beta/ui/components/SettingBase/index.tsx Removed specific scrollbar styles; used theme.scrollBar.
web/src/beta/ui/fields/CommonField.tsx Removed explicit scrollbar styles; replaced with theme.scrollBar.
web/src/beta/ui/layout/Area/index.tsx Added new Window styled component; replaced custom scrollbar styles with theme.scrollBar.
web/src/services/theme/reearthTheme/common/index.ts Updated Common type to include new scrollbar properties; modified common object.
web/src/services/theme/reearthTheme/common/scrollBar.ts Introduced new file defining scrollBar styles; exported related types.

Possibly related PRs

Suggested reviewers

  • m-abe-dev
  • airslice
  • pyshx

🐇 "In the land of code where the scrollbars play,
We’ve simplified styles in a unified way.
No more custom rules, just themes that we share,
For a smoother experience, with love and with care.
So hop along, friends, let’s celebrate this feat,
With clean, tidy scrolls, our project’s now neat!" 🐇


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.

@mkumbobeaty mkumbobeaty marked this pull request as ready for review October 30, 2024 12:53
Copy link

netlify bot commented Oct 30, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 0a55ebb
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/67245f3e61ec080008233773
😎 Deploy Preview https://deploy-preview-1211--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.

@github-actions github-actions bot added the web label Oct 30, 2024
@github-actions github-actions bot requested a review from pyshx October 30, 2024 12:53
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 (1)
web/src/services/theme/reearthTheme/common/index.ts (1)

Line range hint 1-38: Consider adding documentation for scroll bar usage patterns.

The centralization of scroll bar styles in the theme is a good architectural decision that promotes consistency and maintainability. To maximize the benefits of this change, consider:

  1. Adding JSDoc comments to document when to use scrollBar vs universalScrollBar
  2. Creating usage examples in the component documentation
  3. Adding migration guidelines for components still using custom scroll bar styles

This will help maintain consistency as the codebase grows and make it easier for other developers to adopt these themed scroll bars.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1eba6e1 and 7f286ee.

📒 Files selected for processing (12)
  • web/src/beta/features/Dashboard/index.tsx (1 hunks)
  • web/src/beta/features/Editor/Map/shared/SharedComponent.tsx (1 hunks)
  • web/src/beta/features/ProjectSettings/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Widgets/Widget/builtin/DataAttribution/index.tsx (1 hunks)
  • web/src/beta/lib/reearth-ui/components/PopupMenu/index.tsx (1 hunks)
  • web/src/beta/lib/reearth-ui/components/Selector/index.tsx (1 hunks)
  • web/src/beta/ui/components/ManagerBase/ManagerContent.tsx (1 hunks)
  • web/src/beta/ui/components/SettingBase/index.tsx (1 hunks)
  • web/src/beta/ui/fields/CommonField.tsx (1 hunks)
  • web/src/beta/ui/layout/Area/index.tsx (1 hunks)
  • web/src/services/theme/reearthTheme/common/index.ts (3 hunks)
  • web/src/services/theme/reearthTheme/common/scrollBar.ts (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • web/src/beta/features/ProjectSettings/index.tsx
  • web/src/beta/features/Visualizer/Crust/Widgets/Widget/builtin/DataAttribution/index.tsx
  • web/src/beta/lib/reearth-ui/components/PopupMenu/index.tsx
  • web/src/beta/lib/reearth-ui/components/Selector/index.tsx
  • web/src/beta/ui/components/SettingBase/index.tsx
  • web/src/services/theme/reearthTheme/common/scrollBar.ts
🔇 Additional comments (7)
web/src/beta/ui/components/ManagerBase/ManagerContent.tsx (1)

9-9: LGTM! Clean implementation of theme-based scrollbar styling.

The change effectively implements the centralized scrollbar styling approach while maintaining the component's responsive behavior.

Let's verify the theme type definitions:

✅ Verification successful

Theme integration verified and properly implemented

The universalScrollBar is correctly defined in the theme system and properly used in the component:

  • Type definitions and implementation exist in web/src/services/theme/reearthTheme/common/scrollBar.ts
  • The theme object is correctly imported and spread in the styled component
  • The implementation is consistent with other components using the same styling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify theme type definitions include universalScrollBar
# Expected: Find type definitions for universalScrollBar in theme files

# Search for theme type definitions
rg -t typescript "universalScrollBar.*interface|interface.*universalScrollBar|type.*universalScrollBar" 

# Search for actual theme implementation
rg -t typescript "universalScrollBar.*=.*{|export.*universalScrollBar"

Length of output: 371


Script:

#!/bin/bash
# Search for theme type definitions and implementations with fixed regex
rg "universalScrollBar" 

# Specifically look for theme-related files
fd "theme" --type f --extension ts --extension tsx --exec cat {}

Length of output: 6315


Script:

#!/bin/bash
# Get the content of the scrollBar.ts file to verify the implementation
cat web/src/services/theme/reearthTheme/common/scrollBar.ts

# Check how the theme is imported and used in the component
cat web/src/beta/ui/components/ManagerBase/ManagerContent.tsx

Length of output: 1316

web/src/beta/ui/fields/CommonField.tsx (1)

35-35: Verify if scrollbar styles are necessary for this component.

The Wrapper component doesn't have any overflow properties set, so the scrollbar styles won't have any effect. Consider if this component actually needs scrolling behavior.

If scrolling is needed:

const Wrapper = styled("div")(({ theme }) => ({
  display: "flex",
  flexDirection: "column",
  gap: theme.spacing.small,
+ overflow: "auto",
  ...theme.universalScrollBar
}));

If not, remove the unnecessary scrollbar styles:

const Wrapper = styled("div")(({ theme }) => ({
  display: "flex",
  flexDirection: "column",
  gap: theme.spacing.small,
-  ...theme.universalScrollBar
}));

Let's verify if this component needs scrolling behavior:

web/src/services/theme/reearthTheme/common/index.ts (3)

4-9: LGTM! Clean import structure.

The new scroll bar imports are well-organized and follow the existing pattern of importing both types and values.


33-35: LGTM! Consistent object structure.

The new scroll bar properties are properly added to the common object, maintaining consistency with the type definition.


23-24: Verify the distinction between scrollBar and universalScrollBar.

While the type additions are clean, it would be helpful to understand the intended use cases for each scroll bar type to ensure they're applied consistently across components.

Let's check the implementation details:

✅ Verification successful

The previous output revealed the implementation difference (universalScrollBar uses * ::-webkit-scrollbar while scrollBar uses ::-webkit-scrollbar), but we need to understand their usage patterns to provide a complete verification.


Clear distinction found between scrollBar and universalScrollBar implementations

The verification reveals that both scroll bar types serve different purposes:

  • universalScrollBar (with * ::-webkit-scrollbar) is used for global styling contexts, applied to components that may contain nested scrollable content. Found in:

    • Layout components (Area, ManagerContent, Dashboard)
    • Setting panels (SettingBase, ProjectSettings)
    • Form fields (CommonField)
    • Data displays (DataAttribution)
  • scrollBar (with ::-webkit-scrollbar) is used for self-contained components where the scroll styling should only apply to the component itself. Found in:

    • UI components (Selector, PopupMenu)

The distinction is appropriate and consistently applied across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Examine the scrollBar module implementation and its usage

# Check scrollBar.ts implementation
echo "=== ScrollBar Implementation ==="
cat web/src/services/theme/reearthTheme/common/scrollBar.ts

# Check usage patterns
echo -e "\n=== Usage Patterns ==="
rg -A 2 "theme\.scrollBar|theme\.universalScrollBar" --type ts --type tsx

Length of output: 1178


Script:

#!/bin/bash
# Let's try a different approach to find usage patterns
# Search for any mentions of scrollBar or universalScrollBar in ts files
echo "=== ScrollBar Usage Patterns ==="
rg "scrollBar|universalScrollBar" --type ts -C 2

# Also check for style-related imports and usage
echo -e "\n=== Style Imports and Usage ==="
rg "import.*scrollBar|from.*scrollBar" --type ts -C 2

Length of output: 6898

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

79-79: LGTM! Scrollbar styling successfully moved to theme

The change appropriately implements the centralized scrollbar styling approach by utilizing theme.universalScrollBar. This aligns well with the PR's objective of standardizing scrollbar styles across the application.

Let's verify that the theme properly defines the universal scrollbar styles:

✅ Verification successful

Scrollbar styling implementation verified and properly defined

The theme.universalScrollBar is correctly implemented in the theme system with proper styling for scrollbar width, track, thumb, and hover states. The implementation uses rgba colors for proper transparency and includes all necessary scrollbar pseudo-elements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the theme implementation of universalScrollBar
# Expected: Find the definition of universalScrollBar in theme files

# Search for universalScrollBar definition in theme files
rg -g '*.ts*' 'universalScrollBar.*=' --type ts

Length of output: 141


Script:

#!/bin/bash
# Let's check the actual implementation of universalScrollBar
cat web/src/services/theme/reearthTheme/common/scrollBar.ts

Length of output: 938

web/src/beta/ui/layout/Area/index.tsx (1)

425-425: LGTM! Consistent with the theme standardization effort.

The addition of theme.universalScrollBar to the Window component aligns with the PR objective of centralizing scrollbar styles in the theme.

Let's verify the theme implementation:

✅ Verification successful

Let me gather more information about the theme implementation.


✅ Verified: Theme's universalScrollBar is properly implemented and consistently used

The universalScrollBar is correctly defined in web/src/services/theme/reearthTheme/common/scrollBar.ts with a complete set of scrollbar styling rules, and it's being consistently used across 8 components including the Area component. The implementation aligns with the PR's objective of standardizing scrollbar styling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the universalScrollBar theme implementation and its usage across the codebase

# Test 1: Check if universalScrollBar is properly defined in the theme
rg -A 5 "universalScrollBar.*=.*{" 

# Test 2: Check for consistent usage of universalScrollBar across components
rg "theme\.universalScrollBar"

Length of output: 845


Script:

#!/bin/bash
# Search for the definition of universalScrollBar in theme files
rg -l "universalScrollBar" web/src/beta/theme/

# Check the actual implementation
ast-grep --pattern 'const universalScrollBar = $_'
ast-grep --pattern 'export const universalScrollBar = $_'

Length of output: 2843

["* ::-webkit-scrollbar-thumb:hover"]: {
background: theme.relative.lighter
}
...theme.universalScrollBar
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Custom scrollbar styles need to be migrated to use theme.scrollBar or theme.universalScrollBar

The verification reveals inconsistencies in scrollbar styling implementation:

  • Several components still use direct ::-webkit-scrollbar styling:
    • web/src/beta/features/Visualizer/Crust/StoryPanel/PanelContent/index.tsx
    • web/src/beta/features/Visualizer/Crust/Widgets/Widget/builtin/Timeline/UI/index.tsx
  • Only two components are currently using the themed scrollbar styles:
    • web/src/beta/lib/reearth-ui/components/Selector/index.tsx
    • web/src/beta/lib/reearth-ui/components/PopupMenu/index.tsx

While this change is correct, there are other components that need similar updates to maintain consistency across the codebase.

🔗 Analysis chain

LGTM! The change aligns with the centralization of scrollbar styles.

The modification correctly implements the universal scrollbar styles from the theme, which supports the PR's objective of centralizing scrollbar styling.

Let's verify the theme implementation:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of scrollbar style implementation across the codebase
# Expected: All components should use either theme.universalScrollBar or theme.scrollBar

# Test 1: Check for any remaining webkit-scrollbar implementations that should be migrated
rg -g '*.{ts,tsx}' '::-webkit-scrollbar'

# Test 2: Verify the usage of theme scrollbar styles
rg -g '*.{ts,tsx}' 'theme\.(universal)?scrollBar'

Length of output: 1539

@airslice airslice merged commit e9a0d16 into main Nov 1, 2024
13 checks passed
@airslice airslice deleted the common-scroll branch November 1, 2024 05:00
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.

3 participants