Skip to content

fix(grid): [grid] fix x-design theme style #2355

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

Merged
merged 2 commits into from
Oct 23, 2024
Merged

fix(grid): [grid] fix x-design theme style #2355

merged 2 commits into from
Oct 23, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Oct 22, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced tooltip configuration flexibility in the grid component.
    • Improved styling for grid components, including padding and margin adjustments for better layout.
  • Bug Fixes

    • Resolved visual inconsistencies in the grid menu and table components.
  • Documentation

    • Updated descriptions for tooltip configurations in both English and Chinese for clarity.
  • Chores

    • Removed unnecessary stylesheet dependency for the BaseSelect component.

@gimmyhehe gimmyhehe added bug Something isn't working enhancement New feature or request (功能增强) labels Oct 22, 2024
Copy link

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request encompass updates to various files related to the grid component, including modifications to tooltip configurations, CSS styles, and mixins. The tooltip property in the grid.js file has been generalized, allowing for more flexible configurations. Additionally, CSS adjustments in custom.less, menu.less, and table.less enhance the layout and spacing of grid elements. New CSS variables for small table configurations have been introduced in vars.less, while an unused stylesheet import has been removed from base-select/index.ts. Overall, these changes aim to improve styling and functionality within the grid component.

Changes

File Change Summary
examples/sites/demos/apis/grid.js Updated tooltip property type from IToolTipConfig to Tooltip.Props; clarified documentation.
packages/theme/src/grid/custom.less Adjusted padding values for various CSS classes related to the grid component.
packages/theme/src/grid/menu.less Modified styling for grid menu components, including padding and border adjustments.
packages/theme/src/grid/mixins/table.less Updated .MiniColumnHeight() mixin height from 30px to 32px; added .SmallTdPadding() mixin.
packages/theme/src/grid/table.less Adjusted sizes and padding for various table component styles, including new mixin usages.
packages/theme/src/grid/vars.less Added new CSS variables for small table configurations; updated existing mini table variable.
packages/vue/src/base-select/index.ts Removed import statement for @opentiny/vue-theme/base-select/index.less.

Possibly related PRs

Suggested reviewers

  • zzcr

🐰 In the grid, where tooltips gleam,
Padding and spacing, a designer's dream.
With colors that dance and styles that play,
Our components shine brighter each day!
Hopping along, we refine and improve,
In the world of code, we make our groove! 🌟


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.

@github-actions github-actions bot removed the enhancement New feature or request (功能增强) label Oct 22, 2024
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)
packages/theme/src/grid/mixins/table.less (1)

56-65: Consider a holistic review of grid styling changes.

The changes in this file appear to be part of a broader update to the grid styling system, particularly for different size variants. To ensure consistency and completeness:

  1. Review all grid-related less files for similar updates.
  2. Check if these changes are reflected in the component's documentation.
  3. Consider updating or creating visual regression tests for the grid component with different sizes.

Would you like assistance in generating a checklist for a comprehensive review of the grid styling system?

packages/theme/src/grid/menu.less (3)

30-30: Padding adjustment improves vertical spacing.

The change from 0 1px to 8px 0 padding enhances the vertical spacing of menu items, which can improve readability and touch targets. This aligns well with the PR's objective of fixing the x-design theme style.

Consider adding a small horizontal padding (e.g., 8px 4px) to prevent text from touching the edges of the menu.


53-54: Improved theme consistency with CSS variables.

Replacing hardcoded color values with CSS variables (var(--tv-Grid-text-color) and var(--tv-Grid-bg-color-active)) enhances theme consistency and maintainability. This change aligns with modern CSS best practices and facilitates easier theme customization.

Consider adding a subtle transition effect to the background-color change for a smoother user experience when hovering or selecting menu items. For example:

transition: background-color 0.2s ease;

59-60: Enhanced disabled state styling and feedback.

Using the CSS variable var(--tv-Grid-text-color-disabled) for the disabled text color improves theme consistency. Setting the cursor to not-allowed provides clear visual feedback for disabled items, enhancing usability and accessibility.

Consider adding an aria-disabled="true" attribute to disabled menu items for improved accessibility. This would require a change in the component's template or rendering logic.

packages/theme/src/grid/table.less (2)

910-911: Enhanced editable table styles

The changes to the editable table styles, particularly the use of CSS variables for padding, improve the flexibility and maintainability of the component. This approach allows for easier theming and customization.

Consider adding a comment explaining the purpose of the --tv-Grid-cell-padding-x variable for better code documentation.


Line range hint 1-1180: Overall improvements to grid component styles

The changes in this file primarily focus on enhancing size variations and editable table styles. These improvements contribute to better consistency, flexibility, and maintainability of the grid component. The use of mixins and CSS variables allows for easier customization and theming.

Consider creating a separate file for size-related mixins to further improve the modularity of the styling system. This would make it easier to manage and update size-specific styles across different components.

examples/sites/demos/apis/grid.js (1)

Line range hint 12-24: Consider revising the discount and fee structure

The current implementation has a potential issue:

  • A flat $20 fee is added to all discounted amounts, regardless of the purchase size.
  • This can lead to situations where customers barely qualifying for a discount (e.g., 3-4 years loyalty) may end up paying more than they would without a discount, especially for smaller purchases.

This structure might discourage customer loyalty or cause dissatisfaction.

Consider adjusting the fee structure or discount policy to ensure it always benefits loyal customers. Would you like assistance in devising a more balanced approach?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 777e852 and b0bb778.

📒 Files selected for processing (7)
  • examples/sites/demos/apis/grid.js (1 hunks)
  • packages/theme/src/grid/custom.less (2 hunks)
  • packages/theme/src/grid/menu.less (2 hunks)
  • packages/theme/src/grid/mixins/table.less (1 hunks)
  • packages/theme/src/grid/table.less (2 hunks)
  • packages/theme/src/grid/vars.less (1 hunks)
  • packages/vue/src/base-select/index.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/vue/src/base-select/index.ts
🧰 Additional context used
🔇 Additional comments (13)
packages/theme/src/grid/mixins/table.less (2)

63-65: LGTM. Verify CSS variable definitions.

The addition of the .SmallTdPadding() mixin is a good improvement, allowing for more flexible styling of small-sized table cells. It follows the pattern of existing padding mixins.

Please ensure that the CSS variables --tv-Grid-cell-padding-y-small and --tv-Grid-cell-padding-x-small are properly defined. Run the following script to check for their definitions:

Also, verify that this new mixin is being used appropriately in the relevant less files. Run:

✅ Verification successful

Verification Successful. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for CSS variable definitions
rg --type=less "tv-Grid-cell-padding-(x|y)-small"

Length of output: 427


Script:

#!/bin/bash
# Description: Check for usage of .SmallTdPadding() mixin
rg --type=less "SmallTdPadding\(\)"

Length of output: 159


56-56: LGTM. Verify impact on existing layouts.

The change to increase the mini column height from 30px to 32px looks good. It now matches the .MiniHeaderColumnHeight() mixin, which should improve consistency.

Please verify that this change doesn't negatively impact existing layouts using mini-sized grid components. Run the following script to find potential usage:

packages/theme/src/grid/menu.less (1)

45-47: Improved visual consistency by removing the last border.

Removing the border for the last child element in the menu list enhances the overall visual appearance. This is a good UI practice and aligns well with the PR's objective of improving the x-design theme style.

packages/theme/src/grid/custom.less (3)

34-34: LGTM: Improved vertical padding for tabs body

The increase in vertical padding from 12px to 16px should enhance the visual spacing of the tabs body content.


43-43: Verify the impact of removed bottom padding

The change from 12px 0 24px to 8px 0 0 reduces top padding and removes bottom padding. While this aligns with the overall adjustments, please verify that removing the bottom padding (24px) doesn't negatively impact the layout or spacing between this element and the next.


47-47: LGTM: Simplified padding for setting items

The change from 10px 8px to 8px simplifies the padding to a uniform value on all sides. This is generally good for consistency.

Please verify that the reduction in horizontal padding (from 8px to 8px) doesn't negatively impact the layout of the setting items, especially for any text or icons that might be close to the edges.

packages/theme/src/grid/vars.less (5)

149-149: LGTM: Updated comment accurately represents the section's scope.

The comment now correctly includes both mini and small table configurations, improving clarity for developers.


153-153: Verify the reduction in vertical padding for mini tables.

The vertical padding for mini table cells has been reduced from 8px to 4px. Please confirm that this change:

  1. Aligns with the intended design specifications.
  2. Doesn't negatively impact the appearance or usability of mini tables.

154-155: LGTM: New variable for small table horizontal padding.

The addition of --tv-Grid-cell-padding-x-small with a value of 16px is appropriate and consistent with the mini table horizontal padding.


156-157: Verify the vertical padding for small tables.

A new variable --tv-Grid-cell-padding-y-small has been added with a value of 8px. Please confirm that:

  1. This value aligns with the intended design specifications for small tables.
  2. The difference in vertical padding between small (8px) and mini (4px) tables is intentional and provides the desired visual distinction.

149-157: Summary: New small table configurations and updates to mini table styles

The changes introduce support for small table configurations and update existing mini table styles. While the additions and changes seem appropriate, please ensure:

  1. The reduction in vertical padding for mini tables (from 8px to 4px) is intentional and doesn't negatively impact usability.
  2. The vertical padding for small tables (8px) aligns with design specifications and provides the desired visual distinction from mini tables.

These verifications will help maintain consistency and usability across different table size configurations.

packages/theme/src/grid/table.less (2)

101-101: Improved size variations and consistency

The changes to the small, medium, and mini size classes, including the use of new mixins like .SmallTdPadding() and .SmallColumnHeight(), enhance the consistency and flexibility of the grid component. This modular approach allows for easier maintenance and customization of different size variations.

Also applies to: 910-911


Line range hint 1-1180: Summary of changes and their impact

The modifications to packages/theme/src/grid/table.less primarily focus on:

  1. Enhancing size variations (small, medium, mini) using new mixins for padding and height adjustments.
  2. Improving editable table styles with the use of CSS variables for padding.

These changes contribute to:

  • Better consistency across different size variations
  • Increased flexibility for customization and theming
  • Improved maintainability of the styling system

Overall, these updates represent a positive step towards a more modular and adaptable grid component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants