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: adjust the position of the marker point. #942

Closed
wants to merge 3 commits into from

Conversation

SonyLeo
Copy link
Contributor

@SonyLeo SonyLeo commented Dec 18, 2024

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

What is the current behavior?

设计器的 页面Schema 标记点的 大小 和 位置 显示错误
设计器的 页面JS 标记点的 大小 和 位置 显示错误

Issue Number: N/A

What is the new behavior?

设计器的 页面Schema 和 页面JS 标记点的 大小 和 位置 正常显示

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for schema parsing with user notifications for invalid schemas.
    • Improved layout for icon elements and updated editor functionality to reflect the current state accurately.
  • Bug Fixes

    • Adjusted vertical positioning of elements to improve overall layout.
  • Style

    • Updated styles for the .icon-wrap class and the .dots class within the save button for better visual representation, including changes in dimensions and positioning.

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces modifications to the Main.vue files in two plugins, focusing on improving the schema editor's functionality and the save button's appearance. Changes include updates to the template styling, enhancements to error handling for schema parsing, and adjustments to the save button's dimensions and positioning. The modifications ensure better user feedback when schema parsing fails and improve the synchronization between the editor's content and the page state.

Changes

File Change Summary
packages/plugins/schema/src/Main.vue - Added position: relative to .icon-wrap class
- Adjusted dimensions and positioning of .red class
- Enhanced saveSchema function with error handling
- Modified editorChange function for state synchronization
- Updated onActivated hook to sync page schema and trigger resize
packages/plugins/script/src/Main.vue - Adjusted dimensions and positioning of .dots class in save button
- No changes to script logic or lifecycle methods

Possibly related PRs

  • Ospp 2024/optimize schema generation #832: This PR modifies the Main.vue component, enhancing the chat interface and functionalities, which may relate to the overall schema management and editor interactions in the main PR.
  • fix: resolve some schema update issue #956: This PR resolves schema update issues, which directly relates to the changes in the saveSchema method in the main PR, enhancing schema handling and state management.

Suggested reviewers

  • hexqi
  • rhlin

Poem

🐰 In the realm of code, a schema takes flight
Parsing with care, making errors just right
Relative icons dance, layout so neat
Monaco whispers secrets, making changes complete
A rabbit's code review, with joy and delight! 🖥️


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae63be and d4d0ceb.

📒 Files selected for processing (2)
  • packages/plugins/schema/src/Main.vue (2 hunks)
  • packages/plugins/script/src/Main.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/plugins/script/src/Main.vue
  • packages/plugins/schema/src/Main.vue

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 bug Something isn't working refactor-main refactor/develop branch feature labels Dec 18, 2024
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 (2)
packages/plugins/schema/src/Main.vue (2)

Line range hint 89-98: Enhance schema validation and error messaging.

The current error handling could be more informative and robust. Consider these improvements:

  1. Add specific format requirements in the error message
  2. Implement detailed schema validation before saving
 const saveSchema = () => {
   const editorValue = string2Obj(app.refs.container.getEditor().getValue())
   if (!editorValue) {
     useNotify({
       type: 'error',
       title: 'schema 保存失败',
-      message: 'schema 解析异常,请确保格式正确'
+      message: 'schema 解析异常,请确保是有效的 JSON 格式,并包含必要的字段(properties, componentName 等)'
     })
     return
   }
+  
+  // Validate required schema structure
+  if (!editorValue.properties) {
+    useNotify({
+      type: 'error',
+      title: 'schema 验证失败',
+      message: '缺少必要的 properties 字段'
+    })
+    return
+  }

Line range hint 170-184: Position fix looks good! Consider using CSS custom properties for magic numbers.

The positioning fix correctly establishes the layout context for the marker. To improve maintainability, consider extracting the magic numbers into CSS custom properties.

 .icon-wrap {
   position: relative;
   .tiny-button {
-    width: 40px;
-    padding: 0;
-    min-width: 40px;
-    margin-right: 2px;
-    height: 24px;
-    line-height: 24px;
+    --button-width: 40px;
+    --button-height: 24px;
+    width: var(--button-width);
+    min-width: var(--button-width);
+    height: var(--button-height);
+    line-height: var(--button-height);
+    padding: 0;
+    margin-right: 2px;
   }
   .red {
-    width: 5px;
-    height: 5px;
-    border-radius: 3px;
+    --marker-size: 5px;
+    --marker-radius: 3px;
+    width: var(--marker-size);
+    height: var(--marker-size);
+    border-radius: var(--marker-radius);
     background-color: #f00;
     display: block;
     z-index: 100;
     position: absolute;
     right: 1px;
   }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb76a70 and c224fd8.

📒 Files selected for processing (1)
  • packages/plugins/schema/src/Main.vue (1 hunks)

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/script/src/Main.vue (1)

152-158: Consider using relative units for better scaling

The current implementation uses fixed pixel values for positioning. Consider using relative units (like em or %) for better scaling across different button sizes:

.dots {
-  width: 6px;
-  height: 6px;
   background: var(--ti-lowcode-warning-color-1);
   border-radius: 50%;
   position: absolute;
-  top: 9px;
-  right: 34px;
+  width: 0.375em;  /* 6px ÷ 16px base font size */
+  height: 0.375em;
+  top: 37.5%;      /* 9px ÷ 24px button height */
+  right: 85%;      /* 34px ÷ 40px button width */
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c224fd8 and dba4f89.

📒 Files selected for processing (2)
  • packages/plugins/schema/src/Main.vue (2 hunks)
  • packages/plugins/script/src/Main.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/plugins/schema/src/Main.vue
🔇 Additional comments (1)
packages/plugins/script/src/Main.vue (1)

152-153: Verify the marker point visibility across themes

The marker point dimensions and position have been adjusted to be more proportional to the save button size (40px × 24px). While the changes look reasonable, please ensure that:

  1. The marker point remains visible against all background colors (it uses --ti-lowcode-warning-color-1)
  2. The 6px × 6px size is sufficient for visibility on high-DPI displays

Also applies to: 157-158

✅ Verification successful

Marker point color and visibility verified

The warning indicator uses appropriate colors that ensure visibility:

  • Light theme: Uses #f7d916 (yellow)
  • Dark theme: Uses #fac20a (bright yellow)

Both themes use high-contrast yellow shades that are visible against typical button backgrounds. The 6px × 6px size combined with these bright warning colors provides sufficient visibility, even on high-DPI displays.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the warning color variable is defined consistently across theme files
rg --type=css --type=less "ti-lowcode-warning-color-1" 

Length of output: 233


Script:

#!/bin/bash
# Let's check the base warning color definition in light theme
rg --type=css --type=less "ti-lowcode-base-warn-color-1"

# Also check for any other uses of this warning color to understand contrast context
rg --type=vue --type=css --type=less "ti-lowcode-warning-color-1"

# Check the save button's background color to verify contrast
rg --type=vue "class=\".*save.*\"" -A 5 -B 5

Length of output: 474

@SonyLeo SonyLeo closed this Jan 7, 2025
@SonyLeo SonyLeo deleted the refactor/develop branch January 8, 2025 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor-main refactor/develop branch feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants