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(button): [button]fix error css var #2312

Merged
merged 4 commits into from
Oct 19, 2024

Conversation

shenjunjian
Copy link
Collaborator

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

    • Removed the reset-time attribute from all <tiny-button> components, streamlining button usage.
    • Simplified button declarations by removing native-type="submit" from primary buttons.
  • Style

    • Updated CSS variable for button line height to improve clarity and semantic meaning.

These changes enhance button functionality and maintain a cleaner codebase for better user experience.

Copy link

coderabbitai bot commented Oct 19, 2024

Walkthrough

The changes in this pull request involve the removal of the reset-time attribute from all instances of the <tiny-button> component in two Vue files: ghost-composition-api.vue and ghost.vue. Additionally, the native-type="submit" attribute has been removed from the primary button in two other Vue files: basic-usage-composition-api.vue and basic-usage.vue. Updates to the CSS variable definitions in vars.less include changing the line height variable to better reflect its purpose. The overall structure of the button components remains unchanged, focusing on attribute and variable adjustments.

Changes

File Path Change Summary
examples/sites/demos/pc/app/button/ghost-composition-api.vue Removed reset-time attribute from all <tiny-button> instances.
examples/sites/demos/pc/app/button/ghost.vue Removed reset-time attribute from all <tiny-button> instances.
examples/sites/demos/pc/app/button/basic-usage-composition-api.vue Removed native-type="submit" from primary <tiny-button>.
examples/sites/demos/pc/app/button/basic-usage.vue Removed native-type="submit" from primary <tiny-button>.
packages/theme/src/button/vars.less Updated --tv-Button-line-height variable to use var(--tv-line-height-number) instead of var(--tv-border-width); clarified comments.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

In a world of buttons, shiny and bright,
We’ve tidied up attributes, oh what a sight!
No more reset-time, just pure button cheer,
With styles that shimmer, let’s give a big cheer!
Hopping along, we celebrate this day,
For cleaner code makes us dance and play! 🐇✨


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 added the bug Something isn't working label Oct 19, 2024
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

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6524d21 and 595dd8b.

📒 Files selected for processing (3)
  • examples/sites/demos/pc/app/button/ghost-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/button/ghost.vue (1 hunks)
  • packages/theme/src/button/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (5)
examples/sites/demos/pc/app/button/ghost.vue (3)

3-3: Consistent removal of reset-time attribute.

The reset-time attribute has been removed from this button, which is consistent with the changes made to other buttons in this file. This change doesn't affect the button's primary functionality or appearance.


4-4: Consistent removal of reset-time attribute and absence of type attribute.

The reset-time attribute has been removed from this button, consistent with other changes. Note that this button doesn't have a type attribute, which may result in a default style. Ensure this is the intended behavior for this "次要按钮" (secondary button).


5-8: Consistent removal of reset-time attribute across all buttons.

The reset-time attribute has been removed from all buttons consistently. Each button retains its ghost attribute and specific type attribute, maintaining the intended variety of button styles (success, info, warning, danger).

packages/theme/src/button/vars.less (2)

Line range hint 1-324: Summary of changes and potential impact

The change to the --tv-Button-line-height variable is the only modification in this file. This update improves the correctness of button styling by using an appropriate line height value instead of a border width.

While this change is beneficial, it's important to note that it may have a visual impact on buttons throughout the application. Thorough testing across different button sizes, states, and scenarios is recommended to ensure consistent and improved button appearance.


19-20: Approve the line height variable change and suggest UI verification.

The change from var(--tv-border-width) to var(--tv-line-height-number) for the --tv-Button-line-height variable is a logical improvement. It correctly aligns the variable's purpose (button text line height) with an appropriate value.

To ensure this change doesn't unexpectedly affect button appearance, please verify the following:

  1. Check if the overall button height remains consistent across different button sizes.
  2. Confirm that text alignment within buttons is correct and improved.
  3. Test buttons with multi-line text to ensure proper spacing.

Run the following script to find button-related component files that might be affected:

Review the output to identify components that may need visual inspection or testing.

✅ Verification successful

Verification Successful: No issues found.

The change from var(--tv-border-width) to var(--tv-line-height-number) for the --tv-Button-line-height variable has been correctly applied. The variable is properly defined in vars.less and used in index.less, ensuring consistent line height for buttons.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find button-related component files that might be affected by the line height change.

# Search for files that likely contain button styling
echo "Files potentially affected by button line height change:"
fd -e vue -e scss -e less -e css | xargs rg -l 'button|Button'

# Search for specific usage of the changed variable
echo "\nFiles directly using --tv-Button-line-height:"
rg '--tv-Button-line-height'

Length of output: 58163


Script:

#!/bin/bash
# Description: Find button-related component files that might be affected by the line height change.

# Search for files that likely contain button styling
echo "Files potentially affected by button line height change:"
fd -e vue -e scss -e less -e css | xargs rg -l 'button|Button'

# Search for specific usage of the changed variable
echo "\nFiles directly using --tv-Button-line-height:"
rg -- '--tv-Button-line-height'

Length of output: 55279


Script:

#!/bin/bash
# Description: Find button-related component files that might be affected by the line height change.

# Search for files that likely contain button styling without using xargs to avoid argument conflicts
echo "Files potentially affected by button line height change:"
fd -e vue -e scss -e less -e css 'button|Button' --type f

# Search for specific usage of the changed variable without additional flags
echo "\nFiles directly using --tv-Button-line-height:"
rg '--tv-Button-line-height' .

Length of output: 4315


Script:

#!/bin/bash
# Description: Find button-related component files and search for specific usage of --tv-Button-line-height.

# Search for files that likely contain button styling
echo "Files potentially affected by button line height change:"
fd -e vue -e scss -e less -e css 'button|Button' --type f

# Search for specific usage of the changed variable using the -e flag
echo "\nFiles directly using --tv-Button-line-height:"
rg -e '--tv-Button-line-height' .

Length of output: 4071

Comment on lines +3 to +8
<tiny-button ghost type="primary">主要按钮</tiny-button>
<tiny-button ghost>次要按钮</tiny-button>
<tiny-button ghost type="success">成功按钮</tiny-button>
<tiny-button ghost type="info">信息按钮</tiny-button>
<tiny-button ghost type="warning">告警按钮</tiny-button>
<tiny-button ghost type="danger">危险按钮</tiny-button>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent removal of reset-time attribute across the codebase.

The reset-time attribute is still present in numerous button components across multiple .vue files. This indicates that the removal was not applied consistently, which may lead to unexpected behavior in parts of the application.

Recommended Actions:

  1. Review Scope: Ensure that the removal of reset-time is intended to be global. If so, apply the change consistently across all relevant files.
  2. Verify Functionality: Confirm that removing reset-time does not adversely affect button behavior where it remains.
  3. Update Documentation: Reflect these changes accurately in the PR description for better clarity and documentation.
🔗 Analysis chain

Consistent removal of reset-time attribute, but clarification needed.

The reset-time attribute has been consistently removed from all six button components. This change appears intentional and aligns with the AI-generated summary.

However, I have a few points for consideration:

  1. Could you please clarify the purpose of removing the reset-time attribute? Understanding its impact on button behavior would be helpful.
  2. The PR objectives mention fixing a CSS var error, but this change doesn't directly relate to CSS variables. Could you explain how this change addresses the stated objective?
  3. It would be beneficial to update the PR description to reflect these specific changes for better documentation.

To ensure this change is consistent across the codebase, let's check for any remaining usage of reset-time in button components:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of reset-time in button components
rg --type vue 'reset-time' | grep -i button

Length of output: 71


Script:

#!/bin/bash
# Search for any remaining usage of reset-time in button components within .vue files
rg 'reset-time' --glob '*.vue' | grep -i button

Length of output: 32314

Comment on lines +3 to +8
<tiny-button ghost type="primary">主要按钮</tiny-button>
<tiny-button ghost>次要按钮</tiny-button>
<tiny-button ghost type="success">成功按钮</tiny-button>
<tiny-button ghost type="info">信息按钮</tiny-button>
<tiny-button ghost type="warning">告警按钮</tiny-button>
<tiny-button ghost type="danger">危险按钮</tiny-button>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent Removal of reset-time Attribute

The reset-time attribute has not been removed consistently from <tiny-button> components across the project. Numerous files still contain instances of :reset-time, which may lead to inconsistent behavior.

Please ensure that the reset-time attribute is either fully deprecated and removed from all relevant components or retained where necessary with proper documentation.

🔗 Analysis chain

Summary: Consistent removal of reset-time attribute from all buttons.

The changes in this file consistently remove the reset-time attribute from all <tiny-button> components while maintaining their other attributes and overall structure. This appears to be part of a larger effort to remove this attribute from buttons across the project.

To ensure completeness of the review:

  1. Could you provide context on why the reset-time attribute was removed and what its purpose was?
  2. Are there any potential side effects or behavioral changes expected from removing this attribute?
  3. Have all other files using <tiny-button> components been updated similarly?

To verify the consistent removal of the reset-time attribute across the project, please run the following script:

This script will help identify any inconsistencies in the removal of the reset-time attribute and find any related documentation that might need updating.


To address the issue with the rg command not recognizing the vue file type, please run the following updated script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of the reset-time attribute on tiny-button components

# Search for tiny-button components with reset-time attribute
echo "Searching for remaining reset-time attributes on tiny-button components:"
rg --type vue '<tiny-button.*reset-time.*>' -g '!examples/sites/demos/pc/app/button/ghost.vue'

# Search for any mentions of reset-time in relation to buttons in comments or documentation
echo "Searching for mentions of reset-time in relation to buttons:"
rg --type vue 'reset-time.*button|button.*reset-time' -g '!examples/sites/demos/pc/app/button/ghost.vue'

Length of output: 545


Script:

#!/bin/bash
# Description: Check for any remaining instances of the reset-time attribute on tiny-button components

# Search for tiny-button components with reset-time attribute in .vue files
echo "Searching for remaining reset-time attributes on tiny-button components:"
rg '<tiny-button.*reset-time.*>' --glob '*.vue' -g '!examples/sites/demos/pc/app/button/ghost.vue'

# Search for any mentions of reset-time in relation to buttons in comments or documentation within .vue files
echo "Searching for mentions of reset-time in relation to buttons:"
rg 'reset-time.*button|button.*reset-time' --glob '*.vue' -g '!examples/sites/demos/pc/app/button/ghost.vue'

Length of output: 64490

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 595dd8b and 49358cc.

📒 Files selected for processing (2)
  • examples/sites/demos/pc/app/button/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/button/basic-usage.vue (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
examples/sites/demos/pc/app/button/basic-usage.vue (1)

5-5: Clarify the intent behind removing native-type="submit"

The native-type="submit" attribute has been removed from the primary button. While this change aligns with the PR summary, it's important to consider its implications:

  1. The button will no longer act as a submit button for forms by default.
  2. This might affect form submission behavior if this button was intended to submit a form.

Could you please clarify the reasoning behind this change? If it's intentional, consider adding a comment in the code or updating the component's documentation to reflect this change in behavior.

To ensure this change doesn't unintentionally affect other parts of the application, please run the following script to check for any form-related usage of this button:

If the script returns any results, please review those instances to ensure they're not affected by this change.

@@ -2,7 +2,7 @@
<tiny-layout>
<p>基本按钮</p>
<tiny-row>
<tiny-button type="primary" native-type="submit"> 主要按钮 </tiny-button>
<tiny-button type="primary"> 主要按钮 </tiny-button>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent Usage of native-type="submit" in Other Components

The native-type="submit" attribute is still present in the following .vue files:

  • examples/sites/demos/pc/app/drawer/footer-slot-composition-api.vue
  • examples/sites/demos/pc/app/drawer/footer-slot.vue
  • examples/sites/demos/mobile-first/app/button/icon.vue
  • examples/sites/demos/mobile-first/app/button/banner.vue
  • examples/sites/demos/mobile-first/app/button/basic-usage.vue

Please ensure that the removal of native-type="submit" is consistently applied across all button components to maintain standardized behavior and prevent unexpected form submission issues.

🔗 Analysis chain

Verify the intended behavior of the primary button

The native-type="submit" attribute has been removed from the primary button. This change alters the button's behavior in form submissions, as it will no longer automatically submit a form when clicked.

Please confirm if this change is intentional and part of the CSS variable fix mentioned in the PR title. If so, ensure that:

  1. This modification doesn't break any existing form submission functionality in the application.
  2. The change is consistent across all relevant components.
  3. Documentation is updated to reflect this change in button behavior, if necessary.

To check for consistency, you can run the following script to find other instances of native-type="submit" in button components:

Consider adding a comment in the code explaining why the native-type="submit" attribute was removed, to provide context for future developers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of native-type="submit" in button components
rg --type vue 'native-type="submit"' examples/sites/demos/pc/app/button

Length of output: 101


Script:

#!/bin/bash
# Search for other instances of native-type="submit" in .vue button components
rg 'native-type="submit"' examples/sites/demos/pc/app/button --type-add 'vue:*.vue' --type vue

Length of output: 96


Script:

#!/bin/bash
# Search for all instances of native-type="submit" in .vue files across the entire repository
rg 'native-type="submit"' --type-add 'vue:*.vue' --type vue

Length of output: 1089

@zzcr zzcr changed the title fix(button): fix error css var fix(button): [button]fix error css var Oct 19, 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