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: variable convergence #1087

Open
wants to merge 3 commits into
base: refactor/develop
Choose a base branch
from

Conversation

xuanlid
Copy link
Contributor

@xuanlid xuanlid commented Jan 27, 2025

English | 简体中文

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)
  • Built its own designer, fully self-validated

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:

Background and solution

主要修改:页面JS,schema,物料(组件/区块),页面管理,状态管理,大纲树

a.检查每个模块插件包,用到的色值全都改成模块变量
b.检查模块变量有没有被非该模块的vue文件使用,修改非该模块的vue文件使用的变量
c.将模块变量回归到各个模块里面
d.模块变量回归模块后,再排查一遍该模块有没有直接使用--te-common的,有的话,需要转成模块变量。去保证整个链路是这样的: base/common less -> module less -> vue文件

common中的变量改为common中的变量,不使用模块变量

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

  • Styling Updates

    • Introduced new CSS variables across multiple plugins to enhance theming and design consistency.
    • Updated color schemes for Materials, Page, Schema, and Script plugins.
    • Standardized color naming conventions from --ti- to --te- prefix.
  • New Features

    • Added centralized style variable management for easier theme customization.
    • Improved visual design with more precise color and background configurations.
  • Performance

    • Minimal impact on application performance.
    • Lightweight styling updates without changing component logic.
  • Compatibility

    • Maintains existing component functionality.
    • Seamless integration with current design system.

Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

Warning

Rate limit exceeded

@xuanlid has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5548442 and 80e621b.

📒 Files selected for processing (3)
  • packages/plugins/tree/index.js (1 hunks)
  • packages/plugins/tree/src/Main.vue (2 hunks)
  • packages/plugins/tree/src/styles/vars.less (1 hunks)

Walkthrough

This pull request introduces a comprehensive styling update across multiple plugins, focusing on standardizing color variables and improving visual consistency. The changes involve importing new LESS stylesheets (vars.less) in various plugin index files and updating component-level styles to use new, more semantically named CSS variables. The modifications span materials, page, schema, and script plugins, indicating a systematic approach to design system refinement.

Changes

File Path Change Summary
packages/plugins/materials/index.js Added import for ./src/styles/vars.less
packages/plugins/materials/src/styles/vars.less Added new CSS custom properties for component colors
Multiple Vue components in materials/src/meta/block/ Updated color variables from --ti-* to --te-materials-*
packages/plugins/page/index.js Added import for ./src/styles/vars.less
packages/plugins/page/src/styles/vars.less Added new CSS custom properties for page management colors
Multiple Vue components in page/src/ Updated color variables from --ti-* to --te-page-manage-*
packages/plugins/schema/index.js Added import for ./src/styles/vars.less
packages/plugins/schema/src/styles/vars.less Added new CSS custom properties for schema panel colors
packages/plugins/script/index.js Added import for ./src/styles/vars.less
packages/plugins/script/src/styles/vars.less Added new CSS custom properties for script panel colors
packages/plugins/state/index.js Added import for ./src/styles/vars.less
packages/plugins/state/src/styles/vars.less Added new CSS custom properties for state management colors

Possibly related PRs

  • feat: update block filters UI in materials #914: The changes in this PR involve updates to the block filters UI, specifically modifying the filtering interface to improve usability, which relates to the styling changes in the main PR that introduced a new stylesheet for consistent styling across components.
  • fix: block list filters not clearing #1006: This PR addresses the issue of block list filters not clearing, which is relevant to the main PR's focus on styling and organization of components, ensuring that the UI reflects the correct state after operations.
  • feat: Modify css variables #1051: The modifications to CSS variables in this PR align with the main PR's updates to styling, as both aim to standardize and improve the visual consistency of the application.

Suggested Reviewers

  • hexqi
  • lichunn

Poem

🐰 Styling rabbits hop with glee,
Variables dancing, now so free!
From ti to te, colors bright,
Our design system shines just right!
Code consistency, our delight! 🎨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 enhancement New feature or request refactor-main refactor/develop branch feature labels Jan 27, 2025
Copy link
Contributor

@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

🧹 Nitpick comments (6)
packages/plugins/materials/src/styles/vars.less (1)

1-44: Well-organized variable definitions with clear component grouping!

The variables are well-structured and properly reference common theme variables. The organization by component type (list, detail, group, etc.) makes it easy to maintain.

A few suggestions to improve consistency:

  1. Consider adding a comment header describing the purpose of this file.
  2. Consider grouping related variables using CSS custom property naming patterns, e.g.:
 // 区块详情
-  --te-materials-block-detail-bg-color: var(--te-common-bg-default);
-  --te-materials-block-detail-text-color: var(--te-common-text-primary);
+  --te-materials-block-detail-color-bg: var(--te-common-bg-default);
+  --te-materials-block-detail-color-text: var(--te-common-text-primary);
packages/plugins/page/src/styles/vars.less (3)

7-9: Consider revising these variable mappings for better semantics.

  1. The tip-text-dim-color maps to --te-common-text-primary, which seems inconsistent with its "dim" designation. Consider mapping it to --te-common-text-weaken instead.
  2. Both tree-related background colors map to the same value. Consider consolidating them into a single variable to reduce redundancy.
-  --te-page-manage-tip-text-dim-color: var(--te-common-text-primary);
-  --te-page-manage-tree-text-background-color: var(--te-common-bg-default);
-  --te-page-manage-tree-node-background-color: var(--te-common-bg-default);
+  --te-page-manage-tip-text-dim-color: var(--te-common-text-weaken);
+  --te-page-manage-tree-background-color: var(--te-common-bg-default);

1-23: Improve organization with semantic grouping and documentation.

Consider reorganizing the variables into logical groups with comments for better maintainability. Here's a suggested structure:

 :root {
+  /* General */
   --te-page-manage-text-color: var(--te-common-text-secondary);
   --te-page-manage-icon-color: var(--te-common-icon-secondary);
+
+  /* Input Fields */
   --te-page-manage-input-background-color: var(--te-common-bg-default);
   --te-page-manage-input-border-color: var(--te-common-border-default);
   --te-page-manage-input-head-text-color: var(--te-common-text-primary);
   --te-page-manage-input-or-output-text-color: var(--te-common-text-secondary);
+
+  /* Tree Component */
   --te-page-manage-tree-node-background-color: var(--te-common-bg-default);
   --te-page-manage-tree-node-hover-background-color: var(--te-common-bg-container);
+
   /* ... continue for other components */
 }

1-23: Great job implementing a robust color system!

The implementation successfully:

  • Converts all colors to module variables
  • Maintains proper variable flow from common to module-specific variables
  • Provides good abstraction for theme customization

This architecture will make it easier to:

  • Implement dark mode or other theme variations
  • Maintain consistency across the application
  • Make global color scheme updates
packages/plugins/script/src/Main.vue (1)

150-150: Consider renaming the dot indicator variable.

The variable name --te-plugin-js-dot-color is somewhat generic. Consider a more semantic name that reflects its purpose as an unsaved changes indicator, such as --te-plugin-js-unsaved-indicator-color.

packages/plugins/script/src/styles/vars.less (1)

1-9: Consider grouping and documenting variables.

While the variables follow the correct naming pattern, consider:

  1. Grouping related variables (e.g., panel-related, border-related)
  2. Adding comments for all variables, not just the panel title
  3. Documenting the purpose of each variable and when to use them

Example structure:

:root {
  // Panel appearance
  --te-plugin-js-panel-bg-color: var(--te-common-bg-default);
  --te-plugin-js-panel-shadow-color: var(--te-common-shadow-panel);
  --te-plugin-js-panel-title-color: var(--te-common-text-primary);

  // Borders and dividers
  --te-plugin-js-common-border-color: var(--te-common-border-divider);

  // Status indicators
  --te-plugin-js-dot-color: var(--te-common-color-error); // Indicates unsaved changes
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2883f1 and cc309fe.

📒 Files selected for processing (25)
  • packages/plugins/materials/index.js (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockDetail.vue (3 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroup.vue (3 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue (2 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupFilters.vue (3 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupSort.vue (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupTransferPanel.vue (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockPanel.vue (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (1 hunks)
  • packages/plugins/materials/src/meta/component/src/Main.vue (2 hunks)
  • packages/plugins/materials/src/styles/vars.less (1 hunks)
  • packages/plugins/page/index.js (1 hunks)
  • packages/plugins/page/src/PageGeneral.vue (2 hunks)
  • packages/plugins/page/src/PageHome.vue (1 hunks)
  • packages/plugins/page/src/PageInputOutput.vue (3 hunks)
  • packages/plugins/page/src/PageTree.vue (3 hunks)
  • packages/plugins/page/src/Tree.vue (3 hunks)
  • packages/plugins/page/src/styles/vars.less (1 hunks)
  • packages/plugins/schema/index.js (1 hunks)
  • packages/plugins/schema/src/Main.vue (4 hunks)
  • packages/plugins/schema/src/styles/vars.less (1 hunks)
  • packages/plugins/script/index.js (1 hunks)
  • packages/plugins/script/src/Main.vue (4 hunks)
  • packages/plugins/script/src/styles/vars.less (1 hunks)
✅ Files skipped from review due to trivial changes (19)
  • packages/plugins/page/index.js
  • packages/plugins/materials/index.js
  • packages/plugins/schema/index.js
  • packages/plugins/materials/src/meta/block/src/BlockGroupSort.vue
  • packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue
  • packages/plugins/page/src/PageHome.vue
  • packages/plugins/materials/src/meta/block/src/BlockPanel.vue
  • packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue
  • packages/plugins/materials/src/meta/component/src/Main.vue
  • packages/plugins/page/src/PageTree.vue
  • packages/plugins/page/src/PageInputOutput.vue
  • packages/plugins/page/src/Tree.vue
  • packages/plugins/materials/src/meta/block/src/BlockGroupTransferPanel.vue
  • packages/plugins/materials/src/meta/block/src/BlockGroupFilters.vue
  • packages/plugins/script/index.js
  • packages/plugins/schema/src/styles/vars.less
  • packages/plugins/materials/src/meta/block/src/BlockDetail.vue
  • packages/plugins/page/src/PageGeneral.vue
  • packages/plugins/schema/src/Main.vue
🔇 Additional comments (9)
packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue (1)

77-77: Color variables properly converted to module-specific variables!

The icon color states now use module-specific variables, improving maintainability and theme consistency:

  • Default: --te-materials-block-group-arrange-icon-color
  • Hover: --te-materials-block-group-arrange-icon-hover-color
  • Active: --te-materials-block-group-arrange-icon-active-color

Also applies to: 86-86, 89-89

packages/plugins/materials/src/meta/block/src/BlockGroup.vue (3)

Line range hint 411-422: Block editing styles properly use module variables!

The border and SVG colors now use module-specific variables:

  • Border: --te-materials-block-group-item-border-color
  • SVG: --te-materials-block-group-svg-color

429-429: Consistent use of border color variable!

The underline style uses the same module-specific border color variable, maintaining consistency.


469-469: Popper text colors properly use module variables!

The popper text colors now use module-specific variables:

  • Title: --te-materials-block-group-popper-title-color
  • Content: --te-materials-block-group-popper-content-color

Also applies to: 475-475

packages/plugins/page/src/styles/vars.less (1)

1-23: LGTM! Well-structured variable naming convention.

The variables follow a consistent and clear naming pattern that effectively prevents naming conflicts and clearly indicates their scope and purpose.

packages/plugins/script/src/Main.vue (3)

112-113: LGTM: Panel styling follows the module variable pattern.

The background and shadow variables now correctly use the module-specific prefix --te-plugin-js-* instead of generic variables.


124-124: Consistent border color usage across component.

Good consistency in using --te-plugin-js-common-border-color for both the header border and editor container border.

Also applies to: 165-165


132-133: Mixed variable usage in title styling.

While the color uses the module-specific --te-plugin-js-panel-title-color, the font weight still uses the base variable --te-base-font-weight-bold. Consider if this is intentional or if font weight should also be module-specific.

Let's verify if other plugins follow the same pattern for font weights:

✅ Verification successful

Font weight usage follows codebase convention

The mixed variable usage is intentional and consistent with the rest of the codebase. All plugins use base font-weight variables (--te-base-font-weight-*) while having module-specific color variables, suggesting this is a deliberate architectural decision to maintain consistent typography while allowing for module-specific colors.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for font weight variable usage across plugins
rg --type=vue --type=less "font-weight: var\(--te-(base|plugin)" packages/plugins/

Length of output: 112


Script:

#!/bin/bash
# Search for font weight variable usage without file type restrictions
rg "font-weight: var\(--te-(base|plugin)" packages/plugins/ -A 2

# Search for font weight variable definitions
rg "(?:--|@)te-.*font-weight" packages/plugins/

Length of output: 1922

packages/plugins/script/src/styles/vars.less (1)

2-4: Verify variable inheritance across themes.

These variables inherit from common variables. Let's verify that all referenced common variables are defined across all supported themes to prevent undefined values.

Also applies to: 7-8

✅ Verification successful

Common variables are properly defined across themes

The referenced common variables (--te-common-shadow-panel, --te-common-bg-default, --te-common-border-divider) are properly defined in both light and dark themes with appropriate values, ensuring consistent theming support.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the referenced common variables in theme files
echo "Checking common variables used in vars.less:"
common_vars=(
  "--te-common-shadow-panel"
  "--te-common-bg-default"
  "--te-common-border-divider"
  "--te-common-text-primary"
  "--te-common-color-error"
)

for var in "${common_vars[@]}"; do
  echo "Checking $var:"
  rg "$var" packages/theme/
done

Length of output: 3169


Script:

#!/bin/bash
# Search for the referenced common variables in theme files
echo "Checking common variables used in vars.less:"
echo "----------------------------------------"

# Use fd to find all CSS and Less files in the theme package
fd "\.(css|less)$" packages/theme/ -x rg -A 1 -B 1 \
  -e "\\-\\-te-common-shadow-panel" \
  -e "\\-\\-te-common-bg-default" \
  -e "\\-\\-te-common-border-divider" \
  {} || true

# Also search in any potential theme configuration files
fd "theme|style" packages/theme/ -x rg -A 1 -B 1 \
  -e "\\-\\-te-common-shadow-panel" \
  -e "\\-\\-te-common-bg-default" \
  -e "\\-\\-te-common-border-divider" \
  {} || true

Length of output: 13856

Copy link
Contributor

@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

🧹 Nitpick comments (1)
packages/plugins/state/src/styles/vars.less (1)

1-21: Well-organized CSS variables with consistent naming!

The variables are logically grouped and follow a consistent naming convention with the --te-state- prefix. This promotes maintainability and reusability across the state management components.

Consider adding comments to document the purpose and usage of each variable group. For example:

 :root {
+  /* Button styles */
   --te-state-add-btn-border-color: var(--te-common-border-default);
   --te-state-add-btn--hover-border-color: var(--te-common-border-hover);
   --te-state-add-btn--icon-color: var(--te-common-icon-secondary);

+  /* Common element styles */
   --te-state-common-text-color: var(--te-common-text-primary);
   /* ... */
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc309fe and 5548442.

📒 Files selected for processing (9)
  • packages/plugins/state/index.js (1 hunks)
  • packages/plugins/state/src/CreateStore.vue (2 hunks)
  • packages/plugins/state/src/CreateVariable.vue (3 hunks)
  • packages/plugins/state/src/DataSourceList.vue (5 hunks)
  • packages/plugins/state/src/EditorI18nTool.vue (1 hunks)
  • packages/plugins/state/src/Main.vue (4 hunks)
  • packages/plugins/state/src/StateFullscreenHead.vue (1 hunks)
  • packages/plugins/state/src/StateTips.vue (1 hunks)
  • packages/plugins/state/src/styles/vars.less (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • packages/plugins/state/index.js
  • packages/plugins/state/src/StateTips.vue
  • packages/plugins/state/src/EditorI18nTool.vue
  • packages/plugins/state/src/CreateStore.vue
  • packages/plugins/state/src/StateFullscreenHead.vue
  • packages/plugins/state/src/DataSourceList.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: push-check
🔇 Additional comments (5)
packages/plugins/state/src/Main.vue (3)

407-409: LGTM! Button styling uses new state-specific variables.

The button border and icon colors now use the state-specific variables, maintaining consistency with the new styling system.

Also applies to: 415-415


427-429: LGTM! Title styling uses new state-specific variables.

The title's text color, font weight, and border color now use the state-specific variables.


458-460: LGTM! Panel styling uses new state-specific variables.

The panel's shadow, border, background, and text colors now use the state-specific variables.

Also applies to: 473-475

packages/plugins/state/src/CreateVariable.vue (2)

442-443: LGTM! Tips styling uses new state-specific variables.

The tips section's background and text colors now use the state-specific variables.


464-464: LGTM! Form elements use new state-specific variables.

The form labels and description text colors now use the state-specific variables, maintaining consistency with the new styling system.

Also applies to: 468-468, 484-484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor-main refactor/develop branch feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant