_drop_element.scss 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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-weight: $font-weight-semi-bold;
  9. background: $theme-bg;
  10. color: $theme-color;
  11. padding: $space-sm;
  12. word-wrap: break-word;
  13. max-width: 280px;
  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: 560px;
  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 .drop-content {
  77. margin-top: $popover-arrow-size;
  78. &:before {
  79. bottom: 100%;
  80. left: $popover-arrow-size;
  81. border-bottom-color: $border-color;
  82. }
  83. }
  84. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-middle .drop-content {
  85. margin-top: $popover-arrow-size;
  86. &:before {
  87. bottom: 100%;
  88. right: $popover-arrow-size;
  89. border-bottom-color: $border-color;
  90. }
  91. }
  92. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-middle .drop-content {
  93. margin-bottom: $popover-arrow-size;
  94. &:before {
  95. top: 100%;
  96. left: $popover-arrow-size;
  97. border-top-color: $border-color;
  98. }
  99. }
  100. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-middle .drop-content {
  101. margin-bottom: $popover-arrow-size;
  102. &:before {
  103. top: 100%;
  104. right: $popover-arrow-size;
  105. border-top-color: $border-color;
  106. }
  107. }
  108. // Top and bottom corners
  109. &.drop-element-attached-top.drop-element-attached-left.drop-target-attached-bottom .drop-content {
  110. margin-top: $popover-arrow-size;
  111. &:before {
  112. bottom: 100%;
  113. left: $popover-arrow-size;
  114. border-bottom-color: $border-color;
  115. }
  116. }
  117. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-bottom .drop-content {
  118. margin-top: $popover-arrow-size;
  119. &:before {
  120. bottom: 100%;
  121. right: $popover-arrow-size;
  122. border-bottom-color: $border-color;
  123. }
  124. }
  125. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-top .drop-content {
  126. margin-bottom: $popover-arrow-size;
  127. &:before {
  128. top: 100%;
  129. left: $popover-arrow-size;
  130. border-top-color: $border-color;
  131. }
  132. }
  133. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-top .drop-content {
  134. margin-bottom: $popover-arrow-size;
  135. &:before {
  136. top: 100%;
  137. right: $popover-arrow-size;
  138. border-top-color: $border-color;
  139. }
  140. }
  141. // Side corners
  142. &.drop-element-attached-top.drop-element-attached-right.drop-target-attached-left .drop-content {
  143. margin-right: $popover-arrow-size;
  144. &:before {
  145. top: $popover-arrow-size;
  146. left: 100%;
  147. border-left-color: $border-color;
  148. }
  149. }
  150. &.drop-element-attached-top.drop-element-attached-left.drop-target-attached-right .drop-content {
  151. margin-left: $popover-arrow-size;
  152. &:before {
  153. top: $popover-arrow-size;
  154. right: 100%;
  155. border-right-color: $border-color;
  156. }
  157. }
  158. &.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-left .drop-content {
  159. margin-right: $popover-arrow-size;
  160. &:before {
  161. bottom: $popover-arrow-size;
  162. left: 100%;
  163. border-left-color: $border-color;
  164. }
  165. }
  166. &.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-right .drop-content {
  167. margin-left: $popover-arrow-size;
  168. &:before {
  169. bottom: $popover-arrow-size;
  170. right: 100%;
  171. border-right-color: $border-color;
  172. }
  173. }
  174. }
  175. }
  176. @mixin drop-animation-scale($themePrefix: 'drop', $themeName: 'default', $attachmentOffset: 0, $easing: 'linear') {
  177. .#{$themePrefix}-element.#{$themePrefix}-#{$themeName} {
  178. transform: translateZ(0);
  179. transition: opacity 100ms;
  180. opacity: 0;
  181. .#{$themePrefix}-content {
  182. transition: transform 0.2s $easing;
  183. transform: scale(0.8) translateZ(0);
  184. }
  185. &.#{$themePrefix}-open {
  186. display: none;
  187. }
  188. &.#{$themePrefix}-open-transitionend {
  189. display: block;
  190. }
  191. &.#{$themePrefix}-after-open {
  192. transition: none;
  193. opacity: 1;
  194. .#{$themePrefix}-content {
  195. transform: scale(1) translateZ(0);
  196. }
  197. }
  198. // Centers and middles
  199. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-center .#{$themePrefix}-content {
  200. transform-origin: 50% calc(100% + #{$attachmentOffset});
  201. }
  202. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-center .#{$themePrefix}-content {
  203. transform-origin: 50% (-$attachmentOffset);
  204. }
  205. &.#{$themePrefix}-element-attached-right.#{$themePrefix}-element-attached-middle .#{$themePrefix}-content {
  206. transform-origin: calc(100% + #{$attachmentOffset}) 50%;
  207. }
  208. &.#{$themePrefix}-element-attached-left.#{$themePrefix}-element-attached-middle .#{$themePrefix}-content {
  209. transform-origin: -($attachmentOffset 50%);
  210. }
  211. // Top and bottom corners
  212. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-bottom
  213. .#{$themePrefix}-content {
  214. transform-origin: 0 (-$attachmentOffset);
  215. }
  216. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-bottom
  217. .#{$themePrefix}-content {
  218. transform-origin: 100% (-$attachmentOffset);
  219. }
  220. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-top
  221. .#{$themePrefix}-content {
  222. transform-origin: 0 calc(100% + #{$attachmentOffset});
  223. }
  224. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-top
  225. .#{$themePrefix}-content {
  226. transform-origin: 100% calc(100% + #{$attachmentOffset});
  227. }
  228. // Side corners
  229. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-left
  230. .#{$themePrefix}-content {
  231. transform-origin: calc(100% + #{$attachmentOffset}) 0;
  232. }
  233. &.#{$themePrefix}-element-attached-top.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-right
  234. .#{$themePrefix}-content {
  235. transform-origin: (-$attachmentOffset) 0;
  236. }
  237. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-right.#{$themePrefix}-target-attached-left
  238. .#{$themePrefix}-content {
  239. transform-origin: calc(100% + #{$attachmentOffset}) 100%;
  240. }
  241. &.#{$themePrefix}-element-attached-bottom.#{$themePrefix}-element-attached-left.#{$themePrefix}-target-attached-right
  242. .#{$themePrefix}-content {
  243. transform-origin: (-$attachmentOffset) 100%;
  244. }
  245. }
  246. }