popper.scss 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @use 'mixins/mixins' as *;
  2. @use 'mixins/var' as *;
  3. @use 'common/var' as *;
  4. @include b(popper) {
  5. @include set-component-css-var('popper', $popper);
  6. }
  7. @include b(popper) {
  8. position: absolute;
  9. border-radius: getCssVar('popper', 'border-radius');
  10. padding: 5px 11px;
  11. z-index: 2000;
  12. font-size: 12px;
  13. line-height: 20px;
  14. min-width: 10px;
  15. overflow-wrap: break-word;
  16. visibility: visible;
  17. $arrow-selector: #{& + '__arrow'};
  18. @include when(dark) {
  19. color: getCssVar('bg-color');
  20. background: getCssVar('text-color', 'primary');
  21. border: 1px solid getCssVar('text-color', 'primary');
  22. #{$arrow-selector}::before {
  23. border: 1px solid getCssVar('text-color', 'primary');
  24. background: getCssVar('text-color', 'primary');
  25. right: 0;
  26. }
  27. }
  28. @include when(light) {
  29. background: getCssVar('bg-color', 'overlay');
  30. border: 1px solid getCssVar('border-color', 'light');
  31. #{$arrow-selector}::before {
  32. border: 1px solid getCssVar('border-color', 'light');
  33. background: getCssVar('bg-color', 'overlay');
  34. right: 0;
  35. }
  36. }
  37. @include when(pure) {
  38. padding: 0;
  39. }
  40. @include e(arrow) {
  41. position: absolute;
  42. width: 10px;
  43. height: 10px;
  44. z-index: -1;
  45. &::before {
  46. position: absolute;
  47. width: 10px;
  48. height: 10px;
  49. z-index: -1;
  50. content: ' ';
  51. transform: rotate(45deg);
  52. background: getCssVar('text-color', 'primary');
  53. box-sizing: border-box;
  54. }
  55. }
  56. $placements: (
  57. 'top': 'bottom',
  58. 'bottom': 'top',
  59. 'left': 'right',
  60. 'right': 'left',
  61. );
  62. @each $placement, $opposite in $placements {
  63. &[data-popper-placement^='#{$placement}'] > #{$arrow-selector} {
  64. #{$opposite}: -5px;
  65. &::before {
  66. @if $placement == top {
  67. border-bottom-right-radius: 2px;
  68. }
  69. @if $placement == bottom {
  70. border-top-left-radius: 2px;
  71. }
  72. @if $placement == left {
  73. border-top-right-radius: 2px;
  74. }
  75. @if $placement == right {
  76. border-bottom-left-radius: 2px;
  77. }
  78. }
  79. }
  80. }
  81. @each $placement,
  82. $adjacency
  83. in ('top': 'left', 'bottom': 'right', 'left': 'bottom', 'right': 'top')
  84. {
  85. &[data-popper-placement^='#{$placement}'] {
  86. #{$arrow-selector}::before {
  87. border-#{$placement}-color: transparent !important;
  88. border-#{$adjacency}-color: transparent !important;
  89. }
  90. }
  91. }
  92. }