Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 9, 2025

Link issues

fixes #6002

Summary By Copilot

This pull request introduces a new FullScreenButton component, enhances the existing fullscreen functionality, and updates localization and documentation files to support these changes. The most important changes are grouped below by theme.

New FullScreenButton Component:

  • Added FullScreenButton component in FullScreenButtons.razor to allow users to make the entire webpage or specific elements fullscreen. Includes localized titles, introductions, and attributes for customization such as Icon, FullScreenExitIcon, TargetId, and Text. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-1e3ebfd2f457daaa68b4e5f84ac9f2f4d4fd21d4cb541d1f2fad1cd56b5e6fe4R1-R18), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-91b94eea8e9f31b131d3fdbe168e7bd4b4a19681b1d5dc2c6496309a5e5bbe79R1-R52))

Enhancements to Fullscreen Functionality:

  • Updated FullScreenOption class to include a new Selector property, allowing fullscreen functionality to target elements using CSS selectors. ([src/BootstrapBlazor/Components/FullScreen/FullScreenOption.csR22-R26](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-4ddee33c988bae6aa9b9f6fa21648d78337994a41a95f7ff1f08c4164846b849R22-R26))
  • Enhanced fullscreen.js to support the Selector property for targeting elements via querySelector. ([src/BootstrapBlazor/wwwroot/modules/fullscreen.jsR9-R11](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-8aa429d27b934de4f85adf96dcb3d72eb24fe159e093ab6101bf0dbd3aa8bc67R9-R11))
  • Updated unit tests in FullScreenServiceTest.cs to validate the new Selector property in FullScreenOption. ([test/UnitTest/Services/FullScreenServiceTest.csL91-R94](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-8834010fd624e2564d81a021541aa98a8b2b57d4b74efcf65a7a9e2348ef07c8L91-R94))

Localization Updates:

  • Added new localization entries for FullScreenButton and updated existing entries in en-US.json and zh-CN.json to reflect the new component and its functionality. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-790d42ebea731775f0fee88a92b20fadb044e53706fd6d3025dfa095df9b1b41L2254-R2265), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-790d42ebea731775f0fee88a92b20fadb044e53706fd6d3025dfa095df9b1b41L4926-R4931), [[3]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-746b8cc3c80dd10d0a1bf77b8d6571652e15bcc7c33dcac0954d93b1a728cc7fL2254-R2265), [[4]](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-746b8cc3c80dd10d0a1bf77b8d6571652e15bcc7c33dcac0954d93b1a728cc7fL4926-R4931))

Documentation and Navigation:

  • Added a new menu item for FullScreenButton in MenusLocalizerExtensions.cs to integrate it into the demo navigation. ([src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.csR1185-R1190](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-0da175523aa74d67c07cc125ac55664960a8e14e9b980fc8394ee1b9fff866f7R1185-R1190))
  • Updated docs.json to include the fullscreen-button entry for documentation purposes. ([src/BootstrapBlazor.Server/docs.jsonL235-R236](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-7f22699a321cdff3a7bd4a3f85ae66d0fbe78560628329c39cca784d9d64dfb7L235-R236))

Minor Adjustments:

  • Deprecated the ButtonIcon property in FullScreenButton.razor.cs in favor of the new Icon parameter. ([src/BootstrapBlazor/Components/FullScreen/FullScreenButton.razor.csL14-R14](https://github.com/dotnetcore/BootstrapBlazor/pull/6005/files#diff-f182532ae1eb08180641260b2b44480261d072f72fb663989cfc129e296d962aL14-R14))

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

Enhance fullscreen functionality by introducing a new FullScreenButton component and extending FullScreenOption with CSS selector support

New Features:

  • Add FullScreenButton component for easy fullscreen toggling
  • Introduce new Selector property in FullScreenOption to target elements via CSS selectors

Enhancements:

  • Update fullscreen JavaScript module to support CSS selector targeting
  • Deprecate ButtonIcon property in favor of new Icon parameter

Documentation:

  • Add documentation and demo page for FullScreenButton
  • Update localization entries for new component
  • Add new menu item for FullScreenButton in navigation

Tests:

  • Update unit tests to validate new Selector property in FullScreenOption

@ArgoZhang ArgoZhang requested a review from Copilot May 9, 2025 07:48
@bb-auto bb-auto bot added the documentation Improvements or additions to documentation label May 9, 2025
@bb-auto bb-auto bot added this to the v9.6.0 milestone May 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new FullScreenButton component and enhances fullscreen functionality by adding a Selector property to FullScreenOption, which enables targeting HTML elements using CSS selectors. It also updates related documentation, localization files, and samples while deprecating the ButtonIcon property in favor of Icon.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/UnitTest/Services/FullScreenServiceTest.cs Updated test for FullScreenOption to include the Selector property
src/BootstrapBlazor/wwwroot/modules/fullscreen.js Added support for using the Selector property with querySelector
src/BootstrapBlazor/Components/FullScreen/FullScreenOption.cs Introduced a new nullable string property, Selector
src/BootstrapBlazor/Components/FullScreen/FullScreenButton.razor.cs Updated documentation and deprecated ButtonIcon in favor of Icon
src/BootstrapBlazor.Server/docs.json Added documentation entry for fullscreen-button
Locales (zh-CN.json, en-US.json) Updated localization entries for FullScreenButton and related descriptions
src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs Added a new menu item for FullScreenButton
Samples (FullScreens.razor, FullScreenButtons.razor, FullScreenButtons.razor.cs) Updated samples to reflect component usage

@ArgoZhang ArgoZhang merged commit cd0284c into main May 9, 2025
3 of 4 checks passed
@ArgoZhang ArgoZhang deleted the doc-fs branch May 9, 2025 07:49
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 9, 2025

Reviewer's Guide

This pull request introduces a new UI component for toggling fullscreen mode, implemented with Razor and C# logic. This component is customizable with parameters for icons, target elements, and display text. The underlying fullscreen functionality was enhanced by enabling elements to be targeted via CSS selectors; this involved modifying the options class and updating the corresponding client-side JavaScript. To support these additions, new demonstration pages were created, existing samples were refactored, localization resources for English and Chinese were updated, and the component was integrated into the documentation and navigation systems. Unit tests were also updated to cover the new targeting capabilities. Finally, an older property in the new component was marked as deprecated in favor of a newer parameter.

File-Level Changes

Change Details Files
Introduced a new UI component for toggling fullscreen mode, along with its demonstration sample pages.
  • Implemented the new FullScreenButton component's logic and markup.
  • Created a new sample page to demonstrate the component.
  • Refactored an existing fullscreen sample page and its code-behind.
src/BootstrapBlazor/Components/FullScreen/FullScreenButton.razor.cs
src/BootstrapBlazor.Server/Components/Samples/FullScreenButtons.razor
src/BootstrapBlazor.Server/Components/Samples/FullScreenButtons.razor.cs
src/BootstrapBlazor.Server/Components/Samples/FullScreens.razor
src/BootstrapBlazor.Server/Components/Samples/FullScreens.razor.cs
Enhanced fullscreen targeting mechanism by enabling element selection via CSS selectors.
  • Added a new property to the fullscreen options class to accept a CSS selector.
  • Updated JavaScript module to use document.querySelector for the new selector property.
  • Modified unit tests to validate the new selector-based targeting.
src/BootstrapBlazor/Components/FullScreen/FullScreenOption.cs
src/BootstrapBlazor/wwwroot/modules/fullscreen.js
test/UnitTest/Services/FullScreenServiceTest.cs
Updated localization resources for English and Chinese.
  • Added new translation strings for the recently introduced fullscreen component and its documentation.
  • Updated existing translations related to fullscreen features.
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
Integrated the new component into the documentation and demo navigation structure.
  • Added a new navigation link for the component in the demo application's menu.
  • Updated the documentation metadata file to include the new component.
src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs
src/BootstrapBlazor.Server/docs.json
Refined the API of the new fullscreen component by deprecating a property.
  • Marked an older icon-related property as obsolete, guiding users to a new preferred parameter.
src/BootstrapBlazor/Components/FullScreen/FullScreenButton.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6002 Add sample code for the FullScreenButton component.

Possibly linked issues


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!

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

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:

  • The PR title could be updated to better reflect the introduction of the FullScreenButton component and the new Selector targeting option.
  • Consider adding a TargetSelector parameter to FullScreenButton to align its targeting capabilities with the new Selector option in FullScreenOption.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 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.

Comment on lines +9 to +11
else if (options.selector) {
el = document.querySelector(options.selector);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): Added CSS selector based lookup for full-screen elements.

Validate options.selector to prevent querySelector errors and unexpected behavior.

Suggested change
else if (options.selector) {
el = document.querySelector(options.selector);
}
else if (typeof options.selector === "string" && options.selector.trim() !== "") {
try {
el = document.querySelector(options.selector);
} catch (e) {
console.warn("Invalid CSS selector provided:", options.selector, e);
el = null;
}
}

var option = new FullScreenOption() { Element = new("test01", null), Id = "test", Selector = "test-selector" };
Assert.NotNull(option.Id);
Assert.Null(option.Element.Context);
Assert.Null(option.Selector);
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (testing): Incorrect assertion for Selector property.

You initialized Selector to "test-selector", so Assert.Null(option.Selector) will always fail. Replace it with Assert.Equal("test-selector", option.Selector) (or at least Assert.NotNull(option.Selector)) to verify the property was set correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(FullScreenButton): add FullScreenOption documentation

2 participants