_userbar.scss 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. @use 'sass:map';
  2. @use 'sass:math';
  3. @use 'sass:string';
  4. // =============================================================================
  5. // Variables
  6. // =============================================================================
  7. $size-home-button: 3.5em;
  8. $position: 2em;
  9. $box-shadow-props: 0 0 1px 0 rgba(107, 214, 230, 1),
  10. 0 1px 10px 0 rgba(107, 214, 230, 0.7);
  11. $max-items: 12;
  12. $userbar-radius: 6px;
  13. // Possible positions for the userbar to exist in. These are set through the
  14. // {% wagtailuserbar 'bottom-left' %} template tag.
  15. $positions: (
  16. 'top-left': (
  17. 'vertical': 'top',
  18. 'horizontal': 'left',
  19. ),
  20. 'top-right': (
  21. 'vertical': 'top',
  22. 'horizontal': 'right',
  23. ),
  24. 'bottom-left': (
  25. 'vertical': 'bottom',
  26. 'horizontal': 'left',
  27. ),
  28. 'bottom-right': (
  29. 'vertical': 'bottom',
  30. 'horizontal': 'right',
  31. ),
  32. );
  33. // =============================================================================
  34. // Wagtail userbar proper
  35. // =============================================================================
  36. .w-userbar {
  37. position: fixed;
  38. z-index: 9999;
  39. font-size: initial;
  40. line-height: initial;
  41. margin: 0;
  42. padding: 0;
  43. // Stop hiding the userbar once stylesheets are loaded.
  44. // stylelint-disable-next-line declaration-no-important
  45. display: block !important;
  46. border: 0;
  47. width: auto;
  48. height: auto;
  49. &-icon {
  50. @include svg-icon(2em);
  51. }
  52. }
  53. @media print {
  54. .w-userbar {
  55. display: none;
  56. }
  57. }
  58. .w-userbar-trigger {
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. width: $size-home-button;
  63. height: $size-home-button;
  64. margin: 0;
  65. background-color: $color-white;
  66. border: 2px solid transparent;
  67. border-radius: 50%;
  68. color: $color-black;
  69. padding: 0;
  70. cursor: pointer;
  71. box-shadow: $box-shadow-props;
  72. transition: all 0.2s ease-in-out;
  73. font-size: 1rem;
  74. text-decoration: none;
  75. position: relative;
  76. .w-icon:before {
  77. transition: color 0.2s ease;
  78. font-size: 2rem;
  79. width: auto;
  80. margin: 0;
  81. }
  82. .w-userbar-axe-count {
  83. display: flex;
  84. justify-content: center;
  85. align-items: center;
  86. background-color: theme('colors.critical.200');
  87. border-radius: theme('borderRadius.full');
  88. color: $color-white;
  89. font-size: theme('fontSize.14');
  90. line-height: theme('lineHeight.none');
  91. height: theme('spacing.5');
  92. width: theme('spacing.5');
  93. position: absolute;
  94. inset-inline-end: -5px;
  95. top: -5px;
  96. @media (forced-colors: $media-forced-colours) {
  97. border: theme('spacing.px') solid ButtonText;
  98. }
  99. }
  100. &:focus {
  101. outline: $color-focus-outline solid 3px;
  102. }
  103. }
  104. .w-userbar-items {
  105. display: block;
  106. list-style: none;
  107. position: absolute;
  108. margin: 0;
  109. min-width: 210px;
  110. visibility: hidden;
  111. font-family: $font-sans;
  112. font-size: 0.875rem;
  113. padding-inline-start: 0;
  114. text-decoration: none;
  115. .w-userbar.is-active & {
  116. visibility: visible;
  117. }
  118. }
  119. .w-userbar-nav {
  120. background: transparent;
  121. padding: 0;
  122. margin: 0;
  123. display: block;
  124. .w-action {
  125. background: transparent;
  126. }
  127. }
  128. .w-userbar__item {
  129. margin: 0;
  130. background-color: theme('colors.primary.DEFAULT');
  131. opacity: 0;
  132. overflow: hidden;
  133. transition-duration: 0.125s;
  134. transition-timing-function: cubic-bezier(0.55, 0, 0.1, 1);
  135. font-family: $font-sans;
  136. font-size: 1rem;
  137. text-decoration: none;
  138. @media (prefers-reduced-motion: reduce) {
  139. transition: none;
  140. // Force disable transitions for all items
  141. transition-delay: 0s;
  142. }
  143. &:first-child {
  144. // Remove once we drop support for Safari 14.
  145. // stylelint-disable-next-line property-disallowed-list
  146. border-top-left-radius: $userbar-radius;
  147. border-start-start-radius: $userbar-radius;
  148. // Remove once we drop support for Safari 14.
  149. // stylelint-disable-next-line property-disallowed-list
  150. border-top-right-radius: $userbar-radius;
  151. border-start-end-radius: $userbar-radius;
  152. }
  153. &:last-child {
  154. // Remove once we drop support for Safari 14.
  155. // stylelint-disable-next-line property-disallowed-list
  156. border-bottom-right-radius: $userbar-radius;
  157. border-end-end-radius: $userbar-radius;
  158. // Remove once we drop support for Safari 14.
  159. // stylelint-disable-next-line property-disallowed-list
  160. border-bottom-left-radius: $userbar-radius;
  161. border-end-start-radius: $userbar-radius;
  162. }
  163. a,
  164. .w-action,
  165. button {
  166. color: $color-white;
  167. display: block;
  168. text-decoration: none;
  169. transform: none;
  170. transition: none;
  171. margin: 0;
  172. font-size: 0.875rem;
  173. &:hover,
  174. &:focus {
  175. color: $color-white;
  176. background-color: rgba(100, 100, 100, 0.15);
  177. }
  178. &:focus {
  179. outline: $color-focus-outline solid 3px;
  180. }
  181. &-icon {
  182. @include svg-icon(1em, middle);
  183. margin-inline-end: 0.5em;
  184. fill: currentColor;
  185. opacity: 0.4;
  186. }
  187. .w-a11y-result__count {
  188. margin-inline-end: theme('spacing.2');
  189. }
  190. }
  191. .w-icon {
  192. position: relative;
  193. &:before {
  194. position: absolute;
  195. top: 50%;
  196. transform: translateY(-50%);
  197. inset-inline-start: 14px;
  198. }
  199. }
  200. a,
  201. button {
  202. font-size: 0.875rem;
  203. text-align: start;
  204. padding: theme('spacing.[3.5]');
  205. }
  206. button {
  207. border: 0;
  208. width: 100%;
  209. background-color: transparent;
  210. outline: none;
  211. display: flex;
  212. align-items: center;
  213. }
  214. }
  215. .w-dialog--userbar {
  216. // Display off to the side of the page rather than in the middle.
  217. inset-inline-start: auto;
  218. font-family: $font-sans;
  219. padding-inline-end: 2rem;
  220. .w-dialog__close-button {
  221. $size: theme('spacing.6');
  222. width: $size;
  223. height: $size;
  224. top: calc(-1 * $size / 2);
  225. inset-inline-end: calc(-1 * $size / 2);
  226. border-radius: theme('borderRadius.full');
  227. border: 2px solid theme('colors.primary.DEFAULT');
  228. background: theme('colors.white.DEFAULT');
  229. }
  230. .w-dialog__content {
  231. padding: 0;
  232. min-height: unset;
  233. max-height: 60vh;
  234. }
  235. .w-dialog__header {
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. }
  240. .w-dialog__title {
  241. @apply w-h3;
  242. padding: theme('spacing.4') theme('spacing.5');
  243. margin-bottom: 0;
  244. }
  245. .w-dialog__subtitle {
  246. @apply w-body-text;
  247. padding-inline-end: theme('spacing.5');
  248. display: flex;
  249. align-items: center;
  250. gap: theme('spacing.2');
  251. margin-bottom: 0;
  252. }
  253. .w-a11y-result__row {
  254. border-top: 1px solid theme('colors.grey.100');
  255. }
  256. .w-a11y-result__header {
  257. margin: 0;
  258. padding: theme('spacing.4') theme('spacing.5');
  259. width: 100%;
  260. display: flex;
  261. justify-content: space-between;
  262. gap: theme('spacing.2');
  263. font: inherit;
  264. font-weight: theme('fontWeight.bold');
  265. }
  266. .w-a11y-result__name {
  267. color: theme('colors.primary.200');
  268. }
  269. .w-a11y-result__container {
  270. display: flex;
  271. flex-wrap: wrap;
  272. padding: 0 theme('spacing.5') theme('spacing.5') theme('spacing.5');
  273. }
  274. .w-a11y-result__subtotal_count {
  275. color: theme('colors.grey.600');
  276. width: theme('spacing.5');
  277. text-align: center;
  278. }
  279. .w-a11y-result__selector {
  280. display: flex;
  281. align-items: center;
  282. background: theme('colors.grey.50');
  283. color: theme('colors.grey.600');
  284. border-radius: theme('borderRadius.DEFAULT');
  285. margin-inline-end: theme('spacing.[2.5]');
  286. margin-bottom: theme('spacing.[2.5]');
  287. padding: theme('spacing.[1.5]');
  288. &:hover,
  289. &:focus {
  290. background: theme('colors.secondary.DEFAULT');
  291. color: theme('colors.white.DEFAULT');
  292. .w-a11y-result__icon {
  293. fill: theme('colors.white.DEFAULT');
  294. }
  295. }
  296. @media (forced-colors: $media-forced-colours) {
  297. border: theme('spacing.px') solid ButtonText;
  298. }
  299. }
  300. .w-a11y-result__icon {
  301. flex-shrink: 0;
  302. fill: theme('colors.secondary.DEFAULT');
  303. height: theme('spacing.[3.5]');
  304. width: theme('spacing.[3.5]');
  305. margin-inline-end: theme('spacing.[2.5]');
  306. }
  307. }
  308. .w-a11y-result__count {
  309. display: flex;
  310. flex-shrink: 0;
  311. justify-content: center;
  312. align-items: center;
  313. background-color: theme('colors.positive.100');
  314. border-radius: theme('borderRadius.full');
  315. font-size: theme('fontSize.14');
  316. line-height: theme('lineHeight.none');
  317. height: theme('spacing.5');
  318. width: theme('spacing.5');
  319. color: theme('colors.white.DEFAULT');
  320. &.has-errors {
  321. background-color: theme('colors.critical.200');
  322. }
  323. @media (forced-colors: $media-forced-colours) {
  324. border: theme('spacing.px') solid ButtonText;
  325. }
  326. }
  327. //Media for Windows High Contrast
  328. @media (forced-colors: $media-forced-colours) {
  329. .w-userbar-icon {
  330. fill: $system-color-link-text;
  331. }
  332. .w-userbar__item {
  333. border: 1px solid $system-color-button-text;
  334. }
  335. }
  336. // =============================================================================
  337. // Userbar positional classes (tl, tr, bl, br)
  338. // =============================================================================
  339. @each $pos, $attrs in $positions {
  340. $vertical: map.get($attrs, vertical);
  341. $horizontal: map.get($attrs, horizontal);
  342. .w-userbar--#{$pos} {
  343. #{$vertical}: $position;
  344. #{$horizontal}: $position;
  345. .w-userbar-items {
  346. #{$vertical}: 100%;
  347. #{$horizontal}: 0;
  348. padding-#{$vertical}: theme('spacing.2');
  349. }
  350. .w-userbar-nav .w-userbar__item {
  351. @if $vertical == 'bottom' {
  352. transform: translateY(1em);
  353. } @else {
  354. transform: translateY(-1em);
  355. }
  356. }
  357. &.is-active .w-userbar__item {
  358. @for $i from 1 through $max-items {
  359. @if $vertical == 'bottom' {
  360. &:nth-last-child(#{$i}) {
  361. transition-delay: 0.05s * $i;
  362. }
  363. }
  364. @if $vertical == 'top' {
  365. &:nth-child(#{$i}) {
  366. transition-delay: 0.05s * $i;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. // =============================================================================
  374. // States
  375. // =============================================================================
  376. // Active state for the list items comes last.
  377. .w-userbar.is-active .w-userbar__item {
  378. transform: translateY(0);
  379. opacity: 1;
  380. }