-
Notifications
You must be signed in to change notification settings - Fork 302
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
Conversation
WalkthroughThe pull request introduces significant structural changes across several Vue components, primarily focusing on enhancing fullscreen functionality and user interface organization. The Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 thecancel
method for clarityThe 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 tohandleClose
oronClose
.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 newcancel
(orhandleClose
) methodTo ensure the close functionality works as intended, consider adding unit tests for the
cancel
method. This will help verify that theclose
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 conflictsThe 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
📒 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. Usingflex: 1
ensures the content takes up all available space, whileoverflow: 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 functionalityThe 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 issueConsistent placement of
<state-tips>
componentThe
<state-tips>
component is included both within thefullscreenFooter
slot (line 43) and immediately after themonaco-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 emitsclose
eventThe
cancel
method is properly defined and emits theclose
event when called.
108-108
: Verify the import path forCloseIcon
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
: Confirmcancel
method binding onclose-icon
The
close-icon
component is using the@close
event to trigger thecancel
method. Ensure that thecancel
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 theclose
event:
There was a problem hiding this 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
toStateFullscreenHeader
to match the template namefullscreenHead
.
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 tocloseFullscreen
. 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
📒 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
toStateFullscreenHeader
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:
- Fullscreen templates are consistently added to all editors.
- New components (StateTips and StateFullscreenHead) are properly imported, registered, and used.
- The 'close' event handling is correctly implemented.
Suggestions for further improvement:
- Consider renaming
StateFullscreenHead
toStateFullscreenHeader
for consistency with template names.- Explore refactoring the repeated fullscreen head templates into a single, reusable component or directive to reduce duplication.
- Rename the
cancel
method tocloseFullscreen
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 offullscreenHead
andfullscreenFooter
templatesThe
fullscreenHead
andfullscreenFooter
templates are properly implemented in the initial value editor, enhancing the user interface.
50-57
: Consistent application of fullscreen templates for getter editorThe
fullscreenHead
andfullscreenFooter
templates are consistently applied to the getter editor.
69-76
: Consistent application of fullscreen templates for setter editorThe
fullscreenHead
andfullscreenFooter
templates are consistently applied to the setter editor.
105-106
: Components are correctly importedThe
StateTips
andStateFullscreenHead
components are properly imported from their respective paths.
111-112
: Components are properly registeredThe
StateTips
andStateFullscreenHead
components are correctly registered in thecomponents
object.
135-136
:emits
array updated to include 'close' eventThe
emits
array now includes the'close'
event, which matches the event emitted by thecancel
method.
357-360
:cancel
method correctly emits 'close' eventThe
cancel
method successfully emits the'close'
event, ensuring the close functionality works as expected.
390-391
:cancel
method exposed in setup returnThe
cancel
method is correctly exposed in the returned object from thesetup
function, making it accessible in the template.
There was a problem hiding this 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:
- Using the STATE constant for the title and name improves consistency.
- The new fullscreen functionality with dedicated header and footer improves the editing experience for larger code blocks.
- 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:
- The cancel method emits the 'close' event as expected.
- The return statement is properly updated to include the new constants and cancel method.
Consider renaming the
cancel
method tocloseFullscreen
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:
- Implementation of fullscreen functionality for all editor sections (state, getters, actions).
- Introduction of reusable components (StateTips, StateFullscreenHead) for consistent UI.
- Use of constants (STATE, GETTERS, ACTIONS) for improved maintainability.
- 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:
- Consider extracting the fullscreen template into a separate, reusable component to reduce duplication.
- Rename the
cancel
method to more accurately reflect its purpose in the context of fullscreen functionality.- Evaluate the possibility of further componentization to enhance modularity and reusability across the application.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 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:
- Using GETTERS and ACTIONS constants for titles and names.
- 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:
- The 'close' emit enables proper handling of the fullscreen close action.
- The STATE, GETTERS, and ACTIONS constants enhance code consistency and reduce the risk of typos.
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Release Notes
New Features
StateTips
andStateFullscreenHead
components to enhance user guidance and interaction.Enhancements
CreateStore
andCreateVariable
components.These updates aim to provide a more interactive and organized editing experience across the application.