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(calendar): [calendar] refactor theme vars #2323

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Oct 21, 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 styling for the calendar component, including new color schemes and fixed dimensions for improved consistency.
    • Introduced a new naming convention for CSS variables, enhancing clarity and organization.
  • Bug Fixes

    • Adjusted hover and focus states for input fields and calendar elements to improve user interaction.
  • Documentation

    • Enhanced comments in the CSS variables function to clarify the intended use of each variable.

Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in this pull request involve significant modifications to the LESS stylesheets for a calendar component. Key updates include renaming a mixin, changing CSS variable prefixes, and standardizing dimensions and colors. The updates reflect a new theming approach with a focus on fixed values rather than variables for certain properties, enhancing consistency in the calendar's visual presentation.

Changes

File Path Change Summary
packages/theme/src/calendar/index.less Renamed mixin from .component-css-vars-calendar() to .inject-Calendar-vars(). Updated background color variable and standardized dimensions, colors, and font sizes for various elements.
packages/theme/src/calendar/vars.less Replaced .component-css-vars-calendar() with .inject-Calendar-vars(), introducing new CSS custom properties with --tv- prefix.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

🐇 In the garden where colors play,
The calendar blooms in a brand-new way.
With tv hues and dimensions set,
A fresh new look, we won't forget!
So hop along, let’s celebrate,
A stylish change, oh, isn't it great? 🌼


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 21, 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: 5

🧹 Outside diff range and nitpick comments (4)
packages/theme/src/calendar/index.less (4)

114-114: Approve theme variables for colors, consider variable for icon size.

The changes to icon styling improve theme consistency:

  1. The use of --tv-Calendar-text-color-primary and --tv-Calendar-hover-text-color for fill colors is good for maintainability and theming.
  2. Consider using a theme variable for the icon font size instead of a fixed value (14px) to allow for more flexibility:
- font-size: 14px;
+ font-size: var(--tv-Calendar-icon-font-size);

Also applies to: 120-120, 123-123


177-177: Approve use of theme variable for calendar header font size.

The calendar header font size now uses the theme variable --tv-Calendar-content-heard-font-size. This change improves maintainability and ensures consistency across the component.

There's a typo in the variable name: "heard" should be "header". Consider fixing this in the variable definition.


195-195: Approve theme variables, suggest variable for border color.

The calendar day styling has been updated:

  1. Approve the use of theme variables for background and text colors in different states (selected, hover). This improves theming capabilities.
  2. The border color has been changed to a fixed color (#999999). Consider using a theme variable for better flexibility:
- border-top: 3px solid #999999;
+ border-top: 3px solid var(--tv-Calendar-day-border-color);

Also applies to: 201-201, 204-204, 209-209


282-282: Approve use of theme variable, consider separate variable for tip header.

The calendar tip header font size now uses the theme variable --tv-Calendar-content-heard-font-size. While this improves maintainability, consider the following:

  1. There's a typo in the variable name: "heard" should be "header".
  2. The tip header and the main content header might require different sizes. Consider using a separate variable for the tip header:
- font-size: var(--tv-Calendar-content-heard-font-size);
+ font-size: var(--tv-Calendar-tip-header-font-size);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 363f40f and 7ffb106.

📒 Files selected for processing (2)
  • packages/theme/src/calendar/index.less (12 hunks)
  • packages/theme/src/calendar/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (11)
packages/theme/src/calendar/vars.less (1)

13-57: Summary of changes and potential impact

This refactoring of the calendar theme variables represents a significant improvement in the customization capabilities of the calendar component. The changes include:

  1. A new naming convention with the --tv- prefix.
  2. More comprehensive coverage of different states and elements within the calendar.
  3. Better organization and documentation of variables.

These changes will likely improve the maintainability and flexibility of the calendar component's styling. However, it's important to note that this is a breaking change for any existing code that relies on the old variable names.

To ensure that these changes are consistently applied across the project, please run the following verification script:

This script will help identify any remaining instances of old variable usage and confirm the adoption of the new variables across the project.

packages/theme/src/calendar/index.less (10)

25-25: Consistent application of new variable naming convention.

The background color variable has been updated to use the new --tv- prefix and PascalCase for the component name. This change is consistent with the new naming convention observed throughout the file.


40-41: Improved theming flexibility for selected state.

The selected state styling has been updated to use the new --tv- prefixed variables. This change not only aligns with the new naming convention but also provides more granular control over the theming of the selected state.

Also applies to: 43-43, 45-45


71-71: Consider flexibility vs. consistency in input field dimensions.

The input field styling has been updated with fixed dimensions and new theme variables. While this improves consistency, it might reduce flexibility for different use cases.

  1. The fixed width (104px) and height (32px) ensure consistent sizing but may limit adaptability to different layouts. Consider if these should remain as variables for more flexibility.
  2. The use of new --tv- prefixed variables for colors, border-radius, and font-size is good for maintainability and theming.

Could you confirm if the fixed dimensions are intentional and if they meet all use case requirements?

Also applies to: 77-83


135-138: Consider flexibility in tab dimensions, approve use of theme variables.

The tabs styling has been updated with fixed dimensions and theme variables:

  1. Fixed dimensions (width: 52px, height: 32px) ensure consistency but might limit flexibility. Consider if these should be theme variables for adaptability to different designs.
  2. The use of --tv-Calendar-input-font-size and --tv-Calendar-text-color-info is good for maintainability and theming.

Could you confirm if the fixed tab dimensions are intentional and meet all design requirements?

Also applies to: 140-140, 142-142


160-161: Approve use of theme variables for active tab styling.

The active tab styling has been updated to use the new theme variables --tv-Calendar-text-color-primary. This change is consistent with the new naming convention and improves maintainability and theming capabilities.


213-213: Approve enhanced theming capabilities for disabled states.

The disabled day styling has been significantly improved:

  1. New theme variables are used for different states (info, success, warning, error) in the disabled context.
  2. This change provides great flexibility for theming and is consistent with the new naming convention.

These updates allow for more granular control over the appearance of disabled days, which can greatly enhance the user experience and accessibility of the calendar.

Also applies to: 216-216, 220-220, 224-224, 228-228


234-234: Approve use of theme variable for current month and today styling.

The border color for the current month and today now uses the theme variable --tv-Calendar-text-color-primary. This change is consistent with the new naming convention and improves theming capabilities, allowing for easier customization of these important calendar states.


258-258: Approve enhanced theming capabilities for event indicators.

The event indicator styling has been improved:

  1. New theme variables are used for different event types (info, success, warning, error).
  2. This change provides great flexibility for theming and is consistent with the new naming convention.

These updates allow for more granular control over the appearance of event indicators, which can enhance the visual distinction between different event types in the calendar.

Also applies to: 262-262, 266-266, 270-270


300-300: Consider flexibility in dimensions, approve use of theme variables for colors.

The calendar selector and list item styling has been updated:

  1. Fixed dimensions are used for the selector width (104px) and list item height (32px). Consider if these should be theme variables for more flexibility across different designs.
  2. Approve the use of theme variables for colors in different states (normal, hover, selected). This improves theming capabilities and is consistent with the new naming convention.

Could you confirm if the fixed dimensions for the selector and list items are intentional and meet all design requirements?

Also applies to: 307-308, 314-314, 318-318, 322-323


Line range hint 1-325: Overall assessment: Improved theming with some considerations

The changes in this file significantly improve the theming capabilities of the calendar component:

  1. The new --tv- prefixed variables provide more granular control over various aspects of the calendar's appearance.
  2. The consistent use of theme variables for colors enhances maintainability and customization options.

However, there are a few areas that could be further improved:

  1. Consider using theme variables for dimensions (e.g., input width, tab width) to maintain flexibility for different designs.
  2. Replace remaining hardcoded colors (e.g., #191919, #999999) with theme variables for complete theming control.
  3. Fix the typo in the mixin name (injiectinject) and the content header variable name (heardheader).
  4. Consider separate variables for elements that might need different sizes (e.g., main content header vs. tip header).

Overall, these changes represent a significant improvement in the component's theming capabilities, with minor adjustments needed for optimal flexibility and consistency.

packages/theme/src/calendar/vars.less Outdated Show resolved Hide resolved
packages/theme/src/calendar/vars.less Outdated Show resolved Hide resolved
packages/theme/src/calendar/vars.less Show resolved Hide resolved
packages/theme/src/calendar/index.less Outdated Show resolved Hide resolved
packages/theme/src/calendar/index.less Outdated Show resolved Hide resolved
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 (1)
packages/theme/src/calendar/vars.less (1)

15-59: Consider using lowercase "calendar" in variable names

For better consistency with CSS naming conventions, consider changing "Calendar" to "calendar" in all variable names. This would improve readability and align with common CSS practices.

For example:

---tv-Calendar-bg-color
+--tv-calendar-bg-color

This change should be applied to all variables in the mixin.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7ffb106 and e57b667.

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

13-13: LGTM: Mixin name corrected and structure improved

The mixin name has been corrected to .inject-Calendar-vars(), addressing the typo mentioned in a previous review. The use of a mixin for injecting variables is a good practice for maintaining modular and reusable CSS.


51-59: 🛠️ Refactor suggestion

Consider differentiating disabled states

Currently, all disabled states (info, success, warning, error) use the same background color (var(--tv-color-bg-secondary)). This might not provide enough visual distinction between these states when disabled.

Consider using slightly different shades or opacities for each disabled state to maintain visual hierarchy:

---tv-Calendar-disabled-info-bg-color: var(--tv-color-bg-secondary);
---tv-Calendar-disabled-success-bg-color: var(--tv-color-bg-secondary);
---tv-Calendar-disabled-warning-bg-color: var(--tv-color-bg-secondary);
---tv-Calendar-disabled-error-bg-color: var(--tv-color-bg-secondary);
+--tv-Calendar-disabled-info-bg-color: var(--tv-color-info-bg-disabled);
+--tv-Calendar-disabled-success-bg-color: var(--tv-color-success-bg-disabled);
+--tv-Calendar-disabled-warning-bg-color: var(--tv-color-warning-bg-disabled);
+--tv-Calendar-disabled-error-bg-color: var(--tv-color-error-bg-disabled);

Ensure that these new variables are defined in your global theme with appropriate values that provide subtle differentiation while maintaining the disabled appearance.

Likely invalid or redundant comment.

packages/theme/src/calendar/vars.less Show resolved Hide resolved
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