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(pager): [pager] refactor pager style #2162

Merged
merged 6 commits into from
Sep 23, 2024
Merged

refactor(pager): [pager] refactor pager style #2162

merged 6 commits into from
Sep 23, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Sep 20, 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 styling options for the pager component with new CSS variables and improved design consistency.
    • Added new variables for better visual feedback on disabled, hover, and active states within the pager component.
  • Bug Fixes

    • Updated various styling properties to ensure consistent behavior across different states of the pager component.
  • Refactor

    • Renamed CSS variables to align with a new naming convention, improving the overall structure and clarity of the styling system.
    • Consolidated and streamlined the number of CSS variables for the pager component.

Copy link

coderabbitai bot commented Sep 20, 2024

Walkthrough

The pull request involves a significant renaming and restructuring of CSS variables in the pager component's vars.less file. The previous variable prefix --ti- has been replaced with --tv-, reflecting a new naming convention. This update includes modifications to various styling variables related to text colors, sizes, and states, aiming for a more organized and cohesive design system.

Changes

File Change Summary
packages/theme/src/pager/vars.less Restructured and renamed CSS variables, consolidating many under the new --tv- prefix.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • zzcr

🐰 In the land of styles, a change takes flight,
With colors and sizes, everything feels right.
The pager now dances with a brand new name,
From ti- to tv-, it’s all part of the game!
Hopping through code, with joy we proclaim,
A vibrant new look, and it’s never the same! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ec8417 and d836555.

Files selected for processing (1)
  • packages/theme/src/pager/vars.less (1 hunks)
Additional comments not posted (9)
packages/theme/src/pager/vars.less (9)

17-19: LGTM!

The variable declarations and assigned values look good. The naming convention is consistent, and referencing other CSS variables promotes reusability.


25-33: Looks good!

The variable declarations for pager icons are well-structured and cover various states. The naming convention is consistent, and referencing other CSS variables promotes reusability.


35-45: Looks good!

The variable declarations for pager borders and background colors are well-structured and cover various states. The naming convention is consistent, and referencing other CSS variables promotes reusability.


47-49: LGTM!

The variable declarations for pager height and vertical padding are consistent with the naming convention and reference other CSS variables for reusability.


59-71: Looks good!

The variable declarations for pager page item styles are well-structured and cover various states and properties. The naming convention is consistent, and the assigned values are appropriate.


73-75: LGTM!

The variable declarations for pager page item minimum width and horizontal padding are consistent with the naming convention and use appropriate values.


78-88: Looks good!

The variable declarations for pager previous and next button styles are well-structured and cover relevant properties. The naming convention is consistent, and the assigned values are appropriate.


91-93: LGTM!

The variable declarations for pager input border radius and height are consistent with the naming convention and reference other CSS variables for reusability.


99-107: Looks good!

The variable declarations for pager size dropdown styles are well-structured and cover relevant properties. The naming convention is consistent, and the assigned values are appropriate.


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

[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

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 (3)
packages/theme/src/pager/index.less (1)

37-39: Consider using a CSS variable for the margin value.

To maintain consistency and flexibility, consider defining a CSS variable for the margin value instead of using a hardcoded value.

- margin-left: 16px;
+ margin-left: var(--tv-Pager-group-margin-left);
packages/theme/src/pager/vars.less (2)

79-79: Clarify variable naming for custom prev/next text color

The variable --tv-Pager-custom-prev-next-text-color defined in line 79 may benefit from clearer naming to indicate its purpose more precisely.

Consider renaming it to --tv-Pager-prev-next-custom-text-color or --tv-Pager-prev-next-text-color-custom to better reflect that it pertains to the custom text color of the previous and next buttons.

Apply this diff if you choose to rename:

---tv-Pager-custom-prev-next-text-color: var(--tv-color-text-link);
+--tv-Pager-prev-next-text-color-custom: var(--tv-color-text-link);

Ensure that you update all instances where this variable is used.


81-87: Group margin variables for better readability

Lines 81 to 87 define margin variables for the previous and next buttons. Grouping related variables and adding descriptive comments can enhance readability.

Consider organizing the variables as follows:

// Previous button margins
--tv-Pager-prev-margin-left: var(--tv-space-xl);
--tv-Pager-prev-margin-right: var(--tv-space-md);

// Next button margins
--tv-Pager-next-margin-left: var(--tv-space-md);
--tv-Pager-next-margin-right: 0;

This grouping, along with comments, clarifies the purpose of each variable.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 981fe15 and 15da6f7.

Files selected for processing (4)
  • .vscode/settings.json (1 hunks)
  • packages/theme/src/pager/index.less (12 hunks)
  • packages/theme/src/pager/old-theme.js (1 hunks)
  • packages/theme/src/pager/vars.less (1 hunks)
Additional comments not posted (6)
.vscode/settings.json (1)

84-91: LGTM!

The new tag is a valid addition to the "better-comments" extension settings. It provides a visually distinct style for specific comments without affecting the project code.

packages/theme/src/pager/index.less (4)

28-29: LGTM!

The changes to the padding and color properties are consistent with the new CSS variable naming convention.


35-36: LGTM!

The change to the font size property is consistent with the new CSS variable naming convention.


48-49: LGTM!

The changes to various CSS properties are consistent with the new CSS variable naming convention. The updates follow a clear pattern and maintain the overall styling of the pager component.

Also applies to: 52-52, 62-62, 67-68, 73-73, 77-84, 88-88, 92-92, 97-100, 103-103, 111-111, 116-116, 122-125


146-156: LGTM!

The changes to various CSS properties throughout the file are consistent with the new CSS variable naming convention. The updates maintain the existing styling while adhering to the new variable names.

Also applies to: 163-163, 170-177, 183-186, 194-195, 198-198, 200-200, 217-218, 222-223, 231-246, 251-251, 255-256, 261-262, 265-265, 277-277, 281-281, 287-288, 297-297, 300-300, 316-319, 327-327, 332-332, 337-337, 340-340, 345-345, 374-379, 392-392, 398-398, 402-404, 415-421, 426-427, 442-442, 446-447, 452-453, 458-458, 462-462, 483-483, 488-488, 490-490, 494-494, 497-497, 501-501, 506-509, 514-514, 520-520, 528-528

packages/theme/src/pager/vars.less (1)

89-94: Verify input height variables for consistency

Lines 92 and 94 define the input heights for default and mini sizes. Ensure that these sizes correspond correctly to the intended design specifications.

Run the following script to check the usage of these variables across the codebase:

This will help confirm that the variables are applied consistently in the styles.

Verification successful

To gather the necessary information for a complete verification, I'll run two more scripts.


Input height variables are consistent with design specifications

The verification process confirms that the input height variables for both default and mini sizes are correctly defined and consistently used across the pager component styles:

  • Default size (--tv-Pager-input-height) uses --tv-size-height-md (32px)
  • Mini size (--tv-Pager-input-height-xs) uses --tv-size-height-xs (24px)

These values align with common design systems for medium and mini sizes, and their application in the styles is appropriate for maintaining consistent sizing across the pager component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the input height variables are used consistently.

# Expect: Variables should be used in the pager component styles.
rg --type less "\-\-tv\-Pager\-input\-height"

Length of output: 1077


Script:

#!/bin/bash
# Search for definitions of --tv-size-height-md and --tv-size-height-xs
rg --type less "\-\-tv\-size\-height\-(md|xs):"

# Examine the context where --tv-Pager-input-height-xs is used
rg --type less -C 5 "\-\-tv\-Pager\-input\-height\-xs" packages/theme/src/pager/index.less

Length of output: 716

Comment on lines +2 to +43
'tv-Pager-sizes-num-margin-right': 'var(--ti-common-space-base, 4px)',
'tv-Pager-mini-min-width': '18px',
'tv-Pager-selector-padding-y': 'var(--ti-common-space-3x, 12px)',
'tv-Pager-input-btn-padding-horizontal': '6px',
'tv-Pager-sizes-input-hover-text-color': 'var(--ti-common-color-info-normal, #252b3a)',
'tv-Pager-prev-next-hover-bg-color': 'var(--ti-common-color-hover-background, #f2f5fc)',
'tv-Pager-dot-is-popup-svg-font-size': '14px',
'tv-Pager-svg-font-size': 'var(--tv-Pager-font-size)',
'tv-Pager-total-svg-fill-color': 'var(--ti-common-color-info-normal, #252b3a)',
'tv-Pager-total-line-height': '24px',
'tv-Pager-total-height': '24px',
'tv-Pager-total-font-size': '12px',
'tv-Pager-btn-svg-fill-color': 'var(--ti-common-color-info-normal, #252b3a)',
'tv-Pager-next-margin-left': '6px',
'tv-Pager-next-margin-right': '6px',
'tv-Pager-next-padding-right': '4px',
'tv-Pager-prev-margin-right': '4px',
'tv-Pager-prev-margin-left': '4px',
'tv-Pager-prev-padding-right': '6px',
'tv-Pager-prev-padding-left': '6px',
'tv-Pager-goto-btn-text-hover-color': 'var(--ti-common-color-text-highlight, #526ecc)',
'tv-Pager-poplist-item-min-height': '30px',
'tv-Pager-poplist-item-selected-bg-color': 'var(--ti-common-color-selected-background, #5e7ce0)',
'tv-Pager-poplist-item-hover-text-color': 'var(--ti-common-color-text-highlight, #526ecc)',
'tv-Pager-poplist-item-hover-bg-color': 'var(--ti-common-color-hover-background, #f2f5fc)',
'tv-Pager-li-item-hover-font-weight': 'var(--ti-common-font-weight-normal)',
'tv-Pager-li-item-hover-text-color': 'var(--ti-common-color-text-highlight, #526ecc)',
'tv-Pager-li-border-radius': 'var(--ti-common-border-radius-normal, 2px)',
'tv-Pager-poplist-item-padding-horizontal': 'var(--ti-common-space-6, 6px)',
'tv-Pager-input-padding-horizontal': '0',
'tv-Pager-input-width': '40px',
'tv-Pager-min-width': 'auto',
'tv-Pager-height': 'var(--ti-common-size-height-mini, 24px)',
'tv-Pager-normal-text-padding-left': 'calc(var(--ti-common-space-base) * 3 + 2px, 14px)',
'tv-Pager-mini-font-size': 'var(--ti-common-font-size-base, 12px)',
'tv-Pager-input-padding-y': '10px',
'tv-Pager-input-height': 'var(--ti-common-size-height-mini, 24px)',
'tv-Pager-input-border-color': 'var(--ti-common-color-border, #adb0b8)',
'tv-Pager-active-font-weight': 'var(--ti-common-font-weight-normal)',
'tv-Pager-active-bg-color': 'var(--ti-common-color-primary-normal, #5e7ce0)',
'tv-Pager-active-font-color': 'var(--ti-common-color-text-white, #fff)',
'tv-Pager-primary-bg-color': 'var(--ti-common-color-primary-normal, #5e7ce0)'
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Inconsistent naming convention detected. Consider reverting or extending the changes.

The renaming from 'ti-pager-' to 'tv-Pager-' in packages/theme/src/pager/old-theme.js appears to be an isolated change. This inconsistency may lead to potential issues:

  1. Other theme files (infinity-theme, aurora-theme) still use the 'ti-pager-' prefix.
  2. No imports or uses of old-theme.js were found, raising questions about its purpose and integration.
  3. Lack of documentation or comments about this renaming process.

To address these issues:

  • Either revert the changes in old-theme.js to maintain consistency with other theme files, or
  • Extend the renaming process to all relevant files in the project.
  • Add documentation explaining the rationale behind the naming change if it's intentional.

Please review and clarify the intended scope of this renaming to ensure consistency across the codebase.

Analysis chain

LGTM! Verify the usage of the renamed properties.

The renaming of properties from ti- to tv- prefix is consistent across the object and does not introduce any functional changes. However, ensure that all references to these properties in the codebase have been updated to use the new naming convention.

Run the following script to verify the usage of the renamed properties:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the old property names are not used in the codebase.

# Test: Search for the old property names. Expect: No occurrences.
rg --type js $'ti-pager-'

Length of output: 2544


Script:

#!/bin/bash
# Description: Check for new naming convention and usage of old-theme.js

# Search for the new naming convention
echo "Searching for new naming convention 'tv-Pager-':"
rg --type js 'tv-Pager-'

echo -e "\nSearching for imports or uses of old-theme.js:"
rg --type js 'old-theme\.js'

echo -e "\nSearching for comments about renaming process:"
rg --type js -i 'renaming|refactor.*pager'

Length of output: 4664

// 分页输入框纵向内边距
--ti-pager-input-padding-vertical: var(--ti-common-space-3x);
// 分页数字字体
--tv-Pager-number-font-family: arial, helvetica, sans-serif;
Copy link

Choose a reason for hiding this comment

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

Capitalize font family names for standard fonts

In line 15, the font family names are all in lowercase. According to CSS conventions, standard font family names should be capitalized to ensure consistency and prevent any potential issues with font rendering.

Apply this diff to capitalize the font family names:

--tv-Pager-number-font-family: arial, helvetica, sans-serif;
+--tv-Pager-number-font-family: Arial, Helvetica, sans-serif;
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-Pager-number-font-family: arial, helvetica, sans-serif;
--tv-Pager-number-font-family: Arial, Helvetica, sans-serif;

Comment on lines 70 to 72
--tv-Pager-page-item-min-width: 32px;
// 小尺寸分页页码项最小宽度
--tv-Pager-min-width-xs: 24px;
Copy link

Choose a reason for hiding this comment

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

Ensure consistent naming for minimum width variables

At line 70, the variable is named --tv-Pager-page-item-min-width, whereas at line 72, the variable is --tv-Pager-min-width-xs. The inconsistency in naming may lead to confusion.

For consistency, consider renaming --tv-Pager-min-width-xs to --tv-Pager-page-item-min-width-xs, aligning it with the naming convention used in line 70.

Apply this diff to rename the variable:

---tv-Pager-min-width-xs: 24px;
+--tv-Pager-page-item-min-width-xs: 24px;

Remember to update any references to this variable in other parts of the codebase.

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-Pager-page-item-min-width: 32px;
// 小尺寸分页页码项最小宽度
--tv-Pager-min-width-xs: 24px;
--tv-Pager-page-item-min-width: 32px;
// 小尺寸分页页码项最小宽度
--tv-Pager-page-item-min-width-xs: 24px;

Comment on lines 23 to 27
--tv-Pager-text-color-disabled: var(--tv-color-text-disabled);
// 分页二级文本颜色,页码项文本色
--tv-Pager-text-color-secondary: var(--tv-color-text-secondary);
// 分页禁用状态下字体颜色
--tv-Pager-disabled-text-color: var(--tv-color-text-disabled);
Copy link

Choose a reason for hiding this comment

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

Consolidate duplicate variables for disabled text color

Lines 23 and 27 define two variables for the disabled text color:

  • --tv-Pager-text-color-disabled
  • --tv-Pager-disabled-text-color

Both variables are assigned the same value var(--tv-color-text-disabled). This redundancy can lead to confusion and makes maintenance more difficult.

Consider consolidating these into a single variable to improve clarity and maintainability. If both are necessary, ensure that their purposes are clearly differentiated in the comments.

Apply this diff to remove the duplicate variable:

-// 分页禁用状态下字体颜色
---tv-Pager-disabled-text-color: var(--tv-color-text-disabled);

Alternatively, if both variables serve different purposes, update the comments to reflect their distinct uses.

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-Pager-text-color-disabled: var(--tv-color-text-disabled);
// 分页二级文本颜色,页码项文本色
--tv-Pager-text-color-secondary: var(--tv-color-text-secondary);
// 分页禁用状态下字体颜色
--tv-Pager-disabled-text-color: var(--tv-color-text-disabled);
--tv-Pager-text-color-disabled: var(--tv-color-text-disabled);
// 分页二级文本颜色,页码项文本色
--tv-Pager-text-color-secondary: var(--tv-color-text-secondary);

--tv-Pager-input-height-xs: var(--tv-size-height-xs);
// -------跳至相关样式------
// 跳至左侧文字左侧内边距
--tv-Pager-goto-left-padding-left: var(--tv-space-xl);
Copy link

Choose a reason for hiding this comment

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

Correct redundancy in variable name

The variable --tv-Pager-goto-left-padding-left in line 97 contains redundant wording with "left" appearing twice.

Simplify the variable name to improve clarity:

---tv-Pager-goto-left-padding-left: var(--tv-space-xl);
+--tv-Pager-goto-padding-left: var(--tv-space-xl);

Update any references to this variable in the codebase to reflect the change.

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-Pager-goto-left-padding-left: var(--tv-space-xl);
--tv-Pager-goto-padding-left: var(--tv-space-xl);

@gimmyhehe gimmyhehe changed the title Cgm/pager refactor refactor(pager): [pager] refactor pager style Sep 21, 2024
@github-actions github-actions bot added the refactoring Refactoring label Sep 21, 2024
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