_drop_element.scss 8.3 KB

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