message-box.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'common/var' as *;
  5. @use 'common/popup' as *;
  6. @include b(message-box) {
  7. @include set-component-css-var('messagebox', $messagebox);
  8. }
  9. @include b(message-box) {
  10. display: inline-block;
  11. max-width: getCssVar('messagebox-width');
  12. width: 100%;
  13. padding-bottom: 10px;
  14. vertical-align: middle;
  15. background-color: getCssVar('bg-color');
  16. border-radius: getCssVar('messagebox-border-radius');
  17. border: 1px solid getCssVar('border-color-lighter');
  18. font-size: getCssVar('messagebox-font-size');
  19. box-shadow: getCssVar('box-shadow-light');
  20. text-align: left;
  21. overflow: hidden;
  22. backface-visibility: hidden;
  23. // To avoid small screen overflowing, see #11919
  24. box-sizing: border-box;
  25. &:focus {
  26. outline: none !important;
  27. }
  28. @at-root .#{$namespace}-overlay.is-message-box {
  29. .#{$namespace}-overlay-message-box {
  30. text-align: center;
  31. position: fixed;
  32. top: 0;
  33. right: 0;
  34. bottom: 0;
  35. left: 0;
  36. padding: 16px;
  37. overflow: auto;
  38. &::after {
  39. content: '';
  40. display: inline-block;
  41. height: 100%;
  42. width: 0;
  43. vertical-align: middle;
  44. }
  45. }
  46. }
  47. @include when(draggable) {
  48. @include e(header) {
  49. cursor: move;
  50. user-select: none;
  51. }
  52. }
  53. @include e(header) {
  54. position: relative;
  55. padding: getCssVar('messagebox-padding-primary');
  56. padding-bottom: 10px;
  57. }
  58. @include e(title) {
  59. padding-left: 0;
  60. margin-bottom: 0;
  61. font-size: getCssVar('messagebox-font-size');
  62. line-height: 1;
  63. color: getCssVar('messagebox-title-color');
  64. }
  65. @include e(headerbtn) {
  66. position: absolute;
  67. top: getCssVar('messagebox-padding-primary');
  68. right: getCssVar('messagebox-padding-primary');
  69. padding: 0;
  70. border: none;
  71. outline: none;
  72. background: transparent;
  73. font-size: var(
  74. #{getCssVarName('message-close-size')},
  75. map.get($message, 'close-size')
  76. );
  77. cursor: pointer;
  78. .#{$namespace}-message-box__close {
  79. color: getCssVar('color-info');
  80. font-size: inherit;
  81. }
  82. &:focus,
  83. &:hover {
  84. .#{$namespace}-message-box__close {
  85. color: getCssVar('color-primary');
  86. }
  87. }
  88. }
  89. @include e(content) {
  90. padding: 10px getCssVar('messagebox-padding-primary');
  91. color: getCssVar('messagebox-content-color');
  92. font-size: getCssVar('messagebox-content-font-size');
  93. }
  94. @include e(container) {
  95. position: relative;
  96. }
  97. @include e(input) {
  98. padding-top: 15px;
  99. & div.invalid > input {
  100. border-color: getCssVar('color-error');
  101. &:focus {
  102. border-color: getCssVar('color-error');
  103. }
  104. }
  105. }
  106. @include e(status) {
  107. position: absolute;
  108. top: 50%;
  109. transform: translateY(-50%);
  110. font-size: 24px !important;
  111. &::before {
  112. // 防止图标切割
  113. padding-left: 1px;
  114. }
  115. &.#{$namespace}-icon {
  116. // 防止 el-icon 的position样式覆盖
  117. position: absolute;
  118. }
  119. + .#{$namespace}-message-box__message {
  120. padding-left: 36px;
  121. padding-right: 12px;
  122. word-break: break-word;
  123. }
  124. @each $type in (success, info, warning, error) {
  125. &.#{$namespace}-message-box-icon--#{$type} {
  126. @include css-var-from-global(('messagebox', 'color'), ('color', $type));
  127. color: getCssVar('messagebox-color');
  128. }
  129. }
  130. }
  131. @include e(message) {
  132. margin: 0;
  133. & p {
  134. margin: 0;
  135. line-height: 24px;
  136. }
  137. }
  138. @include e(errormsg) {
  139. color: getCssVar('color-error');
  140. font-size: getCssVar('messagebox-error-font-size');
  141. min-height: 18px;
  142. margin-top: 2px;
  143. }
  144. @include e(btns) {
  145. padding: 5px 15px 0;
  146. display: flex;
  147. flex-wrap: wrap;
  148. justify-content: flex-end;
  149. align-items: center;
  150. & button:nth-child(2) {
  151. margin-left: 10px;
  152. }
  153. }
  154. @include e(btns-reverse) {
  155. flex-direction: row-reverse;
  156. }
  157. // centerAlign 布局
  158. @include m(center) {
  159. @include e(title) {
  160. position: relative;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. }
  165. @include e(status) {
  166. position: relative;
  167. top: auto;
  168. padding-right: 5px;
  169. text-align: center;
  170. transform: translateY(-1px);
  171. }
  172. @include e(message) {
  173. margin-left: 0;
  174. }
  175. @include e(btns) {
  176. justify-content: center;
  177. }
  178. @include e(content) {
  179. $padding-horizontal: calc(
  180. #{getCssVar('messagebox', 'padding-primary')} + 12px
  181. );
  182. padding-left: $padding-horizontal;
  183. padding-right: $padding-horizontal;
  184. text-align: center;
  185. }
  186. }
  187. }
  188. .fade-in-linear-enter-active {
  189. .#{$namespace}-overlay-message-box {
  190. animation: msgbox-fade-in getCssVar('transition-duration');
  191. }
  192. }
  193. .fade-in-linear-leave-active {
  194. .#{$namespace}-overlay-message-box {
  195. animation: msgbox-fade-in getCssVar('transition-duration') reverse;
  196. }
  197. }
  198. @keyframes msgbox-fade-in {
  199. 0% {
  200. transform: translate3d(0, -20px, 0);
  201. opacity: 0;
  202. }
  203. 100% {
  204. transform: translate3d(0, 0, 0);
  205. opacity: 1;
  206. }
  207. }