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(tabs): [tabs] refactor the Tabs Theme #2270

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

chenxi-20
Copy link
Collaborator

@chenxi-20 chenxi-20 commented Oct 15, 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 documentation for theme initialization and dynamic switching.
    • Expanded section on theme customization with custom CSS variables.
  • Bug Fixes

    • Improved rendering logic for demo components and API documentation.
  • Refactor

    • Updated CSS variable naming conventions from --ti- to --tv- for consistency across themes.
  • Style

    • Adjustments to styling for tabs and UI elements to align with new variable names.
  • Documentation

    • Comprehensive guide on replacing old CSS variable names with new ones, including a mapping table and replacement script.

@chenxi-20 chenxi-20 added the refactoring Refactoring (重构) label Oct 15, 2024
Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request primarily focus on updating the theme configuration and variable naming conventions within the TinyVue multi-topic framework. Key modifications include the introduction of a new prefix for CSS variables, transitioning from --ti- to --tv-, along with enhanced documentation on theme initialization and customization. Various files have been updated to reflect these changes, ensuring consistency across the framework. The updates also include improvements in component templates and styles to align with the new naming conventions.

Changes

File Path Change Summary
examples/sites/demos/pc/webdoc/theme-en.md Updated theme configuration, variable naming conventions, and expanded theme customization guide.
examples/sites/src/views/components/components.vue Enhanced template structure, script logic, and updated CSS variable names from --ti- to --tv-.
packages/theme/src/bulletin-board/index.less Updated CSS variable references for tabs styling, changing from --ti- to --tv-.
packages/theme/src/tabs/aurora-theme.js Modified keys in tinyTabsAuroraTheme object from ti- to tv-.
packages/theme/src/tabs/index.less Refactored styles with updated variable names from --ti- to --tv-.
packages/theme/src/tabs/old-theme.js Replaced keys in tinyTabsOldTheme from ti- to tv-, preserving values.
packages/theme/src/tabs/vars.less Updated LESS variables from --ti- to --tv-, added new variables, and streamlined code.
packages/theme/src/theme/infinity-theme/component-vars.js Renamed properties in infinityConcat object from ti- to tv-.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

In the garden where themes bloom bright,
A rabbit hops with pure delight.
With --tv- now, the colors sing,
New styles and names, oh what a fling!
From tabs to themes, all in a row,
TinyVue shines, watch it glow! 🌼✨


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

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

🧹 Outside diff range and nitpick comments (7)
packages/theme/src/tabs/old-theme.js (1)

2-2: Inconsistent capitalization in new key name

The new key name uses 'Tabs' with a capital 'T', which is different from the old naming convention. Consider using lowercase 'tabs' for consistency with other variable names, unless there's a specific reason for this capitalization.

examples/sites/demos/pc/webdoc/theme-en.md (3)

158-160: LGTM! Clear examples for manual variable replacement.

The new examples for manually replacing CSS variables are clear and helpful. They provide good guidance for users migrating to the new naming convention, especially for complex cases where old variables are split into multiple new ones.

Consider adding a brief introductory sentence before these examples to provide context, such as:
"Here are some examples of how to manually replace variables in different scenarios:"


310-323: LGTM! New variables added with correct prefix and split components.

The new variables --tv-Tabs-item-active-border, --tv-Tabs-item-border-bottom, and --tv-Tabs-icon-close-margin are correctly added with the new --tv- prefix. The split components for each variable provide more granular control over styles, which is beneficial for developers.

For consistency, consider using the same naming pattern for all split components. For example:

  • Change --tv-Tabs-item-bottom-border-weight to --tv-Tabs-item-border-bottom-weight
  • Change --tv-Tabs-item-bottom-border-style to --tv-Tabs-item-border-bottom-style
  • Change --tv-Tabs-item-bottom-border-color to --tv-Tabs-item-border-bottom-color

This would make the relationship between the main variable and its components more apparent.


Line range hint 1-323: LGTM! Comprehensive and well-structured theme documentation.

The overall structure and content of the theme documentation are excellent. The file provides clear instructions for using predefined themes, customizing themes, and migrating from old to new variable names. The addition of examples and explanations for special cases is particularly helpful.

Consider adding a table of contents at the beginning of the document to help users quickly navigate to specific sections, especially given the length and depth of the content.

packages/theme/src/theme/infinity-theme/component-vars.js (1)

83-103: Ensure comprehensive update of tab-related variable references.

While the changes in this file are clear and improve consistency, they may have a widespread impact on the codebase. To ensure a smooth transition:

  1. Perform a comprehensive search and replace across the entire codebase to update all references to these variables.
  2. Update any relevant documentation that mentions these CSS variables.
  3. If there's a migration guide or changelog, add an entry about this naming convention change.

To assist with the comprehensive update, you can use the following script to generate a list of files that need to be checked:

#!/bin/bash
# Description: Generate a list of files that potentially need updating

# Search for files containing any of the old variable names
rg --type css --type js --type vue --files-with-matches 'ti-tabs-' -g '!packages/theme/src/theme/infinity-theme/component-vars.js'

# Search for files containing template strings with the old variable names
rg --type js --type vue --files-with-matches "['`\"]ti-tabs-" -g '!packages/theme/src/theme/infinity-theme/component-vars.js'

This script will output a list of files that potentially need to be updated. Review each file and update the variable references as necessary.

packages/theme/src/tabs/index.less (2)

Line range hint 756-759: Update variable prefix from --ti- to --tv-.

The variable --ti-common-color-icon-white should be updated to --tv-common-color-icon-white to maintain consistency with the new naming convention.

Apply this diff to fix the variable prefix:

- fill: var(--ti-common-color-icon-white);
+ fill: var(--tv-common-color-icon-white);

367-367: Standardize code comments and remove internal annotations.

The code contains comments like // smb新增 and // aurora新增. Consider replacing them with more descriptive comments or removing them if they are no longer needed, to improve code readability and maintainability.

Also applies to: 373-373, 441-441, 482-482, 519-519, 531-531, 551-551, 681-681

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e2a5fba and 0fa4b5f.

📒 Files selected for processing (8)
  • examples/sites/demos/pc/webdoc/theme-en.md (2 hunks)
  • examples/sites/src/views/components/components.vue (1 hunks)
  • packages/theme/src/bulletin-board/index.less (1 hunks)
  • packages/theme/src/tabs/aurora-theme.js (1 hunks)
  • packages/theme/src/tabs/index.less (29 hunks)
  • packages/theme/src/tabs/old-theme.js (1 hunks)
  • packages/theme/src/tabs/vars.less (1 hunks)
  • packages/theme/src/theme/infinity-theme/component-vars.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/theme/src/bulletin-board/index.less
🧰 Additional context used
🔇 Additional comments (6)
packages/theme/src/tabs/old-theme.js (1)

2-16: Consistent renaming of theme variables

The changes in this file show a systematic renaming of all theme variables from the 'ti-' prefix to the 'tv-' prefix. This is consistent with the PR objectives of refactoring the Tabs Theme.

To ensure this change is consistent across the codebase, let's run the following verification:

examples/sites/demos/pc/webdoc/theme-en.md (1)

Line range hint 1-323: LGTM! Excellent update to the theme configuration documentation.

This update to the theme configuration documentation is comprehensive and well-executed. Key improvements include:

  1. Consistent use of the new --tv- prefix for CSS variables in examples.
  2. Clear instructions for using predefined themes and customizing themes.
  3. Detailed guide for replacing old variable names with new ones, including special cases.
  4. Addition of helpful examples for manual variable replacement.

These changes will greatly assist developers in working with TinyVue themes and migrating to the new naming conventions.

packages/theme/src/theme/infinity-theme/component-vars.js (1)

83-103: Approve renaming of tab-related CSS variables for improved consistency.

The renaming of tab-related CSS variables from 'ti-tabs-' to 'tv-Tabs-' improves naming consistency across the codebase. This change aligns with the project's refactoring efforts to standardize variable naming conventions.

To ensure these changes don't introduce any regressions, please run the following script to check for any remaining occurrences of the old variable names:

If the script returns any results, those occurrences should be updated to use the new variable names.

✅ Verification successful

Script encountered errors. Generating a corrected script to re-verify the codebase:


All old tab-related CSS variables have been successfully renamed. No remaining occurrences found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of old tab-related variable names

# Search for old variable names in CSS, JavaScript, and Vue files
rg --type css --type js --type vue 'ti-tabs-' -g '!packages/theme/src/theme/infinity-theme/component-vars.js'

# Search for usage of the old variable names in template strings
rg --type js --type vue "['`\"]ti-tabs-" -g '!packages/theme/src/theme/infinity-theme/component-vars.js'

Length of output: 231


Script:

#!/bin/bash
# Description: Check for any remaining occurrences of old tab-related variable names

# Search for old variable names in CSS, JavaScript, and Vue files by file extension
rg 'ti-tabs-' --glob '!packages/theme/src/theme/infinity-theme/component-vars.js' -g '*.css' -g '*.js' -g '*.vue'

Length of output: 113

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

13-179: Ensure All Variable Prefixes Are Updated from --ti- to --tv-

While this file has been updated, please verify that all references to the old --ti- prefixed variables throughout the codebase have been changed to --tv- to prevent any mismatches or styling issues.

Run the following script to check for any remaining --ti- variables:

examples/sites/src/views/components/components.vue (1)

776-778: CSS variables updated correctly

The CSS variables on lines 776-778 are correctly updated to use the new --tv- prefix and have appropriate values.

packages/theme/src/tabs/index.less (1)

23-23: Mixins are correctly applied to inject variables.

The .inject-Tabs-vars(); mixin is appropriately used to include the updated variables. This ensures that all the necessary variables are injected consistently.

Also applies to: 27-27

packages/theme/src/tabs/aurora-theme.js Show resolved Hide resolved
packages/theme/src/tabs/vars.less Outdated Show resolved Hide resolved
packages/theme/src/tabs/vars.less Outdated Show resolved Hide resolved
packages/theme/src/tabs/vars.less Outdated Show resolved Hide resolved
packages/theme/src/tabs/vars.less Outdated Show resolved Hide resolved
examples/sites/src/views/components/components.vue Outdated Show resolved Hide resolved
@zzcr zzcr merged commit a8fccf6 into dev Oct 16, 2024
3 checks passed
@kagol kagol deleted the refactor/tabs-theme-20241014 branch November 4, 2024 04:00
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