Skip to content

feat(search): adapt to Search Components#4124

Merged
zzcr merged 3 commits intoopentiny:devfrom
James-9696:fix-search-adapt
Mar 20, 2026
Merged

feat(search): adapt to Search Components#4124
zzcr merged 3 commits intoopentiny:devfrom
James-9696:fix-search-adapt

Conversation

@James-9696
Copy link
Copy Markdown
Collaborator

@James-9696 James-9696 commented Mar 9, 2026

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: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Style
    • Enabled responsive styling for the search component to improve layout and behavior on screens up to 1280px.
    • Added a responsive spacing variable to optimize the search input’s right padding on smaller screens.
    • Updated the search styles to load the new responsive rules for consistent appearance across viewports.

@github-actions github-actions Bot added the bug Something isn't working label Mar 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

Walkthrough

Switches the search styling import from a commented adaptation file to an active responsive stylesheet, adds search/responsive.less with a rule for screens ≤1280px that injects responsive vars and sets input selector spacing, and introduces .inject-Search-responsive-vars() with --tv-Search-responsive-selector-space.

Changes

Cohort / File(s) Summary
Adaptation index
packages/theme/src/adaptation-index.less
Replaced a commented search/adaptation.less import with an active import of search/responsive.less.
Search responsive stylesheet
packages/theme/src/search/responsive.less
Added new file; imports ../custom.less and ./vars.less, defines @search-prefix-cls, and adds a responsive block (≤1280px) that injects .inject-Search-responsive-vars() and sets .@{search-prefix-cls}__input padding-right to var(--tv-Search-responsive-selector-space).
Search variables
packages/theme/src/search/vars.less
Added mixin .inject-Search-responsive-vars() that defines --tv-Search-responsive-selector-space: var(--tv-space-sm, 4px); for small-screen selector spacing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through lines of LESS today,
Turned a comment into a responsive way,
A tiny var, four pixels to spare,
Search snug on small screens with care,
A happy nibble — styles in play!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'feat(search): adapt to Search Components' is partially related to the changeset. It correctly identifies search component adaptation as the focus, but the changes specifically implement responsive styling for small screens (per PR description), not generic 'Search Components' adaptation. The title is somewhat vague about the actual scope. Consider revising the title to be more specific, such as 'feat(search): add responsive styling for small screens' to better reflect the actual implementation of responsive.less with small-screen media queries.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@James-9696 James-9696 changed the title fix(search): adapt to Search Components (WIP:)fix(search): adapt to Search Components Mar 12, 2026
@github-actions github-actions Bot removed the bug Something isn't working label Mar 12, 2026
@James-9696 James-9696 changed the title (WIP:)fix(search): adapt to Search Components fix(search): adapt to Search Components Mar 13, 2026
@github-actions github-actions Bot added the bug Something isn't working label Mar 13, 2026
Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
packages/theme/src/search/responsive.less (1)

6-14: Consider removing redundant .inject-Search-vars() call to reduce CSS output size.

The mixin is already called at the component level in index.less (which imports this file). CSS custom properties inherit from the parent scope, so --tv-Search-responsive-selector-space will be available inside the media query without re-declaring all variables.

The current implementation re-outputs all ~30 CSS variables inside the media query, which bloats the compiled CSS unnecessarily.

♻️ Suggested simplification
 `@media` screen and (max-width: 1280px) {
   .@{search-prefix-cls} {
-    .inject-Search-vars();
-
     .@{search-prefix-cls}__input {
       padding-right: var(--tv-Search-responsive-selector-space);
     }
   }
 }

Note: The Stylelint error about "Unknown word search-prefix-cls" is a false positive—this is valid Less variable interpolation syntax using @{variable}.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/search/responsive.less` around lines 6 - 14, Remove the
redundant call to the .inject-Search-vars() mixin inside the media query: since
index.less already calls .inject-Search-vars() at the component root, the CSS
custom property --tv-Search-responsive-selector-space will be inherited and
available inside the `@media` block, so delete the .inject-Search-vars() line from
the rule for .@{search-prefix-cls} within the max-width:1280px media query to
avoid re-emitting ~30 variables and reduce compiled CSS size.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/theme/src/search/responsive.less`:
- Around line 6-14: Remove the redundant call to the .inject-Search-vars() mixin
inside the media query: since index.less already calls .inject-Search-vars() at
the component root, the CSS custom property
--tv-Search-responsive-selector-space will be inherited and available inside the
`@media` block, so delete the .inject-Search-vars() line from the rule for
.@{search-prefix-cls} within the max-width:1280px media query to avoid
re-emitting ~30 variables and reduce compiled CSS size.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 52b50991-70cb-4539-9c08-7d4195325b84

📥 Commits

Reviewing files that changed from the base of the PR and between d07a370 and 92dc0f2.

📒 Files selected for processing (2)
  • packages/theme/src/search/responsive.less
  • packages/theme/src/search/vars.less

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/theme/src/search/responsive.less`:
- Line 7: Stylelint is parsing LESS files as SCSS/CSS which fails on LESS
interpolation like .@{search-prefix-cls}; update your Stylelint config
(.stylelintrc.json) to set customSyntax to postcss-less for .less files (install
postcss-less if missing) or add an overrides block that applies "customSyntax":
"postcss-less" to packages/theme/src/**/*.less so the .@{search-prefix-cls}
token is parsed correctly. Ensure the override targets .less files and restart
linting so postcss-less is used for those files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a978bcc4-50e9-4574-b4d0-424631a726b2

📥 Commits

Reviewing files that changed from the base of the PR and between 92dc0f2 and fcaf9cd.

📒 Files selected for processing (2)
  • packages/theme/src/search/responsive.less
  • packages/theme/src/search/vars.less

@search-prefix-cls: ~'@{css-prefix}search';

@media screen and (max-width: 1280px) {
.@{search-prefix-cls} {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Candidate Stylelint config files =="
fd -HI 'stylelint|\.stylelintrc|stylelint\.config'

echo
echo "== LESS parser-related settings in Stylelint configs =="
for f in $(fd -HI '(\.stylelintrc(\..*)?|stylelint\.config\.(js|cjs|mjs|json|yaml|yml))'); do
  echo "--- $f ---"
  rg -n -C2 'customSyntax|postcss-less|overrides|\.less' "$f" || true
done

echo
echo "== Existing LESS selector interpolation usage in theme files =="
rg -n --type-add 'less:*.less' --type less '\.@\{[A-Za-z0-9_-]+\}' packages/theme/src -C1 | head -n 120

Repository: opentiny/tiny-vue

Length of output: 7285


🏁 Script executed:

cat -n .stylelintrc.json

Repository: opentiny/tiny-vue

Length of output: 1277


🏁 Script executed:

cat -n packages/theme/src/search/responsive.less | head -n 20

Repository: opentiny/tiny-vue

Length of output: 470


🏁 Script executed:

rg -n 'postcss|less' package.json package-lock.json -i | head -n 30

Repository: opentiny/tiny-vue

Length of output: 1050


Configure Stylelint with LESS parser for *.less files.

The Stylelint config extends stylelint-config-standard-scss without configuring a custom syntax for LESS files. This causes Stylelint to parse .less files using the SCSS/CSS parser, which doesn't recognize LESS interpolation syntax like .@{search-prefix-cls}.

Add customSyntax to .stylelintrc.json to specify postcss-less for LESS files (install postcss-less if not already present). Alternatively, create file-specific overrides to apply LESS syntax parsing to the packages/theme/src/**/*.less directory.

🧰 Tools
🪛 Stylelint (17.4.0)

[error] 7-7: Unknown word search-prefix-cls (CssSyntaxError)

(CssSyntaxError)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/search/responsive.less` at line 7, Stylelint is parsing
LESS files as SCSS/CSS which fails on LESS interpolation like
.@{search-prefix-cls}; update your Stylelint config (.stylelintrc.json) to set
customSyntax to postcss-less for .less files (install postcss-less if missing)
or add an overrides block that applies "customSyntax": "postcss-less" to
packages/theme/src/**/*.less so the .@{search-prefix-cls} token is parsed
correctly. Ensure the override targets .less files and restart linting so
postcss-less is used for those files.

@James-9696 James-9696 changed the title fix(search): adapt to Search Components feat(search): adapt to Search Components Mar 20, 2026
@github-actions github-actions Bot added enhancement New feature or request (功能增强) and removed bug Something isn't working labels Mar 20, 2026
@zzcr zzcr merged commit 69f3598 into opentiny:dev Mar 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request (功能增强)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants