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

docs(attachments): add with sender demo and update basic demo #100

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

linhf123
Copy link
Collaborator

@linhf123 linhf123 commented Feb 27, 2025

添加配合 Sender.Header 使用的 Demo,并使用 Sender 更新了基础 Demo
image
image

Summary by CodeRabbit

  • Documentation
    • Added a new section titled "组合示例" in the attachments documentation, showcasing how to use the Attachments component with the Sender.Header.
  • New Features
    • Updated demo examples to illustrate a more encapsulated approach to integrating attachments with the Sender component.
    • Introduced a new component, AXAttachmentWithSender, demonstrating the combined functionality of attachments and messaging elements.

Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The changes introduce a new documentation section ("组合示例") in the Attachments component docs that provides a demo linking to attachments/with-sender. In the example component located in docs/examples/attachments/basic.vue, the rendering of Attachments has been refactored into a computed property (attachmentsNode) and is passed to the Sender component. A new Vue component, AXAttachmentWithSender, has also been added in docs/examples/attachments/with-sender.vue. This component combines the use of Sender and Attachments with reactive state and computed properties to manage its UI behaviors without altering underlying file upload logic.

Changes

File(s) Change Summary
docs/component/attachments.md Added a new section "组合示例" with a demo example that links to attachments/with-sender, expanding the documentation without modifying existing functionality.
docs/examples/attachments/basic.vue
docs/examples/attachments/with-sender.vue
In basic.vue, refactored the rendering approach by creating a computed property (attachmentsNode) and passing it as a prefix prop to the Sender component instead of directly using <Attachments />.
In with-sender.vue, added a new component (AXAttachmentWithSender) that integrates Sender and Attachments with reactive state and computed properties for header and badge management.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant D as Demo Function
    participant S as Sender
    participant A as Attachments

    U->>D: Load basic demo component
    D->>D: Compute attachmentsNode
    D->>S: Pass attachmentsNode as prefix prop
    S->>A: Render Attachments component within Sender
    U->>S: Interact with attachments (e.g., file upload)
Loading
sequenceDiagram
    participant U as User
    participant X as AXAttachmentWithSender
    participant S as Sender
    participant A as Attachments
    participant B as Badge

    U->>X: Open the component view
    X->>X: Compute senderHeader with embedded Attachments
    X->>X: Compute badgeNode for uploaded items
    X->>S: Render Sender with senderHeader and badgeNode
    S->>A: Render Attachments (with beforeUpload and onChange handling)
    U->>S: Upload file / interact with Sender
    S->>X: Process submission and update state (reset items and text)
Loading

Poem

I'm a bouncy rabbit coding in delight,
New docs and components shining so bright.
Computed nodes and Sender in a playful dance,
Attachments and badges now get their chance.
Hop along the code trail, crisp and neat,
With every change, our project feels complete.
🐰✨ Happy coding!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/examples/attachments/with-sender.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser 'vue-eslint-parser' declared in '.eslintrc.js': Cannot find module 'vue-eslint-parser'
Require stack:

  • /.eslintrc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)

📜 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 59a81a3 and ac59293.

📒 Files selected for processing (1)
  • docs/examples/attachments/with-sender.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/examples/attachments/with-sender.vue
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - antd-design-x-vue
  • GitHub Check: Header rules - antd-design-x-vue
  • GitHub Check: Pages changed - antd-design-x-vue

🪧 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.
  • @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.

Copy link

netlify bot commented Feb 27, 2025

Deploy Preview for antd-design-x-vue ready!

Name Link
🔨 Latest commit ac59293
🔍 Latest deploy log https://app.netlify.com/sites/antd-design-x-vue/deploys/67c1befbd268010008517a71
😎 Deploy Preview https://deploy-preview-100--antd-design-x-vue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@linhf123
Copy link
Collaborator Author

基础示例现在全局拖拽上传失效,需要处理一下

Copy link

@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: 1

🧹 Nitpick comments (1)
docs/examples/attachments/with-sender.vue (1)

9-15: State management implemented well.

The reactive references for managing component state are appropriately defined. Consider adding type annotations to the empty array for better type safety.

- const items = ref([]);
+ const items = ref<any[]>([]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cf2f9bb and 59a81a3.

📒 Files selected for processing (3)
  • docs/component/attachments.md (1 hunks)
  • docs/examples/attachments/basic.vue (2 hunks)
  • docs/examples/attachments/with-sender.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/component/attachments.md
🔇 Additional comments (7)
docs/examples/attachments/basic.vue (3)

4-5: Import modifications look good.

The imports have been correctly updated to include both Sender and Attachments from the library, as well as adding the computed import from Vue which is needed for the refactoring.


23-36: Well-structured component encapsulation.

Moving the Attachments component into a computed property is a good refactoring choice that improves code modularity and prepares it for use with the Sender component. The implementation preserves all the original functionality while making the code more maintainable.


41-41: Good implementation of the new Sender component.

The replacement of the direct Attachments rendering with a Sender component that uses the computed attachmentsNode as its prefix aligns perfectly with the PR objective to update the basic demo to use Sender.

docs/examples/attachments/with-sender.vue (4)

1-8: Component setup and imports look good.

The component is correctly set up with the appropriate imports and naming convention. The TypeScript setup is properly configured.


16-47: Sender.Header with Attachments is well-implemented.

The computed property for the header component is well-structured. The Attachments component is properly configured with mock upload functionality and dynamic placeholders based on the context.


55-71: Well-structured Sender component implementation.

The Sender component is well configured with the appropriate props and event handlers. The onSubmit handler properly clears both the items and text when the message is sent, providing a good user experience.


74-81: Render function looks good.

The render function correctly wraps the Demo component within an App component, following the pattern used in other examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant