Add BitProPanel component (#9392)#9460
Conversation
…project-template-needs-improvements
…-autoloading-improvements
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new Changes
Assessment against linked issues
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Outside diff range and nitpick comments (17)
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor.cs (1)
13-23: Consider consolidatingBodyandChildContentparametersBoth
BodyandChildContentare of typeRenderFragment?, withBodyserving as an alias forChildContent. To simplify the API and reduce potential confusion, consider using onlyChildContentor ensuring that both properties are synchronized properly.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor.cs (1)
Line range hint
195-215: Ensure consistency in panel content stylingThe inline styles applied within the panel content vary. For better maintainability and consistency, consider creating a CSS class for the panel content padding and applying it uniformly.
Example:
- <div style="width:300px;padding:1rem"> + <div class="panel-content">And define the CSS:
.panel-content { width: 300px; padding: 1rem; }src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor.scss (1)
3-6: Consider using responsive width for panel-bodyThe fixed width of 300px might not be suitable for all viewport sizes. Consider using relative units or CSS variables for better responsiveness.
.panel-body { - width: 300px; + width: min(300px, 100%); padding: 1rem; }src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanelClassStyles.cs (1)
21-24: Fix documentation copy-paste errorThe summary for CloseIcon property appears to be copied from CloseButton.
/// <summary> - /// Custom CSS classes/styles for the close button of the BitProPanel. + /// Custom CSS classes/styles for the close icon of the BitProPanel. /// </summary>src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor.scss (1)
23-29: Consider using CSS custom properties for safe-area marginsThe margin handling for notched devices is good, but could be more maintainable using CSS custom properties.
.header-margin, .custom-header { - margin-top: var(--bit-status-bar-height); + --safe-area-top: var(--bit-status-bar-height); + margin-top: var(--safe-area-top); @supports (-webkit-touch-callout: none) { - margin-top: env(safe-area-inset-top); + --safe-area-top: env(safe-area-inset-top); } }src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.scss (1)
59-63: Consider performance optimization for scrolling containerThe scrolling body could benefit from performance optimizations.
.bit-ppl-bdy { flex-grow: 1; overflow-y: auto; padding: spacing(2); + /* Optimize scrolling performance */ + -webkit-overflow-scrolling: touch; + will-change: transform; + /* Prevent content paint during scroll */ + contain: content; }src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor (1)
48-50: Consider adding overflow handling for the body contentThe body section might benefit from overflow handling to prevent content from breaking the layout.
-<div style="@Styles?.Body" class="bit-ppl-bdy @Classes?.Body"> +<div style="@Styles?.Body; overflow: auto;" class="bit-ppl-bdy @Classes?.Body">src/BlazorUI/Bit.BlazorUI/Bit.BlazorUI.csproj (1)
27-28: Remove unnecessary empty linesThere are two consecutive empty lines between ItemGroups which is unnecessary.
</ItemGroup> - <ItemGroup>src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/ProPanel/BitProPanelTests.cs (4)
10-10: Consider makingisPanelOpenreadonly.Since this field is only modified through the
HandleIsOpenChangedmethod, consider making itreadonlyto better express intent.- private bool isPanelOpen = true; + private readonly bool isPanelOpen = true;
12-15: Add test case for null blocking parameter.Consider adding a test case for when the blocking parameter is null to ensure default behavior is tested.
[DataTestMethod, DataRow(false), - DataRow(true) + DataRow(true), + DataRow(null) ]
109-110: Extract test content strings as constants.Consider extracting test content strings as private constants to improve maintainability and reusability.
+ private const string TEST_HEADER_CONTENT = "<div>Test Header Content</div>"; + private const string TEST_FOOTER_CONTENT = "<div>Test Footer Content</div>"; + private const string TEST_BODY_CONTENT = "<div>Test Content</div>"; - const string headerContent = "<div>Test Header Content</div>"; + const string headerContent = TEST_HEADER_CONTENT;
178-178: Follow C# naming conventions for variables.The variable
PanelElementshould be camelCase as per C# naming conventions.- var PanelElement = com.Find(".bit-pnl-cnt"); + var panelElement = com.Find(".bit-pnl-cnt");src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor.cs (1)
113-128: LGTM! Consider extracting the position check to a helper method.The refactoring improves readability by introducing intermediate variables. To further enhance maintainability, consider extracting the repeated position check logic into a helper method.
+ private bool IsHorizontalPanel() => Position == BitPanelPosition.Start || Position == BitPanelPosition.End; + public async Task _OnStart(decimal startX, decimal startY) { - var start = (Position == BitPanelPosition.Start || Position == BitPanelPosition.End) ? startX : startY; + var start = IsHorizontalPanel() ? startX : startY; await OnSwipeStart.InvokeAsync(start); }src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor (2)
33-55: Consider adding ARIA labels for better accessibility.The implementation is good with proper panel references and consistent styling. Consider adding aria-label attributes to the close buttons for better accessibility.
- <BitButton OnClick="() => blockingPanelRef.Close()">Close</BitButton> + <BitButton OnClick="() => blockingPanelRef.Close()" aria-label="Close blocking panel">Close</BitButton>
88-119: Consider adding responsive size handling.The implementation effectively demonstrates different positions and size control. Consider adding responsive size handling for better mobile experience.
- <BitPanel @bind-Size="customPanelSize" + <BitPanel @bind-Size="@(IsMobile ? Math.Min(customPanelSize, MaxMobileSize) : customPanelSize)"src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor (2)
15-23: Consider adding aria-label for accessibilityThe basic example should include an aria-label on the panel for better accessibility.
-<BitProPanel @bind-IsOpen="isBasicPanelOpen"> +<BitProPanel @bind-IsOpen="isBasicPanelOpen" aria-label="Basic panel example">
252-262: Consider extracting RTL text to resource filesThe hardcoded RTL text should be moved to resource files for better localization support.
Consider implementing a localization system using resource files for better maintainability and scalability of multilingual support.
Also applies to: 264-274
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor.cs(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.scss(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanelClassStyles.cs(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Styles/bit.blazorui.extras.scss(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Styles/components.scss(1 hunks)src/BlazorUI/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csproj(1 hunks)src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/ProPanel/BitProPanelTests.cs(1 hunks)src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Panel/BitPanelTests.cs(0 hunks)src/BlazorUI/Bit.BlazorUI/Bit.BlazorUI.csproj(1 hunks)src/BlazorUI/Bit.BlazorUI/Components/BitComponentBase.cs(1 hunks)src/BlazorUI/Bit.BlazorUI/Components/Progress/Loading/Base/BitLoadingBase.cs(1 hunks)src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor(1 hunks)src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor.cs(3 hunks)src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.scss(3 hunks)src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanelClassStyles.cs(0 hunks)src/BlazorUI/Bit.BlazorUI/Styles/general.scss(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor.cs(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor.scss(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor(5 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor.cs(3 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor.scss(2 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Home/ComponentsSection.razor(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/NavMenu.razor.cs(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/compilerconfig.json(2 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor.cs(1 hunks)
💤 Files with no reviewable changes (2)
- src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Panel/BitPanelTests.cs
- src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanelClassStyles.cs
✅ Files skipped from review due to trivial changes (3)
- src/BlazorUI/Bit.BlazorUI.Extras/Styles/bit.blazorui.extras.scss
- src/BlazorUI/Bit.BlazorUI.Extras/Styles/components.scss
- src/BlazorUI/Bit.BlazorUI/Styles/general.scss
🔇 Additional comments (24)
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor.cs (1)
44-44: Verify the implementation of [TwoWayBound] attribute
The IsOpen property is decorated with [Parameter, TwoWayBound]. Ensure that the [TwoWayBound] attribute is correctly implemented and supported in the project to enable proper two-way binding functionality.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor.cs (1)
245-246:
Initialize bitPanelRef to prevent potential null reference
The bitPanelRef variable is declared but not initialized. Ensure it's properly assigned before use to prevent potential null reference exceptions when calling methods like Open().
Initialize bitPanelRef in the component:
private BitProPanel bitPanelRef = default!;Ensure that it's correctly referenced in the Razor file.
Alternatively, if using @ref ensures proper assignment, you can ignore this if you're confident that Blazor will handle the reference assignment before use.
src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor (2)
20-22: Confirm updated methods for container styles and classes
The methods GetContainerCssStyles() and GetContainerCssClasses() replace the previous methods. Ensure these methods are correctly implemented and return the expected styles and classes for the panel container.
13-16: Ensure the overlay click event handler is correctly assigned
The @onclick for the overlay div has been moved. Verify that the click event correctly dismisses the panel when clicking outside of it, and that the OnOverlayClicked method is properly handled.
Run the following script to check for references to OnOverlayClicked:
✅ Verification successful
The overlay click handler is correctly implemented
The OnOverlayClicked method is properly implemented in the code-behind file (BitPanel.razor.cs) and correctly wired up in the Razor template. It:
- Checks if the panel is blocking (
Blockingproperty) - If not blocking, calls
ClosePanelwhich:- Verifies the panel is enabled
- Updates the
IsOpenstate - Invokes the
OnDismisscallback
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the OnOverlayClicked method is implemented and used appropriately.
# Search for the implementation of OnOverlayClicked
rg -A 5 'void OnOverlayClicked\('
Length of output: 35
Script:
#!/bin/bash
# Let's try a broader search for the BitPanel component implementation
ast-grep --pattern 'class BitPanel {
$$$
}'
# Also search for any method containing "overlay" or "click" in case the method name is different
rg -i "overlay.*click|click.*overlay" -A 5
Length of output: 69681
Script:
#!/bin/bash
# Let's search for the BitPanel.razor file to see the implementation
rg -t razor "OnOverlayClicked" src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor -A 10
# Also search for any code-behind file
fd "BitPanel.razor.cs" src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/
Length of output: 279
Script:
#!/bin/bash
# Let's check the implementation in the code-behind file
cat src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor.cs
# Also let's see the full Razor file content
cat src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor
Length of output: 8144
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor.scss (1)
38-38: LGTM: Consistent padding applied
The padding addition to .custom-container maintains consistency with the panel-body styling.
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanelClassStyles.cs (1)
4-35: LGTM: Well-structured class with clear property documentation
The class follows good practices:
- Proper inheritance from BitPanelClassStyles
- Clear XML documentation for all properties
- Appropriate use of nullable string properties for optional styling
src/BlazorUI/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csproj (1)
27-28: LGTM: Required project reference added
The addition of Bit.BlazorUI.Extras project reference is necessary for testing the new BitProPanel component.
src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.scss (2)
16-16: LGTM: Improved positioning with modern CSS shorthand
The use of inset: 0 is a good modernization, replacing individual positioning properties with a more concise shorthand.
58-58: LGTM: Enhanced horizontal positioning for top/bottom panels
The addition of inset-inline: 0 properly handles horizontal positioning for top/bottom panels using logical properties.
Also applies to: 69-69
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.scss (1)
3-8: Verify RTL support for flex layout
The flex layout should be tested with RTL languages to ensure proper support.
✅ Verification successful
RTL support is properly implemented in the component framework
The flex layout in BitProPanel is safe for RTL languages because:
- The component inherits from BitComponentBase which has built-in RTL support through the
BitDirenum - The framework automatically applies 'bit-rtl' class when RTL direction is set
- The flex-direction: column property is direction-agnostic and works the same way in both LTR and RTL contexts
The component will correctly handle RTL layouts through the framework's built-in direction support system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for RTL-specific styles and potential issues
rg -l "rtl|right-to-left|direction:|float:" --type scss
Length of output: 86
Script:
#!/bin/bash
# Search for RTL-related styles in all CSS/SCSS files using fd and rg
fd -e css -e scss -x rg -l "rtl|right-to-left|direction:|float:"
# Also check for any RTL-related configuration or setup files
fd -t f -x rg -l "rtl|right-to-left|direction" {}
Length of output: 31105
Script:
#!/bin/bash
# Check for RTL-specific styles in BitProPanel and its related components
rg -A 5 "direction:|rtl|right-to-left" ./src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.scss
# Check for RTL support in the base component class and utilities
rg -A 5 "BitDir|direction" ./src/BlazorUI/Bit.BlazorUI/Utils/BitDir.cs
rg -A 5 "BitDir|direction" ./src/BlazorUI/Bit.BlazorUI/Components/BitComponentBase.cs
Length of output: 1996
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProPanel/BitProPanel.razor (1)
4-26: Verify accessibility attributes for the panel component
The component passes various parameters to BitPanel, but there might be room for improvement in accessibility:
- Consider adding
role="dialog"orrole="complementary"depending on the panel's purpose - The
AriaLabelshould have a default value if not provided
src/BlazorUI/Bit.BlazorUI/Components/BitComponentBase.cs (1)
180-182: LGTM! Access modifier change enhances component extensibility.
The change from internal to protected for ClassBuilder and StyleBuilder properties appropriately enables derived components to manage their CSS classes and styles while maintaining encapsulation.
src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/ProPanel/BitProPanelTests.cs (1)
7-193: LGTM! Well-structured and comprehensive test coverage.
The test suite provides excellent coverage of the BitProPanel component's functionality, including:
- Blocking behavior
- Modeless behavior
- Open state management
- Content rendering
- Event handling
- Position management
Good use of data-driven testing and clear test method organization.
src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Panel/BitPanel.razor.cs (2)
Line range hint 203-225: LGTM! Clean implementation of style generation.
The method effectively handles style generation with proper null checks and string interpolation. The use of List for style collection is a good practice.
226-245: LGTM! Well-structured class generation logic.
The method effectively handles class generation with a clean switch expression and proper null checks. The default case aligns with the expected behavior.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/NavMenu.razor.cs (1)
159-159: LGTM! ProPanel navigation item properly added.
The new navigation item follows the established pattern and naming conventions.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Surfaces/Panel/BitPanelDemo.razor (3)
Line range hint 17-22: LGTM! Consistent styling applied.
The padding and width provide a good visual presentation for the panel content.
148-157: LGTM! Well-structured styling examples.
The examples effectively demonstrate both inline styles and class-based styling approaches.
175-189: LGTM! Proper RTL implementation.
The RTL support is well implemented with consistent styling and proper direction handling.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Home/ComponentsSection.razor (1)
256-258: LGTM! ProPanel link added correctly
The new ProPanel component link follows the established pattern and is appropriately placed in the Extras section.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/ProPanel/BitProPanelDemo.razor (2)
1-5: LGTM! Page metadata is properly configured
The page route and metadata are correctly set up with appropriate title and description.
34-34: Consider adding search event handler
The SearchBox component is included in the header but lacks an event handler for search functionality.
-<BitSearchBox Placeholder="Search here..." />
+<BitSearchBox Placeholder="Search here..." OnSearch="HandleSearch" />src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/compilerconfig.json (2)
74-79: LGTM! SCSS configuration added correctly
The configuration for BitProPanelDemo follows the established pattern with correct paths and settings.
315-316: Verify the BitProgressDemo path change
The path for BitProgressDemo has changed from ProgressBar to Progress. Ensure this change is intentional and that all related imports are updated.
✅ Verification successful
Path change from ProgressBar to Progress is valid
The verification shows that:
- The new path
Progress/Progress/BitProgressDemoexists in the codebase - No references to the old path
Progress/ProgressBar/BitProgressDemowere found - The only references to
BitProgressDemoare in the new location and the compiler configuration file
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any remaining references to the old path
rg -l "Progress/ProgressBar/BitProgressDemo"
Length of output: 44
Script:
#!/bin/bash
# Search for any references to BitProgressDemo in the codebase
rg -l "BitProgressDemo"
# Search for any files with Progress/Progress pattern
fd "Progress/Progress"
# Search for any files with Progress/ProgressBar pattern
fd "Progress/ProgressBar"
Length of output: 262
closes #9392
Summary by CodeRabbit
New Features
BitProPanelcomponent with customizable properties for a flexible panel interface.BitProPanel, showcasing various configurations and functionalities.Bug Fixes
BitPanelcomponent by removing unnecessary parameters and attributes for improved usability.Style
BitProPanelcomponent to enhance its layout and interactivity.BitPanelDemocomponent to improve visual spacing and structure.Tests
BitProPanelcomponent to validate its functionalities and interactions.