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(time-spinner): [date-picker] roll back some styles for time-spinner #2383

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Oct 24, 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

    • Enhanced layout and styling for the Time Panel and Time Spinner components, improving overall visual structure.
    • Introduced new CSS variables for better customization of margins and padding.
  • Bug Fixes

    • Adjusted padding and margin properties to refine element alignment and presentation.
  • Chores

    • Cleaned up comments and TODO notes in the CSS codebase for better maintainability.

Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes in this pull request involve modifications to the styling of the time panel and time spinner components in the LESS files. Adjustments include the removal and addition of CSS properties, updates to CSS variables, and refinements to padding, margin, and height settings. The overall structure of the styles is maintained, but the visual layout and spacing of elements within the components are altered to enhance their appearance.

Changes

File Path Change Summary
packages/theme/src/time-panel/index.less Removed height definition from &__header-input, removed margin-top from &__header-title, added padding-bottom to &__content, and cleaned up comments.
packages/theme/src/time-panel/vars.less Updated --tv-TimePanel-padding, updated --tv-TimePanel-header-margin, added --tv-TimePanel-content-padding-bottom.
packages/theme/src/time-spinner/index.less Increased padding-bottom for .@{scrollbar-prefix-cls}__wrap, modified height and margin properties for various classes.
packages/theme/src/time-spinner/vars.less Added --tv-TimeSpinner-list-margin, updated --tv-TimeSpinner-item-margin, and removed --tv-TimeSpinner-arrow-padding.

Suggested labels

refactoring

Suggested reviewers

  • zzcr

Poem

🐇 In the garden of code, changes bloom bright,
With margins and paddings, all set just right.
The time panel dances, the spinner spins free,
A whimsical layout, as lovely as can be!
With LESS now refined, our styles take flight,
A hop and a skip, all feels just right! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 275f39b and 340bc35.

📒 Files selected for processing (1)
  • packages/theme/src/time-panel/vars.less (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/time-panel/vars.less

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

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

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

🧹 Outside diff range and nitpick comments (3)
packages/theme/src/time-panel/vars.less (1)

35-36: Consider enhancing the variable documentation.

The new padding variable is well-structured and follows the established pattern. Consider adding a brief comment explaining the purpose of this bottom padding (e.g., if it's for creating space between content and footer).

  // 内容区底部内间距
- --tv-TimePanel-content-padding-bottom: var(--tv-space-lg, 12px);
+ // 内容区底部内间距 - 用于在内容区和底部之间创建间隔
+ --tv-TimePanel-content-padding-bottom: var(--tv-space-lg, 12px);
packages/theme/src/time-panel/index.less (1)

Line range hint 108-109: Consider addressing or removing the TODO comment.

The TODO comment about borderless scenarios should either be:

  1. Addressed by confirming if the borderless use case exists
  2. Removed if it's no longer relevant

Would you like me to help investigate if there are any borderless use cases in the codebase or create an issue to track this?

packages/theme/src/time-spinner/index.less (1)

46-46: Document the transform values.

The transform values (-32px, -6px) appear to be magic numbers. Consider:

  1. Adding comments explaining why these specific values were chosen
  2. Converting these values to CSS variables for better maintainability
 .@{time-spinner-prefix-cls}__list {
-  transform: translateY(-6px);
+  transform: translateY(var(--tv-TimeSpinner-list-offset, -6px));
   margin: var(--tv-TimeSpinner-list-margin);
 }

Also applies to: 56-59

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 365c7e8 and 275f39b.

📒 Files selected for processing (4)
  • packages/theme/src/time-panel/index.less (1 hunks)
  • packages/theme/src/time-panel/vars.less (1 hunks)
  • packages/theme/src/time-spinner/index.less (7 hunks)
  • packages/theme/src/time-spinner/vars.less (1 hunks)
🔇 Additional comments (8)
packages/theme/src/time-spinner/vars.less (2)

Line range hint 1-46: Verify the impact of removing --tv-TimeSpinner-arrow-padding.

The removal of --tv-TimeSpinner-arrow-padding might affect the arrow's appearance or positioning. Please ensure this change doesn't impact the component's visual consistency.

Let's check how this variable was used:

#!/bin/bash
# Search for any references to the removed arrow padding variable
rg "TimeSpinner-arrow-padding" --type less -A 3 -B 3

32-33: Consider reducing the bottom margin in --tv-TimeSpinner-list-margin.

The bottom margin of 30px seems disproportionately large compared to other spacing values in the component. This might create excessive vertical spacing in the time panel.

Let's check if this large margin is necessary:

packages/theme/src/time-panel/vars.less (1)

32-32: LGTM! Header margin changes align with the spacing system.

The updated margin values properly utilize the design system's spacing variables (--tv-space-xl) while maintaining consistency with other components.

packages/theme/src/time-panel/index.less (2)

54-54: LGTM: Consistent use of CSS variable for padding.

The addition of padding-bottom using the --tv-TimePanel-content-padding-bottom variable maintains consistency with the project's design system approach.


Line range hint 31-41: Verify the impact of removed styles.

According to the AI summary, some styles were removed:

  1. Height definition from header-input > input
  2. margin-top from header-title

Please verify that these removals don't adversely affect the component's layout.

Let's check for any fallback styles:

✅ Verification successful

Let me gather more specific information about the time-panel component to verify the impact of these style removals.

This will help us understand:

  1. The complete context of the time-panel styles
  2. Any CSS variable definitions that might provide fallback values
  3. Any mixins or common styles that might affect the component

Let me check one more thing to verify the variables and any potential default values:

This will help us understand:

  1. The default variable definitions in vars.less
  2. Any other locations where TimePanel variables might be defined or injected

The removal of these styles is safe and well-handled by CSS variables

After analyzing the complete time-panel styles and its variable definitions, I can confirm that:

  1. The removed height from header-input > input was not essential as there's no specific height requirement in the design system for this element.
  2. The removed margin-top from header-title is properly handled by the --tv-TimePanel-header-margin CSS variable, which provides a consistent spacing of 16px 0 24px 0 (defined in vars.less).

The component's layout is maintained through:

  • Proper margin definitions via --tv-TimePanel-header-margin
  • Flex layout in the header-title (display: flex; justify-content: space-around; align-items: center)
  • A comprehensive set of CSS variables that handle all spacing and sizing requirements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other height/margin definitions that might compensate for the removals

# Search for height definitions in related files
echo "Checking for input height definitions:"
rg -l "height.*input" --type less packages/theme/src/

# Search for margin/padding definitions that might affect the header
echo "Checking for header margin/padding definitions:"
rg "(margin|padding).*header" --type less packages/theme/src/

Length of output: 3217


Script:

#!/bin/bash
# Check the complete time-panel styles and its dependencies
echo "Checking time-panel styles:"
cat packages/theme/src/time-panel/index.less

echo -e "\nChecking for any CSS variable definitions that might provide default values:"
rg "tv-TimePanel-" packages/theme/src/variables/

echo -e "\nChecking for any related mixins or common styles:"
rg "time-panel|TimePanel" packages/theme/src/mixins/

Length of output: 3613


Script:

#!/bin/bash
# Check for TimePanel variables and the vars.less file
echo "Checking TimePanel vars.less:"
cat packages/theme/src/time-panel/vars.less

echo -e "\nChecking for any other variable definitions:"
rg -g "*.less" "inject-TimePanel-vars|--tv-TimePanel" packages/theme/src/

Length of output: 6045

packages/theme/src/time-spinner/index.less (3)

34-34: Verify the increased scrollbar padding impact.

The padding-bottom increase from 12px to 15px might affect the visual alignment with other elements. Please ensure this change doesn't create any visual inconsistencies, especially when the scrollbar is visible.


69-70: LGTM! Consistent arrow sizing and positioning.

The changes establish a uniform height for arrows and consistent positioning, improving the overall visual harmony.

Also applies to: 88-88, 92-92


116-116: Verify the increased pseudo-element height impact.

The height increase from 4px to 80px is substantial. Please ensure this change:

  1. Doesn't cause any layout issues in different viewport sizes
  2. Maintains proper spacing when the list is scrolling
  3. Works well with the existing padding and margin values

// 时间项外间距
--tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) var(--tv-space-md, 8px) 0 var(--tv-space-md, 8px);
--tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) 10px 0 10px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider maintaining theme adaptability.

The change from var(--tv-space-md, 8px) to static 10px for left/right margins reduces the component's ability to adapt to different themes and spacing scales. Consider keeping the variable-based approach:

--- --tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) 10px 0 10px;
+++ --tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) var(--tv-space-md, 8px) 0 var(--tv-space-md, 8px);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) 10px 0 10px;
--tv-TimeSpinner-item-margin: var(--tv-space-lg, 12px) var(--tv-space-md, 8px) 0 var(--tv-space-md, 8px);

@@ -122,6 +125,7 @@
line-height: var(--tv-TimeSpinner-line-height);
color: var(--tv-TimeSpinner-text-color);
border-radius: var(--tv-TimeSpinner-item-border-radius);
width: 52px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a CSS variable for item width.

For better maintainability and consistency, consider moving the explicit width to a CSS variable.

-  width: 52px;
+  width: var(--tv-TimeSpinner-item-width, 52px);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
width: 52px;
width: var(--tv-TimeSpinner-item-width, 52px);

@MomoPoppy MomoPoppy changed the title Momo poppy/fallback time spinner 1023 refactor(time-spinner): [date-picker] roll back some styles for time-spinner Oct 24, 2024
@github-actions github-actions bot added the refactoring Refactoring (重构) label Oct 24, 2024
@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

@zzcr zzcr merged commit 2d47f95 into opentiny:dev Oct 24, 2024
9 checks passed
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.

3 participants