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(time-range): [date-picker,time-picker,select,action-menu] optimization demo and modify style for time-range #2481

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Nov 4, 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

    • Updated descriptions in action menu and select components for clarity.
    • Enhanced tiny-select component functionality with updated bindings and sizes.
  • Bug Fixes

    • Adjusted test cases for size options to ensure accuracy in Playwright tests.
  • Style

    • Improved CSS structure and variable usage in the time range picker for better maintainability and flexibility.

Copy link

coderabbitai bot commented Nov 4, 2024

Walkthrough

The pull request introduces several modifications across multiple Vue component files and associated styles. Key changes include updates to text descriptions in the templates, adjustments to bindings for select components, and refinements in CSS styles using variables. Notably, the icon components now reflect a more general display of icons, while the size components have had their bindings and displayed texts swapped. Additionally, the CSS for the time range picker has been streamlined to enhance flexibility through the use of CSS variables.

Changes

File Path Change Summary
examples/sites/demos/pc/app/action-menu/icon-composition-api.vue Updated paragraph text; modified options1 array to include a divided: true property; no changes to structure or styles.
examples/sites/demos/pc/app/action-menu/icon.vue Changed paragraph text; no changes to structure or functionality.
examples/sites/demos/pc/app/select/size-composition-api.vue Altered text in <p> elements; swapped v-model bindings between two tiny-select components.
examples/sites/demos/pc/app/select/size.vue Modified text in <p> elements; adjusted v-model bindings and size attributes for tiny-select components.
examples/sites/demos/pc/app/select/size.spec.ts Adjusted test selectors and updated expected CSS height for 'medium' size; no changes to logic for other tests.
packages/theme/src/time-range/index.less Modified CSS properties, replacing fixed values with CSS variables for padding and border colors; removed several properties for simplification.
packages/theme/src/time-range/vars.less Removed and added several CSS variables; updated --tv-TimeRange-header-line-height to a fixed value; streamlined padding and margin definitions.

Possibly related PRs

Suggested reviewers

  • zzcr

"In the meadow, changes bloom,
Icons dance, dispelling gloom.
Selects swap their values bright,
CSS variables take flight.
With every tweak, our code's refined,
A joyful leap for all aligned!" 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ac7730d and 8928749.

📒 Files selected for processing (1)
  • packages/theme/src/time-range/vars.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/time-range/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.

Copy link

github-actions bot commented Nov 4, 2024

[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

@MomoPoppy MomoPoppy changed the title Momo poppy/feat dosc 1030 optimization demo and modify style for time-range Nov 4, 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: 1

🧹 Outside diff range and nitpick comments (5)
examples/sites/demos/pc/app/select/size-composition-api.vue (1)

8-10: Maintain consistent language in labels

While the changes correctly demonstrate the default size variant, there's an inconsistency in label language:

  • Line 3 uses English ("medium")
  • Line 8 uses Chinese ("默认")

Consider using consistent language across all size labels for better readability.

Suggested change:

-    <p>默认</p>
+    <p>default</p>
examples/sites/demos/pc/app/select/size.vue (2)

3-3: Maintain consistent language in labels

The labels mix Chinese ("默认") and English ("medium") terms, which could be confusing for users. Consider using either all Chinese or all English labels across all size examples for better consistency.

-    <p>medium</p>
+    <p>中等</p>
-    <p>默认</p>
+    <p>默认大小</p>

Also applies to: 8-8


Line range hint 1-22: Consider modernizing the layout structure

The current layout relies heavily on <br /> tags for spacing. Consider using modern CSS layout techniques for better maintainability.

 <template>
-  <div>
+  <div class="select-demo">
-    <p>medium</p>
-    <br />
-    <tiny-select v-model="value2" size="medium" multiple :options="options"></tiny-select>
-    <br />
-    <br />
+    <div class="select-item">
+      <p>medium</p>
+      <tiny-select v-model="value2" size="medium" multiple :options="options"></tiny-select>
+    </div>
     // ... similar changes for other select groups ...
   </div>
 </template>

 <style lang="less" scoped>
+.select-demo {
+  display: flex;
+  flex-direction: column;
+  gap: 2rem;
+}
+.select-item {
+  display: flex;
+  flex-direction: column;
+  gap: 0.5rem;
+}
 .tiny-select {
   width: 280px;
 }
packages/theme/src/time-range/vars.less (1)

31-35: Improve formatting of multi-line CSS variable declaration.

The title padding declaration spans multiple lines in a way that might be hard to maintain. Consider using a single-line format or proper CSS variable concatenation.

--- --tv-TimeRange-title-padding: var(--tv-space-lg, 12px) var(--tv-space-md, 8px) var(--tv-space-md, 8px)
---   var(--tv-space-md, 8px);
+++ --tv-TimeRange-title-padding: var(--tv-space-lg, 12px) var(--tv-space-md, 8px) var(--tv-space-md, 8px) var(--tv-space-md, 8px);
packages/theme/src/time-range/index.less (1)

47-50: Remove unnecessary empty line.

The structural changes and use of CSS variables look good, but there's an unnecessary empty line that affects readability.

  &__cell {
    width: 50%;
-

    .tiny-time-panel__content {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1955deb and ac7730d.

📒 Files selected for processing (7)
  • examples/sites/demos/pc/app/action-menu/icon-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/action-menu/icon.vue (1 hunks)
  • examples/sites/demos/pc/app/select/size-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/select/size.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/select/size.vue (1 hunks)
  • packages/theme/src/time-range/index.less (1 hunks)
  • packages/theme/src/time-range/vars.less (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/demos/pc/app/action-menu/icon.vue
🔇 Additional comments (11)
examples/sites/demos/pc/app/select/size-composition-api.vue (2)

3-5: LGTM! Improved clarity in size demonstration

The changes make the medium size variant more explicit by:

  • Using clear English text label
  • Adding explicit size attribute
  • Maintaining consistent behavior through equivalent v-model binding

3-10: Verify size demonstration consistency across documentation

Let's ensure these changes align with other size demonstration examples in the codebase.

✅ Verification successful

Size demonstration is consistent with component library patterns

The implementation follows the established size patterns across the component library:

  • Shows all four standard sizes: medium, default, small, and mini
  • Uses consistent size prop values: "medium", "small", "mini" (default without prop)
  • Maintains same demonstration order as other form components
  • Uses identical Chinese label "默认" for default size
  • Follows same styling patterns with width and spacing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in size demonstrations across similar components

# Search for other size demonstration files
echo "Searching for related size demonstration files..."
fd -e vue -e ts --full-path "size.*" examples/sites/demos/pc/app

# Check for size-related text patterns
echo "Checking size label patterns..."
rg -i "medium|default|默认" examples/sites/demos/pc/app --type vue

Length of output: 9662


Script:

#!/bin/bash
# Let's check the specific select component size demonstrations and related components

# Check the select size demonstration files
echo "Checking select size demonstration content:"
cat examples/sites/demos/pc/app/select/size.vue examples/sites/demos/pc/app/select/size-composition-api.vue

# Check similar form components for size patterns
echo -e "\nChecking size patterns in related components:"
for comp in "input" "autocomplete" "base-select"
do
  echo -e "\n=== $comp size demonstration ==="
  cat "examples/sites/demos/pc/app/$comp/size-composition-api.vue"
done

Length of output: 6921

examples/sites/demos/pc/app/select/size.vue (1)

5-5: LGTM! Verify size demonstration order

The reordering of select components creates a more logical progression of size demonstrations, from medium → default → small → mini.

Let's verify this is consistent across other size demonstration files:

Also applies to: 10-10

packages/theme/src/time-range/vars.less (2)

38-38: Verify the impact of simplified footer padding.

The footer padding has been simplified to a single value. Please ensure this doesn't affect the footer's layout in different scenarios, especially considering the removal of the footer height variable.

#!/bin/bash
# Search for footer styles usage in the component
rg --type=less "tiny-time-range(__footer|\.time-footer)"

22-22: Verify the impact of consolidated padding variable.

The consolidation of multiple padding variables into a single --tv-TimeRange-cell-content-padding-bottom might reduce layout flexibility. Please ensure this doesn't adversely affect the component's responsiveness or different use cases.

✅ Verification successful

The previous command had a syntax error. Let's try a broader search to understand the padding usage in TimeRange-related files and identify any potential impact of the consolidation.


Padding consolidation is properly implemented and used consistently

The new --tv-TimeRange-cell-content-padding-bottom variable is correctly defined and used in the component's styles. The search results show:

  • The variable is properly used in index.less for cell content padding
  • It's part of a consistent set of padding variables for different parts of the TimeRange component
  • All padding variables follow the same naming convention and use design system spacing tokens
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for removed padding variables usage in the codebase
rg --type=less "tv-TimeRange-(cell-padding|content-padding)"

Length of output: 210


Script:

#!/bin/bash
# Search for TimeRange component styles and usage of padding variables
rg --type=less "TimeRange.*padding|tv-TimeRange.*padding"

# Also check for any Less files that might be importing or using TimeRange styles
fd -e less -x grep -l "TimeRange"

Length of output: 1200

examples/sites/demos/pc/app/action-menu/icon-composition-api.vue (1)

3-3: LGTM! Text description now accurately reflects the implementation.

The updated text "场景1:显示图标" (Scenario 1: Show icons) better describes the actual behavior of the component, which displays both icons and text, rather than the previous text which incorrectly suggested it only showed icons.

examples/sites/demos/pc/app/select/size.spec.ts (2)

8-8: LGTM! Verify selector change aligns with component updates.

The selector change from nth(0) to nth(1) appears correct based on the component modifications mentioned in the summary.

Let's verify the component structure to ensure the selector targets the correct element:


21-21: Verify the medium size height specification.

The medium size height is now explicitly set to 40px, which is significantly larger than the default size (32px). Please verify this is the intended height for medium-sized selects.

Let's check the design specifications and other medium-sized components:

Also applies to: 26-27

✅ Verification successful

Let me analyze the CSS structure and height specifications to verify the medium size height value.


Height specification of 40px for medium-sized select is correct

The height value of 40px for medium-sized select components is consistent across the codebase. Multiple components including select, input, time-picker, cascader, and button all use the same 40px height specification for their medium size variant, as evidenced by their respective test files:

  • select: height: 40px
  • input: height: 40px
  • time-picker: height: 40px
  • cascader: height: 40px
  • button: height: 40px
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other medium-sized component height specifications
# Look for height-related CSS for medium-sized components

rg "tiny-.*-medium.*height:|height:.*40px" --type css

Length of output: 275


Script:

#!/bin/bash
# Let's search for size-related CSS classes and height specifications in the codebase
# First, let's look for select-related CSS files
fd -e css -e scss | xargs rg -l "tiny-select"

# Then, let's look specifically for medium size related styles
rg "medium.*height|height.*medium" --type css -A 2 -B 2

# Also search for size-related constants or configurations
fd "select|size" -e ts -e js | xargs rg "medium.*size|size.*medium|height.*40"

Length of output: 5394

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

41-41: LGTM! Good use of CSS variables.

The switch to CSS variables for padding improves maintainability and theming flexibility. The removal of fixed height/line-height constraints (as per the summary) allows for better content adaptability.


57-57: LGTM! Good use of semantic variable naming.

The changes maintain consistency with CSS variables while using semantic naming (e.g., border-color-divider) that clearly indicates the purpose of each style property.

Also applies to: 60-60


Line range hint 1-100: Verify PR title and type.

The PR title contains "dosc" suggesting documentation changes, but this file contains purely styling changes. Consider updating the PR title and type to accurately reflect the nature of the changes.

Comment on lines 27 to 28
--tv-TimeRange-header-line-height: 48px;

Copy link

@coderabbitai coderabbitai bot Nov 4, 2024

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use existing height variable instead of fixed value.

Consider using var(--tv-size-height-xl) instead of the hardcoded 48px to maintain consistency with the design system and improve maintainability.

--- --tv-TimeRange-header-line-height: 48px;
+++ --tv-TimeRange-header-line-height: var(--tv-size-height-xl, 48px);
📝 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-TimeRange-header-line-height: 48px;
--tv-TimeRange-header-line-height: var(--tv-size-height-xl, 48px);

Copy link
Member

Choose a reason for hiding this comment

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

这里可以用变量:var(--tv-TimeRange-header-height)

Copy link

Choose a reason for hiding this comment

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

@zzcr,感谢您的建议。您说得对,应当使用变量 var(--tv-TimeRange-header-height) 来替代硬编码的 48px,以保持与设计系统的一致性。

修改如下:

--- --tv-TimeRange-header-line-height: 48px;
+++ --tv-TimeRange-header-line-height: var(--tv-TimeRange-header-height);

✏️ Learnings added
Learnt from: zzcr
PR: opentiny/tiny-vue#2481
File: packages/theme/src/time-range/vars.less:27-28
Timestamp: 2024-11-04T09:35:12.932Z
Learning: 在 `packages/theme/src/time-range/vars.less` 文件中,应使用 `var(--tv-TimeRange-header-height)` 作为 `--tv-TimeRange-header-line-height` 的值,以保持一致性。

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@MomoPoppy MomoPoppy changed the title optimization demo and modify style for time-range fix(time-range): [date-picker,time-picker,select,action-menu] optimization demo and modify style for time-range Nov 4, 2024
@github-actions github-actions bot added the bug Something isn't working label Nov 4, 2024
@MomoPoppy
Copy link
Collaborator Author

image

@MomoPoppy MomoPoppy added the documentation Improvements or additions to documentation label Nov 4, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Nov 5, 2024
@zzcr zzcr merged commit a1f6f03 into opentiny:release-3.19.0 Nov 5, 2024
4 checks passed
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