_userbar.scss 10 KB

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