_drop_element.scss 8.6 KB

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