Skip to content

Conversation

@James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Dec 5, 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: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Modal components now support custom text for confirm and cancel buttons
    • Status icons can now be displayed in modal headers
    • New demo examples showcase customized button labels and status displays
  • Style

    • Modal footer layout improved with refined button alignment and spacing

✏️ Tip: You can customize this high-level summary in your review settings.

@James-9696 James-9696 changed the title fix(modal): add attributes (cancel control, confirm control) fix(modal): add attributes (cancel-control, confirm-control) Dec 5, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Walkthrough

This pull request adds customizable confirmation and cancel button text to the TinyModal component. It includes two new demo components showcasing the feature, updates the modal component's rendering logic to support custom button labels with fallback to translations, refines modal footer styling to use flexbox layout, and introduces corresponding documentation and CSS variables.

Changes

Cohort / File(s) Change Summary
Demo Components
packages/demos/app/modal/custom-btn.vue, packages/demos/app/modal/status.vue
New custom-btn.vue demo component showing a custom button toggling a confirmation modal with custom label text. status.vue updated with reactive state and additional modal example.
Component Logic
packages/mobile/components/modal/src/mobile.vue
Modal component enhanced to extract and apply custom button text via confirmContent and cancelContent props; computes confirmButtonText and cancelButtonText with fallbacks to translations; adds status icon rendering in header.
Component Styling
packages/theme-mobile/src/modal/index.less, packages/theme-mobile/src/modal/vars.less
Footer alignment converted from text-align to flexbox; button dimensions removed in favor of margin-based spacing; new CSS variable --tvm-Modal-btn-space added for consistent button spacing.
Documentation
packages/demos/app/modal/webdoc/modal.js
Added public prop definitions for confirm-content and cancel-content; updated status demo label; introduced new 'custom-btn' demo entry with localized descriptions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • packages/mobile/components/modal/src/mobile.vue: Verify computed confirmButtonText and cancelButtonText logic correctly handles prop fallbacks to translations and template integration
  • packages/theme-mobile/src/modal/index.less: Confirm flexbox layout change maintains visual consistency and button alignment across different modal sizes
  • Demo components: Validate that custom-btn.vue and status.vue correctly demonstrate the new custom button text feature
  • Documentation accuracy: Ensure prop descriptions, demoId mappings, and localized labels match implementation

Poem

🐰 A button with words of our own,
Custom labels, in styles yet to own,
Modals now speak with a flexible tongue,
Flex layouts dance where old static clung!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references 'cancel-control' and 'confirm-control' attributes, but the actual changes focus on adding 'cancel-content' and 'confirm-content' props with customizable button text, not control attributes. Update the PR title to accurately reflect the changes, such as 'fix(modal): add content customization props (confirm-content, cancel-content)' or similar.
✅ 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.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-modal-1205

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

@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)
packages/mobile/components/modal/src/mobile.vue (1)

208-209: Refactor class binding to use object syntax.

The conditional class binding works but can be more idiomatic. Adding an empty string to a class array is less clean than using Vue's object-based class binding.

Apply this diff:

           {
             props: {
               type: 'primary',
               size: 'small',
-              class: [type !== 'confirm' ? 'tiny-mobile-button__single' : '']
             },
+            class: { 'tiny-mobile-button__single': type !== 'confirm' },
             on: {
               click: this.confirmEvent
             }
packages/demos/app/modal/custom-btn.vue (1)

8-9: Simplify static prop bindings.

The props are using v-bind (:) with string literals, which is unnecessary for static strings. This is less idiomatic and slightly less performant than passing them as regular attributes.

Apply this diff:

     <tiny-modal 
       v-model="value1" 
       type="confirm" 
       show-footer
-      :confirm-content="'OK'"
-      :cancel-content="'你好'"
+      confirm-content="OK"
+      cancel-content="你好"
     >

Note: Only use v-bind (:) when binding to variables, computed properties, or expressions—not for static string literals.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 893d74e and 8e8d21d.

📒 Files selected for processing (6)
  • packages/demos/app/modal/custom-btn.vue (1 hunks)
  • packages/demos/app/modal/status.vue (1 hunks)
  • packages/demos/app/modal/webdoc/modal.js (3 hunks)
  • packages/mobile/components/modal/src/mobile.vue (3 hunks)
  • packages/theme-mobile/src/modal/index.less (1 hunks)
  • packages/theme-mobile/src/modal/vars.less (1 hunks)
🔇 Additional comments (9)
packages/demos/app/modal/status.vue (1)

9-27: LGTM! Clean demo implementation.

The new status demo section is well-structured, properly imports the required dependencies, and correctly demonstrates the modal with a status icon.

packages/mobile/components/modal/src/mobile.vue (3)

43-48: LGTM! Well-structured button text computation.

The button text fallback chain is correctly implemented using nullish coalescing, providing a clean priority: custom content prop → button props text → localized default.


104-120: LGTM! Flexible status rendering.

The conditional status rendering correctly handles both string-based status icons and custom status components, providing good flexibility for consumers.


193-200: LGTM! Cancel button properly configured.

The button configuration correctly uses the computed cancelButtonText and applies consistent sizing with the updated design.

packages/theme-mobile/src/modal/vars.less (1)

27-27: LGTM! CSS variable addition follows conventions.

The new button spacing variable correctly references the existing design token and follows the established naming pattern.

packages/theme-mobile/src/modal/index.less (2)

393-394: LGTM! Improved footer layout approach.

Switching from text-align to flexbox provides better control over button positioning and is more semantically correct for this use case.


397-397: Review button spacing - margin applies to all buttons including the first.

The current implementation applies margin-left to all buttons via the .@{button-prefix-cls} selector. With justify-content: center, this could cause asymmetric spacing since the first button will also have left margin.

Consider using an adjacent sibling selector to only apply margin between buttons:

     .@{button-prefix-cls} {
-      margin-left: var(--tvm-Modal-btn-space);
+      & + & {
+        margin-left: var(--tvm-Modal-btn-space);
+      }
 
       &__single {

Please verify the rendered layout to ensure the button spacing is symmetric and centered as intended.

packages/demos/app/modal/webdoc/modal.js (2)

29-48: LGTM! Comprehensive prop documentation.

The new confirm-content and cancel-content props are well-documented with clear descriptions, appropriate types, and default values in both Chinese and English.


623-638: LGTM! Clear demo documentation.

The custom-btn demo entry provides clear descriptions and proper code file references for the new button customization feature.

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.

2 participants