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

feat(alert): [alert] display title when size is large #2744

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

wuyiping0628
Copy link
Collaborator

@wuyiping0628 wuyiping0628 commented Jan 6, 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

    • Added show-title property to the Alert component.
    • Ability to control title visibility when Alert size is large.
  • Bug Fixes

    • Improved margin spacing for Alert description to prevent overlap with close icon.
  • Documentation

    • Updated demo descriptions to explain new show-title attribute functionality.
  • Tests

    • Enhanced test coverage to verify title visibility in specific Alert instances.

@wuyiping0628 wuyiping0628 added the enhancement New feature or request (功能增强) label Jan 6, 2025
Copy link

coderabbitai bot commented Jan 6, 2025

Walkthrough

This pull request introduces a new show-title (or showTitle) property to the Alert component, allowing developers to control the visibility of the title when the alert size is set to 'large'. The changes span multiple files, including API definitions, component implementations, demo files, and styling. The new boolean property defaults to true, maintaining the existing behavior while providing an option to hide the title when needed.

Changes

File Change Summary
examples/sites/demos/apis/alert.js Added new show-title prop with boolean type and default true
examples/sites/demos/pc/app/alert/*.vue Updated demo files to demonstrate :show-title="false"
examples/sites/demos/pc/app/alert/webdoc/alert.js Updated Chinese documentation to explain new show-title attribute
packages/theme/src/alert/index.less Added margin-right to description to prevent overlap with close icon
packages/vue/src/alert/src/index.ts Added showTitle prop to alertProps with boolean type
packages/vue/src/alert/src/pc.vue Modified template to conditionally render title based on showTitle
examples/sites/demos/pc/app/alert/title.spec.ts Enhanced test coverage for title visibility

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

🐰 A Rabbit's Ode to Alert Titles
With show-title, control takes flight,
Hide or reveal, make your alert just right!
A boolean dance of visibility's grace,
Customization now has a new embrace!
Hop to it, developers, with joy so bright! 🎉


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. (Beta)
  • @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 PR introduces a new feature to the alert component, allowing the display of a title when the alert size is set to large. A new property showTitle is added to control the visibility of the title. The changes include updates to the component's API, demos, and styling to accommodate this feature.

Changes

File Summary
examples/sites/demos/apis/alert.js Added show-title property to the alert API with default value true.
examples/sites/demos/pc/app/alert/title-composition-api.vue, examples/sites/demos/pc/app/alert/title.vue Updated alert component usage to include :show-title="false" for large size alerts.
examples/sites/demos/pc/app/alert/webdoc/alert.js Updated documentation to include show-title property description.
packages/theme/src/alert/index.less Added margin-right to prevent overlap with close-icon.
packages/vue/src/alert/src/index.ts Introduced showTitle property with default true.
packages/vue/src/alert/src/pc.vue Modified template to conditionally render title based on showTitle property.

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 3683e48 and 74ad4d9.

📒 Files selected for processing (7)
  • examples/sites/demos/apis/alert.js (1 hunks)
  • examples/sites/demos/pc/app/alert/title-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/alert/title.vue (1 hunks)
  • examples/sites/demos/pc/app/alert/webdoc/alert.js (1 hunks)
  • packages/theme/src/alert/index.less (1 hunks)
  • packages/vue/src/alert/src/index.ts (1 hunks)
  • packages/vue/src/alert/src/pc.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (7)
packages/vue/src/alert/src/index.ts (1)

88-91: Consider verifying default behavior and test coverage for the new prop.
The new showTitle prop is a great addition. With a default value of true, it's important to confirm that scenarios requiring no title are tested. Also, ensure consistency between the PascalCase (showTitle) in the underlying code and the kebab-case (show-title) in component usage.

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

56-56: Documentation update approved.
Your documentation expansion clarifies how the show-title attribute controls title visibility when the size is large. This aligns with the introduced property, improving discoverability.

examples/sites/demos/apis/alert.js (1)

121-134: Added property looks consistent.
The show-title property with its default value and meta version is coherent and well-documented. It complements the size property logic. Please confirm that demos cover both true and false scenarios.

examples/sites/demos/pc/app/alert/title-composition-api.vue (1)

9-9: Good example usage.
Explicitly setting :show-title="false" demonstrates disabling the title for large sized alerts. This showcases the new property’s flexibility in practice.

examples/sites/demos/pc/app/alert/title.vue (1)

9-9: LGTM! Good demo coverage of the new feature.

The new example effectively demonstrates how to hide the title using :show-title="false" while maintaining size="large". This complements the existing examples well.

packages/vue/src/alert/src/pc.vue (1)

20-21: LGTM! Clean implementation of conditional title display.

The template logic correctly combines the size check with the new showTitle prop.

packages/theme/src/alert/index.less (1)

57-58: LGTM! Consistent margin implementation.

The margin-right addition for the description follows the same pattern as the title, preventing overlap with the close icon. Good use of existing CSS variables for consistency.

packages/vue/src/alert/src/pc.vue Show resolved Hide resolved
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 (1)
examples/sites/demos/pc/app/alert/title.spec.ts (1)

13-14: Consider enhancing test coverage for show-title property.

While the test verifies the absence of "消息" text, it would be more explicit to directly test the show-title property's functionality.

Consider adding these assertions:

  const alert1 = page.locator('.tiny-alert--large').nth(2)
  await expect(alert1).not.toHaveText('消息')
+ const title1 = alert1.locator('.tiny-alert__title')
+ await expect(title1).toHaveCount(0)

This would explicitly verify that the title element is not present when show-title is false.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74ad4d9 and f612196.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/alert/title.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: PR Unit Test
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

@zzcr zzcr merged commit 929e136 into opentiny:dev Jan 7, 2025
10 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