Modal.razor 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <div class="modal @modalClass" tabindex="-1" role="dialog" style="display:@modalDisplay; overflow-y: auto;">
  2. <div class="modal-dialog modal-lg" role="document">
  3. <div class="modal-content">
  4. <div class="modal-header">
  5. <h5 class="modal-title">@Title</h5>
  6. <button type="button" class="close" data-dismiss="modal" aria-label="Close" @onclick="Close">
  7. <span aria-hidden="true">&times;</span>
  8. </button>
  9. </div>
  10. <div class="modal-body">
  11. @Body
  12. </div>
  13. <div class="modal-footer">
  14. @Footer
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. @if (showBackdrop)
  20. {
  21. <div class="modal-backdrop fade show"></div>
  22. }
  23. @code {
  24. [Parameter]
  25. public RenderFragment Title { get; set; }
  26. [Parameter]
  27. public RenderFragment Body { get; set; }
  28. [Parameter]
  29. public RenderFragment Footer { get; set; }
  30. private string modalDisplay = "none;";
  31. private string modalClass = "";
  32. private bool showBackdrop = false;
  33. public void Open()
  34. {
  35. modalDisplay = "block;";
  36. modalClass = "show";
  37. showBackdrop = true;
  38. }
  39. public void Close()
  40. {
  41. modalDisplay = "none";
  42. modalClass = "";
  43. showBackdrop = false;
  44. }
  45. }