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

feat(dropdown): [dropdown,action-menu,select] Additional features xdesign theme adaptation #2140

Merged
merged 9 commits into from
Sep 23, 2024

Conversation

MomoPoppy
Copy link
Collaborator

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

    • Introduced a selection limit for the tiny-select component, allowing a maximum of two selections.
    • Added user feedback with a show-limit-text property for selection limits.
    • Implemented a new footer slot for custom content in the dropdown.
    • Enhanced icon representation with dynamic loading and add icons.
  • Bug Fixes

    • Improved clarity in multi-select mode by refining limit text display conditions.
  • Style

    • Updated icons for better visual representation.
    • Adjusted styles for dropdown items and filter boxes to enhance spacing and hover effects.
    • Enhanced loading state styles for improved visual structure.
  • Chores

    • Replaced outdated assets and refined color variables for consistency across components.

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 changed the title Momo poppy/feat dropdown 0914 feat(dropdown): [dropdown,action-menu,select] Additional features xdesign theme adaptation Sep 18, 2024
@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Sep 18, 2024
Copy link

coderabbitai bot commented Sep 18, 2024

Walkthrough

The changes introduced in this pull request enhance the functionality of various UI components, particularly the tiny-select component, by adding new properties for selection limits and user feedback. Modifications include updates to icon representations, adjustments in styling for better visual consistency, and the introduction of dynamic components for improved flexibility. Additionally, several LESS files have been updated to refine the overall design and usability of the components.

Changes

Files Change Summary
examples/sites/demos/pc/app/select/copy-multi-composition-api.vue Added :multiple-limit="2" and show-limit-text to tiny-select component.
examples/sites/demos/pc/app/select/copy-multi.vue Introduced a new tiny-select instance with multiple selection capabilities, copyable feature, text-split option, and limit on selections.
examples/sites/demos/pc/app/select/slot-prefix-composition-api.vue Replaced <tiny-icon-share> with <tiny-icon-location> and updated the import statement accordingly.
examples/sites/demos/pc/app/select/slot-prefix.vue Changed <icon-share> to <tiny-icon-location> and updated the import statement for the icon.
packages/design/saas/src/select/index.ts Added addIcon: iconPlus() and loadingIcon to the exported icons object.
packages/renderless/src/select/vue.ts Added designConfig parameter in the initState function.
packages/theme-saas/src/select-dropdown/index.less Updated background image for empty state and modified loading animation styles.
packages/theme/src/action-menu/index.less Restructured CSS selectors for better organization and corrected hover state styles.
packages/theme/src/action-menu/vars.less Updated various CSS variable definitions related to action menu styling.
packages/theme/src/dropdown-item/index.less Replaced padding with margin in &__wrap class and adjusted border styling.
packages/theme/src/dropdown-item/vars.less Renamed padding variables to margin variables and updated color values for dropdown items.
packages/theme/src/filter-box/index.less Added hover state for filter box and adjusted margins for title and labels.
packages/theme/src/filter-box/vars.less Updated button styles and introduced hover color for expand icon.
packages/theme/src/select-dropdown/index.less Adjusted styles for loading state and updated background image for empty states.
packages/theme/src/select-dropdown/vars.less Reformatted width calculation for search box and changed text color for dropdown "create" button.
packages/theme/src/tag/vars.less Updated color variables for primary tag's close icon in light theme.
packages/vue/src/select/src/pc.vue Refined display logic for limit text, updated icon rendering to be dynamic, and introduced a new footer slot for custom content.

Possibly related PRs

Suggested reviewers

  • zzcr

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3b8d606 and 2600c82.

Files selected for processing (5)
  • examples/sites/demos/pc/app/action-menu/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/action-menu/icon.spec.ts (1 hunks)
  • packages/theme/src/filter-box/index.less (3 hunks)
  • packages/theme/src/select-dropdown/vars.less (1 hunks)
  • packages/vue/src/select/src/pc.vue (6 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/theme/src/filter-box/index.less
  • packages/theme/src/select-dropdown/vars.less
  • packages/vue/src/select/src/pc.vue
Additional comments not posted (3)
examples/sites/demos/pc/app/action-menu/basic-usage.spec.ts (1)

19-22: LGTM!

The updated expectation for the SVG path attribute of the moreItem element is in line with the changes made to the icon representation. This change ensures that the test case accurately validates the rendering of the updated icon for the moreItem element.

examples/sites/demos/pc/app/action-menu/icon.spec.ts (2)

14-15: LGTM!

The changes to the width and height assertions for the SVG element are valid and align with the PR objectives. The increased dimensions of 24px should not introduce any functional issues.


16-16: Please clarify the reason for removing the margin assertion.

The AI-generated summary does not mention the removal of the margin assertion for the SVG element. Could you please provide more context on why this assertion was removed? This will help ensure that the change aligns with the overall PR objectives.


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.

@MomoPoppy
Copy link
Collaborator Author

image

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


image

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

Outside diff range and nitpick comments (2)
examples/sites/demos/pc/app/slider/show-input.spec.ts (1)

20-20: Consider the impact on test execution time.

The added delay after hovering over the slider block is a good practice to improve test stability by allowing time for the UI to update. However, please keep in mind that extensively adding similar delays across the test suite might noticeably increase the overall execution time.

Consider extracting the delay value into a constant or configuration variable to maintain consistency and ease of adjustment across the test suite.

const INTERACTION_DELAY = 200;

// ...

await page.waitForTimeout(INTERACTION_DELAY);
packages/renderless/src/slider/index.ts (1)

Line range hint 644-648: The changes to the handleSlotInput function look good.

The simplification of the isLeftInput parameter declaration by removing the explicit type annotation is acceptable, as it does not affect the functionality of the function.

Consider adding a type annotation to the isLeftInput parameter for improved code readability:

-  (event: Event, isLeftInput = true): void => {
+  (event: Event, isLeftInput: boolean = true): void => {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1c6773a and 3b8d606.

Files selected for processing (14)
  • examples/sites/demos/pc/app/dropdown/basic-usage.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/dropdown/disabled.spec.ts (3 hunks)
  • examples/sites/demos/pc/app/dropdown/size.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/dropdown/split-button.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/select/copy-multi.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/select/input-box-type.spec.ts (3 hunks)
  • examples/sites/demos/pc/app/select/multiple.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/select/nest-grid.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/select/size.spec.ts (4 hunks)
  • examples/sites/demos/pc/app/slider/show-input.spec.ts (2 hunks)
  • packages/renderless/src/slider/index.ts (2 hunks)
Additional comments not posted (25)
examples/sites/demos/pc/app/dropdown/size.spec.ts (1)

15-19: Temporarily disabling the assertions is a good practice.

Commenting out the assertions while the button component's size adaptation is being worked on is a good practice to avoid failing tests. The TODO comment serves as a reminder to re-enable the assertions once the button component's size adaptation is complete.

Please ensure that the assertions are re-enabled once the button component's size adaptation is complete to avoid having an incomplete test.

examples/sites/demos/pc/app/slider/show-input.spec.ts (1)

7-7: Verify the consistency of the slider input structure.

The change in the locator for the slider input is appropriate given the updated structure of the component. However, please ensure that this change is consistent across the application and does not break other tests or code that relies on the previous locator.

Run the following script to verify the usage of the previous locator:

examples/sites/demos/pc/app/dropdown/split-button.spec.ts (2)

15-15: LGTM!

The change in background color for the textBtn element is consistent with the PR summary and looks good.


17-17: LGTM!

The change in background color for the dropDownBtn element is consistent with the PR summary and looks good.

examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts (1)

12-12: LGTM! The change aligns with the PR objective.

The modification to the expected border color of the input element upon focus is a visual styling change that aligns with the goal of adapting the components to the xdesign theme. The test case continues to verify the expected behavior of the dropdown remaining hidden when the input cannot be searched.

examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts (3)

26-26: LGTM!

The change in the expected class name for the second row is appropriate and aligns with the updated styling or selection behavior.


27-27: LGTM!

The reduction in the expected row count from 8 to 6 is appropriate and aligns with the changes in the data being displayed or the pagination behavior.


29-34: LGTM!

The adjustments in the scroll actions, targeting the 5th row instead of the 7th row, are appropriate and align with the changes in the data or pagination. The consistent expected row count of 6 after each scroll indicates that the pagination or data loading behavior remains stable.

examples/sites/demos/pc/app/dropdown/basic-usage.spec.ts (2)

16-19: LGTM!

The update to the expected SVG path attribute aligns the test with the modified visual representation of the dropdown arrow. This change ensures that the test accurately verifies the appearance of the dropdown icon.


33-34: LGTM!

The updates to the expected color and background-color values align the test with the modified styling of the dropdown menu items when hovered over. These changes ensure that the test accurately verifies the visual feedback provided to the user when interacting with the dropdown menu.

examples/sites/demos/pc/app/select/multiple.spec.ts (2)

13-25: LGTM!

The changes in the test case align with the expected behavior of a multi-select component. The adjustments to the tag count expectations accurately reflect the selection and deselection of options, including the "All" option. The test case ensures that the component correctly handles the updates to the selected tags based on user interactions.


40-51: LGTM!

The changes in the test case simplify the assertions for option classes, making the test more readable and maintainable. The specific assertions for each option's class accurately reflect the expected behavior of a multi-select component with a selection limit. The test case ensures that the component correctly applies the limit and disables the appropriate options based on the number of selections made.

examples/sites/demos/pc/app/select/copy-multi.spec.ts (2)

60-64: Investigate and fix the root cause of the element positioning issue.

The test case is hovering over the select element. However, the click action on the copy icon and subsequent paste and value assertion are commented out due to an issue with element positioning during test execution.

While commenting out the affected code serves as a temporary workaround, it prevents the test case from fully verifying the copy functionality with a custom separator. Please investigate and fix the root cause of the element positioning issue to enable the commented-out code and ensure a reliable test suite.


Line range hint 1-30: LGTM!

The test case logic for copying a single tag is correct, and the implementation is accurate.

examples/sites/demos/pc/app/select/size.spec.ts (1)

12-12: LGTM!

The updated height expectation for the default size input element looks good.

examples/sites/demos/pc/app/dropdown/disabled.spec.ts (4)

14-14: LGTM!

The color value update for the disabled dropdown trigger is consistent with the changes described in the PR summary.


15-15: LGTM!

The SVG fill color update for the disabled dropdown icon is consistent with the changes described in the PR summary.


38-39: LGTM!

The color value updates for the disabled text and trigger buttons are consistent with the changes described in the PR summary.


41-41: LGTM!

The color value updates for the disabled trigger button icon and dropdown menu item are consistent with the changes described in the PR summary.

Also applies to: 60-60

examples/sites/demos/pc/app/select/input-box-type.spec.ts (3)

16-17: LGTM!

The updates to the expected border color and SVG fill color for the default underline style test case look good. The changes align with the overall visual styling updates mentioned in the PR summary.


37-39: LGTM!

The updates to the expected border color and SVG fill color for the disabled underline style test case look good. The changes align with the overall visual styling updates mentioned in the PR summary.


62-63: LGTM!

The updates to the expected border color and caret fill color for the multiple selection underline style test case look good. The changes align with the overall visual styling updates mentioned in the PR summary.

examples/sites/demos/pc/app/select/nest-grid.spec.ts (1)

24-24: LGTM!

The change in the assertion aligns with the naming convention of the Tiny Vue framework and improves the test case by updating the expectation to match the actual class structure of the selected row.

examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts (1)

31-31: LGTM!

The update to the expected class for the selected row in the grid is appropriate and keeps the test case in sync with the component's behavior.

packages/renderless/src/slider/index.ts (1)

Line range hint 654-661: The changes to the inputOnChange function are valid.

The modification of the parameter type from Event to string and the corresponding update to the internal logic to validate currentValue instead of event.target.value align with the new expectation of receiving the input value directly.

Verify that the calling code has been updated to pass the input value as a string instead of an event object to ensure compatibility with the modified function signature.

Run the following script to search for occurrences of inputOnChange and review the arguments passed to it:

Comment on lines 41 to 48
const copyIcon = select.locator('.tiny-select__copy .tiny-svg')

await page.waitForTimeout(200)
await select.hover()
await select.locator('.tiny-select__copy > .tiny-svg').click()

await copyValueInput.press('Control+V')
await expect(copyValueInput).toHaveValue('北京,上海')
await expect(copyIcon).toBeVisible()
// TODO: 因为执行测试用例时,官网抖动导致定位不通过
// await copyIcon.click()
// await copyValueInput.press('Control+V')
// await expect(copyValueInput).toHaveValue('北京,上海')
Copy link

Choose a reason for hiding this comment

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

Investigate and fix the root cause of the element positioning issue.

The test case is correctly locating the copy icon and checking its visibility. However, the click action on the copy icon and subsequent paste and value assertion are commented out due to an issue with element positioning during test execution.

While commenting out the affected code serves as a temporary workaround, it prevents the test case from fully verifying the copy functionality. Please investigate and fix the root cause of the element positioning issue to enable the commented-out code and ensure a reliable test suite.

Comment on lines 26 to 27
// TODO: 此处继承input 尺寸的话,应该是32
await expect(input.locator('.tiny-input__inner')).toHaveCSS('height', '40px')
Copy link

Choose a reason for hiding this comment

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

Address the TODO comment and update the height expectation if applicable.

The TODO comment suggests that the expected height for the medium size input should be '32px' if inheriting from the input size. However, the current expectation is set to '40px'.

Please clarify whether the height should inherit from the input size or remain at '40px', and update the test case accordingly.

Comment on lines 43 to 44
// TODO: 此处继承input 尺寸的话,应该是28
expect(height).toBeCloseTo(32, 1)
Copy link

Choose a reason for hiding this comment

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

Address the TODO comment and update the height expectation if applicable.

The TODO comment suggests that the expected height for the small size input should be '28px' if inheriting from the input size. However, the current expectation is set to '32px' using the toBeCloseTo matcher.

Please clarify whether the height should inherit from the input size or remain at '32px', and update the test case accordingly.

Comment on lines 59 to 60
// TODO: 此处继承input 尺寸的话,应该是24
expect(height).toBeCloseTo(32, 1)
Copy link

Choose a reason for hiding this comment

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

Address the TODO comment and update the height expectation if applicable.

The TODO comment suggests that the expected height for the mini size input should be '24px' if inheriting from the input size. However, the current expectation is set to '32px' using the toBeCloseTo matcher.

Please clarify whether the height should inherit from the input size or remain at '32px', and update the test case accordingly.

@zzcr zzcr merged commit f559970 into opentiny:dev Sep 23, 2024
6 checks passed
@MomoPoppy MomoPoppy deleted the MomoPoppy/feat-dropdown-0914 branch September 29, 2024 08:19
@coderabbitai coderabbitai bot mentioned this pull request Oct 28, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants