_userbar.scss 9.9 KB

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