_userbar.scss 9.1 KB

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