_drop_element.scss 8.4 KB

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