Skip to content

Conversation

Xopabyteh
Copy link
Contributor

Solves #1080

Bootstrap applies a lot of custom styling along with layout, so it is kinda hacky to get rid of it. (Also because the close button is a custom concept, different from Bootstrap Icons.)

Perhaps the best solution, due to bootstraps decision on this, is to change the $btn-close-bg variable or to use a custom header and avoid reimplementing the close button (as in the current API & this PR)

@crdo crdo requested review from Copilot and crdo June 3, 2025 14:03
Copy link
Contributor

@Copilot 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 adjusts the modal close button to allow a fully custom icon by stripping Bootstrap’s built-in close‐button styling and replacing the wrapper <div> with a real <button>. Key changes include:

  • Added a scoped CSS class to unset Bootstrap’s close-button variables.
  • Swapped the <div> wrapper for a <button> with the new CSS class applied.
  • Updated the test page to demonstrate the new CloseButtonIcon usage.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
HxModal.razor.css Introduces .btn-close-custom-icon to clear Bootstrap defaults
HxModal.razor Replaces <div> with <button> and adds the custom-icon class
BlazorAppTest/Pages/HxModalTest.razor Adds a Title and custom CloseButtonIcon to the demo modal
Comments suppressed due to low confidence (1)

BlazorAppTest/Pages/HxModalTest.razor:17

  • Consider adding an automated test to verify that setting CloseButtonIcon renders the expected custom icon and CSS class in the modal header.
<HxModal @ref="mySecondModal" Title="A very balanced close icon" CloseButtonIcon="BootstrapIcon.YinYang">

crdo and others added 2 commits June 4, 2025 08:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@@ -27,7 +27,9 @@
}
else
{
<div role="button" data-bs-dismiss="modal" aria-label="Close"><HxIcon Icon="CloseButtonIconEffective"/></div>
<button type="button" class="btn-close btn-close-custom-icon center d-flex align-items-center" data-bs-dismiss="modal" aria-label="Close">
Copy link
Member

Choose a reason for hiding this comment

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

@Xopabyteh the "center" css class is suspicious to me. What is it suppose to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intellisense artifact, sorry :D

@@ -0,0 +1,10 @@
/* Remove custom bootstrap styling to preserve custom icon style */
.btn-close-custom-icon {
Copy link
Member

Choose a reason for hiding this comment

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

@Xopabyteh lets call it hx-modal-custom-close-btn and only set --bs-btn-close-bg: unset; and remove the rest. It is very likely that you wanna set some of the vars your own and so I would leave the potential unset on you.

@crdo crdo merged commit bd92a12 into havit:master Jun 13, 2025
1 check passed
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