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(search): [search] add doc for suffix slot #2978

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

gweesin
Copy link
Contributor

@gweesin gweesin commented Feb 26, 2025

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)

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:

What is the current behavior?

Issue Number: #2972

What is the new behavior?

add document for suffix slots

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added an enhanced search input featuring a calendar icon in its right slot. This new clearable search field uses updated placeholder text while retaining original functionalities.
  • Documentation

    • Updated demo content now showcases improved slot customization, allowing tailored display of both left and right elements along with visual feedback for the disabled state.
  • Tests

    • Introduced new tests to verify the visibility of prefix and suffix slots in the search component, as well as the disabled state of input fields.

Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes extend the search demo to support both prefix and suffix slots. A new tiny-search instance featuring a calendar icon in the suffix slot is added, and icon imports and component registrations are updated accordingly. Test files have been enhanced to verify the display of both prefix and suffix slots as well as the disabled state of inputs. Additionally, obsolete tests for the prefix slot have been removed, and the demo metadata has been updated to reflect these enhancements.

Changes

File(s) Change Summary
examples/.../slot-prefix-suffix-composition-api.vue
examples/.../slot-prefix-suffix.vue
Added a new tiny-search instance with a suffix slot featuring a calendar icon; updated icon imports and component registrations.
examples/.../slot-prefix-suffix.spec.ts Introduced tests to verify the visibility and styling of prefix and suffix slots, and to assert the disabled state of the search input using Playwright.
examples/.../slot-prefix.spec.ts Removed the obsolete test file that verified only the left-side (prefix) slot functionality.
examples/.../webdoc/search.js Updated demo metadata (demoId, names, descriptions, and codeFiles) to reflect the combined use of prefix and suffix slots along with the disabled state.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SearchInput
  participant CalendarIcon
  User->>SearchInput: Render search component
  SearchInput->>CalendarIcon: Include calendar icon in suffix slot
  CalendarIcon-->>SearchInput: Icon rendered
  SearchInput-->>User: Display updated search field
Loading
sequenceDiagram
  participant Test
  participant Browser
  participant SearchComponent
  Test->>Browser: Navigate to "search#slot-prefix-suffix"
  Browser-->>SearchComponent: Render search with prefix & suffix slots
  Test->>SearchComponent: Verify slot elements’ visibility and styling
  Test->>SearchComponent: Assert input disabled state upon interaction
Loading

Suggested labels

documentation

Suggested reviewers

  • zzcr

Poem

I'm a little rabbit, hopping through the code,
Discovering new slots where features are bestowed.
A calendar icon dances at the end with glee,
Tests check each detail so meticulously.
With every line and every playful byte,
I cheer the changes in the soft moonlight! 🐇

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.

examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 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 774f774 and 90968c5.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

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

Walkthrough

This pull request introduces documentation content changes to the tiny-vue project. It adds documentation for suffix slots, updating existing demo files to include suffix slot examples and corresponding test cases to ensure proper functionality.

Changes

File(s) Summary
slot-prefix-suffix-composition-api.vue, slot-prefix-suffix.vue Added suffix slot examples and updated imports for icons.
slot-prefix-suffix.spec.ts Added test cases for suffix slot visibility and disabled state.
slot-prefix.spec.ts Removed old test cases related to prefix slot only.
search.js Updated demo identifiers and descriptions to include suffix slots.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 397b0ab and e761d60.

📒 Files selected for processing (5)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix-composition-api.vue (2 hunks)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.vue (1 hunks)
  • examples/sites/demos/pc/app/search/slot-prefix.spec.ts (0 hunks)
  • examples/sites/demos/pc/app/search/webdoc/search.js (1 hunks)
💤 Files with no reviewable changes (1)
  • examples/sites/demos/pc/app/search/slot-prefix.spec.ts
🧰 Additional context used
🪛 Biome (1.9.4)
examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts

[error] 29-29: await is only allowed within async functions and at the top levels of modules.

(parse)

🔇 Additional comments (8)
examples/sites/demos/pc/app/search/slot-prefix-suffix.vue (3)

11-16: Good addition of the suffix slot example.

The new tiny-search instance with a suffix slot shows an excellent example of using a calendar icon. This complements the existing prefix slot example and provides users with a complete understanding of the slot capabilities in the search component.


24-24: Import statement updated correctly.

The import statement has been properly updated to use named imports for both IconCalendar and IconSearch, following the component naming conventions.


30-31: Component registrations are properly implemented.

Both icon components are correctly registered using the function call syntax, which is the proper way to instantiate icon components in this framework.

examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (1)

3-18: Comprehensive test for slot visibility.

The test correctly verifies both prefix and suffix slots are visible and have the expected styling. Good practice to check both the visibility and CSS properties.

examples/sites/demos/pc/app/search/slot-prefix-suffix-composition-api.vue (3)

11-16: Well-implemented suffix slot example.

The new tiny-search component with a suffix slot is properly implemented and consistent with the Options API version, showing good component reusability patterns.


25-25: Icon imports updated consistently.

The import statement has been properly updated to use named imports for both IconCalendar and IconSearch, consistent with the Vue 3 and Composition API best practices.


30-31: Component instantiation is correct.

Both icon components are properly instantiated using the function call syntax, which is the correct pattern for icon components in this framework.

examples/sites/demos/pc/app/search/webdoc/search.js (1)

93-104: Documentation updated comprehensively.

The documentation has been properly updated to reflect the extended functionality. The demoId, name, description, and codeFiles are all consistently updated to reference both prefix and suffix slots, which will help users understand the component's capabilities.

@zzcr
Copy link
Member

zzcr commented Feb 27, 2025

你好,修改下标题触发下E2E测试用例:docs(search): [search] add doc for suffix slot

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Hello, modify the title and trigger the E2E test case: docs(search): [search] add doc for suffix slot

@gweesin gweesin changed the title docs(search): add doc for suffix slot docs(search): [search] add doc for suffix slot Feb 27, 2025
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: 0

🧹 Nitpick comments (2)
examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (2)

3-3: Consider using English test descriptions for consistency.

The test title "插槽是否正常显示" is in Chinese while other parts of the code and the next test use English. Using a consistent language (preferably English) for test descriptions improves maintainability, especially in international teams.

-test('插槽是否正常显示', async ({ page }) => {
+test('slots should display correctly', async ({ page }) => {

1-32: Consider adding test documentation for better maintainability.

While the test implementations are good, adding brief comments explaining the purpose of each test would improve maintainability. This is especially important for documenting the expected behavior of the new suffix slot functionality.

 import { expect, test } from '@playwright/test'

+/**
+ * Tests for prefix and suffix slots in search component
+ */
 test('插槽是否正常显示', async ({ page }) => {
   page.on('pageerror', (exception) => expect(exception).toBeNull())
   await page.goto('search#slot-prefix-suffix')

+  // Verify prefix slot rendering and styling
   const prefixSlotSearch = page.locator('.tiny-search').first()
   const prefixLocator = prefixSlotSearch.locator('.tiny-search__prefix > svg')

   await expect(prefixLocator).toBeVisible()
   await expect(prefixLocator).toHaveCSS('font-size', '16px')

+  // Verify suffix slot rendering and styling
   const suffixSlotSearch = page.locator('.tiny-search').nth(1)
   const suffixLocator = suffixSlotSearch.locator('svg.tiny-search__suffix')

   await expect(suffixLocator).toBeVisible()
   await expect(suffixLocator).toHaveCSS('font-size', '14px')
 })

+/**
+ * Test for verifying the disabled state of search components
+ */
 test('disabled', async ({ page }) => {
   page.on('pageerror', (exception) => expect(exception).toBeNull())
   await page.goto('search#slot-prefix-suffix')

+  // Click the button that toggles disabled state
   await page.locator('.tiny-button').click()

+  // Verify all search inputs are disabled
   const searchLocators = await page.locator('.tiny-search').all()
   for (const search of searchLocators) {
     const input = search.locator('input')
     await expect(input).toBeDisabled()
   }
 })
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b1fccf3 and 774f774.

📒 Files selected for processing (3)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix-composition-api.vue (2 hunks)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/sites/demos/pc/app/search/slot-prefix-suffix-composition-api.vue
  • examples/sites/demos/pc/app/search/slot-prefix-suffix.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (3)
examples/sites/demos/pc/app/search/slot-prefix-suffix.spec.ts (3)

7-11: LGTM! Effective prefix slot verification.

The implementation correctly locates and verifies the prefix slot element and its styling.


13-17: LGTM! Proper suffix slot verification.

The test correctly verifies that the suffix slot is visible and has the expected styling, which aligns with the PR objective of adding documentation for suffix slots.


20-31: LGTM! Well-implemented disabled state test.

The test properly uses a for...of loop to handle async operations when checking disabled state. This is the correct approach, as noted in previous reviews about avoiding await inside forEach loops.

@zzcr zzcr merged commit 48b8bcc into opentiny:dev Feb 28, 2025
5 checks passed
@gweesin gweesin deleted the docs/search-suffix-doc branch February 28, 2025 06:42
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.

3 participants