_drop_element.scss 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. @mixin drop-theme($themeName, $theme-bg, $theme-color, $border-color: $theme-bg) {
  2. .drop-element.drop-#{$themeName} {
  3. max-width: 100%;
  4. max-height: 100%;
  5. .drop-content {
  6. border-radius: $border-radius-lg;
  7. position: relative;
  8. font-family: inherit;
  9. background: $theme-bg;
  10. color: $theme-color;
  11. padding: 0.65rem;
  12. font-size: $font-size-sm;
  13. word-wrap: break-word;
  14. max-width: 20rem;
  15. border: 1px solid $border-color;
  16. &:before {
  17. content: "";
  18. display: block;
  19. position: absolute;
  20. width: 0;
  21. height: 0;
  22. border-color: transparent;
  23. border-width: $popover-arrow-size;
  24. border-style: solid;
  25. pointer-events: null;
  26. }
  27. }
  28. &.drop-wide {
  29. .drop-content {
  30. max-width: 40rem;
  31. }
  32. }
  33. // Centers and middles
  34. &.drop-element-attached-bottom.drop-element-attached-center .drop-content {
  35. margin-bottom: $popover-arrow-size;
  36. &:before {
  37. top: 100%;
  38. left: 50%;
  39. margin-left: - $popover-arrow-size;
  40. border-top-color: $border-color;
  41. }
  42. }
  43. &.drop-element-attached-top.drop-element-attached-center .drop-content {
  44. margin-top: $popover-arrow-size;
  45. &:before {
  46. bottom: 100%;
  47. left: 50%;
  48. margin-left: - $popover-arrow-size;
  49. border-bottom-color: $border-color;
  50. }
  51. }
  52. &.drop-element-attached-right.drop-element-attached-middle .drop-content {
  53. margin-right: $popover-arrow-size;
  54. &:before {
  55. left: 100%;
  56. top: 50%;
  57. margin-top: - $popover-arrow-size;
  58. border-left-color: $border-color;
  59. }
  60. }
  61. &.drop-element-attached-left.drop-element-attached-middle .drop-content {
  62. margin-left: $popover-arrow-size;
  63. &:before {
  64. right: 100%;
  65. top: 50%;
  66. margin-top: - $popover-arrow-size;
  67. border-right-color: $border-color;
  68. }
  69. }
  70. // Target middle/center, element corner
  71. &.drop-element-attached-left.drop-target-attached-center .drop-content {
  72. left: - $popover-arrow-size * 2;
  73. }
  74. &.drop-element-attached-right.drop-target-attached-center .drop-content {
  75. left: $popover-arrow-size * 2;
  76. }
  77. &.drop-element-attached-top.drop-element-attached-left.drop-target-attached-middle .drop-content {
  78. margin-top: $popover-arrow-size;
  79. &:before {
  80. bottom: 100%;
  81. left: $popover-arrow-size;
  82. border-bottom-color: $border-color;
  83. }
  84. }
  85. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-middle .drop-content {
  86. margin-top: $popover-arrow-size;
  87. &:before {
  88. bottom: 100%;
  89. right: $popover-arrow-size;
  90. border-bottom-color: $border-color;
  91. }
  92. }
  93. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-middle .drop-content {
  94. margin-bottom: $popover-arrow-size;
  95. &:before {
  96. top: 100%;
  97. left: $popover-arrow-size;
  98. border-top-color: $border-color;
  99. }
  100. }
  101. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-middle .drop-content {
  102. margin-bottom: $popover-arrow-size;
  103. &:before {
  104. top: 100%;
  105. right: $popover-arrow-size;
  106. border-top-color: $border-color;
  107. }
  108. }
  109. // Top and bottom corners
  110. &.drop-element-attached-top.drop-element-attached-left.drop-target-attached-bottom .drop-content {
  111. margin-top: $popover-arrow-size;
  112. &:before {
  113. bottom: 100%;
  114. left: $popover-arrow-size;
  115. border-bottom-color: $border-color;
  116. }
  117. }
  118. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-bottom .drop-content {
  119. margin-top: $popover-arrow-size;
  120. &:before {
  121. bottom: 100%;
  122. right: $popover-arrow-size;
  123. border-bottom-color: $border-color;
  124. }
  125. }
  126. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-top .drop-content {
  127. margin-bottom: $popover-arrow-size;
  128. &:before {
  129. top: 100%;
  130. left: $popover-arrow-size;
  131. border-top-color: $border-color;
  132. }
  133. }
  134. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-top .drop-content {
  135. margin-bottom: $popover-arrow-size;
  136. &:before {
  137. top: 100%;
  138. right: $popover-arrow-size;
  139. border-top-color: $border-color;
  140. }
  141. }
  142. // Side corners
  143. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-left .drop-content {
  144. margin-right: $popover-arrow-size;
  145. &:before {
  146. top: $popover-arrow-size;
  147. left: 100%;
  148. border-left-color: $border-color;
  149. }
  150. }
  151. &.drop-element-attached-top.drop-element-attached-left.drop-target-attached-right .drop-content {
  152. margin-left: $popover-arrow-size;
  153. &:before {
  154. top: $popover-arrow-size;
  155. right: 100%;
  156. border-right-color: $border-color;
  157. }
  158. }
  159. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-left .drop-content {
  160. margin-right: $popover-arrow-size;
  161. &:before {
  162. bottom: $popover-arrow-size;
  163. left: 100%;
  164. border-left-color: $border-color;
  165. }
  166. }
  167. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-right .drop-content {
  168. margin-left: $popover-arrow-size;
  169. &:before {
  170. bottom: $popover-arrow-size;
  171. right: 100%;
  172. border-right-color: $border-color;
  173. }
  174. }
  175. }
  176. }
  177. @mixin drop-animation-scale($themePrefix: "drop", $themeName: "default", $attachmentOffset: 0, $easing: "linear") {
  178. .#{$themePrefix}-element.#{$themePrefix}-#{$themeName} {
  179. transform: translateZ(0);
  180. transition: opacity 100ms;
  181. opacity: 0;
  182. .#{$themePrefix}-content {
  183. transition: transform 0.2s $easing;
  184. transform: scale(0.8) translateZ(0);
  185. }
  186. &.#{$themePrefix}-open {
  187. display: none;
  188. }
  189. &.#{$themePrefix}-open-transitionend {
  190. display: block;
  191. }
  192. &.#{$themePrefix}-after-open {
  193. transition: none;
  194. opacity: 1;
  195. .#{$themePrefix}-content {
  196. transform: scale(1) translateZ(0);
  197. }
  198. }
  199. // Centers and middles
  200. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-center .#{$themePrefix}-content {
  201. transform-origin: 50% calc(100% + #{$attachmentOffset});
  202. }
  203. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-center .#{$themePrefix}-content {
  204. transform-origin: 50% (-$attachmentOffset);
  205. }
  206. &.#{$themePrefix}-element-attached-right.#{$themePrefix}-element-attached-middle .#{$themePrefix}-content {
  207. transform-origin: calc(100% + #{$attachmentOffset}) 50%;
  208. }
  209. &.#{$themePrefix}-element-attached-left.#{$themePrefix}-element-attached-middle .#{$themePrefix}-content {
  210. transform-origin: -($attachmentOffset 50%);
  211. }
  212. // Top and bottom corners
  213. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-bottom .#{$themePrefix}-content {
  214. transform-origin: 0 (-$attachmentOffset);
  215. }
  216. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-bottom .#{$themePrefix}-content {
  217. transform-origin: 100% (-$attachmentOffset);
  218. }
  219. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-top .#{$themePrefix}-content {
  220. transform-origin: 0 calc(100% + #{$attachmentOffset});
  221. }
  222. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-top .#{$themePrefix}-content {
  223. transform-origin: 100% calc(100% + #{$attachmentOffset});
  224. }
  225. // Side corners
  226. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-left .#{$themePrefix}-content {
  227. transform-origin: calc(100% + #{$attachmentOffset}) 0;
  228. }
  229. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-right .#{$themePrefix}-content {
  230. transform-origin: (-$attachmentOffset) 0;
  231. }
  232. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-left .#{$themePrefix}-content {
  233. transform-origin: calc(100% + #{$attachmentOffset}) 100%;
  234. }
  235. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-right .#{$themePrefix}-content {
  236. transform-origin: (-$attachmentOffset) 100%;
  237. }
  238. }
  239. }