_dropdown.legacy.scss 6.7 KB

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