You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
7.5 KiB

7 months ago
  1. // stylelint-disable function-disallowed-list
  2. // .modal-open - body class for killing the scroll
  3. // .modal - container to scroll within
  4. // .modal-dialog - positioning shell for the actual modal
  5. // .modal-content - actual modal w/ bg and corners and stuff
  6. // Container that the modal scrolls within
  7. .modal {
  8. // scss-docs-start modal-css-vars
  9. --#{$prefix}modal-zindex: #{$zindex-modal};
  10. --#{$prefix}modal-width: #{$modal-md};
  11. --#{$prefix}modal-padding: #{$modal-inner-padding};
  12. --#{$prefix}modal-margin: #{$modal-dialog-margin};
  13. --#{$prefix}modal-color: #{$modal-content-color};
  14. --#{$prefix}modal-bg: #{$modal-content-bg};
  15. --#{$prefix}modal-border-color: #{$modal-content-border-color};
  16. --#{$prefix}modal-border-width: #{$modal-content-border-width};
  17. --#{$prefix}modal-border-radius: #{$modal-content-border-radius};
  18. --#{$prefix}modal-box-shadow: #{$modal-content-box-shadow-xs};
  19. --#{$prefix}modal-inner-border-radius: #{$modal-content-inner-border-radius};
  20. --#{$prefix}modal-header-padding-x: #{$modal-header-padding-x};
  21. --#{$prefix}modal-header-padding-y: #{$modal-header-padding-y};
  22. --#{$prefix}modal-header-padding: #{$modal-header-padding}; // Todo in v6: Split this padding into x and y
  23. --#{$prefix}modal-header-border-color: #{$modal-header-border-color};
  24. --#{$prefix}modal-header-border-width: #{$modal-header-border-width};
  25. --#{$prefix}modal-title-line-height: #{$modal-title-line-height};
  26. --#{$prefix}modal-footer-gap: #{$modal-footer-margin-between};
  27. --#{$prefix}modal-footer-bg: #{$modal-footer-bg};
  28. --#{$prefix}modal-footer-border-color: #{$modal-footer-border-color};
  29. --#{$prefix}modal-footer-border-width: #{$modal-footer-border-width};
  30. // scss-docs-end modal-css-vars
  31. position: fixed;
  32. top: 0;
  33. left: 0;
  34. z-index: var(--#{$prefix}modal-zindex);
  35. display: none;
  36. width: 100%;
  37. height: 100%;
  38. overflow-x: hidden;
  39. overflow-y: auto;
  40. // Prevent Chrome on Windows from adding a focus outline. For details, see
  41. // https://github.com/twbs/bootstrap/pull/10951.
  42. outline: 0;
  43. // We deliberately don't use `-webkit-overflow-scrolling: touch;` due to a
  44. // gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
  45. // See also https://github.com/twbs/bootstrap/issues/17695
  46. }
  47. // Shell div to position the modal with bottom padding
  48. .modal-dialog {
  49. position: relative;
  50. width: auto;
  51. margin: var(--#{$prefix}modal-margin);
  52. // allow clicks to pass through for custom click handling to close modal
  53. pointer-events: none;
  54. // When fading in the modal, animate it to slide down
  55. .modal.fade & {
  56. @include transition($modal-transition);
  57. transform: $modal-fade-transform;
  58. }
  59. .modal.show & {
  60. transform: $modal-show-transform;
  61. }
  62. // When trying to close, animate focus to scale
  63. .modal.modal-static & {
  64. transform: $modal-scale-transform;
  65. }
  66. }
  67. .modal-dialog-scrollable {
  68. height: calc(100% - var(--#{$prefix}modal-margin) * 2);
  69. .modal-content {
  70. max-height: 100%;
  71. overflow: hidden;
  72. }
  73. .modal-body {
  74. overflow-y: auto;
  75. }
  76. }
  77. .modal-dialog-centered {
  78. display: flex;
  79. align-items: center;
  80. min-height: calc(100% - var(--#{$prefix}modal-margin) * 2);
  81. }
  82. // Actual modal
  83. .modal-content {
  84. position: relative;
  85. display: flex;
  86. flex-direction: column;
  87. width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog`
  88. // counteract the pointer-events: none; in the .modal-dialog
  89. color: var(--#{$prefix}modal-color);
  90. pointer-events: auto;
  91. background-color: var(--#{$prefix}modal-bg);
  92. background-clip: padding-box;
  93. border: var(--#{$prefix}modal-border-width) solid var(--#{$prefix}modal-border-color);
  94. @include border-radius(var(--#{$prefix}modal-border-radius));
  95. @include box-shadow(var(--#{$prefix}modal-box-shadow));
  96. // Remove focus outline from opened modal
  97. outline: 0;
  98. }
  99. // Modal background
  100. .modal-backdrop {
  101. // scss-docs-start modal-backdrop-css-vars
  102. --#{$prefix}backdrop-zindex: #{$zindex-modal-backdrop};
  103. --#{$prefix}backdrop-bg: #{$modal-backdrop-bg};
  104. --#{$prefix}backdrop-opacity: #{$modal-backdrop-opacity};
  105. // scss-docs-end modal-backdrop-css-vars
  106. @include overlay-backdrop(var(--#{$prefix}backdrop-zindex), var(--#{$prefix}backdrop-bg), var(--#{$prefix}backdrop-opacity));
  107. }
  108. // Modal header
  109. // Top section of the modal w/ title and dismiss
  110. .modal-header {
  111. display: flex;
  112. flex-shrink: 0;
  113. align-items: center;
  114. padding: var(--#{$prefix}modal-header-padding);
  115. border-bottom: var(--#{$prefix}modal-header-border-width) solid var(--#{$prefix}modal-header-border-color);
  116. @include border-top-radius(var(--#{$prefix}modal-inner-border-radius));
  117. .btn-close {
  118. padding: calc(var(--#{$prefix}modal-header-padding-y) * .5) calc(var(--#{$prefix}modal-header-padding-x) * .5);
  119. margin: calc(-.5 * var(--#{$prefix}modal-header-padding-y)) calc(-.5 * var(--#{$prefix}modal-header-padding-x)) calc(-.5 * var(--#{$prefix}modal-header-padding-y)) auto;
  120. }
  121. }
  122. // Title text within header
  123. .modal-title {
  124. margin-bottom: 0;
  125. line-height: var(--#{$prefix}modal-title-line-height);
  126. }
  127. // Modal body
  128. // Where all modal content resides (sibling of .modal-header and .modal-footer)
  129. .modal-body {
  130. position: relative;
  131. // Enable `flex-grow: 1` so that the body take up as much space as possible
  132. // when there should be a fixed height on `.modal-dialog`.
  133. flex: 1 1 auto;
  134. padding: var(--#{$prefix}modal-padding);
  135. }
  136. // Footer (for actions)
  137. .modal-footer {
  138. display: flex;
  139. flex-shrink: 0;
  140. flex-wrap: wrap;
  141. align-items: center; // vertically center
  142. justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
  143. padding: calc(var(--#{$prefix}modal-padding) - var(--#{$prefix}modal-footer-gap) * .5);
  144. background-color: var(--#{$prefix}modal-footer-bg);
  145. border-top: var(--#{$prefix}modal-footer-border-width) solid var(--#{$prefix}modal-footer-border-color);
  146. @include border-bottom-radius(var(--#{$prefix}modal-inner-border-radius));
  147. // Place margin between footer elements
  148. // This solution is far from ideal because of the universal selector usage,
  149. // but is needed to fix https://github.com/twbs/bootstrap/issues/24800
  150. > * {
  151. margin: calc(var(--#{$prefix}modal-footer-gap) * .5); // Todo in v6: replace with gap on parent class
  152. }
  153. }
  154. // Scale up the modal
  155. @include media-breakpoint-up(sm) {
  156. .modal {
  157. --#{$prefix}modal-margin: #{$modal-dialog-margin-y-sm-up};
  158. --#{$prefix}modal-box-shadow: #{$modal-content-box-shadow-sm-up};
  159. }
  160. // Automatically set modal's width for larger viewports
  161. .modal-dialog {
  162. max-width: var(--#{$prefix}modal-width);
  163. margin-right: auto;
  164. margin-left: auto;
  165. }
  166. .modal-sm {
  167. --#{$prefix}modal-width: #{$modal-sm};
  168. }
  169. }
  170. @include media-breakpoint-up(lg) {
  171. .modal-lg,
  172. .modal-xl {
  173. --#{$prefix}modal-width: #{$modal-lg};
  174. }
  175. }
  176. @include media-breakpoint-up(xl) {
  177. .modal-xl {
  178. --#{$prefix}modal-width: #{$modal-xl};
  179. }
  180. }
  181. // scss-docs-start modal-fullscreen-loop
  182. @each $breakpoint in map-keys($grid-breakpoints) {
  183. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  184. $postfix: if($infix != "", $infix + "-down", "");
  185. @include media-breakpoint-down($breakpoint) {
  186. .modal-fullscreen#{$postfix} {
  187. width: 100vw;
  188. max-width: none;
  189. height: 100%;
  190. margin: 0;
  191. .modal-content {
  192. height: 100%;
  193. border: 0;
  194. @include border-radius(0);
  195. }
  196. .modal-header,
  197. .modal-footer {
  198. @include border-radius(0);
  199. }
  200. .modal-body {
  201. overflow-y: auto;
  202. }
  203. }
  204. }
  205. }
  206. // scss-docs-end modal-fullscreen-loop