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

refactor(dropdown-menu): [dropdown] refactor DropdownMenu and DropdownItem vars and style #2208

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Sep 29, 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

  • New Features

    • Enhanced dropdown item styling with new size-related classes.
    • Improved dropdown menu layout for better alignment and consistency.
  • Bug Fixes

    • Adjusted vertical alignment of the dropdown arrow for better display.
  • Style

    • Comprehensive updates to CSS variable names and styles across dropdown components, reflecting a new theming approach.
    • Streamlined variable structure for easier maintenance.
  • Refactor

    • Updated class binding logic for improved readability and flexibility in dropdown item components.

Copy link

coderabbitai bot commented Sep 29, 2024

Walkthrough

The changes in this pull request involve updates to the dropdown component's styling, functionality, and associated tests. Key modifications include adjustments to CSS variables for theming, enhancements in the state management of dropdown items, and refinements in the rendering logic. The updates aim to streamline the styling approach and improve the overall flexibility of the dropdown components.

Changes

File Path Change Summary
examples/sites/demos/pc/app/dropdown/visible-arrow.spec.ts Adjusted the expected 'top' CSS property value for the dropdown arrow from '-6px' to '-8px', affecting its vertical alignment.
packages/renderless/src/dropdown-item/vue.ts Updated initState and renderless functions to include a new dropdownVm parameter, enhancing state management with a new sizeClass property based on the dropdownVm context.
packages/theme/src/dropdown-item/index.less Comprehensive updates to CSS variable names and styles, transitioning to a new naming convention with tv- prefix, introducing new styles for SVG icons, and refining hover and active states.
packages/theme/src/dropdown-item/vars.less Streamlined CSS variable declarations, reducing the number of variables and changing prefixes from --ti- to --tv-, focusing on essential attributes like font size and line height.
packages/theme/src/dropdown-menu/index.less Updated CSS variable names and values, transitioning to tv- prefix, modifying padding, background color, and arrow element styles for consistency across dropdown placements.
packages/theme/src/dropdown-menu/vars.less Significant updates to CSS variable definitions, removing several old variables and introducing new ones with tv- prefix, consolidating margin and padding variables for better organization.
packages/vue/src/dropdown-item/src/pc.vue Modified class binding logic for the dropdown item component, changing from object syntax to array syntax for improved readability and flexibility, and simplifying conditional classes.

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • zzcr

🐇 In the meadow, changes bloom,
Dropdowns dance, dispelling gloom.
With styles anew and classes bright,
Our components shine, a lovely sight!
Let's hop along, embrace the cheer,
For every tweak brings joy, my dear! 🌼


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

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

@MomoPoppy MomoPoppy added the refactoring Refactoring (重构) label Sep 29, 2024
@MomoPoppy MomoPoppy changed the title refactor DropdownMenu and DropdownItem refactor(dropdown-menu): refactor DropdownMenu and DropdownItem vars and style Sep 29, 2024
@MomoPoppy MomoPoppy changed the title refactor(dropdown-menu): refactor DropdownMenu and DropdownItem vars and style refactor(dropdown-menu): [dropdown] refactor DropdownMenu and DropdownItem vars and style Sep 29, 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: 6

🧹 Outside diff range and nitpick comments (9)
examples/sites/demos/pc/app/dropdown/visible-arrow.spec.ts (1)

20-20: LGTM. Consider adding a comment for clarity.

The change from -6px to -8px for the arrow's top CSS property looks good. This adjustment likely improves the visual alignment of the dropdown arrow.

Consider adding a brief comment explaining the reason for this change. For example:

// Adjusted arrow position for better visual alignment
await expect(arrow).toHaveCSS('top', '-8px')

This would help future developers understand the intent behind this specific value.

packages/theme/src/dropdown-menu/vars.less (2)

17-17: Good use of semantic color variable with fallback.

The --tv-DropdownMenu-bg-color variable effectively uses a semantic color variable with a fallback, which is a best practice for theming and maintainability.

Consider adding a comment explaining the significance of --tv-color-bg-secondary in the context of the DropdownMenu, if it's not obvious from the variable name alone.


15-25: Overall improvement in variable structure and naming convention.

The refactoring of CSS variables for the DropdownMenu component significantly enhances consistency and maintainability. The new --tv- prefix and component-based naming convention improve code readability. Leveraging design system variables for colors, shadows, and spacing ensures consistency across the application and facilitates easier global updates.

However, there are opportunities for further improvement:

  1. Consider using relative units for fixed pixel values to enhance responsiveness.
  2. Evaluate the combination of vertical and horizontal padding into a single variable for potential separation.
  3. Ensure that the removal of specific variables (e.g., border-related variables) doesn't unintentionally affect the component's styling.

To maintain the integrity of these changes across the entire component, ensure that all related files (JavaScript/TypeScript, Vue templates) are updated to use these new CSS variables consistently.

packages/vue/src/dropdown-item/src/pc.vue (1)

17-25: Improved class binding structure.

The refactoring of the class binding from object syntax to array syntax enhances readability and maintainability. The addition of state.sizeClass provides better flexibility for component sizing.

Consider using template literals for multi-line class bindings to improve readability further:

-    :class="[
-      'tiny-dropdown-item',
-      'tiny-dropdown-menu__item',
-      state.sizeClass,
-      disabled ? 'is-disabled' : '',
-      divided ? 'tiny-dropdown-item--divided tiny-dropdown-menu__item--divided' : '',
-      state.checkedStatus && selected ? 'tiny-dropdown-item--check-status' : '',
-      itemData.children && itemData.children.length ? 'has-children' : ''
-    ]"
+    :class="`
+      tiny-dropdown-item
+      tiny-dropdown-menu__item
+      ${state.sizeClass}
+      ${disabled ? 'is-disabled' : ''}
+      ${divided ? 'tiny-dropdown-item--divided tiny-dropdown-menu__item--divided' : ''}
+      ${state.checkedStatus && selected ? 'tiny-dropdown-item--check-status' : ''}
+      ${itemData.children && itemData.children.length ? 'has-children' : ''}
+    `"

This approach can make the class binding even more readable, especially for longer lists of classes.

packages/theme/src/dropdown-item/vars.less (1)

15-61: Consider unifying the language of code comments

The code comments within this file are in Chinese, while the header comments are in English. For consistency and to facilitate collaboration in an international team, it might be beneficial to use a single language for all comments, preferably English.

packages/theme/src/dropdown-menu/index.less (2)

32-32: Avoid unnecessary nesting of the same class selector

The nested selector .@{dropdown-menu-prefix-cls} within itself may be unnecessary and could increase CSS specificity unnecessarily. Consider flattening the structure to improve maintainability.


35-35: Translate code comments into English for consistency

Several comments are written in Chinese at lines 35, 42, and 49. To ensure consistency and readability for all team members, please translate code comments into English.

Also applies to: 42-42, 49-49

packages/theme/src/dropdown-item/index.less (2)

49-50: Remove duplicate content property in :before pseudo-element

There are two identical content: ''; declarations in the :before pseudo-element. The second declaration overrides the first, making the first redundant.

Consider removing the duplicate line:

 &:before {
-    content: '';
     content: '';
     height: 0px;
     display: block;
     margin: 0px;
  }

114-114: Translate code comments to English for consistency

There are comments in Chinese on lines 114 (// 展开项悬浮激活态), 135 (// 选中态), and 141 (// 分割线). To ensure consistency and readability for all contributors, please consider translating these comments into English.

Also applies to: 135-135, 141-141

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 41f9ca8 and 8a4c3b3.

📒 Files selected for processing (7)
  • examples/sites/demos/pc/app/dropdown/visible-arrow.spec.ts (1 hunks)
  • packages/renderless/src/dropdown-item/vue.ts (3 hunks)
  • packages/theme/src/dropdown-item/index.less (4 hunks)
  • packages/theme/src/dropdown-item/vars.less (1 hunks)
  • packages/theme/src/dropdown-menu/index.less (3 hunks)
  • packages/theme/src/dropdown-menu/vars.less (1 hunks)
  • packages/vue/src/dropdown-item/src/pc.vue (2 hunks)
🔇 Additional comments (25)
packages/theme/src/dropdown-menu/vars.less (4)

15-15: Improved naming convention and reusability.

The introduction of --tv-DropdownMenu-box-shadow using the --tv-shadow-3-down variable is a good practice. It enhances consistency across the component and improves maintainability by leveraging predefined shadow styles.


19-19: Consistent use of design system variables.

The --tv-DropdownMenu-border-radius variable effectively leverages the design system's border radius variable. This approach ensures consistency across components and facilitates easier global style updates.


23-23: Effective use of design system spacing variable.

The --tv-DropdownMenu-margin-y variable appropriately uses a design system spacing variable. This approach ensures consistent spacing across components and aligns with best practices for maintainable CSS.


24-25: 🛠️ Refactor suggestion

Consider separating vertical and horizontal padding.

The --tv-DropdownMenu-padding variable combines vertical and horizontal padding, which might limit flexibility in some scenarios.

  1. Consider separating vertical and horizontal padding for more granular control:
--tv-DropdownMenu-padding-y: var(--tv-space-md, 8px);
--tv-DropdownMenu-padding-x: 0px;
  1. Confirm if 0px horizontal padding is intentional, as it might affect the appearance of menu items.

To ensure this change doesn't negatively impact the layout, please run the following command to check for any hardcoded padding values in the DropdownMenu component:

✅ Verification successful

Padding with 0px Confirmed as Intentional

No additional hardcoded padding values with 0px were found in the DropdownMenu component. The use of 0px for horizontal padding in --tv-DropdownMenu-padding appears intentional.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

rg --type less --type vue 'padding:.*?0(px)?' packages/theme/src/dropdown-menu packages/vue/src/dropdown-menu

Length of output: 139


Script:

#!/bin/bash
# Searching for padding patterns with 0px in .less and .vue files
rg 'padding:.*?0(px)?' packages/theme/src/dropdown-menu packages/vue/src/dropdown-menu -g '*.less' -g '*.vue'

Length of output: 212

packages/vue/src/dropdown-item/src/pc.vue (1)

Line range hint 1-114: Summary of changes

The refactoring of the DropdownItem component has successfully improved code readability and maintainability without introducing functional changes. The modifications, particularly in the class binding structure, align with modern Vue.js best practices.

Key points:

  1. Class binding refactored from object to array syntax, enhancing readability.
  2. Addition of state.sizeClass for improved flexibility in component sizing.
  3. A TODO comment added to evaluate the necessity of the 'tiny-svg-size' class.

These changes meet the PR objectives of refactoring without altering functionality or introducing breaking changes. The code quality has been improved, making future maintenance and updates easier.

packages/renderless/src/dropdown-item/vue.ts (2)

61-61: LGTM: Function signature update is appropriate.

The addition of the dropdownVm parameter to the initState function signature is consistent with the refactoring objectives. This change allows the function to access properties from the dropdownVm object, which is used for size-related styling.


Line range hint 1-144: Overall assessment: Well-executed refactoring with minor suggestions for improvement.

The changes made to the packages/renderless/src/dropdown-item/vue.ts file are consistent with the PR objectives of refactoring the DropdownMenu and DropdownItem components. The modifications enhance the flexibility of the dropdown item by introducing size-based styling and improve the overall structure of the code.

Key points:

  1. The initState function now accepts a dropdownVm parameter, allowing for more contextual styling.
  2. A new sizeClass property has been added to the state, enabling dynamic size-based styling.
  3. The renderless function now injects the dropdownVm, integrating it into the component's lifecycle.

These changes appear to be non-breaking and improve the maintainability of the code. The minor suggestions provided in the review comments could further enhance readability and type safety.

packages/theme/src/dropdown-item/vars.less (2)

14-61: Refactoring improves variable naming consistency

The updated variable names with the --tv- prefix enhance the clarity and consistency of the codebase, aligning with the new naming conventions.


14-61: Verify variable renaming is consistent throughout the codebase

While the variables have been updated from the --ti- prefix to --tv- in this file, please ensure that all references to these variables in other files have been updated accordingly to prevent any broken styles or unexpected behavior.

You can run the following script to check for any remaining usages of the old variable names:

packages/theme/src/dropdown-menu/index.less (2)

23-29: Consistent use of CSS variables for dropdown menu styling

The updated CSS variables ensure consistent theming throughout the component.


36-36: ⚠️ Potential issue

Potential browser compatibility issues with the :has() CSS pseudo-class

The :has() pseudo-class is not fully supported in all browsers, notably lacking support in Firefox. This may cause inconsistent behavior in browsers that do not support it.

Consider using alternative selectors or implementing a polyfill to ensure compatibility with all target browsers.

Also applies to: 43-43

packages/theme/src/dropdown-item/index.less (14)

23-26: Appropriate use of theming variables for typography

The font size, height, line-height, and text color are updated to use the new theming variables, enhancing consistency and maintainability.


31-33: Improved layout with flexbox

Applying display: flex and align-items: center improves the layout and alignment of the dropdown items.


36-36: Enhancement of spacing for dropdown items

The addition of padding and the adjustment of margin enhance the spacing and visual appeal of the dropdown items.

Also applies to: 39-39


43-46: Consistent SVG icon styling using theming variables

Applying theming variables to the SVG icon's font size and fill color ensures consistent styling across components.


59-60: Setting wrapper dimensions to full size

Specifying height: 100% and width: 100% for the wrapper ensures it occupies the full available space, which is suitable for alignment purposes.


72-72: Adjusting margin for expand icon

The updated margin-right for the expand icon improves spacing and layout.


90-91: Adding margin to pre-icon for better spacing

The margin adjustment on the pre-icon enhances the spacing between the icon and the label.


98-98: Consistent hover background color

Updating the background color on hover to use the theming variable ensures consistency across components.


104-104: Updating icon color on hover

Changing the SVG icon's fill color on hover to use the theming variable maintains visual consistency.


116-117: Improving active state styling for items with children

The updates to color and background-color enhance the visual indication when hovering over items with children.


123-123: Applying disabled text color

Using the theming variable for the disabled text color ensures consistency in styling disabled items.


129-129: Setting icon color for disabled state

Updating the fill color of SVG icons in the disabled state maintains visual consistency.


135-139: Styling for checked state

The addition of styles for the checked state (&--check-status) using theming variables appropriately reflects the active selection.


150-156: Adding size modifiers for small and mini variants

Introducing &--small and &--mini modifiers with appropriate heights enhances the component's versatility.

// 下拉菜单的最小宽度
--ti-dropdown-menu-min-width: 124px;
--tv-DropdownMenu-min-width: 124px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a relative unit for minimum width.

While the --tv-DropdownMenu-min-width variable follows the new naming convention, using a fixed pixel value (124px) might limit flexibility in responsive designs.

Consider using a relative unit like rem or em, or referencing a design system spacing variable for better scalability across different screen sizes and font settings. For example:

--tv-DropdownMenu-min-width: 7.75rem; /* Equivalent to 124px at 16px base font size */

Comment on lines +40 to +41
<!-- TODO: 评估没什么用的话去掉 tiny-svg-size -->
<component v-if="icon" :is="icon" class="tiny-svg-size tiny-dropdown-item__pre-icon"></component>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Evaluate the impact before removing the 'tiny-svg-size' class.

The tiny-svg-size class is used extensively across multiple components, as identified by the shell script results. Removing it could significantly affect the styling and functionality of various UI elements.

To manage this properly, consider creating a dedicated issue to thoroughly assess the implications of removing or modifying the tiny-svg-size class. This will ensure that all dependencies are evaluated and necessary adjustments are made without disrupting the current functionality.

🔗 Analysis chain

Clarify the TODO comment and consider creating an issue.

The TODO comment suggests evaluating the removal of the 'tiny-svg-size' class, which is a good step towards code optimization. However, more context would be helpful.

Could you provide more information about why this class might be unnecessary? What impact would its removal have on the component's functionality or styling?

To ensure this task isn't forgotten, consider creating a separate issue to track this evaluation. This will allow for a more thorough investigation without blocking the current PR.

This script will help identify other usages of the 'tiny-svg-size' class and its definition, which can aid in the evaluation process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of 'tiny-svg-size' class in the codebase

# Test: Search for 'tiny-svg-size' class usage
echo "Occurrences of 'tiny-svg-size' class in the codebase:"
rg --type vue --type css "tiny-svg-size"

# Test: Check if 'tiny-svg-size' is defined in any CSS/LESS files
echo "\nDefinition of 'tiny-svg-size' class in CSS/LESS files:"
rg --type css "\.tiny-svg-size"

Length of output: 354


Script:

#!/bin/bash
# Description: Correctly search for occurrences and definitions of 'tiny-svg-size' class in the codebase

# Search for 'tiny-svg-size' class usage in .vue and .css/.less files
echo "Occurrences of 'tiny-svg-size' class in .vue and .css/.less files:"
rg "tiny-svg-size" --glob "*.vue" --glob "*.css" --glob "*.less" -A 2

# Search for the definition of 'tiny-svg-size' class in .css/.less files
echo "\nDefinition of 'tiny-svg-size' class in CSS/LESS files:"
rg "\.tiny-svg-size" --glob "*.css" --glob "*.less"

Length of output: 55403

Comment on lines +121 to +122
const dropdownVm = inject('dropdownVm', null)
const state: IDropdownItemState = initState({ reactive, computed, api, props, parent, dropdownMenuVm, dropdownVm })
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

LGTM: Injection of dropdownVm is consistent with other changes.

The injection of dropdownVm and its usage in the initState function call are consistent with the changes made to the initState function signature. This change properly integrates the new dropdownVm parameter into the component's lifecycle.

For consistency with the dropdownMenuVm injection, consider adding a type annotation for dropdownVm:

-  const dropdownVm = inject('dropdownVm', null)
+  const dropdownVm = inject('dropdownVm', null) as IDropdownVm | null

This change would improve type safety and make the code more consistent with the existing style.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const dropdownVm = inject('dropdownVm', null)
const state: IDropdownItemState = initState({ reactive, computed, api, props, parent, dropdownMenuVm, dropdownVm })
const dropdownVm = inject('dropdownVm', null) as IDropdownVm | null
const state: IDropdownItemState = initState({ reactive, computed, api, props, parent, dropdownMenuVm, dropdownVm })

@@ -78,6 +78,7 @@
currentIndex: props.currentIndex,
textField: dropdownMenuVm?.textField || props.textField,
popperClass: dropdownMenuVm?.popperClass || '',
sizeClass: dropdownVm?.size ? `tiny-dropdown-item--${dropdownVm?.size}` : '',
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

LGTM: New sizeClass property enhances flexibility.

The addition of the sizeClass property allows for dynamic size-based styling of the dropdown item, which is consistent with the refactoring objectives. This change enhances the component's flexibility.

Consider extracting the size class generation into a separate computed property for improved readability:

-    sizeClass: dropdownVm?.size ? `tiny-dropdown-item--${dropdownVm?.size}` : '',
+    sizeClass: computed(() => dropdownVm?.size ? `tiny-dropdown-item--${dropdownVm.size}` : ''),

This change would make the code more declarative and easier to maintain.

Committable suggestion was skipped due to low confidence.

Comment on lines +54 to +56
--tv-DropdownItem-height-sm: var(--tv-size-height-sm, 28px);
// 菜单项高度(mini)
--tv-DropdownItem-height-xs: var(--tv-size-height-mi, 24px);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential inconsistency in size variable naming

It appears that in line 56, --tv-DropdownItem-height-xs is set using --tv-size-height-mi, whereas the naming convention suggests it should be --tv-size-height-xs. This could lead to confusion and inconsistency with standard size naming conventions (xs, sm, md, etc.). Please verify if --tv-size-height-mi should be --tv-size-height-xs to align with the variable name.

Suggested change:

--tv-DropdownItem-height-xs: var(--tv-size-height-mi, 24px);
+--tv-DropdownItem-height-xs: var(--tv-size-height-xs, 24px);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--tv-DropdownItem-height-sm: var(--tv-size-height-sm, 28px);
// 菜单项高度(mini)
--tv-DropdownItem-height-xs: var(--tv-size-height-mi, 24px);
--tv-DropdownItem-height-sm: var(--tv-size-height-sm, 28px);
// 菜单项高度(mini)
--tv-DropdownItem-height-xs: var(--tv-size-height-xs, 24px);

border-bottom-width: 0;
}

&.@{css-prefix}popper[x-placement^='top'] .popper__arrow:after {
bottom: 1px;
margin-left: -6px;
border-top-color: var(--ti-dropdown-menu-arrow-after-border-color);
border-top-color: #fff;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use CSS variables instead of hardcoded color values for consistency

The use of hardcoded color values like #fff reduces flexibility in theming and maintenance. Consider replacing them with existing CSS variables or defining new ones to maintain consistency across the component.

Apply these changes:

At line 87:

-        border-top-color: #fff;
+        border-top-color: var(--tv-DropdownMenu-arrow-color);

At line 108:

-        border-bottom-color: #fff;
+        border-bottom-color: var(--tv-DropdownMenu-arrow-color);

At line 125:

-        border-right-color: #fff;
+        border-right-color: var(--tv-DropdownMenu-arrow-color);

At line 145:

-        border-left-color: #fff;
+        border-left-color: var(--tv-DropdownMenu-arrow-color);

Also applies to: 108-108, 125-125, 145-145

@zzcr zzcr merged commit 5fbaf49 into opentiny:dev Sep 30, 2024
16 of 22 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 11, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring (重构)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants