_dropdown.legacy.scss 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. .dropdown {
  2. @include clearfix();
  3. position: relative;
  4. input[type='submit'],
  5. input[type='reset'],
  6. input[type='button'],
  7. button,
  8. .button {
  9. padding: 0 5em 0 1em;
  10. display: block;
  11. width: 100%;
  12. height: 3em;
  13. line-height: 3em;
  14. text-align: start;
  15. float: left;
  16. }
  17. .action-secondary {
  18. opacity: 0.8;
  19. }
  20. input[type='submit'],
  21. input[type='reset'],
  22. input[type='button'],
  23. button {
  24. line-height: inherit;
  25. }
  26. ul {
  27. @include unlist();
  28. background-color: $color-teal;
  29. position: absolute;
  30. overflow: hidden;
  31. top: 100%;
  32. inset-inline-start: -2000px;
  33. z-index: 500;
  34. opacity: 0;
  35. li {
  36. float: none;
  37. border-color: theme('colors.white-15');
  38. border-style: solid;
  39. border-width: 1px 0 0;
  40. overflow: hidden;
  41. a:focus,
  42. button:focus {
  43. border: 3px solid $color-focus-outline;
  44. }
  45. }
  46. // Media for Windows High Contrast
  47. @media (forced-colors: $media-forced-colours) {
  48. li {
  49. border-width: 1px;
  50. }
  51. li:hover {
  52. border-color: Highlight;
  53. }
  54. li a,
  55. li button {
  56. border-color: $color-white;
  57. color: $color-white;
  58. }
  59. li a:focus,
  60. li button:focus {
  61. background-color: $color-black;
  62. forced-color-adjust: none;
  63. border: 4px solid currentColor;
  64. color: $color-white;
  65. }
  66. }
  67. a {
  68. white-space: nowrap;
  69. position: relative;
  70. text-decoration: none;
  71. display: block;
  72. color: $color-white;
  73. padding: 1em;
  74. font-weight: normal;
  75. &:hover {
  76. background-color: $color-teal-darker;
  77. }
  78. &.icon {
  79. padding-inline-end: 5em;
  80. // stylelint-disable-next-line max-nesting-depth
  81. &:before,
  82. &:after {
  83. inset-inline-end: 1em;
  84. }
  85. }
  86. &.shortcut {
  87. padding-inline-end: 7em;
  88. }
  89. }
  90. a,
  91. input[type='submit'],
  92. input[type='reset'],
  93. input[type='button'],
  94. .button,
  95. button {
  96. border-radius: 0;
  97. -webkit-font-smoothing: auto;
  98. }
  99. label {
  100. padding: 1.3em;
  101. }
  102. .kbd {
  103. position: absolute;
  104. inset-inline-end: 1em;
  105. font-weight: 600;
  106. font-size: 0.8em;
  107. color: theme('colors.black-20');
  108. }
  109. }
  110. &.open ul {
  111. box-shadow: 0 3px 3px 0 theme('colors.black-20');
  112. opacity: 1;
  113. inset-inline-start: 0;
  114. display: block;
  115. }
  116. &.match-width ul {
  117. width: 100%;
  118. min-width: 110px;
  119. li {
  120. white-space: nowrap;
  121. }
  122. }
  123. &.dropup ul {
  124. box-shadow: 0 -3px 3px 0 theme('colors.black-20');
  125. top: auto;
  126. bottom: 100%;
  127. li {
  128. border-width: 0 0 1px;
  129. }
  130. }
  131. .dropdown-toggle {
  132. color: $color-white;
  133. background-color: $color-teal;
  134. line-height: 2.8em;
  135. cursor: pointer;
  136. height: 100%;
  137. border-inline-start: 1px solid theme('colors.white-15');
  138. position: absolute;
  139. inset-inline-end: 0;
  140. padding: 0 0.5em;
  141. text-align: center;
  142. &:before,
  143. &:after {
  144. margin: 0;
  145. }
  146. &:before {
  147. width: 1em;
  148. font-size: 1.2rem;
  149. }
  150. &:hover {
  151. background-color: $color-teal-darker;
  152. }
  153. svg.icon {
  154. // TODO: remove svg qualifier once the icon font styles are gone
  155. @include svg-icon(1.3em);
  156. }
  157. }
  158. .bicolor + .dropdown-toggle {
  159. background-color: $color-teal-darker;
  160. &:hover {
  161. background-color: $color-teal-dark;
  162. }
  163. }
  164. &.open .dropdown-toggle {
  165. background-color: $color-teal-darker;
  166. }
  167. .bicolor:hover {
  168. background-color: $color-teal-dark;
  169. }
  170. // Styles for dropdowns which are also buttons e.g page editor
  171. &.dropdown-button {
  172. // Media for Windows High Contrast
  173. @media (forced-colors: $media-forced-colours) {
  174. button {
  175. border-color: ActiveText;
  176. }
  177. button:hover {
  178. border-color: Highlight;
  179. }
  180. a.button.bicolor.button:hover {
  181. border-color: Highlight;
  182. }
  183. }
  184. .dropdown-toggle {
  185. border-radius: 0 3px 3px 0;
  186. // Media for Windows High Contrast
  187. @media (forced-colors: $media-forced-colours) {
  188. background: transparent;
  189. border: 1px solid ActiveText;
  190. }
  191. }
  192. .dropdown-toggle:hover {
  193. // Media for Windows High Contrast
  194. @media (forced-colors: $media-forced-colours) {
  195. background-color: transparent;
  196. border: 1px solid Highlight;
  197. }
  198. }
  199. &.open {
  200. > input[type='button'],
  201. > input[type='submit'],
  202. > button,
  203. > .button {
  204. border-radius: 3px 3px 0 0;
  205. }
  206. .dropdown-toggle {
  207. border-radius: 0 3px 0 0;
  208. }
  209. }
  210. }
  211. &.dropdown-button--white {
  212. ul {
  213. background-color: $color-grey-3;
  214. }
  215. li a,
  216. li .button {
  217. background-color: $color-white;
  218. color: $color-button;
  219. border: 0;
  220. &:hover {
  221. background-color: $color-grey-4;
  222. }
  223. &.no {
  224. color: $color-button-no;
  225. }
  226. &.warning {
  227. color: $color-button-warning;
  228. }
  229. }
  230. }
  231. &.dropup.dropdown-button {
  232. &.open {
  233. > input[type='button'],
  234. > input[type='submit'],
  235. > button,
  236. > .button {
  237. border-radius: 0 0 3px 3px;
  238. }
  239. .dropdown-toggle {
  240. border-radius: 0 0 3px;
  241. }
  242. }
  243. }
  244. }
  245. .dropdown.white {
  246. ul {
  247. background-color: $color-white;
  248. li {
  249. border-top: 1px solid theme('colors.black-10');
  250. }
  251. a {
  252. color: $color-grey-2;
  253. &:hover {
  254. background-color: $color-grey-3;
  255. }
  256. }
  257. }
  258. }
  259. .dropdown.warning {
  260. ul {
  261. background-color: $color-button-warning;
  262. }
  263. .dropdown-toggle {
  264. background-color: $color-button-warning;
  265. }
  266. }
  267. // Transitions
  268. // stylelint-disable-next-line no-duplicate-selectors
  269. .dropdown ul {
  270. @include transition(opacity 0.2s linear);
  271. }
  272. .dropdown-button {
  273. .button svg.icon {
  274. // TODO: leave only class when iconfont styles are removed
  275. @include svg-icon();
  276. }
  277. }