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

feat(date-picker): [date-picker] Fix style issues #2392

Merged
merged 3 commits into from
Oct 25, 2024
Merged

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Oct 25, 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

Release Notes

  • New Features

    • Introduced new styling options for date picker components, enhancing layout and presentation.
    • Added a new CSS variable for improved customization of disabled cell colors in the Month Table.
  • Bug Fixes

    • Adjusted styles for selected date ranges and disabled cells to improve visual consistency.
  • Styling Changes

    • Updated widths of date picker wrappers for better layout management.
    • Enhanced hover effects and background colors for disabled states in month table.

Copy link

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the styling and layout of various date picker components across multiple Vue files. The width of the .demo-date-picker-wrap class is adjusted in several instances, affecting the presentation of the date pickers. Additionally, new CSS variables and style rules are introduced for improved visual representation in related components. Overall, the functionality of the date pickers remains unchanged, with no alterations to the underlying logic or event handling.

Changes

File Path Change Summary
examples/sites/demos/pc/app/date-picker/align-composition-api.vue, examples/sites/demos/pc/app/date-picker/align.vue Modified .demo-date-picker-wrap width from 350px to 280px. Template structure remains unchanged.
examples/sites/demos/pc/app/date-picker/date-range-composition-api.vue, examples/sites/demos/pc/app/date-picker/date-range.vue Added CSS rule setting .demo-date-picker-wrap width to 360px. Template structure unchanged.
examples/sites/demos/pc/app/date-picker/events-composition-api.vue, examples/sites/demos/pc/app/date-picker/events.vue Reduced tiny-col span for onPick date picker from 12 to 6, affecting layout but not functionality.
examples/sites/demos/pc/app/date-picker/now-composition-api.vue, examples/sites/demos/pc/app/date-picker/now.vue Replaced inline width styles with class-based styles for width set to 280px. No changes to script logic.
examples/sites/demos/pc/app/date-picker/timezone-composition-api.vue Introduced new CSS class .demo-date-picker-wrap with width of 280px. No changes to functionality.
packages/theme/src/date-table/index.less Added style rule for .selected.in-range to set background color for selected date ranges.
packages/theme/src/month-table/index.less Updated .disabled class color and hover background properties.
packages/theme/src/month-table/vars.less Added new CSS variable --tv-MonthTable-cell-color-disabled for disabled cell text color.

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

🐇 In the fields where the date pickers play,
A width adjustment brightens the day.
With colors and styles, we dance and we cheer,
For a layout that's lovely, we hold dear.
From left to right, they align just so,
In our little demo, watch the beauty grow! 🌼


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 enhancement New feature or request (功能增强) label Oct 25, 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 (4)
examples/sites/demos/pc/app/date-picker/align-composition-api.vue (1)

34-34: Consider adding a comment explaining the standardized width.

Since this width appears to be standardized across date picker components, it would be helpful to add a comment explaining why 280px was chosen as the standard width.

 .demo-date-picker-wrap {
+  /* Standard width for all date picker demos to ensure consistent appearance */
   width: 280px;
 }
examples/sites/demos/pc/app/date-picker/now.vue (1)

Line range hint 37-43: Consider simplifying the Promise implementation.

The nowClick method uses setTimeout with 0ms delay, which seems unnecessary. Consider simplifying:

    nowClick() {
-      return new Promise((resolve) => {
-        setTimeout(() => {
-          resolve(new Date(2024, 9, 8, 18, 18, 18))
-        }, 0)
-      })
+      return Promise.resolve(new Date(2024, 9, 8, 18, 18, 18))
    }

Also, consider making the date dynamic to avoid hardcoding a specific future date that might become outdated.

examples/sites/demos/pc/app/date-picker/events-composition-api.vue (1)

Line range hint 44-54: Consider enhancing event message formatting.

The event messages could be improved for better user experience and maintainability:

  1. Consider using i18n for internationalization support
  2. Format the date strings in onPick event to be more user-friendly

Here's a suggested improvement:

 const pickerOptions = {
   onPick: ({ minDate, maxDate }) => {
-    Modal.message({ message: `触发 onPick 事件,开始日期为:${minDate},结束日期为:${maxDate}`, status: 'info' })
+    Modal.message({
+      message: t('datePicker.onPickMessage', {
+        startDate: formatDate(minDate),
+        endDate: formatDate(maxDate)
+      }),
+      status: 'info'
+    })
   }
 }
packages/theme/src/date-table/index.less (1)

244-246: LGTM with a minor formatting suggestion.

The new style rule for selected dates within a range is well-placed and uses the appropriate CSS variable pattern.

For consistency with the surrounding code, consider adding spaces after the selector and before the opening brace:

-    &.selected.in-range div{
+    &.selected.in-range div {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6033549 and b8b608e.

📒 Files selected for processing (12)
  • examples/sites/demos/pc/app/date-picker/align-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/align.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/date-range-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/date-range.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/events-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/events.vue (1 hunks)
  • examples/sites/demos/pc/app/date-picker/now-composition-api.vue (3 hunks)
  • examples/sites/demos/pc/app/date-picker/now.vue (3 hunks)
  • examples/sites/demos/pc/app/date-picker/timezone-composition-api.vue (1 hunks)
  • packages/theme/src/date-table/index.less (1 hunks)
  • packages/theme/src/month-table/index.less (1 hunks)
  • packages/theme/src/month-table/vars.less (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • examples/sites/demos/pc/app/date-picker/align.vue
  • examples/sites/demos/pc/app/date-picker/date-range-composition-api.vue
  • examples/sites/demos/pc/app/date-picker/date-range.vue
  • examples/sites/demos/pc/app/date-picker/timezone-composition-api.vue
🔇 Additional comments (9)
examples/sites/demos/pc/app/date-picker/align-composition-api.vue (1)

34-34: Please verify the visual appearance with the reduced width.

The width reduction from 350px to 280px aligns with similar changes across other date-picker examples. However, since this component demonstrates different alignments (left, center, right), please ensure that all alignment options display correctly with the narrower width.

✅ Verification successful

Width change is consistent across all date-picker examples

The width of 280px is consistently applied across all date-picker demo files, including both regular and composition API variants. This standardization ensures a uniform appearance throughout the component library's examples.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all date picker demo files to verify consistent width usage
fd -e vue -e css --full-path "date-picker" | xargs rg "width:.+280px"

Length of output: 2569

examples/sites/demos/pc/app/date-picker/now-composition-api.vue (2)

3-3: LGTM! Clean and consistent styling approach.

The change from inline styles to class-based styling improves maintainability and follows Vue.js best practices.

Also applies to: 12-12


40-42: Verify the reduced width doesn't cause layout issues.

The width has been reduced from 400px to 280px. While this aligns with other date picker components, please ensure:

  1. The date picker dropdown remains properly aligned
  2. All date/time content is fully visible without truncation
  3. The layout works well across different locales and time formats

Consider adding responsive breakpoints if this component needs to adapt to different screen sizes:

 .demo-date-picker {
   width: 280px;
+  @media (max-width: 768px) {
+    width: 100%;
+    max-width: 280px;
+  }
 }
examples/sites/demos/pc/app/date-picker/now.vue (2)

Line range hint 3-15: LGTM! Improved styling approach.

Good refactoring from inline styles to class-based styling, which improves maintainability and follows Vue best practices.


48-50: Verify the reduced width impact.

The width has been reduced from 400px to 280px, which is a significant change. Please verify that:

  1. This width reduction is intentional
  2. The date picker UI elements fit properly within the narrower container
  3. No text truncation or layout issues occur with different date formats

Let's check for any related width definitions or potential conflicts:

✅ Verification successful

Width change appears to be standardized across date picker examples

The width reduction from 400px to 280px aligns with the consistent pattern found across all date picker examples in the codebase. The search results show:

  • Most single date picker examples use 280px width
  • Date range pickers use 360px width
  • Only validation-related examples use 400px width

This indicates the change is intentional and follows the established pattern in the component library's demo examples.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other width definitions that might affect the date picker
rg -l "demo-date-picker" | xargs rg "width:"

# Search for any related style issues or discussions
gh issue list --search "date-picker width style"

Length of output: 6025

examples/sites/demos/pc/app/date-picker/events-composition-api.vue (1)

Line range hint 18-22: LGTM! Layout adjustment improves the component's presentation.

The reduction in column span from 12 to 6 creates a more balanced and compact layout, which is consistent with the style improvements being made across other date picker components.

examples/sites/demos/pc/app/date-picker/events.vue (1)

Line range hint 18-22: LGTM! The layout adjustment improves visual consistency.

The change from span="12" to span="6" for the daterange picker provides a more balanced layout. This width is appropriate for displaying the date range while maintaining visual harmony with other date pickers in the row above (which use span="4").

packages/theme/src/month-table/vars.less (1)

45-46: ⚠️ Potential issue

Consider consolidating similar disabled text color variables.

There appear to be two variables for disabled text color:

  • --tv-MonthTable-text-color-disabled (line 19)
  • --tv-MonthTable-cell-color-disabled (line 46)

Having two variables for seemingly the same purpose could lead to confusion and maintenance issues.

Consider consolidating these variables by:

  1. Using one consistent variable name
  2. Updating all related styles to reference the same variable
  3. Documenting the specific use case if they serve different purposes
- // 文字色(禁用)
- --tv-MonthTable-cell-color-disabled: var(--tv-color-text-disabled, #c2c2c2);

Let's verify the usage of both variables:

packages/theme/src/month-table/index.less (1)

67-71: LGTM! Improved semantic meaning of disabled state styles.

The changes properly separate the concerns between text color and background color for disabled cells, making the code more maintainable. The explicit hover state background prevents any visual changes that might incorrectly suggest interactivity.

@zzcr zzcr merged commit d3c8944 into dev Oct 25, 2024
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants