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: Editor full screen with title, close button, and examples #866

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

lichunn
Copy link
Contributor

@lichunn lichunn commented Oct 21, 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?

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

    • Introduced fullscreen mode for the Monaco Editor with dedicated header and footer slots.
    • Added new StateTips and StateFullscreenHead components to enhance user guidance and interaction.
  • Enhancements

    • Improved layout organization and user interaction in the CreateStore and CreateVariable components.
    • Added close functionality for fullscreen editors, improving usability and overall experience.

These updates aim to provide a more interactive and organized editing experience across the application.

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request introduces significant structural changes across several Vue components, primarily focusing on enhancing fullscreen functionality and user interface organization. The MonacoEditor.vue component now includes new slots for fullscreen headers and footers, while CreateStore.vue and CreateVariable.vue have been updated to utilize these slots, replacing static tips with a dynamic StateTips component. A new StateTips.vue component has also been added. The Main.vue component incorporates event handlers for closing the fullscreen editors, improving user interaction.

Changes

File Path Change Summary
packages/common/component/MonacoEditor.vue Added slots for fullscreen mode; increased z-index for .editor-container-full; added new CSS class .editor-container-content.
packages/plugins/state/src/CreateStore.vue Introduced fullscreen header/footer slots; replaced static tips with state-tips component; added cancel method.
packages/plugins/state/src/CreateVariable.vue Removed tiny-popover components; added fullscreen header/footer slots; updated emits to include close; added cancel method.
packages/plugins/state/src/Main.vue Added event handlers for @close event in create-variable and create-store components; updated cancel method.
packages/plugins/state/src/StateTips.vue New component added with template and scoped styles for displaying various data types.
packages/plugins/state/src/StateFullscreenHead.vue New component added for fullscreen header with title and close functionality.

Possibly related PRs

  • fix some detail styles in the plugins #831: This PR modifies the MonacoEditor.vue component, specifically enhancing the fullscreen functionality and adjusting the z-index, which directly relates to the changes made in the main PR that also involve the MonacoEditor.vue component and its layout adjustments for fullscreen mode.

Suggested labels

ospp-2024

Suggested reviewers

  • hexqi

Poem

In the editor's glow, we hop and play,
With fullscreen slots brightening the way.
Close icons twinkle, tips now in sight,
A new StateTips brings data delight!
So let's cheer for changes, both neat and grand,
A better interface, all crafted by hand! 🐇✨


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.

@github-actions github-actions bot added enhancement New feature or request refactor-main refactor/develop branch feature labels Oct 21, 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: 3

🧹 Outside diff range and nitpick comments (8)
packages/common/component/MonacoEditor.vue (3)

3-4: LGTM! Consider adding an accessibility attribute.

The addition of the fullscreen header slot is a good implementation for customizable content in fullscreen mode. This aligns well with the PR objective.

Consider adding an aria-label to improve accessibility:

-    <slot v-if="fullscreen" name="fullscreenHead"></slot>
+    <slot v-if="fullscreen" name="fullscreenHead" aria-label="Fullscreen editor header"></slot>

33-33: LGTM! Consider adding an accessibility attribute.

The addition of the fullscreen footer slot is a good implementation for customizable content in fullscreen mode. This aligns well with the PR objective.

Consider adding an aria-label to improve accessibility:

-    <slot v-if="fullscreen" name="fullscreenFooter"></slot>
+    <slot v-if="fullscreen" name="fullscreenFooter" aria-label="Fullscreen editor footer"></slot>

144-144: LGTM! Consider a more systematic z-index management.

Increasing the z-index ensures that the fullscreen editor appears above other elements, which is crucial for its functionality.

Consider implementing a z-index management system using CSS variables for better maintainability:

-  z-index: 100;
+  z-index: var(--ti-lowcode-fullscreen-editor-z-index, 100);

Then, define this variable in your global CSS with other z-index values to maintain a clear hierarchy.

packages/plugins/state/src/Main.vue (1)

56-56: LGTM! Close functionality added to variable and store creation panels.

The addition of @close="cancel" event handlers to both <create-variable> and <create-store> components improves the user experience by allowing users to close these panels. This change aligns well with the PR objective of adding a close button to the full-screen editor.

Consider adding a confirmation dialog when closing the panel if there are unsaved changes to prevent accidental data loss.

Also applies to: 66-66

packages/plugins/state/src/CreateStore.vue (3)

228-230: Consider renaming the cancel method for clarity

The method cancel handles the closing action when the user interacts with the close icon. To improve code readability and align with naming conventions for event handlers, consider renaming it to handleClose or onClose.

Apply this diff to rename the method:

-const cancel = () => {
+const handleClose = () => {
   emit('close')
 }

And update the references in the template:

-<close-icon @close="cancel"></close-icon>
+<close-icon @close="handleClose"></close-icon>

Don't forget to update the method name in all occurrences.


228-230: Add unit tests for the new cancel (or handleClose) method

To ensure the close functionality works as intended, consider adding unit tests for the cancel method. This will help verify that the close event is emitted correctly when the close icon is clicked.


281-289: Use consistent styling practices for .fullscreen-head-content

While the styles for .fullscreen-head-content define the necessary properties, consider using CSS variables or mixins if you have similar styling in other components. This promotes consistency and makes future style updates easier.

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

491-499: Scope styles to prevent CSS conflicts

The styles for .fullscreen-head-content are defined. Since the <style> block is scoped, ensure that class names do not conflict with other components.

Consider adding a unique prefix to the class name:

-.fullscreen-head-content {
+.create-variable-fullscreen-head {

And update the template accordingly:

-  <div class="fullscreen-head-content">
+  <div class="create-variable-fullscreen-head">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2dfda14 and 8d4f3b2.

📒 Files selected for processing (5)
  • packages/common/component/MonacoEditor.vue (3 hunks)
  • packages/plugins/state/src/CreateStore.vue (6 hunks)
  • packages/plugins/state/src/CreateVariable.vue (7 hunks)
  • packages/plugins/state/src/Main.vue (2 hunks)
  • packages/plugins/state/src/StateTips.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/plugins/state/src/StateTips.vue
🧰 Additional context used
🔇 Additional comments (9)
packages/common/component/MonacoEditor.vue (3)

4-32: LGTM! Improved layout structure.

The restructuring of the editor container content improves the overall layout organization. The new wrapper div with class "editor-container-content" allows for better control over the layout and overflow behavior, which is particularly useful for the fullscreen mode.


170-173: LGTM! Improved layout control.

The new .editor-container-content class provides better layout control. Using flex: 1 ensures the content takes up all available space, while overflow: hidden prevents any unintended content spillover. These styles contribute to a more robust layout, especially beneficial in fullscreen mode.


Line range hint 1-184: Overall, excellent implementation of fullscreen functionality!

The changes in this file successfully implement the fullscreen editor feature with customizable header and footer, aligning perfectly with the PR objectives. The code structure and organization have been improved, enhancing maintainability and flexibility. The minor suggestions provided (accessibility attributes and z-index management) would further refine the implementation.

packages/plugins/state/src/Main.vue (1)

Line range hint 1-1024: Summary: Improved UI interaction with close functionality

The changes in this file effectively implement the close functionality for the full-screen editor, as outlined in the PR objectives. The addition of @close event handlers to the <create-variable> and <create-store> components enhances the user experience by providing a way to close these panels.

These changes are minimal yet impactful, and they integrate well with the existing component structure. The implementation leverages the already present cancel method, ensuring consistency in behavior and reducing the need for additional code changes.

Overall, this implementation successfully addresses the PR's goal of adding a close button to the full-screen editor while maintaining the component's existing functionality.

packages/plugins/state/src/CreateStore.vue (1)

41-47: ⚠️ Potential issue

Consistent placement of <state-tips> component

The <state-tips> component is included both within the fullscreenFooter slot (line 43) and immediately after the monaco-editor component (line 47). This may lead to duplicate rendering of the same tips. Please verify if both instances are needed or if one can be removed to avoid redundancy.

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

143-143: Event emission updated to include 'close'

The emits array now includes 'close'. Ensure that parent components are listening to this event to handle the close action properly.


365-367: cancel method correctly emits close event

The cancel method is properly defined and emits the close event when called.


108-108: Verify the import path for CloseIcon

Confirm that CloseIcon is correctly exported from @opentiny/tiny-engine-common and that the import path is accurate.

Run the following script to check the export of CloseIcon:

#!/bin/bash
# Description: Verify that `CloseIcon` is exported from `@opentiny/tiny-engine-common`

# Test: Search for the export of `CloseIcon` in the package.
# Expected output: Lines containing `export { CloseIcon }`

rg 'export\s+\{\s*CloseIcon\s*\}' -t js -A 2 --glob '**/tiny-engine-common/**'

38-38: Confirm cancel method binding on close-icon

The close-icon component is using the @close event to trigger the cancel method. Ensure that the cancel method is correctly defined and that the event is properly emitted.

Run the following script to verify that the cancel method exists and is correctly emitting the close event:

packages/plugins/state/src/CreateStore.vue Outdated Show resolved Hide resolved
packages/plugins/state/src/CreateVariable.vue Outdated Show resolved Hide resolved
packages/plugins/state/src/CreateVariable.vue Show resolved Hide resolved
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: 3

🧹 Outside diff range and nitpick comments (6)
packages/plugins/state/src/StateFullscreenHead.vue (3)

7-30: LGTM: Well-structured script with clear responsibilities.

The script section is well-implemented using the Vue 3 composition API. Props, emits, and methods are clearly defined. The separation of concerns is good, with the CloseIcon imported from a common package.

Consider adding type safety to the emit function for better developer experience:

-  setup(props, { emit }) {
+  setup(props, { emit }: { emit: (event: 'close') => void }) {

31-41: LGTM: Well-structured and scoped styles.

The styles are appropriately scoped to the component and make good use of CSS variables for theming. The layout is implemented using flexbox, which is a modern and flexible approach.

Consider adding a media query for better responsiveness on smaller screens:

 .fullscreen-head-content {
   font-size: 12px;
   color: var(--te-common-text-primary);
   height: 30px;
   line-height: 20px;
   width: 100%;
   display: flex;
   justify-content: space-between;
+  
+  @media (max-width: 768px) {
+    font-size: 10px;
+    height: 25px;
+    line-height: 18px;
+  }
 }

1-41: Great job: Well-implemented component aligning with PR objectives.

This StateFullscreenHead component is well-structured, following Vue 3 best practices and composition API. It effectively implements the fullscreen header with a title and close functionality, aligning perfectly with the PR objectives. The modular design ensures easy integration into other components, contributing to a consistent user experience across the application.

As the project grows, consider creating a shared components library for common UI elements like this header to promote reusability and consistency across the application.

packages/plugins/state/src/CreateStore.vue (3)

35-42: LGTM! Consider consistent naming for fullscreen components.

The addition of fullscreen templates enhances the user experience and improves modularity. Great job on linking the close event to the new cancel method.

For consistency, consider renaming StateFullscreenHead to StateFullscreenHeader to match the template name fullscreenHead.


58-62: LGTM! Consider refactoring to reduce duplication.

The addition of the fullscreen head template for the actions editor completes the consistent implementation of fullscreen functionality across all editors. Great job on maintaining the pattern of reusing the StateFullscreenHead component.

To further improve the code, consider refactoring the repeated fullscreen head templates into a single, reusable component or directive. This would reduce duplication and make future updates easier.


103-103: LGTM! Consider renaming 'cancel' to 'closeFullscreen' for clarity.

The addition of the 'close' emit, the cancel method, and its inclusion in the setup function's return statement are all implemented correctly. This allows proper communication with parent components when closing the fullscreen mode.

For improved clarity, consider renaming the cancel method to closeFullscreen. This would make its purpose more immediately apparent to other developers.

Also applies to: 220-222, 238-239

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8d4f3b2 and 31578c2.

📒 Files selected for processing (3)
  • packages/plugins/state/src/CreateStore.vue (5 hunks)
  • packages/plugins/state/src/CreateVariable.vue (6 hunks)
  • packages/plugins/state/src/StateFullscreenHead.vue (1 hunks)
🧰 Additional context used
🔇 Additional comments (14)
packages/plugins/state/src/StateFullscreenHead.vue (1)

1-6: LGTM: Clean and modular template structure.

The template has a clear structure with a title and close icon. The use of a separate close-icon component promotes modularity and reusability.

packages/plugins/state/src/CreateStore.vue (5)

44-44: LGTM! Consistent use of StateTips component.

Adding the StateTips component outside the monaco-editor ensures that helpful information is available in both fullscreen and normal modes. This improves the overall user experience and maintains UI consistency.


49-53: LGTM! Consistent fullscreen functionality for getters editor.

The addition of the fullscreen head template for the getters editor maintains consistency with the state editor and demonstrates good component reusability.

As mentioned earlier, consider renaming StateFullscreenHead to StateFullscreenHeader for consistency with the template name.


75-76: LGTM! Proper import of new components.

The import statements for StateTips and StateFullscreenHead components are correctly added, corresponding to their usage in the template. The use of relative import paths is appropriate for local, feature-specific components.


81-82: LGTM! Correct registration of new components.

The StateTips and StateFullscreenHead components are properly registered in the components object, matching their import statements. This registration is necessary for their use in the template.


Line range hint 1-286: Overall, great implementation of fullscreen functionality!

The changes in this file successfully implement fullscreen editing capabilities for state, getters, and actions, while also improving the overall component structure. Here's a summary of the main points:

  1. Fullscreen templates are consistently added to all editors.
  2. New components (StateTips and StateFullscreenHead) are properly imported, registered, and used.
  3. The 'close' event handling is correctly implemented.

Suggestions for further improvement:

  1. Consider renaming StateFullscreenHead to StateFullscreenHeader for consistency with template names.
  2. Explore refactoring the repeated fullscreen head templates into a single, reusable component or directive to reduce duplication.
  3. Rename the cancel method to closeFullscreen for improved clarity.

These changes significantly enhance the user experience and maintain good coding practices. Great job!

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

35-42: Correct use of fullscreenHead and fullscreenFooter templates

The fullscreenHead and fullscreenFooter templates are properly implemented in the initial value editor, enhancing the user interface.


50-57: Consistent application of fullscreen templates for getter editor

The fullscreenHead and fullscreenFooter templates are consistently applied to the getter editor.


69-76: Consistent application of fullscreen templates for setter editor

The fullscreenHead and fullscreenFooter templates are consistently applied to the setter editor.


105-106: Components are correctly imported

The StateTips and StateFullscreenHead components are properly imported from their respective paths.


111-112: Components are properly registered

The StateTips and StateFullscreenHead components are correctly registered in the components object.


135-136: emits array updated to include 'close' event

The emits array now includes the 'close' event, which matches the event emitted by the cancel method.


357-360: cancel method correctly emits 'close' event

The cancel method successfully emits the 'close' event, ensuring the close functionality works as expected.


390-391: cancel method exposed in setup return

The cancel method is correctly exposed in the returned object from the setup function, making it accessible in the template.

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

🧹 Outside diff range and nitpick comments (3)
packages/plugins/state/src/CreateStore.vue (3)

16-17: Improved structure and consistency in the state editor section.

The changes enhance maintainability and user experience:

  1. Using the STATE constant for the title and name improves consistency.
  2. The new fullscreen functionality with dedicated header and footer improves the editing experience for larger code blocks.
  3. The StateTips component is now used consistently both in fullscreen mode and regular view.

Consider extracting the fullscreen template into a separate component to reduce duplication across state, getters, and actions sections.

Also applies to: 35-42, 44-44


223-230: Implementation of cancel method and updated return statement.

The changes correctly implement the close functionality for the fullscreen mode:

  1. The cancel method emits the 'close' event as expected.
  2. The return statement is properly updated to include the new constants and cancel method.

Consider renaming the cancel method to closeFullscreen or similar to more accurately reflect its purpose in the context of the fullscreen functionality.

Also applies to: 244-245


Line range hint 1-290: Overall assessment: Significant improvements to editor functionality and code quality.

This pull request introduces several positive changes to the CreateStore component:

  1. Implementation of fullscreen functionality for all editor sections (state, getters, actions).
  2. Introduction of reusable components (StateTips, StateFullscreenHead) for consistent UI.
  3. Use of constants (STATE, GETTERS, ACTIONS) for improved maintainability.
  4. Proper event handling for closing fullscreen mode.

These changes enhance the user experience and code maintainability. The consistent application of new features across all editor sections is commendable.

To further improve the component:

  1. Consider extracting the fullscreen template into a separate, reusable component to reduce duplication.
  2. Rename the cancel method to more accurately reflect its purpose in the context of fullscreen functionality.
  3. Evaluate the possibility of further componentization to enhance modularity and reusability across the application.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 31578c2 and 96ecb33.

📒 Files selected for processing (3)
  • packages/common/component/MonacoEditor.vue (2 hunks)
  • packages/plugins/state/src/CreateStore.vue (6 hunks)
  • packages/plugins/state/src/CreateVariable.vue (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/common/component/MonacoEditor.vue
  • packages/plugins/state/src/CreateVariable.vue
🧰 Additional context used
🔇 Additional comments (3)
packages/plugins/state/src/CreateStore.vue (3)

47-53: Consistent improvements applied to getters and actions editors.

The changes to the getters and actions editors mirror those made to the state editor:

  1. Using GETTERS and ACTIONS constants for titles and names.
  2. Adding fullscreen functionality with dedicated headers.

These modifications enhance consistency across all three editor sections.

As mentioned in the previous comment, consider extracting the fullscreen template into a separate component to reduce duplication across these sections.

Also applies to: 56-62


75-76: Proper import and registration of new components.

The StateTips and StateFullscreenHead components are correctly imported and registered. This change supports the new functionality introduced in the template section.

Also applies to: 81-82


103-107: Addition of necessary emit and constants.

The changes improve the component's functionality and maintainability:

  1. The 'close' emit enables proper handling of the fullscreen close action.
  2. The STATE, GETTERS, and ACTIONS constants enhance code consistency and reduce the risk of typos.

@hexqi hexqi merged commit fb00920 into opentiny:refactor/develop Oct 25, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 8, 2024
14 tasks
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.

3 participants