_drop_element.scss 8.7 KB

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