2
0

_userbar.scss 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. @use 'sass:map';
  2. @use 'sass:math';
  3. @use 'sass:string';
  4. @use '../tools' as *;
  5. // =============================================================================
  6. // Variables
  7. // =============================================================================
  8. $size-home-button: 3.5em;
  9. $position: 2em;
  10. $box-shadow-props:
  11. 0 0 1px 0 rgba(107, 214, 230, 1),
  12. 0 1px 10px 0 rgba(107, 214, 230, 0.7);
  13. $max-items: 12;
  14. $userbar-radius: 6px;
  15. $userbar-z-index: 9999;
  16. // Possible positions for the userbar to exist in. These are set through the
  17. // {% wagtailuserbar 'bottom-left' %} template tag.
  18. $positions: (
  19. 'top-left': (
  20. 'vertical': 'top',
  21. 'horizontal': 'left',
  22. ),
  23. 'top-right': (
  24. 'vertical': 'top',
  25. 'horizontal': 'right',
  26. ),
  27. 'bottom-left': (
  28. 'vertical': 'bottom',
  29. 'horizontal': 'left',
  30. ),
  31. 'bottom-right': (
  32. 'vertical': 'bottom',
  33. 'horizontal': 'right',
  34. ),
  35. );
  36. // =============================================================================
  37. // Wagtail userbar proper
  38. // =============================================================================
  39. .w-userbar {
  40. position: fixed;
  41. z-index: $userbar-z-index;
  42. font-size: initial;
  43. line-height: initial;
  44. margin: 0;
  45. padding: 0;
  46. // Stop hiding the userbar once stylesheets are loaded.
  47. // stylelint-disable-next-line declaration-no-important
  48. display: block !important;
  49. border: 0;
  50. width: auto;
  51. height: auto;
  52. &-icon {
  53. @include svg-icon(2em);
  54. }
  55. }
  56. @media print {
  57. .w-userbar {
  58. display: none;
  59. }
  60. }
  61. .w-userbar-trigger {
  62. display: flex;
  63. align-items: center;
  64. justify-content: center;
  65. width: $size-home-button;
  66. height: $size-home-button;
  67. margin: 0;
  68. background-color: theme('colors.white.DEFAULT');
  69. border: 2px solid transparent;
  70. border-radius: 50%;
  71. padding: 0;
  72. cursor: pointer;
  73. box-shadow: $box-shadow-props;
  74. transition: all 0.2s ease-in-out;
  75. font-size: 1rem;
  76. text-decoration: none;
  77. position: relative;
  78. .w-userbar-axe-count {
  79. display: flex;
  80. justify-content: center;
  81. align-items: center;
  82. background-color: theme('colors.critical.200');
  83. border-radius: theme('borderRadius.full');
  84. color: theme('colors.text-button');
  85. font-size: theme('fontSize.14');
  86. line-height: theme('lineHeight.none');
  87. height: theme('spacing.5');
  88. width: theme('spacing.5');
  89. position: absolute;
  90. inset-inline-end: -5px;
  91. top: -5px;
  92. @media (forced-colors: active) {
  93. border: theme('spacing.px') solid ButtonText;
  94. }
  95. }
  96. &:focus {
  97. outline: theme('colors.focus') solid 3px;
  98. }
  99. }
  100. .w-userbar-items {
  101. display: block;
  102. list-style: none;
  103. position: absolute;
  104. margin: 0;
  105. min-width: 210px;
  106. visibility: hidden;
  107. font-family: theme('fontFamily.sans');
  108. font-size: 0.875rem;
  109. padding-inline-start: 0;
  110. text-decoration: none;
  111. .w-userbar--active & {
  112. visibility: visible;
  113. }
  114. }
  115. .w-userbar-nav {
  116. background: transparent;
  117. padding: 0;
  118. margin: 0;
  119. display: block;
  120. .w-action {
  121. background: transparent;
  122. }
  123. }
  124. .w-userbar__item {
  125. margin: 0;
  126. background-color: theme('colors.surface-menus');
  127. opacity: 0;
  128. overflow: hidden;
  129. transition-duration: 0.125s;
  130. transition-timing-function: cubic-bezier(0.55, 0, 0.1, 1);
  131. font-family: theme('fontFamily.sans');
  132. font-size: 1rem;
  133. text-decoration: none;
  134. @media (prefers-reduced-motion: reduce) {
  135. transition: none;
  136. // Force disable transitions for all items
  137. transition-delay: 0s;
  138. }
  139. &:first-child {
  140. border-start-start-radius: $userbar-radius;
  141. border-start-end-radius: $userbar-radius;
  142. }
  143. &:last-child {
  144. border-end-end-radius: $userbar-radius;
  145. border-end-start-radius: $userbar-radius;
  146. }
  147. a,
  148. .w-action,
  149. button {
  150. color: theme('colors.text-label-menus-default');
  151. display: block;
  152. text-decoration: none;
  153. transform: none;
  154. transition: none;
  155. margin: 0;
  156. font-size: 0.875rem;
  157. &:hover,
  158. &:focus {
  159. color: theme('colors.text-label-menus-default');
  160. background-color: theme('colors.surface-menu-item-active');
  161. }
  162. &:focus {
  163. outline: theme('colors.focus') solid 3px;
  164. }
  165. &-icon {
  166. @include svg-icon(1em, middle);
  167. margin-inline-end: 0.5em;
  168. fill: currentColor;
  169. opacity: 0.4;
  170. }
  171. .w-a11y-result__count {
  172. margin-inline-end: theme('spacing.2');
  173. }
  174. }
  175. a,
  176. button {
  177. font-size: 0.875rem;
  178. text-align: start;
  179. padding: theme('spacing.[3.5]');
  180. }
  181. button {
  182. border: 0;
  183. width: 100%;
  184. background-color: transparent;
  185. outline: none;
  186. display: flex;
  187. align-items: center;
  188. }
  189. }
  190. .w-dialog--userbar {
  191. // Display off to the side of the page rather than in the middle.
  192. inset-inline-start: auto;
  193. font-family: theme('fontFamily.sans');
  194. padding-inline-end: 2rem;
  195. z-index: $userbar-z-index;
  196. .w-dialog__close-button {
  197. $size: theme('spacing.6');
  198. width: $size;
  199. height: $size;
  200. top: calc(-1 * $size / 2);
  201. inset-inline-end: calc(-1 * $size / 2);
  202. border-radius: theme('borderRadius.full');
  203. border: 2px solid theme('colors.icon-primary');
  204. background: theme('colors.surface-page');
  205. }
  206. .w-dialog__close-icon {
  207. color: theme('colors.text-context');
  208. }
  209. .w-dialog__content {
  210. padding: 0;
  211. min-height: unset;
  212. max-height: 60vh;
  213. font-size: theme('fontSize.14');
  214. }
  215. .w-dialog__header {
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-between;
  219. }
  220. .w-dialog__body {
  221. padding: 0 theme('spacing.[7.5]') theme('spacing.[7.5]');
  222. display: flex;
  223. flex-direction: column;
  224. gap: theme('spacing.[2.5]');
  225. }
  226. .w-dialog__title {
  227. @apply w-h3;
  228. color: theme('colors.text-context');
  229. padding: theme('spacing.[7.5]');
  230. margin-bottom: 0;
  231. }
  232. .w-dialog__subtitle {
  233. @apply w-body-text;
  234. padding-inline-end: theme('spacing.[7.5]');
  235. display: flex;
  236. align-items: center;
  237. gap: theme('spacing.2');
  238. margin-bottom: 0;
  239. }
  240. }
  241. //Media for Windows High Contrast
  242. @media (forced-colors: active) {
  243. .w-userbar-icon {
  244. fill: LinkText;
  245. }
  246. .w-userbar__item {
  247. border: 1px solid ButtonText;
  248. }
  249. }
  250. // =============================================================================
  251. // Userbar positional classes (tl, tr, bl, br)
  252. // =============================================================================
  253. @each $pos, $attrs in $positions {
  254. $vertical: map.get($attrs, vertical);
  255. $horizontal: map.get($attrs, horizontal);
  256. .w-userbar--#{$pos} {
  257. #{$vertical}: $position;
  258. #{$horizontal}: $position;
  259. .w-userbar-items {
  260. #{$vertical}: 100%;
  261. #{$horizontal}: 0;
  262. padding-#{$vertical}: theme('spacing.2');
  263. }
  264. .w-userbar__item {
  265. @if $vertical == 'bottom' {
  266. transform: translateY(1em);
  267. } @else {
  268. transform: translateY(-1em);
  269. }
  270. }
  271. &.w-userbar--active .w-userbar__item {
  272. @for $i from 1 through $max-items {
  273. @if $vertical == 'bottom' {
  274. &:nth-last-child(#{$i}) {
  275. transition-delay: 0.05s * $i;
  276. }
  277. }
  278. @if $vertical == 'top' {
  279. &:nth-child(#{$i}) {
  280. transition-delay: 0.05s * $i;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. // =============================================================================
  288. // States
  289. // =============================================================================
  290. // Active state for the list items comes last.
  291. .w-userbar--active .w-userbar__item {
  292. transform: translateY(0);
  293. opacity: 1;
  294. }