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(theme): [input] refactor textarea theme vars #2281

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Oct 16, 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

    • Updated the textarea component's styling with a new theming convention.
    • Enhanced CSS variable naming for improved consistency and readability.
  • Bug Fixes

    • Adjusted styling for various states of the textarea, ensuring proper display and functionality.
  • Chores

    • Standardized CSS variable prefixes across the textarea component to align with the new theming system.

Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes in this pull request involve a comprehensive update to the CSS variable naming conventions within the textarea component's styles. The prefix for CSS variables has been changed from --ti- to --tv-, and the mixin .component-css-vars-textarea() has been replaced with .inject-Textarea-vars(). These updates affect various properties, including text color, background color, and padding, while maintaining the overall structure of the CSS.

Changes

File Path Change Summary
packages/theme/src/textarea/index.less Updated mixin from .component-css-vars-textarea() to .inject-Textarea-vars().
packages/theme/src/textarea/vars.less Renamed multiple CSS variables from --ti- prefix to --tv-, including text color, background color, and padding variables.

Possibly related PRs

Suggested labels

refactoring

🐰 In the garden of styles, we play,
With colors and variables, bright as day.
From --ti- to --tv-, a hop and a skip,
Our textarea's charm takes a stylish trip!
So let’s dance with the themes, oh what a sight,
A whimsical world, all dressed up just right! 🌈


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 refactoring Refactoring (重构) label Oct 16, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/theme/src/textarea/vars.less (1)

41-61: LGTM: Consistent update to padding and count-related variables

The changes to padding and count-related variables are consistent with the new naming convention, using the --tv- prefix and PascalCase for "Textarea". The shortening of some variable names (e.g., padding-vertical to padding-y) aligns with common CSS naming conventions and improves readability.

One minor suggestion for consistency:

  • Consider changing --tv-Textarea-padding-right and --tv-Textarea-padding-bottom to --tv-Textarea-padding-r and --tv-Textarea-padding-b respectively, to match the shorthand used for padding-y and padding-x.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 766f054 and eee96db.

📒 Files selected for processing (2)
  • packages/theme/src/textarea/index.less (3 hunks)
  • packages/theme/src/textarea/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (14)
packages/theme/src/textarea/vars.less (5)

13-13: LGTM: Mixin name change improves consistency

The mixin name change from .component-css-vars-textarea() to .inject-Textarea-vars() aligns better with a consistent naming convention, likely matching other components in the system. This change enhances code readability and maintainability.


15-21: LGTM: Consistent update to basic style variables

The changes to text color, background color, and font size variables are consistent and follow the new naming convention. The use of --tv- prefix and PascalCase for "Textarea" improves readability while maintaining the existing theming system.


23-31: LGTM: Consistent update to dimension and border variables

The changes to height, border radius, and border color variables are consistent with the new naming convention. The use of --tv- prefix and PascalCase for "Textarea" enhances code consistency while maintaining the existing theming structure.


33-39: LGTM: Consistent update to state-specific variables

The changes to placeholder, disabled, and exceed state variables are consistent with the new naming convention. The use of --tv- prefix and PascalCase for "Textarea" improves code consistency while maintaining the existing theming structure for different states.


Line range hint 1-61: Summary: Successful refactoring of textarea theme variables

The changes in this file consistently update the CSS variable naming convention for the textarea component. The refactoring:

  1. Changes the prefix from --ti- to --tv-
  2. Uses PascalCase for "Textarea" in variable names
  3. Updates the mixin name to .inject-Textarea-vars()
  4. Maintains the existing theming system and functionality

These changes improve code consistency and readability while preserving the component's styling capabilities. Great job on this refactoring effort!

packages/theme/src/textarea/index.less (9)

29-29: LGTM: CSS variable prefix updated.

The font-size CSS variable has been updated to use the new --tv- prefix, which is consistent with the overall refactoring of CSS variable names. This change improves the specificity and clarity of the variable naming convention.


40-40: LGTM: Border-radius CSS variables updated.

The border-radius CSS variables have been consistently updated to use the new --tv- prefix. This change aligns with the overall refactoring effort and maintains the existing styling while improving variable naming consistency.

Also applies to: 52-52


81-81: LGTM: Exceed state CSS variables updated consistently.

All CSS variables related to the exceed state of the textarea (border color and text color) have been updated to use the new --tv- prefix. This change is consistent with the overall refactoring and maintains the existing styling.

Also applies to: 85-85, 88-88


131-131: LGTM: Hover and focus state CSS variables updated consistently.

All CSS variables related to the hover and focus states of the textarea (border colors) have been updated to use the new --tv- prefix. This change is consistent with the overall refactoring and maintains the existing styling.

Also applies to: 135-135, 139-139


Line range hint 1-280: Summary: Comprehensive update of CSS variable names and mixin injection.

This pull request successfully refactors the textarea component's styles by:

  1. Updating all CSS variable names from the --ti- prefix to the --tv- prefix.
  2. Changing the mixin name from .component-css-vars-textarea() to .inject-Textarea-vars().

These changes improve consistency and specificity in the naming convention, aligning with the Tiny Vue project standards. The overall structure and functionality of the styles remain intact, ensuring that this refactoring should not introduce any breaking changes.

To ensure the refactoring is complete and correct:

  1. Verify that all --ti- prefixed variables have been replaced.
  2. Check that the new .inject-Textarea-vars() mixin is properly implemented and used.
  3. Conduct thorough testing of the textarea component to confirm that all styles are applied correctly, especially for different states (disabled, exceed, hover, focus) and sub-components (inner textarea, count element).

Run the following script to ensure all --ti- prefixes have been replaced:

#!/bin/bash
# Check for any remaining --ti- prefixes in the textarea styles
rg --type less "\-\-ti\-" packages/theme/src/textarea/

94-96: LGTM: Count-related CSS variables updated consistently.

All CSS variables related to the count element of the textarea have been updated to use the new --tv- prefix. This includes color, background, font size, positioning, and border radius. The changes are consistent with the overall refactoring and maintain the existing styling.

Note: There's a slight change in the width calculation on line 103, which might affect the layout.

To ensure the count element's layout remains correct, please verify the rendered styles:

#!/bin/bash
# Verify the count element styling and layout
rg --type less "input__count" packages/theme/src/textarea/

Also applies to: 101-105, 108-108


56-58: LGTM: Disabled state CSS variables updated consistently.

All CSS variables related to the disabled state of the textarea (background color, border color, text color, and placeholder color) have been updated to use the new --tv- prefix. This change is consistent with the overall refactoring and maintains the existing styling.

To ensure the disabled state styling remains intact, please verify the rendered styles:

Also applies to: 60-60, 64-64, 67-67, 71-71, 75-75


23-23: LGTM: Mixin renamed for consistency.

The mixin has been renamed from .component-css-vars-textarea() to .inject-Textarea-vars(), which appears to be part of a larger refactoring effort. The new name is more descriptive and follows a consistent naming pattern.

To ensure the refactoring is complete, please verify the implementation of the new mixin:

✅ Verification successful

Verified: The old mixin .component-css-vars-textarea() has been successfully removed from the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the implementation of the new mixin
rg --type less "inject-Textarea-vars\(\)" packages/theme/src/

Length of output: 193


Script:

#!/bin/bash
# Verify that the old mixin is no longer used
rg --type less "\.component-css-vars-textarea\(\)" packages/theme/src/

Length of output: 72


114-124: LGTM: Inner textarea CSS variables updated consistently.

All CSS variables related to the inner textarea have been updated to use the new --tv- prefix. This includes height, colors, border, padding, and font size. The changes are consistent with the overall refactoring and maintain the existing styling.

Note: There's a new calculation for the minimum height on line 116 using a CSS variable, which provides more flexibility in theming.

To ensure the textarea's layout and styling remain correct, please verify the rendered styles:

Also applies to: 128-128

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
packages/theme/src/textarea/vars.less (2)

15-63: Consider standardizing variable naming to kebab-case

The CSS custom properties use mixed casing, such as --tv-Textarea-text-color. It's generally recommended to use kebab-case and lowercase letters for CSS custom properties for consistency and readability. Consider updating variable names to --tv-textarea-text-color for consistency with standard CSS conventions.


63-63: Use unitless line-height for better scalability

Line 63 sets the --tv-Textarea-count-line-height to the value of --tv-Textarea-count-font-size:

--tv-Textarea-count-line-height: var(--tv-Textarea-count-font-size);

Consider using a unitless number for line-height to enhance scalability across different font sizes and ensure consistent spacing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between eee96db and 0f80572.

📒 Files selected for processing (2)
  • packages/theme/src/textarea/index.less (5 hunks)
  • packages/theme/src/textarea/vars.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/textarea/index.less
🧰 Additional context used
🔇 Additional comments (1)
packages/theme/src/textarea/vars.less (1)

13-63: Variables successfully updated to new naming convention

The variables have been consistently updated to use the new --tv- prefix, and the method name has been changed to .inject-Textarea-vars(), aligning with the new theming system.

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.

1 participant