Skip to content

feat(Watermark): add IsPage parameter #5793

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

Merged
merged 9 commits into from
Apr 8, 2025
Merged

feat(Watermark): add IsPage parameter #5793

merged 9 commits into from
Apr 8, 2025

Conversation

ArgoZhang
Copy link
Collaborator

@ArgoZhang ArgoZhang commented Apr 8, 2025

Link issues

fixes #5792

Summary By Copilot

This pull request introduces several enhancements and bug fixes to the Watermark component in the BootstrapBlazor project. The main changes include adding support for a full-page watermark, updating localization files, and refining the JavaScript and CSS for better handling of watermark properties.

Enhancements to the Watermark component:

  • Added a new IsPage parameter to the Watermark component to support full-page watermarks. This includes updates to the OnParametersSet and OnAfterRenderAsync methods to handle the new parameter. [1] [2] [3]
  • Updated the Watermark.razor.cs file to throw an InvalidOperationException if IsPage is true and ChildContent is set.

Localization updates:

  • Added a new localization string WatermarkDescription to both en-US.json and zh-CN.json files to describe how to add a watermark globally. [1] [2]

JavaScript and CSS refinements:

  • Modified the createWatermark function in Watermark.razor.js to handle the zIndex property and support full-page watermarks. [1] [2] [3] [4]
  • Updated the Watermark.razor.scss file to add styles for the is-page class, ensuring full-page watermarks are positioned correctly.

Testing improvements:

  • Enhanced the WatermarkTest.cs file to include tests for the new IsPage parameter, ensuring proper exception handling and rendering behavior.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add support for full-page watermarks in the Watermark component by introducing an IsPage parameter and updating related JavaScript, CSS, and component logic.

New Features:

  • Introduce IsPage parameter to enable full-page watermark functionality

Enhancements:

  • Update Watermark component to support positioning watermarks across the entire page
  • Modify JavaScript and CSS to handle full-page watermark rendering

Documentation:

  • Add localization strings describing full-page watermark usage

Tests:

  • Add test cases to verify IsPage parameter behavior and exception handling

@bb-auto bb-auto bot added the enhancement New feature or request label Apr 8, 2025
Copy link
Contributor

sourcery-ai bot commented Apr 8, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new IsPage parameter to the Watermark component, allowing for full-page watermarks. It also includes updates to localization files, JavaScript, and CSS to properly handle the new parameter and improve the component's functionality. Additionally, tests have been added to ensure the new functionality works as expected.

Sequence diagram for creating a Watermark with IsPage=true

sequenceDiagram
    participant RazorComponent as Watermark Component
    participant JavaScript as Watermark.razor.js
    participant DOM as Document

    RazorComponent->>JavaScript: Invoke createWatermark(options)
    JavaScript->>JavaScript: Apply default options
    JavaScript->>JavaScript: Create watermark div
    alt IsPage is true
        JavaScript->>DOM: document.body.appendChild(div)
    else IsPage is false
        JavaScript->>DOM: el.appendChild(div)
    end
    JavaScript->>JavaScript: requestAnimationFrame(monitor)
Loading

File-Level Changes

Change Details Files
Added a new IsPage parameter to the Watermark component to support full-page watermarks.
  • Added IsPage parameter to the Watermark component.
  • Updated OnParametersSet to throw an InvalidOperationException if IsPage is true and ChildContent is set.
  • Modified OnAfterRenderAsync to handle the new IsPage parameter.
  • Added tests for the new IsPage parameter in WatermarkTest.cs.
src/BootstrapBlazor/Components/Watermark/Watermark.razor.cs
test/UnitTest/Components/WatermarkTest.cs
Refined JavaScript and CSS to handle the zIndex property and support full-page watermarks.
  • Modified the createWatermark function in Watermark.razor.js to handle the zIndex property.
  • Added styles for the is-page class in Watermark.razor.scss to ensure full-page watermarks are positioned correctly.
  • Modified the createWatermark function in Watermark.razor.js to support full-page watermarks.
src/BootstrapBlazor/Components/Watermark/Watermark.razor.js
src/BootstrapBlazor/Components/Watermark/Watermark.razor.scss
Updated localization files with a new string to describe how to add a watermark globally.
  • Added a new localization string WatermarkDescription to en-US.json.
  • Added a new localization string WatermarkDescription to zh-CN.json.
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json

Assessment against linked issues

Issue Objective Addressed Explanation
#5792 Add an IsPage parameter to the Watermark component to support full-page watermarks.
#5792 Update localization files to include a description of how to add a watermark globally.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added this to the v9.5.0 milestone Apr 8, 2025
@ArgoZhang ArgoZhang merged commit 30ab0b3 into main Apr 8, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the feat-watermark branch April 8, 2025 01:31
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a sample to the demo to showcase the new IsPage parameter.
  • The exception message in Watermark.razor.cs could be more user-friendly, perhaps suggesting an alternative approach when IsPage is true.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (bda6a4f) to head (f1fd38d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5793   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          658       658           
  Lines        30056     30062    +6     
  Branches      4243      4244    +1     
=========================================
+ Hits         30056     30062    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

feat(Watermark): add IsPage parameter
1 participant