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 chevron icon issues (#9075) #9082

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

Cyrus-Sushiant
Copy link
Member

@Cyrus-Sushiant Cyrus-Sushiant commented Nov 1, 2024

This closes #9075

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated icons for navigation buttons in the carousel and swiper components to enhance user experience.
    • Introduced new CSS classes for improved visual effects in carousel and swiper components.
    • Enhanced flexibility for icon customization in pagination, allowing for nullable icon properties.
  • Bug Fixes

    • Enhanced icon handling in pagination to ensure default icons are displayed when specific properties are null.
  • Chores

    • Streamlined CSS by removing redundant classes and improving transformation logic for pagination components.

Copy link

coderabbitai bot commented Nov 1, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes in this pull request primarily involve updates to icon usage and styling within the Bit.BlazorUI components. The BitCarousel and BitSwiper components now utilize right chevron icons instead of left chevrons for navigation buttons. Additionally, new CSS classes for horizontal flipping effects have been introduced in the respective stylesheets. The BitPagination component has also seen enhancements in the logic for icon rendering, allowing for more flexible icon assignments. Overall, the modifications focus on visual representation while maintaining existing functionality.

Changes

File Path Change Summary
src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor Updated right navigation button icon from ChevronLeft to ChevronRight.
src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scss Added new class .bit-csl-rbi for horizontal flip transformation.
src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor Updated left button icon from ChevronLeft to ChevronRight.
src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss Added new class .bit-swp-lbi for horizontal flip transformation.
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor Enhanced icon class logic with fallbacks for pagination buttons.
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor.cs Changed icon properties from non-nullable to nullable strings.
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.scss Removed .bit-pgn-ico and .bit-rtl classes; added .bit-pgn-btl class for icon transformation.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Pagination/BitPaginationDemo.razor.cs Updated icon parameters to nullable types with default values set to null.

Assessment against linked issues

Objective Addressed Explanation
Replace ChevronLeft and ChevronLeftEnd6 icons with ChevronRight and ChevronRightEnd6 with transform (#9075)

🐰 In the carousel, the icons now gleam,
With right chevrons, they dance and beam.
A flip here, a twist there, oh what a sight,
Pagination's icons, now feeling just right!
Hopping along, we celebrate this change,
For every click, our joy will arrange! 🐇✨


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.

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.

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: 0

🧹 Outside diff range and nitpick comments (7)
src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scss (1)

70-72: LGTM! Consider adding a comment for clarity.

The implementation is correct and efficient, using GPU-accelerated CSS transform for the horizontal flip effect.

Consider adding a brief comment to document the purpose:

+/* Horizontally flips an element (used for converting right-facing icons to left-facing) */
.bit-csl-rbi {
    transform: scaleX(-1);
}
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor (1)

78-78: Last button icon implementation is well-implemented!

The implementation correctly follows the established pattern and handles directionality appropriately.

Consider extracting the default icon names into constants to improve maintainability:

+private const string DefaultFirstLastIcon = "ChevronRightEnd6";
+private const string DefaultPrevNextIcon = "ChevronRight";

-<i ... class="bit-icon bit-icon--@(FirstIcon ?? "ChevronRightEnd6") ..." />
+<i ... class="bit-icon bit-icon--@(FirstIcon ?? DefaultFirstLastIcon) ..." />
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.scss (1)

35-37: LGTM! Consider adding a descriptive comment.

The implementation of .bit-pgn-btl with scaleX(-1) transform is a clean solution for horizontally flipping icons. This aligns well with the PR objective of using right chevron icons with appropriate transformations.

Consider adding a comment to explain the purpose of this class:

+// Horizontally flips icons (e.g., converting right chevron to left chevron)
.bit-pgn-btl {
    transform: scaleX(-1);
}
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor.cs (2)

46-46: Consider documenting the default icon values.

Since the icon properties are now nullable, consider adding XML documentation to specify the default icon values that will be used when these properties are null. This helps developers understand the component's behavior without having to check the razor template.

     /// <summary>
-    /// The icon name of the first button.
+    /// The icon name of the first button. If null, defaults to ChevronRightEnd6 with horizontal flip.
     /// </summary>
     [Parameter] public string? FirstIcon { get; set; }

     /// <summary>
-    /// The icon name of the last button.
+    /// The icon name of the last button. If null, defaults to ChevronRightEnd6.
     /// </summary>
     [Parameter] public string? LastIcon { get; set; }

     /// <summary>
-    /// The icon name of the next button.
+    /// The icon name of the next button. If null, defaults to ChevronRight.
     /// </summary>
     [Parameter] public string? NextIcon { get; set; }

     /// <summary>
-    /// The icon name of the previous button.
+    /// The icon name of the previous button. If null, defaults to ChevronRight with horizontal flip.
     /// </summary>
     [Parameter] public string? PreviousIcon { get; set; }

Also applies to: 51-51, 63-63, 73-73


46-46: Consider adding migration guide for breaking changes.

The removal of default values from icon properties is a breaking change that might affect existing applications. Consider adding a migration guide in the PR description or documentation to help users update their code.

Also applies to: 51-51, 63-63, 73-73

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Pagination/BitPaginationDemo.razor.cs (2)

49-50: Verify FirstIcon documentation completeness.

The parameter's type has been updated to be nullable, but the description doesn't mention the default icon that will be used when null. Consider updating the description to clarify the fallback behavior.

Suggested description update:

-    Description = "The icon name of the first button."
+    Description = "The icon name of the first button. When null, defaults to ChevronRightEnd6 with appropriate transformation."

56-57: Ensure consistent documentation for icon parameters.

The changes to make LastIcon, NextIcon, and PreviousIcon nullable align with the new flexible icon system. However, like FirstIcon, their descriptions should be updated to document the default behavior when null.

Consider updating the descriptions to be more informative:

-    Description = "The icon name of the last button."
+    Description = "The icon name of the last button. When null, defaults to ChevronRightEnd6."

-    Description = "The icon name of the next button."
+    Description = "The icon name of the next button. When null, defaults to ChevronRight."

-    Description = "The icon name of the previous button."
+    Description = "The icon name of the previous button. When null, defaults to ChevronRight with appropriate transformation."

Also applies to: 70-71, 84-85

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2ee4888 and 98d7685.

📒 Files selected for processing (8)
  • src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scss (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor (4 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor.cs (3 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.scss (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Pagination/BitPaginationDemo.razor.cs (3 hunks)
🔇 Additional comments (9)
src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor (1)

25-25: LGTM! Elegant solution using CSS transform.

The change aligns with the PR objectives by replacing the ChevronLeft icon with ChevronRight. Using CSS transform via bit-swp-lbi class is an elegant approach as it maintains DRY principles by reusing the same icon.

Let's verify the CSS class exists:

✅ Verification successful

CSS transform class is properly defined and implemented

The bit-swp-lbi class is correctly defined in the SCSS file with transform: scaleX(-1), which will horizontally flip the ChevronRight icon to create a left-pointing chevron. This confirms that the elegant solution using CSS transform is working as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the bit-swp-lbi class is defined in the stylesheet
# Expected: Should find the class definition with transform: scaleX(-1)

rg -l "bit-swp-lbi" "src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss"
rg "bit-swp-lbi.*transform:\s*scaleX\(-1\)" "src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss"

Length of output: 260


Script:

#!/bin/bash
# Let's check the actual content of the SCSS file to see the definition of bit-swp-lbi class
cat "src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss"

Length of output: 1912

src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor (1)

30-30: Implementation aligns with requirements.

The change correctly implements the ChevronRight icon with a flip transformation class for the right button, while the left button uses the same icon without transformation.

Let's verify the CSS class implementation:

✅ Verification successful

CSS class implementation is correct and functional

The bit-csl-rbi class is properly defined in the carousel SCSS file and uses transform: scaleX(-1) to horizontally flip the ChevronRight icon, which is the correct approach for creating a mirror image of the right button icon to serve as the left button icon. This implementation aligns with the review comment's objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the CSS class implementation for the flip transform
# Expected: Find the bit-csl-rbi class definition in the SCSS/CSS files

# Search for the CSS class definition
rg -t scss -t css 'bit-csl-rbi'

Length of output: 60


Script:

#!/bin/bash
# Let's try different approaches to find the CSS class:

# 1. Search for the class in all files (not just scss/css)
rg "bit-csl-rbi"

# 2. Find all potential style files using fd
fd -e css -e scss -e sass -e less

# 3. Look for carousel-related style files
fd -e css -e scss -e sass -e less -g "*carousel*"

# 4. Search for transform/rotate styles that might be related
rg -t css "transform.*rotate|rotate.*transform" 

Length of output: 365121


Script:

#!/bin/bash
# Let's check the carousel SCSS file to see the bit-csl-rbi class definition
cat src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scss

Length of output: 1938

src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss (1)

64-66: LGTM! Clean implementation of icon flipping.

The new .bit-swp-lbi class implements a horizontal flip transformation that elegantly solves the chevron icon replacement requirement. The implementation:

  • Follows the existing naming conventions
  • Uses the standard scaleX(-1) transform for horizontal flipping
  • Is placed logically in the stylesheet structure
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor (4)

16-16: First button icon implementation looks good!

The implementation correctly handles the icon direction by applying the horizontal flip class when appropriate, ensuring consistent visual representation in both LTR and RTL modes.


27-27: Previous button icon implementation is consistent!

The implementation follows the same pattern as the First button, maintaining consistency in the codebase while correctly handling directionality.


67-67: Next button icon implementation correctly handles directionality!

The implementation appropriately inverts the flip logic for RTL mode, ensuring the icon points in the correct direction for "next" navigation in both LTR and RTL contexts.


Line range hint 16-78: Overall implementation is robust and well-structured!

The changes consistently handle icon directionality across all navigation buttons, successfully addressing the chevron icon issue (#9075). The implementation:

  • Uses a consistent pattern for all navigation buttons
  • Correctly handles both LTR and RTL modes
  • Provides flexibility through nullable icon parameters
  • Maintains proper fallback behavior
src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor.cs (1)

46-46: Verify the default icon fallbacks in the razor template.

The icon properties have been made nullable, which is a breaking change. Ensure that the razor template (BitPagination.razor) implements appropriate fallback logic to handle null values and uses the correct chevron icons as specified in issue #9075.

Also applies to: 51-51, 63-63, 73-73

✅ Verification successful

Let me check the content of the remaining files that still contain references to the old icons.


Icon properties and fallback implementation are correctly handled

The verification shows that:

  1. The razor template implements proper fallback logic for all nullable icon properties using the null coalescing operator (??)
  2. Default icons are set to ChevronRight and ChevronRightEnd6 as intended
  3. RTL support is handled via the bit-pgn-btl class based on the Dir property

The remaining references to ChevronLeft and ChevronLeftEnd6 in style and icon definition files are expected as they are part of the icon library's complete set of available icons.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the razor template implementation and icon usage

# Test 1: Check the razor template for fallback logic
echo "Checking BitPagination.razor for fallback logic..."
rg -A 5 'FirstIcon|LastIcon|NextIcon|PreviousIcon' 'src/BlazorUI/Bit.BlazorUI/Components/Navs/Pagination/BitPagination.razor'

# Test 2: Verify no remaining usage of old chevron icons
echo "Checking for any remaining usage of old chevron icons..."
rg -l 'ChevronLeft|ChevronLeftEnd6' 'src/BlazorUI'

Length of output: 1614


Script:

#!/bin/bash
# Check the content of files still containing old chevron references
echo "Checking fabric.mdl2.bit.blazoui.scss..."
rg -C 2 'ChevronLeft|ChevronLeftEnd6' 'src/BlazorUI/Bit.BlazorUI/Styles/fabric.mdl2.bit.blazoui.scss'

echo "Checking BitIconName.cs..."
rg -C 2 'ChevronLeft|ChevronLeftEnd6' 'src/BlazorUI/Bit.BlazorUI.Icons/BitIconName.cs'

echo "Checking fabric.mdl2.icons.scss..."
rg -C 2 'ChevronLeft|ChevronLeftEnd6' 'src/BlazorUI/Bit.BlazorUI.Icons/Styles/fabric.mdl2.icons.scss'

Length of output: 3107

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Pagination/BitPaginationDemo.razor.cs (1)

49-50: Verify the impact on demo examples.

The change to nullable icon parameters with null defaults represents a significant change in the component's behavior. Please ensure that the demo page includes examples demonstrating:

  1. Default behavior with null icons
  2. Custom icon override scenarios
  3. RTL handling with the new icon system

Also applies to: 56-57, 70-71, 84-85

✅ Verification successful

The demo page adequately covers all icon-related scenarios

Looking at the demo page content, I can verify that:

  1. Default behavior with null icons is demonstrated in multiple examples (Basic, Variants, etc.)
  2. Custom icon override scenarios are shown in example 7 with NextIcon="@BitIconName.Next" PreviousIcon="@BitIconName.Previous"
  3. RTL handling is demonstrated in example 12 with proper RTL pagination examples

The demo page comprehensively covers all the necessary scenarios related to the nullable icon parameters change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the demo page includes examples for both default and custom icons
rg -l "BitPaginationDemo\.razor" | xargs rg -A 10 "<BitPagination"

Length of output: 68


Script:

#!/bin/bash
# Let's try a different approach to find the pagination demo files and their content
fd "BitPaginationDemo.razor" --type f

# After finding the file, let's look at its content
fd "BitPaginationDemo.razor" --type f --exec cat {}

Length of output: 30784

@msynk msynk merged commit ce9e6cb into bitfoundation:develop Nov 1, 2024
3 checks passed
@msynk msynk changed the title Fix chevron icon issue (#9075) Fix chevron icon issues (#9075) Nov 1, 2024
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.

Replace ChevronLeft and ChevronLeftEnd6 icons with ChevronRight and ChevronRightEnd6 with transform
2 participants