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

Added a Theme from Material UI To disable default behaviour which cause navbar to shift on notifications click #982

Open
wants to merge 2 commits into
base: testnet
Choose a base branch
from

Conversation

OWK50GA
Copy link

@OWK50GA OWK50GA commented Dec 13, 2024

Bugfix

Resolves: #975

Navbar elements shifting was due to Material UI default behaviour of disabling scroll on Modal open. Added a custom theme from Material UI in the components/UI/theme.tsx which solves this.

Close #975

Summary by CodeRabbit

  • New Features

    • Introduced theming capabilities with a new ThemeProvider for enhanced layout customization.
    • Added a new theme configuration that allows the MuiModal component to function without locking the scroll of underlying content.
  • Bug Fixes

    • Adjusted modal behavior to improve user experience by enabling scroll when the modal is open. The navbar elements were shifting due to Material UI's default behaviour of disabling scroll, which causes the elements to shift. This has been fixed

Copy link

vercel bot commented Dec 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:51am

Copy link

vercel bot commented Dec 13, 2024

@OWK50GA is attempting to deploy a commit to the LFG Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @typescript-eslint/[email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error dev eslint@"^9.11.1" from the root project
npm error peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm error node_modules/@eslint-community/eslint-utils
npm error @eslint-community/eslint-utils@"^4.2.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/utils
npm error @typescript-eslint/utils@"5.62.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error 1 more (eslint-config-next)
npm error 1 more (@typescript-eslint/type-utils)
npm error @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm error 5 more (@typescript-eslint/type-utils, ...)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error @typescript-eslint/eslint-plugin@"^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0" from [email protected]
npm error node_modules/eslint-config-next
npm error dev eslint-config-next@"^14.0.1" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/eslint
npm error peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error @typescript-eslint/eslint-plugin@"^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0" from [email protected]
npm error node_modules/eslint-config-next
npm error dev eslint-config-next@"^14.0.1" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /root/.npm/_logs/2024-12-13T03_49_36_519Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-12-13T03_49_36_519Z-debug-0.log

Walkthrough

The changes introduced in this pull request involve the integration of Material-UI's ThemeProvider into the RootLayout component of the application. This encapsulation allows for theming capabilities throughout the layout, which includes the Navbar, main content area, and Footer. Additionally, a new theme.tsx file has been created to define a custom theme, specifically modifying the behavior of the MuiModal component.

Changes

File Path Change Summary
app/layout.tsx Added ThemeProvider from Material-UI and wrapped the layout structure with it. Imported theme.
components/UI/theme.tsx Introduced a new file exporting a theme constant created with createTheme, modifying MuiModal.

Assessment against linked issues

Objective Addressed Explanation
Fix navbar elements shift (#975) The changes do not address the navbar shift issue.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4bb9e0 and 0b5a3cd.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • app/layout.tsx (2 hunks)
  • components/UI/theme.tsx (1 hunks)
🔇 Additional comments (4)
components/UI/theme.tsx (2)

1-3: LGTM! Correct setup for client-side MUI theme

The 'use client' directive is properly placed for client-side rendering of MUI components.


5-13: Verify the theme configuration across different modal scenarios

The implementation correctly addresses the navbar shifting issue by disabling scroll lock. However, we should verify this doesn't affect other modals negatively.

✅ Verification successful

Disabling scroll lock in MuiModal is safe for this codebase

Based on the codebase analysis:

  • The only custom scroll handling is in the quiz component which manages its own overflow state
  • Most components with scroll/overflow styles use specific CSS classes for contained scrolling areas
  • No components rely on the Modal's scroll lock functionality for their behavior
  • The theme configuration is consistently applied across all modal usages

The global setting disableScrollLock: true is appropriate as it solves the navbar shifting issue without introducing side effects, since:

  1. All scrollable content is properly contained within their respective components
  2. No modals in the codebase depend on body scroll locking for their functionality
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all Modal usages to ensure this global setting won't cause issues
rg -l "Modal|Dialog" --type tsx --type jsx

# Search for any custom scroll lock implementations that might conflict
rg "scroll|overflow|lock" --type tsx --type jsx

Length of output: 150


Script:

#!/bin/bash
# Search for all Modal usages without file type restrictions
rg -l "Modal|Dialog"

# Search for any custom scroll lock implementations
rg "scroll|overflow|lock"

# Also check for MUI theme customizations
rg "createTheme|MuiModal"

Length of output: 21574

app/layout.tsx (2)

7-8: LGTM! Proper import organization

The imports for ThemeProvider and custom theme are correctly placed with other UI-related imports.


58-64: Verify theme propagation to nested components

The ThemeProvider is correctly positioned to provide theme context to all child components. Please verify the fix works with:

  1. Multiple notifications opened simultaneously
  2. Nested modals if any
  3. Different viewport sizes
✅ Verification successful

Based on the gathered information, I can now provide the final response:

Theme propagation has been properly implemented

The verification shows that:

  • ThemeProvider is correctly positioned at the root layout level, wrapping all components including modals and notifications
  • Modal components (ModalNotifications, ModalMessage) are using MUI's Modal component which inherits theme context
  • The implementation supports multiple notifications as shown in modalNotifications.tsx
  • Responsive styles are implemented across various components including modals and notifications
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for nested modal scenarios that might be affected
ast-grep --pattern 'Modal {
  $$$
  Modal {
    $$$
  }
  $$$
}'

# Search for notification-related components
rg -l "notification|toast|alert" --type tsx --type jsx

Length of output: 151


Script:

#!/bin/bash
# Search for modal components and their usage
rg -t js -t jsx -t ts -t tsx "Modal" -l

# Search for notification/toast/alert components and their usage
rg -t js -t jsx -t ts -t tsx "notification|toast|alert" -l

# Search for theme usage in components
rg -t js -t jsx -t ts -t tsx "useTheme|theme\." -l

# Check responsive styles
rg -t js -t jsx -t ts -t tsx "@media|sm:|md:|lg:|xl:" -l

Length of output: 324


Script:

#!/bin/bash
# Find all potential React/Next.js component files first
fd -e js -e jsx -e tsx -e ts

# Then use these files to search for components and theme usage
fd -e js -e jsx -e tsx -e ts -x rg -l "Modal|Dialog" {}
fd -e js -e jsx -e tsx -e ts -x rg -l "notification|toast|alert" {}
fd -e js -e jsx -e tsx -e ts -x rg -l "useTheme|theme\." {}
fd -e js -e jsx -e tsx -e ts -x rg -l "@media|sm:|md:|lg:|xl:" {}

Length of output: 13539


Script:

#!/bin/bash
# Let's check the theme implementation and its usage in modals and notifications
rg -A 5 "ThemeProvider" app/layout.tsx
rg -A 10 "Modal" components/UI/modalMessage.tsx components/UI/notifications/modalNotifications.tsx
rg -A 10 "useTheme" components/UI/notifications/notificationDetail.tsx components/UI/profileCard/profileCard.tsx

Length of output: 7718


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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.

Navbar elements to fix
1 participant