-
Notifications
You must be signed in to change notification settings - Fork 264
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(drawer): [drawer] modify demo #2420
Conversation
WalkthroughThe changes in this pull request involve updates to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (1)
examples/sites/demos/pc/app/drawer/width-composition-api.vue (1)
Line range hint
1-37
: Consider adding documentation for width behavior.Since this is a demo component showcasing width control, it would be helpful to add comments explaining the different width values (pixel vs percentage) and their effects.
Add documentation above the methods:
+// Drawer width can be set using: +// - Pixel values (e.g., '900px', '700px') for fixed widths +// - Percentage values (e.g., '80%') for responsive widths relative to viewport function openDrawer0() {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- examples/sites/demos/apis/drawer.js (1 hunks)
- examples/sites/demos/pc/app/drawer/width-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/drawer/width.vue (1 hunks)
🔇 Additional comments (2)
examples/sites/demos/pc/app/drawer/width-composition-api.vue (1)
Line range hint
25-33
: LGTM! Proper state update order.The
openDrawer1
andopenDrawer2
methods correctly set the width before changing visibility, which ensures smooth transitions when opening the drawer.examples/sites/demos/apis/drawer.js (1)
Line range hint
283-297
: Verify type dependencies for IDrawerConfigs interface.The interface looks well-structured, but there are potential type dependencies to verify:
IDrawerProps
interface that's being extendedVNode
andComponent
types from Vue✅ Verification successful
Let me generate additional scripts to search for IDrawerProps and related type definitions since the previous results didn't show it.
Let me search for the actual drawer props definition and Vue imports in the drawer component.
Based on the gathered information, I can now provide the final response:
Type dependencies are properly handled in the drawer component.
The verification shows that:
- IDrawerProps is correctly defined in
packages/renderless/types/drawer.type.ts
usingExtractPropTypes
from Vue- The drawer component properly imports and uses Vue's type system through
@opentiny/vue-common
- The props are well-structured with proper type definitions
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for IDrawerProps definition echo "Searching for IDrawerProps definition..." rg "interface IDrawerProps" --type ts # Search for Vue type imports echo "Searching for Vue type imports..." rg "import.*\{.*(?:VNode|Component).*\}.*from.*vue" --type tsLength of output: 27421
Script:
#!/bin/bash # Search for IDrawerProps in ts/js files echo "Searching for IDrawerProps definition in ts/js files..." rg "(?:interface|type)\s+IDrawerProps" --type ts --type js -A 5 # Search for drawer-related type imports echo "Searching for drawer type imports..." rg "import.*drawer.*types?" --type ts --type js # Search for drawer component props definition echo "Searching for drawer props definition..." ast-grep --pattern 'export const props = { $$$ }'Length of output: 897
Script:
#!/bin/bash # Search for drawer props definition echo "Searching for drawerProps definition..." rg "const\s+drawerProps\s*=\s*" --type ts -A 10 # Search for Vue imports in drawer files echo "Searching for Vue imports in drawer files..." rg "import.*from\s+'vue'" packages/vue/src/drawer/ packages/renderless/types/drawer.type.ts # Search for drawer component implementation echo "Searching for drawer component implementation..." rg "defineComponent\s*\(\s*\{" packages/vue/src/drawer/src/index.ts -A 10Length of output: 1383
@@ -19,6 +19,7 @@ const width = ref('900px') | |||
|
|||
function openDrawer0() { | |||
visible.value = true | |||
width.value = '900px' |
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.
Fix inconsistent state update order in openDrawer0.
The width update in openDrawer0
occurs after setting visibility, while other methods set width before visibility. This inconsistency could cause visual flickering.
Apply this diff to maintain consistent state update order:
function openDrawer0() {
- visible.value = true
width.value = '900px'
+ visible.value = true
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
width.value = '900px' | |
function openDrawer0() { | |
width.value = '900px' | |
visible.value = true | |
} |
this.visible = true | ||
this.width = '900px' | ||
}, |
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.
Fix inconsistent width setting order in openDrawer0
.
The current implementation sets the width after making the drawer visible, which differs from openDrawer1
and openDrawer2
. This could cause a visual "jump" as the drawer initially opens with the default width before applying the new width.
Apply this diff to maintain consistency with other methods and prevent potential visual artifacts:
openDrawer0() {
- this.visible = true
this.width = '900px'
+ this.visible = true
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
this.visible = true | |
this.width = '900px' | |
}, | |
this.width = '900px' | |
this.visible = true | |
}, |
@@ -119,7 +119,7 @@ export default { | |||
'en-US': '' | |||
}, | |||
mode: ['pc', 'mobile-first'], | |||
pcDemo: 'Show bottom or not', | |||
pcDemo: 'footer-slot', |
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.
Add missing English description for show-footer property.
While the pcDemo value now correctly references the 'footer-slot' demo, the English description ('en-US') for the show-footer property is missing.
Add the English description to maintain documentation consistency:
desc: {
'zh-CN': '是否显示底部',
- 'en-US': ''
+ 'en-US': 'Whether to display the footer'
},
Committable suggestion was skipped due to low confidence.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
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
New Features
show-footer
property and event handling.IDrawerConfigs
interface to define configuration parameters.Improvements
Bug Fixes