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(transfer): [transfer] update smb design #2249

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Oct 12, 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

对接 smb design 规范

Summary by CodeRabbit

  • New Features
    • Enhanced visual representation of the tree component with the addition of lines between nodes.
  • Bug Fixes
    • Adjusted CSS properties for improved layout and alignment in various components.
  • Style
    • Updated text color and font weight for selectable and active items in the dropdown list.
    • Modified line-height and font size for filter box components.
    • Improved styling for transfer component buttons.
  • Tests
    • Revised test cases to focus on functionality without CSS property checks.

Copy link

coderabbitai bot commented Oct 12, 2024

Walkthrough

The pull request includes modifications to various Vue component files and their associated test cases. Key changes involve the removal of specific CSS assertions in tests, updates to the styling of Cascader components, and adjustments to CSS variables affecting visual presentation. Notably, a new property for displaying lines in tree components is introduced, and several CSS properties are refined across different components to enhance layout and styling consistency.

Changes

File Path Change Summary
examples/sites/demos/pc/app/cascader/check-strictly-multiple.spec.ts Removed assertions checking CSS background color of menu items.
examples/sites/demos/pc/app/cascader/filter-mode-composition-api.vue Added a style attribute to adjust margin-top for the second tiny-cascader component.
examples/sites/demos/pc/app/cascader/filter-mode.vue Added a style attribute to adjust margin-top for the second tiny-cascader component.
examples/sites/demos/pc/app/cascader/size.spec.ts Changed height expectation for .tiny-cascader.tiny-cascader--small input from 32px to 28px.
examples/sites/demos/pc/app/transfer/nested-tree-composition-api.vue Added showLine: true to treeConfig for visual representation of tree nodes.
examples/sites/demos/pc/app/transfer/nested-tree.vue Added showLine: true to treeConfig for visual representation of tree nodes.
packages/theme/src/cascader-node/vars.less Updated CSS variables for text color and font weight of selectable items in dropdown list.
packages/theme/src/filter-box/index.less Adjusted line-height for .value class from inherit to 1.5.
packages/theme/src/filter-box/vars.less Changed variable for font size from --ti-common-font-size-base to --ti-common-font-size-0.
packages/theme/src/transfer/index.less Added new CSS properties for layout adjustments within the transfer component.
packages/vue/src/transfer-panel/src/pc.vue Updated class names for icons in checkbox component and modified import statements.

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • zzcr

🐰 In the garden where changes bloom,
Cascaders dance, dispelling gloom.
With colors bright and lines that show,
Our components shine, oh how they glow!
A hop, a skip, adjustments made,
In code we trust, our plans displayed! 🌼


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.

@shenjunjian shenjunjian changed the title Dev update cascader x fix(transfer): [transfer] update smb design Oct 12, 2024
@github-actions github-actions bot added the bug Something isn't working label Oct 12, 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: 1

🧹 Outside diff range and nitpick comments (7)
examples/sites/demos/pc/app/transfer/nested-tree-composition-api.vue (1)

77-77: LGTM! Consider reordering properties for consistency.

The addition of showLine: true to the treeConfig object is a good enhancement. It will improve the visual representation of the tree structure in the transfer component, making it easier for users to understand the hierarchy of items.

For consistency with the object's current structure, consider moving the showLine property after checkStrictly:

 const treeConfig = ref({
-  showLine: true,
   showCheckbox: true,
   nodeKey: 'id',
   checkStrictly: true,
+  showLine: true,
   filterNodeMethod(query, data) {
     return data.label.includes(query)
   }
 })

This ordering aligns better with the existing property arrangement, placing boolean configurations together.

examples/sites/demos/pc/app/transfer/nested-tree.vue (1)

Line range hint 1-93: Suggestions for improving component readability and maintainability

While the current implementation is functional, consider the following improvements:

  1. Rename the value data property to something more descriptive, such as selectedNodes or transferredItems.
  2. Add comments to explain the purpose of the component and how to use it, especially regarding the tree structure and transfer functionality.
  3. Implement error handling or validation for the tree data structure to ensure it always has the expected format.

Example of adding comments:

<script lang="jsx">
import { Transfer, Tree } from '@opentiny/vue'

/**
 * NestedTreeTransfer Component
 * 
 * This component provides a transfer interface with a nested tree structure.
 * It allows users to move items between two lists, where items are organized in a hierarchical manner.
 * 
 * Usage:
 * <nested-tree-transfer v-model="selectedItems" :data="treeData" />
 */
export default {
  // ... rest of the component code
}
</script>

These changes would enhance the component's maintainability and make it easier for other developers to understand and use.

packages/theme/src/cascader-node/vars.less (1)

Line range hint 1-51: Summary: Verify cascader styling changes in the context of the entire component

The changes to the cascader node styling variables appear to be part of a design update, shifting towards a more subtle visual presentation. While the modifications themselves don't present any syntax issues, it's crucial to verify their impact on the overall user experience of the cascader component.

Consider the following recommendations:

  1. Review these changes in the context of the entire cascader component to ensure they align with the intended design direction.
  2. Conduct thorough testing, including accessibility and usability tests, to validate that the new styles maintain or improve the component's effectiveness.
  3. If not already done, update the component's documentation to reflect these styling changes and any new best practices for using the cascader in different contexts.

To assist in this verification, you can run the following command to locate relevant component files and tests:

#!/bin/bash
# Find cascader component files and tests
echo "Cascader Component Files:"
fd -e vue -e js -e ts cascader packages/
echo "\nCascader Test Files:"
fd -e spec.js -e spec.ts -e test.js -e test.ts cascader packages/
examples/sites/demos/pc/app/cascader/filter-mode.vue (1)

12-12: Consider using a CSS class for spacing instead of inline style.

The addition of vertical spacing between the Cascader components improves the layout. However, I have a few suggestions to enhance this change:

  1. Instead of using an inline style, consider moving this to a CSS class. This approach improves maintainability and consistency across the application.
  2. Verify if the 16px spacing aligns with your project's design system. If you have predefined spacing values, it would be better to use one of those for consistency.

Here's an example of how you could refactor this:

-    <div style="margin-top: 16px">
+    <div class="cascader-spacing">
       <tiny-cascader v-model="value" :options="options" shape="filter" label="开发文档" blank></tiny-cascader>
     </div>

Then add a style block to your component (or in a separate CSS file if you prefer):

<style scoped>
.cascader-spacing {
  margin-top: var(--tiny-spacing-medium, 16px); /* Adjust the variable name as per your design system */
}
</style>

This approach allows for easier maintenance and better alignment with your design system.

packages/vue/src/transfer-panel/src/pc.vue (2)

73-76: LGTM! Consider using CSS classes for styling consistency.

The changes to the icon classes improve clarity and the styling adjustment for the unchecked state is appropriate. However, for better maintainability and consistency, consider moving the inline style to a CSS class.

You could refactor the inline style as follows:

-<icon-check
-  v-if="!(state.checked.length > 0 && state.checked.indexOf(item[state.keyProp]) > -1)"
-  class="tiny-svg-size icon-no-checked"
-  style="fill: transparent"
-/>
+<icon-check
+  v-if="!(state.checked.length > 0 && state.checked.indexOf(item[state.keyProp]) > -1)"
+  class="tiny-svg-size icon-no-checked transparent-fill"
+/>

Then add the following CSS class:

.transparent-fill {
  fill: transparent;
}

This approach would make it easier to manage styles across the component.


176-177: LGTM! Consider enhancing accessibility for icon states.

The update to use iconYes() for both IconCheckedSur and IconCheck components is consistent with the import changes. This simplification can lead to more maintainable code.

To enhance accessibility and user experience, consider adding aria labels or titles to differentiate between the checked and unchecked states:

-IconCheckedSur: iconYes(),
-IconCheck: iconYes(),
+IconCheckedSur: {
+  ...iconYes(),
+  props: {
+    ...iconYes().props,
+    title: 'Checked'
+  }
+},
+IconCheck: {
+  ...iconYes(),
+  props: {
+    ...iconYes().props,
+    title: 'Unchecked'
+  }
+},

This approach would provide additional context for screen readers and improve the overall accessibility of the component.

packages/theme/src/transfer/index.less (1)

115-116: LGTM! Consider translating the comment to English.

The changes improve the vertical alignment of text and icons within the transfer buttons. The transform: translateY(-3px) adjusts the position, while display: inline-block ensures proper inline behavior.

Consider translating the Chinese comment to English for consistency and to improve maintainability for non-Chinese speaking developers. For example:

-      transform: translateY(-3px); // 适配 xdesign, 让span居中
+      transform: translateY(-3px); // Adapt for xdesign, center the span element
       display: inline-block;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 98246dd and c7a5cd3.

📒 Files selected for processing (11)
  • examples/sites/demos/pc/app/cascader/check-strictly-multiple.spec.ts (0 hunks)
  • examples/sites/demos/pc/app/cascader/filter-mode-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/cascader/filter-mode.vue (1 hunks)
  • examples/sites/demos/pc/app/cascader/size.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/transfer/nested-tree-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/transfer/nested-tree.vue (1 hunks)
  • packages/theme/src/cascader-node/vars.less (2 hunks)
  • packages/theme/src/filter-box/index.less (1 hunks)
  • packages/theme/src/filter-box/vars.less (1 hunks)
  • packages/theme/src/transfer/index.less (1 hunks)
  • packages/vue/src/transfer-panel/src/pc.vue (3 hunks)
💤 Files with no reviewable changes (1)
  • examples/sites/demos/pc/app/cascader/check-strictly-multiple.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/demos/pc/app/cascader/filter-mode-composition-api.vue
🧰 Additional context used
🔇 Additional comments (6)
examples/sites/demos/pc/app/cascader/size.spec.ts (1)

9-9: Verify the intentional change in small-sized Cascader input height.

The expected height for the small-sized Cascader input has been updated from 32px to 28px. This change appears to maintain a logical size progression (24px for mini, 28px for small, 40px for medium).

Please ensure that:

  1. This change aligns with the updated design specifications for the Cascader component.
  2. The corresponding CSS in the component implementation has been updated to match this new expectation.
  3. Other components using the 'small' size variant have been consistently updated if necessary.

To verify the consistency of this change across the codebase, please run the following script:

Consider adding a comment explaining the reason for this height change to improve maintainability.

packages/theme/src/filter-box/vars.less (1)

26-26: LGTM. Verify consistency and update documentation if needed.

The change from --ti-common-font-size-base to --ti-common-font-size-0 looks good and seems to be part of a standardization effort. Both variables have the same fallback value of 12px, which should maintain the current visual appearance if the new variable is not defined.

To ensure consistency across the project, please run the following script:

If this change is part of a larger update to the design system or variable naming convention, consider updating the relevant documentation to reflect this change.

packages/theme/src/cascader-node/vars.less (2)

51-51: Verify the impact of changing active item font weight

The font weight for active (highlighted) items in the cascader dropdown has been changed from bold to normal. While this change might be part of a broader design update for a more subtle look, it's crucial to ensure it doesn't negatively impact the user experience.

Could you please provide the reasoning behind this change? It would be beneficial to verify that this modification:

  1. Maintains clear visual distinction for active items.
  2. Doesn't impair usability, especially for users who rely on strong visual cues.

To assist in verifying the impact, you can run the following command to check for any related usability or accessibility tests:

#!/bin/bash
# Search for relevant test files
fd -e spec.js -e spec.ts -e test.js -e test.ts | xargs rg -i "cascader.*active item|cascader.*highlighted item|cascader.*font weight"

23-23: Clarify the rationale for changing the selectable text color

The text color for selectable items in the cascader dropdown has been changed from a highlighted state to the primary text color. While this change might align with updated design guidelines or improve consistency, it's important to ensure it doesn't negatively impact the user experience or accessibility.

Could you please clarify the reasoning behind this change? Additionally, it would be beneficial to verify that this modification:

  1. Maintains sufficient contrast for accessibility standards.
  2. Doesn't reduce the visual clarity of selectable items for users.

To assist in verifying the impact, you can run the following command to check for any related accessibility or UX tests:

packages/theme/src/filter-box/index.less (1)

90-90: Consider using a relative unit for line-height

The change from inherit to a fixed value of 1.5 for line-height may improve readability. However, it's important to verify that this doesn't cause any layout issues within the filter box, especially considering the fixed height and flexbox alignment of the parent container.

To maintain flexibility and scalability, consider using a relative unit like em instead of a unitless value. For example:

-    line-height: 1.5;
+    line-height: 1.5em;

This allows the line height to scale with the font size while maintaining the desired spacing.

Please verify the visual appearance of the filter box component across different contexts and screen sizes to ensure this change doesn't negatively impact the layout or alignment.

packages/vue/src/transfer-panel/src/pc.vue (1)

133-133: LGTM! Verify icon suitability for both states.

The consolidation of icon imports to use iconYes for both checked and unchecked states is a good optimization. However, it's crucial to ensure that this icon is visually appropriate for both states.

Please confirm that the iconYes icon is visually suitable for representing both the checked and unchecked states in the transfer panel. If possible, provide a visual comparison of the previous icons (iconCheckedSur and iconCheck) with the new iconYes icon to ensure there's no loss in visual clarity or user experience.

@@ -79,6 +79,7 @@ export default {
}
],
treeConfig: {
showLine: true,
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

LGTM: Addition of showLine property enhances tree visualization.

While showLine: true is consistently used across other components, it is not currently documented. Please update the Tree component documentation to include the showLine property to ensure clarity and maintain comprehensive documentation.

🔗 Analysis chain

LGTM: Addition of showLine property enhances tree visualization.

The addition of showLine: true to the treeConfig object is a valid enhancement. This property will enable the display of lines connecting tree nodes, improving the visual representation of the nested structure.

To ensure this change is consistent with the component's documentation and usage, let's verify:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the Tree component documentation mentions the showLine property
# and if it's used consistently in other examples.

# Search for Tree component documentation
echo "Searching for Tree component documentation:"
rg --type=vue --type=md "Tree.*component" -g '!node_modules'

# Search for other usage of showLine property in Tree configurations
echo "\nSearching for other usage of showLine property:"
rg --type=vue "showLine:\s*(true|false)" -g '!node_modules'

Length of output: 386


Script:

#!/bin/bash
# Description: Check if the Tree component documentation mentions the showLine property
# and if it's used consistently in other examples.

# Search for Tree component documentation in .md and .vue files
echo "Searching for Tree component documentation:"
rg "Tree.*component" -g '*.vue' -g '*.md' -g '!node_modules'

# Search for other usage of showLine property in Tree configurations within .vue files
echo "\nSearching for other usage of showLine property:"
rg "showLine:\s*(true|false)" -g '*.vue' -g '!node_modules'

Length of output: 2073

zzcr
zzcr previously approved these changes Oct 14, 2024
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