dropdown-menu.scss 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. $dropdown-item-min-height: 36px;
  2. .dropdown {
  3. display: inline-flex;
  4. .no-left-border {
  5. border-left: none;
  6. }
  7. .custom-toggle {
  8. &::after {
  9. content: none !important;
  10. }
  11. padding-left: var(--spacing-04);
  12. padding-right: var(--spacing-05);
  13. display: flex;
  14. align-items: center;
  15. }
  16. }
  17. .dropdown-header {
  18. @include body-xs;
  19. display: flex;
  20. align-items: center;
  21. min-height: $dropdown-item-min-height; // a minimum height of 36px to be accessible for touch screens
  22. padding: var(--spacing-05) var(--spacing-06) var(--spacing-02)
  23. var(--spacing-04);
  24. }
  25. .dropdown-menu.dropdown-menu-unpositioned {
  26. position: unset;
  27. top: unset;
  28. left: unset;
  29. z-index: unset;
  30. display: block;
  31. float: unset;
  32. }
  33. .dropdown-menu {
  34. @include shadow-md;
  35. min-width: 240px;
  36. &.dropdown-menu-sm-width {
  37. min-width: 160px;
  38. }
  39. .subdued {
  40. color: var(--content-disabled);
  41. }
  42. }
  43. .dropdown-item {
  44. @include body-sm;
  45. --bs-dropdown-item-border-radius: var(--border-radius-base);
  46. display: grid;
  47. grid-auto-flow: column;
  48. place-content: center start;
  49. min-height: $dropdown-item-min-height; // a minimum height of 36px to be accessible for touch screens
  50. position: relative;
  51. &:active {
  52. background-color: var(--bg-accent-03);
  53. }
  54. &,
  55. &:active,
  56. &:visited {
  57. color: var(--neutral-90);
  58. }
  59. &:hover:not(.active),
  60. &:focus:not(.active) {
  61. background-color: var(--bg-light-secondary);
  62. cursor: pointer;
  63. text-decoration: none;
  64. }
  65. &[variant='danger'] {
  66. color: var(--content-danger);
  67. &:hover:not(.active),
  68. &:focus:not(.active) {
  69. background-color: var(--bg-danger-03);
  70. }
  71. }
  72. &.active {
  73. background-color: var(--bg-accent-03);
  74. color: var(--green-70);
  75. }
  76. &.btn-link {
  77. text-decoration: none;
  78. &:hover,
  79. &:focus {
  80. color: inherit;
  81. }
  82. }
  83. }
  84. .dropdown-divider {
  85. border-top-color: var(--border-divider);
  86. margin: var(--spacing-01) var(--spacing-03);
  87. }
  88. .dropdown-item-description {
  89. @include body-xs;
  90. color: var(--content-secondary);
  91. margin-top: var(--spacing-01);
  92. text-wrap: wrap;
  93. }
  94. .dropdown-item-description-container {
  95. grid-auto-flow: row;
  96. min-height: 44px;
  97. display: grid;
  98. place-content: center start;
  99. }
  100. .dropdown-item-trailing-icon {
  101. position: absolute;
  102. right: 10px;
  103. top: 50%;
  104. transform: translateY(-50%);
  105. }
  106. .dropdown-item-leading-icon {
  107. display: flex;
  108. align-items: center;
  109. padding-right: var(--spacing-04);
  110. &.spinner {
  111. margin-left: var(--spacing-01);
  112. margin-right: var(--spacing-01);
  113. }
  114. }
  115. .dropdown-item-leading-icon,
  116. .dropdown-item-trailing-icon {
  117. .material-symbols {
  118. vertical-align: top;
  119. }
  120. }
  121. .dropdown-item-leading-icon-empty {
  122. display: inline-block;
  123. width: 20px;
  124. }
  125. // description text should look disabled when the dropdown item is disabled
  126. .dropdown-item.disabled .dropdown-item-description,
  127. .dropdown-item[aria-disabled='true'] .dropdown-item-description {
  128. background-color: transparent;
  129. color: var(--content-disabled);
  130. }
  131. // override disabled styles when the state is active
  132. .dropdown-item.active .dropdown-item-description {
  133. background-color: initial;
  134. color: var(--green-70);
  135. }
  136. .dropdown-button-toggle {
  137. border-bottom-left-radius: 0;
  138. border-top-left-radius: 0;
  139. padding-right: var(--spacing-05);
  140. padding-left: var(--spacing-05);
  141. margin-left: 0;
  142. &.btn-primary,
  143. &.btn-danger {
  144. border-left: 1px solid rgb($neutral-90, 0.16);
  145. }
  146. &.btn-secondary {
  147. border-left: 1px solid var(--neutral-60);
  148. }
  149. &[disabled],
  150. &[aria-disabled='true'] {
  151. border-left: 1px solid var(--neutral-10);
  152. }
  153. }
  154. .select-dropdown-menu {
  155. top: 100%;
  156. margin-top: var(--spacing-04);
  157. width: 100%;
  158. max-height: 200px;
  159. overflow: auto;
  160. overflow-x: hidden;
  161. }
  162. .dropdown-item-highlighted {
  163. background-color: var(--bg-light-secondary);
  164. }
  165. .dropdown-item-material-icon-small {
  166. .material-symbols,
  167. &.material-symbols {
  168. font-size: var(--bs-body-font-size);
  169. // Centre the symbol in a 20px-by-20px box
  170. width: 20px;
  171. line-height: 20px;
  172. text-align: center;
  173. }
  174. }