Skip to content

feat(modal): adapt to Modal Components#4129

Closed
James-9696 wants to merge 5 commits intoopentiny:devfrom
James-9696:fix-modal-adapt
Closed

feat(modal): adapt to Modal Components#4129
James-9696 wants to merge 5 commits intoopentiny:devfrom
James-9696:fix-modal-adapt

Conversation

@James-9696
Copy link
Copy Markdown
Collaborator

@James-9696 James-9696 commented Mar 11, 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
    • Improved modal responsiveness: refined spacing, padding, margins and font sizes for better layout across tablet and mobile; header, body and footer adapt at medium and small breakpoints.
  • New Features
    • Added reusable responsive modal mixin and theme variables plus a new aggregated responsive styles entrypoint; app now includes the responsive theme.
  • Chores
    • Removed an obsolete component-adaptation stylesheet entrypoint.
  • Refactor
    • Small formatting cleanup in an image upload helper.

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

coderabbitai Bot commented Mar 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ddc52cdd-b933-44be-9a40-219dd1409610

📥 Commits

Reviewing files that changed from the base of the PR and between 831938f and e939d07.

📒 Files selected for processing (4)
  • examples/sites/src/main.js
  • packages/renderless/src/fluent-editor/index.ts
  • packages/theme/src/adaptation-index.less
  • packages/theme/src/responsive-index.less
💤 Files with no reviewable changes (1)
  • packages/theme/src/adaptation-index.less
✅ Files skipped from review due to trivial changes (3)
  • packages/renderless/src/fluent-editor/index.ts
  • packages/theme/src/responsive-index.less
  • examples/sites/src/main.js

Walkthrough

Removes packages/theme/src/adaptation-index.less; adds packages/theme/src/responsive-index.less; introduces packages/theme/src/modal/responsive.less and a .inject-Modal-responsive-vars() mixin in modal/vars.less; updates examples/sites/src/main.js to import the responsive stylesheet; tiny formatting tweak in fluent-editor upload helper.

Changes

Cohort / File(s) Summary
Theme entry removed
packages/theme/src/adaptation-index.less
Removes the adaptation-index.less stylesheet entrypoint and its component-specific adaptation imports.
Responsive entry added
packages/theme/src/responsive-index.less
Adds a new responsive entrypoint that aggregates component responsive LESS imports (button, link, modal, notify, popover, etc.).
Modal responsive styles
packages/theme/src/modal/responsive.less
New file: defines modal-responsive mixin, sets header/body/footer paddings, widths, and two media-query variants (600–1280px and ≤599px); imports ../custom.less and ./vars.less.
Modal variables
packages/theme/src/modal/vars.less
Adds .inject-Modal-responsive-vars() introducing four CSS custom properties for modal spacing and font sizes.
App stylesheet import
examples/sites/src/main.js
Adds @opentiny/vue-theme/responsive-index.less import to the app entry.
Minor formatter change
packages/renderless/src/fluent-editor/index.ts
Single-line refactor of readFileToBlob arrow function in handleUploadImage — no logic change.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through files with nimble paws,
Swapped an entry, stitched responsive laws,
Tiny mixins tucked in header and pad,
Breakpoints cozy, not a pixel sad,
A carrot-coded cheer for layouts glad.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(modal): adapt to Modal Components' directly aligns with the main changes, which focus on adding responsive styling to modal components across multiple files.
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

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.

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: 2

🤖 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/modal/responsive.less`:
- Around line 50-65: At the 600px boundary both media queries match causing the
second to override the first; make the breakpoint exclusive by changing one of
the media queries so only one matches at 600px (for example update the first to
`@media` (min-width: 601px) and (max-width: 1280px) or update the second to `@media`
screen and (max-width: 599px)), leaving the .modal-responsive calls and their
params unchanged so the 600px width has a single owner.
- Around line 58-63: The modal uses a hard-coded `@box-width`: 320px inside
.modal-responsive which, combined with horizontal margins, causes overflow under
352px; change the `@box-width` argument in the .modal-responsive invocation to be
responsive (for example use a max-width value or compute it from the
viewport/margins such as max-width: 100% or calc(100% - 2 *
`@modal-adapt-space-part`) or set `@box-width`: auto) so the modal shrinks on very
narrow screens and doesn’t overflow when the viewport is below 352px.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5d07df58-b00e-40d5-ac49-2888107e6638

📥 Commits

Reviewing files that changed from the base of the PR and between cec377d and 4bbca33.

📒 Files selected for processing (3)
  • packages/theme/src/adaptation-index.less
  • packages/theme/src/modal/responsive.less
  • packages/theme/src/modal/vars.less

Comment thread packages/theme/src/modal/responsive.less
Comment thread packages/theme/src/modal/responsive.less Outdated
@James-9696 James-9696 changed the title fix(modal): adapt to Modal Components (WIP:)fix(modal): adapt to Modal Components Mar 12, 2026
@James-9696 James-9696 changed the title (WIP:)fix(modal): adapt to Modal Components fix(modal): adapt to Modal Components Mar 12, 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.

Actionable comments posted: 1

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

18-18: Consider making top responsive.

The top: 100px value is hardcoded while other spacing values use the responsive CSS custom properties. For consistency with the small-screen adaptation goal, consider using a responsive variable or at least a smaller value for the narrow-screen media query.

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

In `@packages/theme/src/modal/responsive.less` at line 18, The hardcoded "top:
100px" in packages/theme/src/modal/responsive.less should be made responsive:
replace the literal with your responsive CSS custom property (e.g., top:
var(--modal-top, 100px)) and ensure the narrow-screen media query overrides that
variable (or sets a smaller value like var(--modal-top-sm, 64px)). Update the
declaration where "top: 100px" appears and add or adjust the corresponding CSS
custom properties used elsewhere for spacing so the modal spacing adapts on
small screens.
🤖 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/modal/responsive.less`:
- Around line 17-21: The .@{modal-prefix-cls}__box rule currently uses
transform: translateX(-5%) without an explicit horizontal anchor, causing
inconsistent placement; change the horizontal centering to use left: 50%
together with transform: translateX(-50%) in the .@{modal-prefix-cls}__box rule
(or, if the -5% offset was intentional, add a comment explaining the rationale
and keep the existing transform), and ensure no conflicting left/right
properties remain that would override centering.

---

Nitpick comments:
In `@packages/theme/src/modal/responsive.less`:
- Line 18: The hardcoded "top: 100px" in
packages/theme/src/modal/responsive.less should be made responsive: replace the
literal with your responsive CSS custom property (e.g., top: var(--modal-top,
100px)) and ensure the narrow-screen media query overrides that variable (or
sets a smaller value like var(--modal-top-sm, 64px)). Update the declaration
where "top: 100px" appears and add or adjust the corresponding CSS custom
properties used elsewhere for spacing so the modal spacing adapts on small
screens.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 560fa0bf-e734-4d2e-84e4-63821ae818f1

📥 Commits

Reviewing files that changed from the base of the PR and between 4bbca33 and ec691cf.

📒 Files selected for processing (2)
  • packages/theme/src/modal/responsive.less
  • packages/theme/src/modal/vars.less
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/modal/vars.less

Comment thread packages/theme/src/modal/responsive.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.

♻️ Duplicate comments (2)
packages/theme/src/modal/responsive.less (2)

19-20: ⚠️ Potential issue | 🟡 Minor

Centering still appears offset left.

With left: 50% on Line 19, translateX(-55%) on Line 20 shifts the modal an extra 5% left. If true centering is intended, use -50% (or document why the offset is intentional).

💡 Suggested fix
-          transform: translateX(-55%);
+          transform: translateX(-50%);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/modal/responsive.less` around lines 19 - 20, The modal
centering is offset because the rule using transform: translateX(-55%) shifts it
5% further left relative to left: 50%; update the transform in the responsive
modal CSS (the rule containing left: 50% and transform: translateX(...)) to use
translateX(-50%) for true centering, or if the 5% offset is intentional add a
comment explaining why and keep translateX(-55%).

63-64: ⚠️ Potential issue | 🟠 Major

Mobile width can still overflow on very narrow screens.

At Line 64, fixed 320px width plus horizontal margins can exceed viewport width on smaller devices, which conflicts with the small-screen adaptation goal.

💡 Suggested fix
 `@media` screen and (max-width: 599px) {
   .modal-responsive(
     `@header-padding`: `@modal-responsive-space-part` `@modal-responsive-space-part`;
     `@body-padding`: 0 `@modal-responsive-space-part`;
     `@box-margin`: 0 `@modal-responsive-space-part` 50px;
-    `@box-width`: 320px;
+    `@box-width`: min(320px, calc(100vw - (2 * `@modal-responsive-space-part`)));
   );
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/modal/responsive.less` around lines 63 - 64, The fixed
`@box-width`: 320px can cause horizontal overflow on very narrow viewports; update
the responsive rule to use a fluid constraint (e.g. replace the fixed `@box-width`
with a responsive expression such as using CSS min()/max-width semantics) so the
modal never exceeds the viewport width — change the `@box-width` variable to a
responsive value (for example use min(320px, 100%) or set width: 100% with
max-width: 320px where the modal uses `@box-width`) and ensure the modal layout
that uses `@box-margin` and `@box-width` respects those max-width constraints to
prevent overflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/theme/src/modal/responsive.less`:
- Around line 19-20: The modal centering is offset because the rule using
transform: translateX(-55%) shifts it 5% further left relative to left: 50%;
update the transform in the responsive modal CSS (the rule containing left: 50%
and transform: translateX(...)) to use translateX(-50%) for true centering, or
if the 5% offset is intentional add a comment explaining why and keep
translateX(-55%).
- Around line 63-64: The fixed `@box-width`: 320px can cause horizontal overflow
on very narrow viewports; update the responsive rule to use a fluid constraint
(e.g. replace the fixed `@box-width` with a responsive expression such as using
CSS min()/max-width semantics) so the modal never exceeds the viewport width —
change the `@box-width` variable to a responsive value (for example use min(320px,
100%) or set width: 100% with max-width: 320px where the modal uses `@box-width`)
and ensure the modal layout that uses `@box-margin` and `@box-width` respects those
max-width constraints to prevent overflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bbb4ef5c-f4e5-4aba-8b65-cf6b1c3f7559

📥 Commits

Reviewing files that changed from the base of the PR and between ec691cf and 4e713fa.

📒 Files selected for processing (1)
  • packages/theme/src/modal/responsive.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.

♻️ Duplicate comments (2)
packages/theme/src/modal/responsive.less (2)

17-22: ⚠️ Potential issue | 🟠 Major

Use true centering for the modal box.

At Line 20, translateX(-55%) over-shifts the dialog left relative to left: 50%, so alert/confirm modals are no longer centered.

💡 Suggested fix
         .@{modal-prefix-cls}__box {
           top: 100px;
           left: 50% !important;
-          transform: translateX(-55%);
+          transform: translateX(-50%);
           margin: `@box-margin`;
           width: `@box-width`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/modal/responsive.less` around lines 17 - 22, The modal box
rule .@{modal-prefix-cls}__box currently uses left: 50% with transform:
translateX(-55%) causing mis-centering; change the transform to translateX(-50%)
(or use transform: translate(-50%, 0)) so the dialog is truly centered
horizontally when combined with left: 50%; update the CSS rule in
responsive.less for .@{modal-prefix-cls}__box accordingly.

59-65: ⚠️ Potential issue | 🟠 Major

Avoid fixed 320px width on ultra-narrow screens.

At Line 64, fixed 320px width combined with horizontal margins (Line 63) can exceed viewport width on devices below ~352px, causing horizontal overflow.

💡 Suggested fix
 `@media` screen and (max-width: 599px) {
   .modal-responsive(
     `@header-padding`: `@modal-responsive-space-part` `@modal-responsive-space-part`;
     `@body-padding`: 0 `@modal-responsive-space-part`;
     `@box-margin`: 0 `@modal-responsive-space-part` 50px;
-    `@box-width`: 320px;
+    `@box-width`: min(320px, calc(100vw - (2 * `@modal-responsive-space-part`)));
   );
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/modal/responsive.less` around lines 59 - 65, The modal
uses a fixed `@box-width`: 320px which together with `@box-margin` can exceed very
narrow viewports; update the .modal-responsive parameters so `@box-width` is
responsive (e.g. set it to a min/max expression or percentage that accounts for
the left/right margins) instead of a fixed 320px and ensure the computed width
uses the horizontal spacing from `@box-margin/`@modal-responsive-space-part so the
modal never causes horizontal overflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/theme/src/modal/responsive.less`:
- Around line 17-22: The modal box rule .@{modal-prefix-cls}__box currently uses
left: 50% with transform: translateX(-55%) causing mis-centering; change the
transform to translateX(-50%) (or use transform: translate(-50%, 0)) so the
dialog is truly centered horizontally when combined with left: 50%; update the
CSS rule in responsive.less for .@{modal-prefix-cls}__box accordingly.
- Around line 59-65: The modal uses a fixed `@box-width`: 320px which together
with `@box-margin` can exceed very narrow viewports; update the .modal-responsive
parameters so `@box-width` is responsive (e.g. set it to a min/max expression or
percentage that accounts for the left/right margins) instead of a fixed 320px
and ensure the computed width uses the horizontal spacing from
`@box-margin/`@modal-responsive-space-part so the modal never causes horizontal
overflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1bd827d1-3544-4134-a385-ae1ba2780f18

📥 Commits

Reviewing files that changed from the base of the PR and between 4e713fa and 831938f.

📒 Files selected for processing (2)
  • packages/theme/src/modal/responsive.less
  • packages/theme/src/modal/vars.less
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/modal/vars.less

@James-9696 James-9696 changed the title fix(modal): adapt to Modal Components feat(modal): adapt to Modal 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 previously approved these changes Mar 20, 2026
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